Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / warn-range-loop-analysis-trivially-copyable.cpp
blobe345ef40aed9ca5f74baf60cbcb8137202be2658
1 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wloop-analysis -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wrange-loop-analysis -verify %s
4 void test_POD_64_bytes() {
5 struct Record {
6 char a[64];
7 };
9 Record records[8];
10 for (const auto r : records)
11 (void)r;
14 void test_POD_65_bytes() {
15 struct Record {
16 char a[65];
19 // expected-warning@+3 {{loop variable 'r' creates a copy from type 'const Record'}}
20 // expected-note@+2 {{use reference type 'const Record &' to prevent copying}}
21 Record records[8];
22 for (const auto r : records)
23 (void)r;
26 void test_TriviallyCopyable_64_bytes() {
27 struct Record {
28 Record() {}
29 char a[64];
32 Record records[8];
33 for (const auto r : records)
34 (void)r;
37 void test_TriviallyCopyable_65_bytes() {
38 struct Record {
39 Record() {}
40 char a[65];
43 // expected-warning@+3 {{loop variable 'r' creates a copy from type 'const Record'}}
44 // expected-note@+2 {{use reference type 'const Record &' to prevent copying}}
45 Record records[8];
46 for (const auto r : records)
47 (void)r;
50 void test_NonTriviallyCopyable() {
51 struct Record {
52 Record() {}
53 ~Record() {}
54 volatile int a;
55 int b;
58 // expected-warning@+3 {{loop variable 'r' creates a copy from type 'const Record'}}
59 // expected-note@+2 {{use reference type 'const Record &' to prevent copying}}
60 Record records[8];
61 for (const auto r : records)
62 (void)r;
65 void test_TrivialABI_64_bytes() {
66 struct [[clang::trivial_abi]] Record {
67 Record() {}
68 ~Record() {}
69 char a[64];
72 Record records[8];
73 for (const auto r : records)
74 (void)r;
77 void test_TrivialABI_65_bytes() {
78 struct [[clang::trivial_abi]] Record {
79 Record() {}
80 ~Record() {}
81 char a[65];
84 // expected-warning@+3 {{loop variable 'r' creates a copy from type 'const Record'}}
85 // expected-note@+2 {{use reference type 'const Record &' to prevent copying}}
86 Record records[8];
87 for (const auto r : records)
88 (void)r;