Ignore:
Timestamp:
Jan 8, 2019, 11:31:21 AM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
08222c7, 274da98
Parents:
84b4d607 (diff), d5b2ac8 (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/fallthrough.cfa

    r84b4d607 r25cdca5  
    1010// Created On       : Wed Mar 14 10:06:25 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec  4 21:36:14 2018
    13 // Update Count     : 17
     12// Last Modified On : Mon Dec 24 11:24:35 2018
     13// Update Count     : 22
    1414//
    1515
     
    1818void test(int choice) {
    1919        choose ( choice ) {
    20                 case 1:
    21                         sout | "case 1";
    22                         fallthru;
    23                 case 2:
    24                         sout | "case 2";
    25                         fallthru;
    26                         sout | "did not fallthru";
    27                         if ( 7 ) fallthru common2;
    28                         fallthru common1;
    29                 case 3:
    30                         sout | "case 3";
    31                         fallthru default;
    32                         fallthru common1;
    33                 common1:
    34                         sout | "common1";
     20          case 1:
     21                sout | "case 1";
     22                fallthru;
     23          case 2:
     24                sout | "case 2";
     25                fallthru;
     26                sout | "did not fallthru";
     27                if ( 7 ) fallthru common2;
     28                fallthru common1;
     29          case 3:
     30                sout | "case 3";
     31                fallthru default;
     32                fallthru common1;
     33          common1:
     34                sout | "common1";
    3535                // break
    36                 case 4:
    37                         sout | "case 4";
    38                         fallthru common2;
    39                 case 5:
    40                         sout | "case 5";
    41                         fallthru common2;
    42                         fallthru default;
    43                 case 6:
    44                         sout | "case 6";
    45                         fallthru common2;
    46                 common2:
    47                         sout | "common2";
     36          case 4:
     37                sout | "case 4";
     38                fallthru common2;
     39          case 5:
     40                sout | "case 5";
     41                fallthru common2;
     42                fallthru default;
     43          case 6:
     44                sout | "case 6";
     45                fallthru common2;
     46          common2:
     47                sout | "common2";
    4848                // break
    49                 default:
    50                         sout | "default";
    51                         fallthru;
    52         }
     49          default:
     50                sout | "default";
     51                fallthru;
     52        } // choose
    5353
    5454        sout | nl;
     
    6161                        sout | "case 1";
    6262                        for ( int i = 0; i < 4; i += 1 ) {
    63                                 printf("%d\n", i);
     63                                sout | i;
    6464                                if ( i == 2 ) fallthru common;
    6565                        } // for
     
    7777                } // if
    7878          common:
    79                 printf( "common\n" );
     79                sout | "common";
    8080                fallthru;
    8181                break;
    8282          default:
    83                 printf( "default\n" );
     83                sout | "default";
    8484                fallthru;
    8585        } // switch
     
    9393        fallthru default;
    9494        choose ( 3 ) {
    95                 case 2:
    96                         for () {
    97                                 choose ( 2 ) {
    98                                         case 1:
    99                                                 // ERROR: default is later, but in a different switch
    100                                                 fallthru default;
    101                                                 // ERROR: common3 is later, but not at the same level as a case clause
    102                                                 fallthru common3;
    103                                 }
    104                                 common3: ;
     95          case 2:
     96                for () {
     97                        choose ( 2 ) {
     98                          case 1:
     99                                // ERROR: default is later, but in a different switch
     100                                fallthru default;
     101                                // ERROR: common3 is later, but not at the same level as a case clause
     102                                fallthru common3;
    105103                        }
    106                 default:
    107                 case 1:
    108                 common4:
    109                         // ERROR: attempt to jump up with fallthrough
    110                         if ( 7 ) fallthru common4;
    111                         // ERROR: attempt to jump up with fallthrough
    112                         fallthru default;
    113         }
     104                  common3: ;
     105                } // for
     106          default:
     107          case 1:
     108          common4:
     109                // ERROR: attempt to jump up with fallthrough
     110                if ( 7 ) fallthru common4;
     111                // ERROR: attempt to jump up with fallthrough
     112                fallthru default;
     113        } // choose
    114114#endif
    115115}
Note: See TracChangeset for help on using the changeset viewer.