- Timestamp:
- Jul 3, 2015, 6:08:20 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- f6d7e0f
- Parents:
- 0df292b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Tests/LabelledExit.c
r0df292b r2871210 1 1 int main() { 2 3 2 int i; 3 int x, y; 4 4 5 5 x = 0; y = 0; 6 6 7 // block, labelled exits7 // block, labelled exits 8 8 9 9 Block: { 10 if ( x == y ) {11 12 y += 1;13 if ( y < 10 ) break Block;14 15 }16 10 if ( x == y ) { 11 for ( ; i < y; ) { 12 y += 1; 13 if ( y < 10 ) break Block; 14 } 15 } 16 } 17 17 18 // loops, labelled exits18 // loops, labelled exits 19 19 20 20 w1: while ( y == 10 ); 21 21 22 22 w2: while ( x < 10 ) { 23 24 25 26 27 }23 while (y < 5 ) { 24 if ( y == 3 ) break w2; 25 } 26 x += 1; 27 } 28 28 29 29 A: for ( i = 0; i < 10; i += 1 ) { 30 B: for ( i = 0; i < 10; i += 1 ) {31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 }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 46 47 47 D: for ( ;; ) { 48 49 50 }48 break D; 49 continue D; 50 } 51 51 52 53 52 Z : i += 1; 53 goto Z; 54 54 X: Y: for ( ;; ) { 55 56 57 58 59 60 }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 61 XX: for ( ;; ) { 62 YY: for ( ;; ) {63 64 65 66 67 68 69 70 71 72 73 74 }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 75 76 77 78 79 76 for ( ;; ) ; 77 for ( int i = 0 ;; ) ; 78 for ( ; i < 0; ) ; 79 for ( ; ; i += 1 ) ; 80 80 L0: L1: L2: L3: L4: L5: L6: L7: L8: L9: 81 81 L10: L11: L12: L13: L14: L15: L16: L17: L18: L19: 82 82 L20: L21: L22: L23: L24: L25: L26: L27: L28: L29: 83 83 L31: L32: L33: L34: 84 85 break L0;86 84 for ( ;; ) { 85 break L0; 86 } 87 87 88 // switch/choose, labelled exits88 // switch/choose, labelled exits 89 89 90 90 Switch: switch ( i ) { 91 default:92 93 case 0:94 95 96 case 1:97 98 99 100 101 102 103 }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 104 105 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 #if 0 123 // computed goto 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 } 124 122 125 { 126 static void *array[] = { &&foo, &&bar, &&hack }; 123 // computed goto 124 { 125 void *array[] = { &&foo, &&bar, &&hack }; 126 foo: bar: hack: 127 &&foo; 128 &&bar; 129 goto *array[i]; 130 } 127 131 128 foo: bar: hack:129 goto *array[i];130 }131 #endif132 132 #if 0 133 133 Q: if ( i > 5 ) { 134 135 136 137 134 i += 1; 135 break Q; 136 } else 137 i += 1; 138 138 #endif 139 139 } 140 141 // Local Variables: // 142 // tab-width: 4 // 143 // compile-command: "cfa LabelledExit.c" // 144 // End: //
Note: See TracChangeset
for help on using the changeset viewer.