source: tests/ctrl-flow/labelledExit.cfa@ e1358c0

Last change on this file since e1358c0 was bada452, checked in by Andrew Beach <ajbeach@…>, 8 months ago

Removed warnings from serveral tests and removed them from the ..._TO_INVESTIGATE list. One test triggered a Cforall warning and a new test to check that has been added. collections/vector-demo has no warnings in its body, but the library it uses does have warnings and will have to move after that is fixed.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// labelledExit.cfa --
8//
9// Author : Peter A. Buhr
10// Created On : Wed Aug 10 07:29:39 2016
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Fri Jan 17 14:18:15 2025
13// Update Count : 14
14//
15
16int foo() {
17 int i = 0;
18 int x = 0, y = 0;
19
20 // block, labelled exits
21
22 Block: {
23 if ( x == y ) {
24 for ( ; i < y; ) {
25 y += 1;
26 if ( y < 10 ) break Block;
27 }
28 }
29 }
30
31 // loops, labelled exits
32
33 w1: while ( y == 10 ) break w1;
34
35 w2: while ( x < 10 ) {
36 while (y < 5 ) {
37 if ( y == 3 ) break w2;
38 }
39 x += 1;
40 }
41
42 A: for ( i = 0; i < 10; i += 1 ) {
43 B: for ( i = 0; i < 10; i += 1 ) {
44 C: for ( i = 0; i < 10; i += 1 ) {
45 goto A;
46 goto B;
47 goto C;
48 continue A;
49 continue B;
50 continue C;
51 continue;
52 break A;
53 break B;
54 break C;
55 break;
56 }
57 }
58 }
59
60 D: for () {
61 break D;
62 continue D;
63 }
64
65 Z : i += 1;
66 goto Z;
67 X: Y: for () {
68 i += 1;
69 if ( i > 5 ) continue X;
70 if ( i < 5 ) break X;
71 if ( i < 5 ) break Y;
72 break;
73 }
74 XX: for () {
75 YY: for () {
76 ZZ: for () {
77 i += 1;
78 if ( i > 5 ) continue XX;
79 if ( i < 5 ) continue YY;
80 if ( i < 5 ) continue ZZ;
81 if ( i > 5 ) break XX;
82 if ( i < 5 ) break YY;
83 if ( i < 5 ) break ZZ;
84 break;
85 }
86 }
87 }
88
89 for () ;
90 for ( int i = 0 ;; ) ++i;
91 for ( ; i < 0; ) ;
92 for ( ; ; i += 1 ) ;
93 L0: L1: L2: L3: L4: L5: L6: L7: L8: L9:
94 L10: L11: L12: L13: L14: L15: L16: L17: L18: L19:
95 L20: L21: L22: L23: L24: L25: L26: L27: L28: L29:
96 L31: L32: L33: L34:
97 for () {
98 break L0;
99 break L1; break L2; break L3; break L4; break L5; break L6;
100 break L7; break L8; break L9; break L10; break L11; break L12;
101 break L13; break L14; break L15; break L16; break L17; break L18;
102 break L19; break L20; break L21; break L22; break L23; break L24;
103 break L25; break L26; break L27; break L28; break L29; break L31;
104 break L32; break L33; break L34;
105 }
106
107 // switch/choose, labelled exits
108
109 Switch: switch ( i ) {
110 default:
111 i += 1;
112 fallthrough;
113 case 0:
114 i += 1;
115 break Switch;
116 case 1:
117 switch ( i ) {
118 case 0:
119 break Switch;
120 default:
121 ; break;
122 }
123 }
124
125 Choose: choose ( i ) {
126 default:
127 i += 1;
128 case 0:
129 i += 1;
130 break Choose;
131 case 1:
132 choose ( i ) {
133 case 0:
134 break;
135 default:
136 break Choose;
137 }
138 fallthrough;
139 case 2:
140 i += 1;
141 }
142
143 // all nested control options, labelled exits
144
145 Comp: {
146 Try: try {
147 For: for ( ;; ) {
148 While: while ( true ) {
149 Do: do {
150 If: if ( true ) {
151 Switch2: switch ( 3 ) {
152 case 3:
153 break Try;
154 break Comp;
155 break For; continue For;
156 break While; continue While;
157 break Do; continue Do;
158 break If;
159 break Switch2;
160 } // switch
161 } // if
162 } while ( true );
163 } // while
164 } // for
165 } finally {} // always executed
166 } // compound
167
168 // computed goto
169 {
170 void *array[] = { &&foo, &&bar, &&hack };
171 foo: bar: hack:
172 &&foo;
173 &&bar;
174 goto *array[i];
175 }
176
177 Q: if ( i > 5 ) {
178 i += 1;
179 break Q;
180 }
181 else
182 i += 1;
183}
184
185int main() {
186 printf("done\n");
187}
188
189// Local Variables: //
190// tab-width: 4 //
191// compile-command: "cfa labelledExit.cfa" //
192// End: //
Note: See TracBrowser for help on using the repository browser.