1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -x c++ -Werror %s
3 
pr8880_1()4 int pr8880_1() {
5   int first = 1;
6   for ( ; ({ if (first) { first = 0; continue; } 0; }); )
7     return 0;
8   return 1;
9 }
10 
pr8880_2(int first)11 void pr8880_2(int first) {
12   for ( ; ({ if (first) { first = 0; break; } 0; }); ) {}
13 }
14 
pr8880_3(int first)15 void pr8880_3(int first) {
16   for ( ; ; (void)({ if (first) { first = 0; continue; } 0; })) {}
17 }
18 
pr8880_4(int first)19 void pr8880_4(int first) {
20   for ( ; ; (void)({ if (first) { first = 0; break; } 0; })) {}
21 }
22 
pr8880_5(int first)23 void pr8880_5 (int first) {
24   while(({ if (first) { first = 0; continue; } 0; })) {}
25 }
26 
pr8880_6(int first)27 void pr8880_6 (int first) {
28   while(({ if (first) { first = 0; break; } 0; })) {}
29 }
30 
pr8880_7(int first)31 void pr8880_7 (int first) {
32   do {} while(({ if (first) { first = 0; continue; } 0; }));
33 }
34 
pr8880_8(int first)35 void pr8880_8 (int first) {
36   do {} while(({ if (first) { first = 0; break; } 0; }));
37 }
38 
pr8880_10(int i)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}}
42 }
43 
pr8880_11(int i)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}}
47 }
48 
pr8880_12(int i,int j)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}}
52 }
53 
pr8880_13(int i,int j)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}}
57 }
58 
pr8880_14(int i)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}}
62 }
63 
pr8880_15(int i)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}}
67 }
68 
pr8880_16(int i)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}}
72 }
73 
pr8880_17(int i)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}}
77 }
78 
pr8880_18(int x,int y)79 void pr8880_18(int x, int y) {
80   while(x > 0)
81     switch(({if(y) break; y;})) {
82     case 2: x = 0;
83     }
84 }
85 
pr8880_19(int x,int y)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;
91     }
92   }
93 }
94 
pr8880_20(int x,int y)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}}
99   }
100 }
101 
pr8880_21(int x,int y)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}}
106   }
107 }
108 
pr8880_22(int x,int y)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}}
113   }
114 }
115 
pr8880_23(int x,int y)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}}
120   }
121 }
122 
pr32648_1(int x,int y)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
127   }
128 }
129 
pr32648_2(int x,int y)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}}
133   }
134 }
135 
pr32648_3(int x,int y)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
140   }
141 }
142 
pr32648_4(int x,int y)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}}
147   }
148 }
149 
pr32648_5(int x,int y)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}}
154   }
155 }
156 
pr32648_6(int x,int y)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}}
161   }
162 }
163 
pr32648_7(int x,int y)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
168   }
169 }
170