Changeset 515a037 for tests/fallthrough.cfa
- Timestamp:
- Dec 12, 2018, 3:52:19 PM (7 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:
- 1b8f13f0
- Parents:
- cdc02f2 (diff), 85acec94 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 moved
-
tests/fallthrough.cfa (moved) (moved from tests/fallthrough.c ) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/fallthrough.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // fallthrough.c --7 // fallthrough.cfa -- 8 8 // 9 9 // Author : Rob Schluntz 10 10 // Created On : Wed Mar 14 10:06:25 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 16 08:21:46201813 // Update Count : 1 412 // Last Modified On : Tue Dec 4 21:36:14 2018 13 // Update Count : 17 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"; 20 22 fallthru; 21 23 case 2: 22 printf("case 2\n");24 sout | "case 2"; 23 25 fallthru; 24 printf("did not fallthru\n");26 sout | "did not fallthru"; 25 27 if ( 7 ) fallthru common2; 26 28 fallthru common1; 27 29 case 3: 28 printf("case 3\n");30 sout | "case 3"; 29 31 fallthru default; 30 32 fallthru common1; 31 33 common1: 32 printf("common1\n");34 sout | "common1"; 33 35 // break 34 36 case 4: 35 printf("case 4\n");37 sout | "case 4"; 36 38 fallthru common2; 37 39 case 5: 38 printf("case 5\n");40 sout | "case 5"; 39 41 fallthru common2; 40 42 fallthru default; 41 43 case 6: 42 printf("case 6\n");44 sout | "case 6"; 43 45 fallthru common2; 44 46 common2: 45 printf("common2\n");47 sout | "common2"; 46 48 // break 47 49 default: 48 printf("default\n");50 sout | "default"; 49 51 fallthru; 50 52 } 51 53 52 printf("\n");54 sout | nl; 53 55 54 56 switch ( choice ) { 55 57 case 1: 56 printf("case 1\n");58 sout | "case 1"; 57 59 switch ( choice ) { 58 60 case 1: 59 printf("case 1\n");61 sout | "case 1"; 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"; 68 70 if ( choice == 5 ) { 69 71 if ( choice != 5 ) { 70 printf("error\n");72 sout | "error"; 71 73 } else { 72 printf("check\n");74 sout | "check"; 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 | nl; 120 test( 5 ); 119 121 } 120 122 121 123 // Local Variables: // 122 124 // tab-width: 4 // 123 // compile-command: "cfa fallthrough.c " //125 // compile-command: "cfa fallthrough.cfa" // 124 126 // End: //
Note:
See TracChangeset
for help on using the changeset viewer.