[Reland][Runtimes] Merge 'compile_commands.json' files from runtimes build (#116303)
[llvm-project.git] / clang / test / Sema / loop-control.c
blob67a0eb5bdfb4c1e1382d1d5ad9f3cced90b3a81c
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -x c++ -Werror %s
4 int pr8880_1(void) {
5 int first = 1;
6 for ( ; ({ if (first) { first = 0; continue; } 0; }); )
7 return 0;
8 return 1;
11 void pr8880_2(int first) {
12 for ( ; ({ if (first) { first = 0; break; } 0; }); ) {}
15 void pr8880_3(int first) {
16 for ( ; ; (void)({ if (first) { first = 0; continue; } 0; })) {}
19 void pr8880_4(int first) {
20 for ( ; ; (void)({ if (first) { first = 0; break; } 0; })) {}
23 void pr8880_5 (int first) {
24 while(({ if (first) { first = 0; continue; } 0; })) {}
27 void pr8880_6 (int first) {
28 while(({ if (first) { first = 0; break; } 0; })) {}
31 void pr8880_7 (int first) {
32 do {} while(({ if (first) { first = 0; continue; } 0; }));
35 void pr8880_8 (int first) {
36 do {} while(({ if (first) { first = 0; break; } 0; }));
39 void pr8880_10(int i) {
40 for ( ; i != 10 ; i++ )
41 for ( ; ; (void)({ ++i; continue; i;})) {} // expected-warning{{'continue' is bound to current loop, GCC binds it to the enclosing loop}}
44 void pr8880_11(int i) {
45 for ( ; i != 10 ; i++ )
46 for ( ; ; (void)({ ++i; break; i;})) {} // expected-warning{{'break' is bound to current loop, GCC binds it to the enclosing loop}}
49 void pr8880_12(int i, int j) {
50 for ( ; i != 10 ; i++ )
51 for ( ; ({if (i) continue; i;}); j++) {} // expected-warning {{'continue' is bound to current loop, GCC binds it to the enclosing loop}}
54 void pr8880_13(int i, int j) {
55 for ( ; i != 10 ; i++ )
56 for ( ; ({if (i) break; i;}); j++) {} // expected-warning{{'break' is bound to current loop, GCC binds it to the enclosing loop}}
59 void pr8880_14(int i) {
60 for ( ; i != 10 ; i++ )
61 while(({if (i) break; i;})) {} // expected-warning {{'break' is bound to current loop, GCC binds it to the enclosing loop}}
64 void pr8880_15(int i) {
65 while (--i)
66 while(({if (i) continue; i;})) {} // expected-warning {{'continue' is bound to current loop, GCC binds it to the enclosing loop}}
69 void pr8880_16(int i) {
70 for ( ; i != 10 ; i++ )
71 do {} while(({if (i) break; i;})); // expected-warning {{'break' is bound to current loop, GCC binds it to the enclosing loop}}
74 void pr8880_17(int i) {
75 for ( ; i != 10 ; i++ )
76 do {} while(({if (i) continue; i;})); // expected-warning {{'continue' is bound to current loop, GCC binds it to the enclosing loop}}
79 void pr8880_18(int x, int y) {
80 while(x > 0)
81 switch(({if(y) break; y;})) {
82 case 2: x = 0;
86 void pr8880_19(int x, int y) {
87 switch(x) {
88 case 1:
89 switch(({if(y) break; y;})) {
90 case 2: x = 0;
95 void pr8880_20(int x, int y) {
96 switch(x) {
97 case 1:
98 while(({if (y) break; y;})) {} //expected-warning {{'break' is bound to loop, GCC binds it to switch}}
102 void pr8880_21(int x, int y) {
103 switch(x) {
104 case 1:
105 do {} while(({if (y) break; y;})); //expected-warning {{'break' is bound to loop, GCC binds it to switch}}
109 void pr8880_22(int x, int y) {
110 switch(x) {
111 case 1:
112 for ( ; ; (void)({ ++y; break; y;})) {} // expected-warning{{'break' is bound to loop, GCC binds it to switc}}
116 void pr8880_23(int x, int y) {
117 switch(x) {
118 case 1:
119 for ( ; ({ ++y; break; y;}); ++y) {} // expected-warning{{'break' is bound to loop, GCC binds it to switch}}
123 void pr32648_1(int x, int y) {
124 switch(x) {
125 case 1:
126 for ( ; ({ ++y; switch (y) { case 0: break; } y;}); ++y) {} // no warning
130 void pr32648_2(int x, int y) {
131 while(x) {
132 for ( ; ({ ++y; switch (y) { case 0: continue; } y;}); ++y) {} // expected-warning {{'continue' is bound to current loop, GCC binds it to the enclosing loop}}
136 void pr32648_3(int x, int y) {
137 switch(x) {
138 case 1:
139 for ( ; ({ ++y; for (; y; y++) { break; } y;}); ++y) {} // no warning
143 void pr32648_4(int x, int y) {
144 switch(x) {
145 case 1:
146 for ( ; ({ ++y; for (({ break; }); y; y++) { } y;}); ++y) {} // expected-warning{{'break' is bound to loop, GCC binds it to switch}}
150 void pr32648_5(int x, int y) {
151 switch(x) {
152 case 1:
153 for ( ; ({ ++y; while (({ break; y; })) {} y;}); ++y) {} // expected-warning{{'break' is bound to current loop, GCC binds it to the enclosing loop}}
157 void pr32648_6(int x, int y) {
158 switch(x) {
159 case 1:
160 for ( ; ({ ++y; do {} while (({ break; y; })); y;}); ++y) {} // expected-warning{{'break' is bound to current loop, GCC binds it to the enclosing loop}}
164 void pr32648_7(int x, int y) {
165 switch(x) {
166 case 1:
167 for ( ; ({ ++y; do { break; } while (y); y;}); ++y) {} // no warning