1 // RUN: %clang_cc1 -Wno-gcc-compat -emit-llvm -o - %s | FileCheck %s
2 
pr8880_cg_1(int * iptr)3 void pr8880_cg_1(int *iptr) {
4 // CHECK-LABEL: define {{.*}}void @pr8880_cg_1(
5   int i, j;
6 // CHECK: br label %[[OUTER_COND:[0-9A-Za-z$._]+]]
7   for (i = 2; i != 10 ; i++ )
8 // CHECK: [[OUTER_COND]]
9 // CHECK: label %[[OUTER_BODY:[0-9A-Za-z$._]+]], label %[[OUTER_END:[0-9A-Za-z$._]+]]
10 // CHECK: [[OUTER_BODY]]
11 // CHECK: br label %[[INNER_COND:[0-9A-Za-z$._]+]]
12     for (j = 3 ; j < 22; (void)({ ++j; break; j;})) {
13 // CHECK: [[INNER_COND]]
14 // CHECK: label %[[INNER_BODY:[0-9A-Za-z$._]+]], label %[[INNER_END:[0-9A-Za-z$._]+]]
15 // CHECK: [[INNER_BODY]]
16       *iptr = 7;
17 // CHECK: store i32 7,
18 // CHECK: br label %[[INNER_INC:[0-9A-Za-z$._]+]]
19 // CHECK: [[INNER_INC]]
20 
21 // break in 3rd expression of inner loop causes branch to end of inner loop
22 
23 // CHECK: br label %[[INNER_END:[0-9A-Za-z$._]+]]
24 // CHECK: [[INNER_END]]
25     }
26 // CHECK: br label %[[OUTER_INC:[0-9A-Za-z$._]+]]
27 // CHECK: [[OUTER_INC]]
28 // CHECK: br label %[[OUTER_COND]]
29 // CHECK: [[OUTER_END]]
30 // CHECK: ret
31 }
32 
pr8880_cg_2(int * iptr)33 void pr8880_cg_2(int *iptr) {
34 // CHECK-LABEL: define {{.*}}void @pr8880_cg_2(
35   int i, j;
36 // CHECK: br label %[[OUTER_COND:[0-9A-Za-z$._]+]]
37   for (i = 2; i != 10 ; i++ )
38 // CHECK: [[OUTER_COND]]
39 // CHECK: label %[[OUTER_BODY:[0-9A-Za-z$._]+]], label %[[OUTER_END:[0-9A-Za-z$._]+]]
40 // CHECK: [[OUTER_BODY]]
41 // CHECK: br label %[[INNER_COND:[0-9A-Za-z$._]+]]
42     for (j = 3 ; j < 22; (void)({ ++j; continue; j;})) {
43 // CHECK: [[INNER_COND]]
44 // CHECK: label %[[INNER_BODY:[0-9A-Za-z$._]+]], label %[[INNER_END:[0-9A-Za-z$._]+]]
45 // CHECK: [[INNER_BODY]]
46       *iptr = 7;
47 // CHECK: store i32 7,
48 // CHECK: br label %[[INNER_INC:[0-9A-Za-z$._]+]]
49 // CHECK: [[INNER_INC]]
50 
51 // continue in 3rd expression of inner loop causes branch to inc of inner loop
52 
53 // CHECK: br label %[[INNER_INC]]
54 // CHECK: [[INNER_END]]
55     }
56 // CHECK: br label %[[OUTER_INC:[0-9A-Za-z$._]+]]
57 // CHECK: [[OUTER_INC]]
58 // CHECK: br label %[[OUTER_COND]]
59 // CHECK: [[OUTER_END]]
60 // CHECK: ret
61 }
62 
pr8880_cg_3(int * iptr)63 void pr8880_cg_3(int *iptr) {
64 // CHECK-LABEL: define {{.*}}void @pr8880_cg_3(
65   int i, j;
66 // CHECK: br label %[[OUTER_COND:[0-9A-Za-z$._]+]]
67   for (i = 2 ; i != 10 ; i++ )
68 // CHECK: [[OUTER_COND]]
69 // CHECK: label %[[OUTER_BODY:[0-9A-Za-z$._]+]], label %[[OUTER_END:[0-9A-Za-z$._]+]]
70 // CHECK: [[OUTER_BODY]]
71 // CHECK: br label %[[INNER_COND:[0-9A-Za-z$._]+]]
72     for (j = 3 ; ({break; j;}); j++) {
73 
74 // break in 2nd expression of inner loop causes branch to end of inner loop
75 
76 // CHECK: [[INNER_COND]]
77 // CHECK: br label %[[INNER_END:[0-9A-Za-z$._]+]]
78 // CHECK: label %[[INNER_BODY:[0-9A-Za-z$._]+]], label %[[INNER_END:[0-9A-Za-z$._]+]]
79 // CHECK: [[INNER_BODY]]
80       *iptr = 7;
81 // CHECK: store i32 7,
82 // CHECK: br label %[[INNER_INC:[0-9A-Za-z$._]+]]
83 // CHECK: [[INNER_INC]]
84 // CHECK: br label %[[INNER_COND]]
85     }
86 // CHECK: [[INNER_END]]
87 // CHECK: br label %[[OUTER_INC:[0-9A-Za-z$._]+]]
88 // CHECK: [[OUTER_INC]]
89 // CHECK: br label %[[OUTER_COND]]
90 // CHECK: [[OUTER_END]]
91 // CHECK: ret
92 }
93 
pr8880_cg_4(int * iptr)94 void pr8880_cg_4(int *iptr) {
95 // CHECK-LABEL: define {{.*}}void @pr8880_cg_4(
96   int i, j;
97 // CHECK: br label %[[OUTER_COND:[0-9A-Za-z$._]+]]
98   for (i = 2 ; i != 10 ; i++ )
99 // CHECK: [[OUTER_COND]]
100 // CHECK: label %[[OUTER_BODY:[0-9A-Za-z$._]+]], label %[[OUTER_END:[0-9A-Za-z$._]+]]
101 // CHECK: [[OUTER_BODY]]
102 // CHECK: br label %[[INNER_COND:[0-9A-Za-z$._]+]]
103     for (j = 3 ; ({continue; j;}); j++) {
104 
105 // continue in 2nd expression of inner loop causes branch to inc of inner loop
106 
107 // CHECK: [[INNER_COND]]
108 // CHECK: br label %[[INNER_INC:[0-9A-Za-z$._]+]]
109 // CHECK: label %[[INNER_BODY:[0-9A-Za-z$._]+]], label %[[INNER_END:[0-9A-Za-z$._]+]]
110 // CHECK: [[INNER_BODY]]
111       *iptr = 7;
112 // CHECK: store i32 7,
113 // CHECK: br label %[[INNER_INC]]
114 // CHECK: [[INNER_INC]]
115 // CHECK: br label %[[INNER_COND]]
116     }
117 // CHECK: [[INNER_END]]
118 // CHECK: br label %[[OUTER_INC:[0-9A-Za-z$._]+]]
119 // CHECK: [[OUTER_INC]]
120 // CHECK: br label %[[OUTER_COND]]
121 // CHECK: [[OUTER_END]]
122 // CHECK: ret
123 }
124 
pr8880_cg_5(int x,int * iptr)125 void pr8880_cg_5(int x, int *iptr) {
126 // CHECK-LABEL: define {{.*}}void @pr8880_cg_5(
127   int y = 5;
128 // CHECK: br label %[[OUTER_COND:[0-9A-Za-z$._]+]]
129 // CHECK: [[OUTER_COND]]
130   while(--x) {
131 // CHECK: label %[[OUTER_BODY:[0-9A-Za-z$._]+]], label %[[OUTER_END:[0-9A-Za-z$._]+]]
132 // CHECK: [[OUTER_BODY]]
133 // CHECK: br label %[[INNER_COND:[0-9A-Za-z$._]+]]
134     while(({ break; --y; })) {
135 // CHECK: [[INNER_COND]]
136 // CHECK: br label %[[INNER_END:[0-9A-Za-z$._]+]]
137 // CHECK: label %[[INNER_BODY:[0-9A-Za-z$._]+]], label %[[INNER_END:[0-9A-Za-z$._]+]]
138 // CHECK: [[INNER_BODY]]
139       *iptr = 7;
140 // CHECK: store i32 7,
141     }
142 // CHECK: br label %[[INNER_COND]]
143   }
144 // CHECK: [[INNER_END]]
145 // CHECK: br label %[[OUTER_COND]]
146 // CHECK: [[OUTER_END]]
147 // CHECK: ret void
148 }
149 
pr8880_cg_6(int x,int * iptr)150 void pr8880_cg_6(int x, int *iptr) {
151 // CHECK-LABEL: define {{.*}}void @pr8880_cg_6(
152   int y = 5;
153 // CHECK: br label %[[OUTER_COND:[0-9A-Za-z$._]+]]
154 // CHECK: [[OUTER_COND]]
155   while(--x) {
156 // CHECK: label %[[OUTER_BODY:[0-9A-Za-z$._]+]], label %[[OUTER_END:[0-9A-Za-z$._]+]]
157 // CHECK: [[OUTER_BODY]]
158 // CHECK: br label %[[INNER_BODY:[0-9A-Za-z$._]+]]
159 // CHECK: [[INNER_BODY]]
160     do {
161 // CHECK: store i32 7,
162       *iptr = 7;
163 // CHECK: br label %[[INNER_COND:[0-9A-Za-z$._]+]]
164     } while(({ break; --y; }));
165 // CHECK: [[INNER_COND]]
166 // CHECK: br label %[[INNER_END:[0-9A-Za-z$._]+]]
167 // CHECK: label %[[INNER_BODY:[0-9A-Za-z$._]+]], label %[[INNER_END]]
168   }
169 // CHECK: [[INNER_END]]
170 // CHECK: br label %[[OUTER_COND]]
171 // CHECK: [[OUTER_END]]
172 // CHECK: ret void
173 }
174