Changeset 303d866
- Timestamp:
- Nov 8, 2018, 9:00:00 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 80228a7
- Parents:
- f1aeede
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/fallthrough.cfa
rf1aeede r303d866 10 10 // Created On : Wed Mar 14 10:06:25 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Nov 6 17:53:32201813 // Update Count : 1 512 // Last Modified On : Thu Nov 8 09:09:09 2018 13 // Update Count : 16 14 14 // 15 16 #include <fstream.hfa> 15 17 16 18 void test(int choice) { 17 19 choose ( choice ) { 18 20 case 1: 19 printf("case 1\n");21 sout | "case 1" | endl; 20 22 fallthru; 21 23 case 2: 22 printf("case 2\n");24 sout | "case 2" | endl; 23 25 fallthru; 24 printf("did not fallthru\n");26 sout | "did not fallthru" | endl; 25 27 if ( 7 ) fallthru common2; 26 28 fallthru common1; 27 29 case 3: 28 printf("case 3\n");30 sout | "case 3" | endl; 29 31 fallthru default; 30 32 fallthru common1; 31 33 common1: 32 printf("common1\n");34 sout | "common1" | endl; 33 35 // break 34 36 case 4: 35 printf("case 4\n");37 sout | "case 4" | endl; 36 38 fallthru common2; 37 39 case 5: 38 printf("case 5\n");40 sout | "case 5" | endl; 39 41 fallthru common2; 40 42 fallthru default; 41 43 case 6: 42 printf("case 6\n");44 sout | "case 6" | endl; 43 45 fallthru common2; 44 46 common2: 45 printf("common2\n");47 sout | "common2" | endl; 46 48 // break 47 49 default: 48 printf("default\n");50 sout | "default" | endl; 49 51 fallthru; 50 52 } 51 53 52 printf("\n");54 sout | endl; 53 55 54 56 switch ( choice ) { 55 57 case 1: 56 printf("case 1\n");58 sout | "case 1" | endl; 57 59 switch ( choice ) { 58 60 case 1: 59 printf("case 1\n");61 sout | "case 1" | endl; 60 62 for ( int i = 0; i < 4; i += 1 ) { 61 63 printf("%d\n", i); … … 65 67 break; 66 68 case 5: 67 printf("case 5\n");69 sout | "case 5" | endl; 68 70 if ( choice == 5 ) { 69 71 if ( choice != 5 ) { 70 printf("error\n");72 sout | "error" | endl; 71 73 } else { 72 printf("check\n");74 sout | "check" | endl; 73 75 fallthru common; 74 76 } // if … … 114 116 115 117 int main() { 116 test( 1);117 printf("\n");118 test( 5);118 test( 1 ); 119 sout | endl; 120 test( 5 ); 119 121 } 120 122
Note: See TracChangeset
for help on using the changeset viewer.