ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since c13d970 was
540b275,
checked in by Thierry Delisle <tdelisle@…>, 8 years ago
|
added labelled break on if statments to relevant tests
|
-
Property mode set to
100644
|
File size:
2.3 KB
|
Rev | Line | |
---|
[10dc7491] | 1 | int foo() { |
---|
[62edde5] | 2 | int i; |
---|
| 3 | int x, y; |
---|
| 4 | |
---|
| 5 | x = 0; y = 0; |
---|
| 6 | |
---|
| 7 | // block, labelled exits |
---|
| 8 | |
---|
| 9 | Block: { |
---|
| 10 | if ( x == y ) { |
---|
| 11 | for ( ; i < y; ) { |
---|
| 12 | y += 1; |
---|
| 13 | if ( y < 10 ) break Block; |
---|
| 14 | } |
---|
| 15 | } |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | // loops, labelled exits |
---|
| 19 | |
---|
| 20 | w1: while ( y == 10 ); |
---|
| 21 | |
---|
| 22 | w2: while ( x < 10 ) { |
---|
| 23 | while (y < 5 ) { |
---|
| 24 | if ( y == 3 ) break w2; |
---|
| 25 | } |
---|
| 26 | x += 1; |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | A: for ( i = 0; i < 10; i += 1 ) { |
---|
| 30 | B: for ( i = 0; i < 10; i += 1 ) { |
---|
| 31 | C: for ( i = 0; i < 10; i += 1 ) { |
---|
| 32 | goto A; |
---|
| 33 | goto B; |
---|
| 34 | goto C; |
---|
| 35 | continue A; |
---|
| 36 | continue B; |
---|
| 37 | continue C; |
---|
| 38 | continue; |
---|
| 39 | break A; |
---|
| 40 | break B; |
---|
| 41 | break C; |
---|
| 42 | break; |
---|
| 43 | } |
---|
| 44 | } |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | D: for ( ;; ) { |
---|
| 48 | break D; |
---|
| 49 | continue D; |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | Z : i += 1; |
---|
| 53 | goto Z; |
---|
| 54 | X: Y: for ( ;; ) { |
---|
| 55 | i += 1; |
---|
| 56 | if ( i > 5 ) continue X; |
---|
| 57 | if ( i < 5 ) break X; |
---|
| 58 | if ( i < 5 ) break Y; |
---|
| 59 | break; |
---|
| 60 | } |
---|
| 61 | XX: for ( ;; ) { |
---|
| 62 | YY: for ( ;; ) { |
---|
| 63 | ZZ: for ( ;; ) { |
---|
| 64 | i += 1; |
---|
| 65 | if ( i > 5 ) continue XX; |
---|
| 66 | if ( i < 5 ) continue YY; |
---|
| 67 | if ( i < 5 ) continue ZZ; |
---|
| 68 | if ( i > 5 ) break XX; |
---|
| 69 | if ( i < 5 ) break YY; |
---|
| 70 | if ( i < 5 ) break ZZ; |
---|
| 71 | break; |
---|
| 72 | } |
---|
| 73 | } |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | for ( ;; ) ; |
---|
| 77 | for ( int i = 0 ;; ) ; |
---|
| 78 | for ( ; i < 0; ) ; |
---|
| 79 | for ( ; ; i += 1 ) ; |
---|
| 80 | L0: L1: L2: L3: L4: L5: L6: L7: L8: L9: |
---|
| 81 | L10: L11: L12: L13: L14: L15: L16: L17: L18: L19: |
---|
| 82 | L20: L21: L22: L23: L24: L25: L26: L27: L28: L29: |
---|
| 83 | L31: L32: L33: L34: |
---|
| 84 | for ( ;; ) { |
---|
| 85 | break L0; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | // switch/choose, labelled exits |
---|
| 89 | |
---|
| 90 | Switch: switch ( i ) { |
---|
| 91 | default: |
---|
| 92 | i += 1; |
---|
| 93 | case 0: |
---|
| 94 | i += 1; |
---|
| 95 | break Switch; |
---|
| 96 | case 1: |
---|
| 97 | switch ( i ) { |
---|
| 98 | case 0: |
---|
| 99 | break Switch; |
---|
| 100 | default: |
---|
| 101 | ; break; |
---|
| 102 | } |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | Choose: choose ( i ) { |
---|
| 106 | default: |
---|
| 107 | i += 1; |
---|
| 108 | case 0: |
---|
| 109 | i += 1; |
---|
| 110 | break Choose; |
---|
| 111 | case 1: |
---|
| 112 | choose ( i ) { |
---|
| 113 | case 0: |
---|
| 114 | break; |
---|
| 115 | default: |
---|
| 116 | break Choose; |
---|
| 117 | } |
---|
| 118 | fallthru; |
---|
| 119 | case 2: |
---|
| 120 | i += 1; |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | // computed goto |
---|
[c017d5b] | 124 | // { |
---|
| 125 | // void *array[] = { &&foo, &&bar, &&hack }; |
---|
| 126 | // foo: bar: hack: |
---|
| 127 | // &&foo; |
---|
| 128 | // &&bar; |
---|
| 129 | // goto *array[i]; |
---|
| 130 | // } |
---|
[62edde5] | 131 | |
---|
| 132 | Q: if ( i > 5 ) { |
---|
| 133 | i += 1; |
---|
[540b275] | 134 | break Q; |
---|
| 135 | } |
---|
| 136 | else |
---|
[62edde5] | 137 | i += 1; |
---|
[540b275] | 138 | |
---|
[62edde5] | 139 | } |
---|
| 140 | |
---|
[aaf1f4d] | 141 | int main(int argc, char const *argv[]) { |
---|
| 142 | /* code */ |
---|
| 143 | return 0; |
---|
| 144 | } |
---|
| 145 | |
---|
[62edde5] | 146 | // Local Variables: // |
---|
| 147 | // tab-width: 4 // |
---|
| 148 | // compile-command: "cfa LabelledExit.c" // |
---|
| 149 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.