Changes in / [753f13c9:3fd3bda]


Ignore:
Location:
src
Files:
3 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/MLEMutator.cc

    r753f13c9 r3fd3bda  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar  8 17:08:25 2018
    13 // Update Count     : 219
     12// Last Modified On : Thu Aug  4 11:21:32 2016
     13// Update Count     : 202
    1414//
    1515
     
    3838        }
    3939        namespace {
    40                 bool isLoop( const MLEMutator::Entry & e ) { return dynamic_cast< WhileStmt * >( e.get_controlStructure() ) || dynamic_cast< ForStmt * >( e.get_controlStructure() ); }
    41                 bool isSwitch( const MLEMutator::Entry & e ) { return dynamic_cast< SwitchStmt *>( e.get_controlStructure() ); }
    42 
    43                 bool isBreakTarget( const MLEMutator::Entry & e ) { return isLoop( e ) || isSwitch( e ) || dynamic_cast< CompoundStmt *>( e.get_controlStructure() ); }
    44                 bool isContinueTarget( const MLEMutator::Entry & e ) { return isLoop( e ); }
    45                 bool isFallthroughTarget( const MLEMutator::Entry & e ) { return dynamic_cast< CaseStmt *>( e.get_controlStructure() );; }
    46                 bool isFallthroughDefaultTarget( const MLEMutator::Entry & e ) { return isSwitch( e ); }
    47         } // namespace
     40                Statement * isLoop( Statement * stmt ) { return dynamic_cast< WhileStmt * >( stmt ) ? stmt : dynamic_cast< ForStmt * >( stmt ) ? stmt : 0; }
     41        }
    4842
    4943        // break labels have to come after the statement they break out of, so mutate a statement, then if they inform us
    5044        // through the breakLabel field tha they need a place to jump to on a break statement, add the break label to the
    5145        // body of statements
    52         void MLEMutator::fixBlock( std::list< Statement * > &kids, bool caseClause ) {
    53                 SemanticErrorException errors;
    54 
     46        void MLEMutator::fixBlock( std::list< Statement * > &kids ) {
    5547                for ( std::list< Statement * >::iterator k = kids.begin(); k != kids.end(); k++ ) {
    56                         if ( caseClause ) {
    57                                 // once a label is seen, it's no longer a valid fallthrough target
    58                                 for ( Label & l : (*k)->labels ) {
    59                                         fallthroughLabels.erase( l );
    60                                 }
    61                         }
    62 
    63                         // aggregate errors since the PassVisitor mutate loop was unrollled
    64                         try {
    65                                 *k = (*k)->acceptMutator(*visitor);
    66                         } catch( SemanticErrorException &e ) {
    67                                 errors.append( e );
    68                         }
     48                        *k = (*k)->acceptMutator(*visitor);
    6949
    7050                        if ( ! get_breakLabel().empty() ) {
     
    7555                        } // if
    7656                } // for
    77 
    78                 if ( ! errors.isEmpty() ) {
    79                         throw errors;
    80                 }
    8157        }
    8258
     
    8763                        Label brkLabel = generator->newLabel("blockBreak", cmpndStmt);
    8864                        enclosingControlStructures.push_back( Entry( cmpndStmt, brkLabel ) );
    89                         GuardAction( [this]() { enclosingControlStructures.pop_back(); } );
    9065                } // if
    9166
     
    9974                                set_breakLabel( enclosingControlStructures.back().useBreakExit() );
    10075                        } // if
     76                        enclosingControlStructures.pop_back();
    10177                } // if
    10278        }
     
    136112                                        if ( isContinue ) {
    137113                                                // continue target is outermost loop
    138                                                 targetEntry = std::find_if( enclosingControlStructures.rbegin(), enclosingControlStructures.rend(), isContinueTarget );
     114                                                targetEntry = std::find_if( enclosingControlStructures.rbegin(), enclosingControlStructures.rend(), [](Entry &e) { return isLoop( e.get_controlStructure() ); } );
    139115                                        } else {
    140                                                 // break target is outermost loop, switch, or block control structure
    141                                                 if ( enclosingControlStructures.empty() ) SemanticError( branchStmt->location, "'break' outside a loop, 'switch', or labelled block" );
    142                                                 targetEntry = std::find_if( enclosingControlStructures.rbegin(), enclosingControlStructures.rend(), isBreakTarget );
     116                                                // break target is outmost control structure
     117                                                if ( enclosingControlStructures.empty() ) SemanticError( branchStmt->location, "'break' outside a loop, switch, or labelled block" );
     118                                                targetEntry = enclosingControlStructures.rbegin();
    143119                                        } // if
    144120                                } else {
     
    147123                                } // if
    148124                                // ensure that selected target is valid
    149                                 if ( targetEntry == enclosingControlStructures.rend() || (isContinue && ! isContinueTarget( *targetEntry ) ) ) {
     125                                if ( targetEntry == enclosingControlStructures.rend() || (isContinue && ! isLoop( targetEntry->get_controlStructure() ) ) ) {
    150126                                        SemanticError( branchStmt->location, toString( (isContinue ? "'continue'" : "'break'"), " target must be an enclosing ", (isContinue ? "loop: " : "control structure: "), originalTarget ) );
    151127                                } // if
    152128                                break;
    153129                        }
    154                         case BranchStmt::FallThrough:
    155                                 targetEntry = std::find_if( enclosingControlStructures.rbegin(), enclosingControlStructures.rend(), isFallthroughTarget );
    156                                 // ensure that selected target is valid
    157                                 if ( targetEntry == enclosingControlStructures.rend() ) {
    158                                         SemanticError( branchStmt->location, "'fallthrough' must be enclosed in a 'switch' or 'choose'" );
    159                                 } // if
    160                                 if ( branchStmt->get_target() != "" ) {
    161                                         // labelled fallthrough
    162                                         // target must be in the set of valid fallthrough labels
    163                                         if ( ! fallthroughLabels.count( branchStmt->get_target() ) ) {
    164                                                 SemanticError( branchStmt->location, toString( "'fallthrough' target must be a later case statement: ", originalTarget ) );
    165                                         }
    166                                         return new BranchStmt( originalTarget, BranchStmt::Goto );
    167                                 }
    168                                 break;
    169                         case BranchStmt::FallThroughDefault: {
    170                                 // fallthrough default
    171                                 targetEntry = std::find_if( enclosingControlStructures.rbegin(), enclosingControlStructures.rend(), isFallthroughDefaultTarget );
    172 
    173                                 // ensure that fallthrough is within a switch or choose
    174                                 if ( targetEntry == enclosingControlStructures.rend() ) {
    175                                         SemanticError( branchStmt->location, "'fallthrough' must be enclosed in a 'switch' or 'choose'" );
    176                                 } // if
    177 
    178                                 // ensure that switch or choose has a default clause
    179                                 SwitchStmt * switchStmt = strict_dynamic_cast< SwitchStmt * >( targetEntry->get_controlStructure() );
    180                                 bool foundDefault = false;
    181                                 for ( Statement * stmt : switchStmt->statements ) {
    182                                         CaseStmt * caseStmt = strict_dynamic_cast< CaseStmt * >( stmt );
    183                                         if ( caseStmt->isDefault() ) {
    184                                                 foundDefault = true;
    185                                         } // if
    186                                 } // for
    187                                 if ( ! foundDefault ) {
    188                                         SemanticError( branchStmt->location, "'fallthrough default' must be enclosed in a 'switch' or 'choose' control structure with a 'default' clause" );
    189                                 }
    190                                 break;
    191                         }
    192 
    193130                        default:
    194131                                assert( false );
     
    206143                                exitLabel = targetEntry->useContExit();
    207144                                break;
    208                   case BranchStmt::FallThrough:
    209                                 assert( targetEntry->useFallExit() != "");
    210                                 exitLabel = targetEntry->useFallExit();
    211                                 break;
    212                   case BranchStmt::FallThroughDefault:
    213                                 assert( targetEntry->useFallDefaultExit() != "");
    214                                 exitLabel = targetEntry->useFallDefaultExit();
    215                                 // check that fallthrough default comes before the default clause
    216                                 if ( ! targetEntry->isFallDefaultValid() ) {
    217                                         SemanticError( branchStmt->location, "'fallthrough default' must precede the 'default' clause" );
    218                                 }
    219                                 break;
    220145                  default:
    221146                                assert(0);                                      // shouldn't be here
     
    262187                Label contLabel = generator->newLabel("loopContinue", loopStmt);
    263188                enclosingControlStructures.push_back( Entry( loopStmt, brkLabel, contLabel ) );
    264                 GuardAction( [this]() { enclosingControlStructures.pop_back(); } );
    265189        }
    266190
     
    273197
    274198                // this will take the necessary steps to add definitions of the previous two labels, if they are used.
    275                 loopStmt->body = mutateLoop( loopStmt->get_body(), e );
     199                loopStmt->set_body( mutateLoop( loopStmt->get_body(), e ) );
     200                enclosingControlStructures.pop_back();
    276201                return loopStmt;
    277202        }
     
    299224                        Label brkLabel = generator->newLabel("blockBreak", ifStmt);
    300225                        enclosingControlStructures.push_back( Entry( ifStmt, brkLabel ) );
    301                         GuardAction( [this]() { enclosingControlStructures.pop_back(); } );
    302226                } // if
    303227        }
     
    309233                                set_breakLabel( enclosingControlStructures.back().useBreakExit() );
    310234                        } // if
     235                        enclosingControlStructures.pop_back();
    311236                } // if
    312237                return ifStmt;
     
    315240        void MLEMutator::premutate( CaseStmt *caseStmt ) {
    316241                visit_children = false;
    317 
    318                 // mark default as seen before visiting its statements to catch default loops
    319                 if ( caseStmt->isDefault() ) {
    320                         enclosingControlStructures.back().seenDefault();
    321                 } // if
    322 
    323242                caseStmt->condition = maybeMutate( caseStmt->condition, *visitor );
    324                 Label fallLabel = generator->newLabel( "fallThrough", caseStmt );
    325                 {
    326                         // ensure that stack isn't corrupted by exceptions in fixBlock
    327                         auto guard = makeFuncGuard( [&]() { enclosingControlStructures.push_back( Entry( caseStmt, fallLabel ) ); }, [this]() { enclosingControlStructures.pop_back(); } );
    328 
    329                         // empty case statement
    330                         if( ! caseStmt->stmts.empty() ) {
    331                                 // the parser ensures that all statements in a case are grouped into a block
    332                                 CompoundStmt * block = strict_dynamic_cast< CompoundStmt * >( caseStmt->stmts.front() );
    333                                 fixBlock( block->kids, true );
    334 
    335                                 // add fallthrough label if necessary
    336                                 assert( ! enclosingControlStructures.empty() );
    337                                 if ( enclosingControlStructures.back().isFallUsed() ) {
    338                                         std::list<Label> ls{ enclosingControlStructures.back().useFallExit() };
    339                                         caseStmt->stmts.push_back( new NullStmt( ls ) );
    340                                 } // if
    341                         } // if
    342                 }
    343                 assert( ! enclosingControlStructures.empty() );
    344                 assertf( dynamic_cast<SwitchStmt *>( enclosingControlStructures.back().get_controlStructure() ), "Control structure enclosing a case clause must be a switch, but is: %s", toCString( enclosingControlStructures.back().get_controlStructure() ) );
    345                 if ( caseStmt->isDefault() ) {
    346                         if ( enclosingControlStructures.back().isFallDefaultUsed() ) {
    347                                 // add fallthrough default label if necessary
    348                                 std::list<Label> ls{ enclosingControlStructures.back().useFallDefaultExit() };
    349                                 caseStmt->stmts.push_front( new NullStmt( ls ) );
    350                         } // if
    351                 } // if
     243                fixBlock( caseStmt->stmts );
    352244        }
    353245
     
    355247                // generate a label for breaking out of a labeled switch
    356248                Label brkLabel = generator->newLabel("switchBreak", switchStmt);
    357                 auto it = std::find_if( switchStmt->statements.rbegin(), switchStmt->statements.rend(), [](Statement * stmt) {
    358                         CaseStmt * caseStmt = strict_dynamic_cast< CaseStmt * >( stmt );
    359                         return caseStmt->isDefault();
    360                 });
    361                 CaseStmt * defaultCase = it != switchStmt->statements.rend() ? strict_dynamic_cast<CaseStmt *>( *it ) : nullptr;
    362                 Label fallDefaultLabel = defaultCase ? generator->newLabel( "fallThroughDefault", defaultCase ) : "";
    363                 enclosingControlStructures.push_back( Entry(switchStmt, brkLabel, fallDefaultLabel) );
    364                 GuardAction( [this]() { enclosingControlStructures.pop_back(); } );
    365 
    366                 // Collect valid labels for fallthrough. This is initially all labels at the same level as a case statement.
    367                 // As labels are seen during traversal, they are removed, since fallthrough is not allowed to jump backwards.
    368                 for ( Statement * stmt : switchStmt->statements ) {
    369                         CaseStmt * caseStmt = strict_dynamic_cast< CaseStmt * >( stmt );
    370                         if ( caseStmt->stmts.empty() ) continue;
    371                         CompoundStmt * block = dynamic_cast< CompoundStmt * >( caseStmt->stmts.front() );
    372                         for ( Statement * stmt : block->kids ) {
    373                                 for ( Label & l : stmt->labels ) {
    374                                         fallthroughLabels.insert( l );
    375                                 }
    376                         }
    377                 }
     249                enclosingControlStructures.push_back( Entry(switchStmt, brkLabel) );
    378250        }
    379251
     
    400272
    401273                assert ( enclosingControlStructures.back() == switchStmt );
     274                enclosingControlStructures.pop_back();
    402275                return switchStmt;
    403276        }
  • src/ControlStruct/MLEMutator.h

    r753f13c9 r3fd3bda  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar  8 16:42:32 2018
    13 // Update Count     : 41
     12// Last Modified On : Sat Jul 22 09:19:59 2017
     13// Update Count     : 35
    1414//
    1515
     
    1919#include <map>                     // for map
    2020#include <string>                  // for string
    21 #include <set>                     // for unordered_set
    2221
    2322#include "Common/PassVisitor.h"
     
    3029        class LabelGenerator;
    3130
    32         class MLEMutator : public WithVisitorRef<MLEMutator>, public WithShortCircuiting, public WithGuards {
     31        class MLEMutator : public WithVisitorRef<MLEMutator>, public WithShortCircuiting {
     32                class Entry;
     33
    3334          public:
    34                 class Entry;
    3535                MLEMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) : targetTable( t ), breakLabel(std::string("")), generator( gen ) {}
    3636                ~MLEMutator();
     
    5252                Label &get_breakLabel() { return breakLabel; }
    5353                void set_breakLabel( Label newValue ) { breakLabel = newValue; }
    54 
     54          private:
    5555                class Entry {
    5656                  public:
    57                         // specialized constructors for each combination of statement with labelled break/continue/fallthrough that is valid to cleanup the use cases
    58                         explicit Entry( ForStmt *stmt, Label breakExit, Label contExit ) :
    59                                 stmt( stmt ), breakExit( breakExit ), contExit( contExit ) {}
     57                        explicit Entry( Statement *_loop, Label _breakExit, Label _contExit = Label("") ) :
     58                                loop( _loop ), breakExit( _breakExit ), contExit( _contExit ), breakUsed(false), contUsed(false) {}
    6059
    61                         explicit Entry( WhileStmt *stmt, Label breakExit, Label contExit ) :
    62                                 stmt( stmt ), breakExit( breakExit ), contExit( contExit ) {}
     60                        bool operator==( const Statement *stmt ) { return loop == stmt; }
     61                        bool operator!=( const Statement *stmt ) { return loop != stmt; }
    6362
    64                         explicit Entry( CompoundStmt *stmt, Label breakExit ) :
    65                                 stmt( stmt ), breakExit( breakExit ) {}
     63                        bool operator==( const Entry &other ) { return loop == other.get_controlStructure(); }
    6664
    67                         explicit Entry( IfStmt *stmt, Label breakExit ) :
    68                                 stmt( stmt ), breakExit( breakExit ) {}
    69 
    70                         explicit Entry( CaseStmt *stmt, Label fallExit ) :
    71                                 stmt( stmt ), fallExit( fallExit ) {}
    72 
    73                         explicit Entry( SwitchStmt *stmt, Label breakExit, Label fallDefaultExit ) :
    74                                 stmt( stmt ), breakExit( breakExit ), fallDefaultExit( fallDefaultExit ) {}
    75 
    76                         bool operator==( const Statement *other ) { return stmt == other; }
    77                         bool operator!=( const Statement *other ) { return stmt != other; }
    78 
    79                         bool operator==( const Entry &other ) { return stmt == other.get_controlStructure(); }
    80 
    81                         Statement *get_controlStructure() const { return stmt; }
     65                        Statement *get_controlStructure() const { return loop; }
    8266
    8367                        Label useContExit() { contUsed = true; return contExit; }
    8468                        Label useBreakExit() { breakUsed = true; return breakExit; }
    85                         Label useFallExit() { fallUsed = true; return fallExit; }
    86                         Label useFallDefaultExit() { fallDefaultUsed = true; return fallDefaultExit; }
    8769
    8870                        bool isContUsed() const { return contUsed; }
    8971                        bool isBreakUsed() const { return breakUsed; }
    90                         bool isFallUsed() const { return fallUsed; }
    91                         bool isFallDefaultUsed() const { return fallDefaultUsed; }
    92                         void seenDefault() { fallDefaultValid = false; }
    93                         bool isFallDefaultValid() const { return fallDefaultValid; }
    9472                  private:
    95                         Statement *stmt;
    96                         Label breakExit, contExit, fallExit, fallDefaultExit;
    97                         bool breakUsed = false, contUsed = false, fallUsed = false, fallDefaultUsed = false;
    98                         bool fallDefaultValid = true;
     73                        Statement *loop;
     74                        Label breakExit, contExit;
     75                        bool breakUsed, contUsed;
    9976                };
    10077
    101           private:
    10278                std::map< Label, Statement * > *targetTable;
    103                 std::set< Label > fallthroughLabels;
    10479                std::list< Entry > enclosingControlStructures;
    10580                Label breakLabel;
     
    11287                Statement * posthandleLoopStmt( LoopClass * loopStmt );
    11388
    114                 void fixBlock( std::list< Statement * > &kids, bool caseClause = false );
     89                void fixBlock( std::list< Statement * > &kids );
    11590        };
    11691} // namespace ControlStruct
  • src/Parser/ParseNode.h

    r753f13c9 r3fd3bda  
    392392
    393393Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt );
    394 Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt );
     394Statement * build_switch( ExpressionNode * ctl, StatementNode * stmt );
    395395Statement * build_case( ExpressionNode * ctl );
    396396Statement * build_default();
  • src/Parser/StatementNode.cc

    r753f13c9 r3fd3bda  
    1010// Created On       : Sat May 16 14:59:41 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar  8 14:31:32 2018
    13 // Update Count     : 348
     12// Last Modified On : Fri Sep  1 23:25:23 2017
     13// Update Count     : 346
    1414//
    1515
     
    116116}
    117117
    118 Statement *build_switch( bool isSwitch, ExpressionNode *ctl, StatementNode *stmt ) {
     118Statement *build_switch( ExpressionNode *ctl, StatementNode *stmt ) {
    119119        std::list< Statement * > branches;
    120120        buildMoveList< Statement, StatementNode >( stmt, branches );
    121         if ( ! isSwitch ) {                                                                             // choose statement
    122                 for ( Statement * stmt : branches ) {
    123                         CaseStmt * caseStmt = strict_dynamic_cast< CaseStmt * >( stmt );
    124                         if ( ! caseStmt->stmts.empty() ) {                      // code after "case" => end of case list
    125                                 CompoundStmt * block = strict_dynamic_cast< CompoundStmt * >( caseStmt->stmts.front() );
    126                                 block->kids.push_back( new BranchStmt( "", BranchStmt::Break ) );
    127                         } // if
    128                 } // for
    129         } // if
    130121        // branches.size() == 0 for switch (...) {}, i.e., no declaration or statements
    131122        return new SwitchStmt( maybeMoveBuild< Expression >(ctl), branches );
  • src/Parser/parser.yy

    r753f13c9 r3fd3bda  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar  9 11:37:35 2018
    13 // Update Count     : 3075
     12// Last Modified On : Thu Feb 22 17:48:54 2018
     13// Update Count     : 3028
    1414//
    1515
     
    254254%type<sn> statement_decl                                statement_decl_list                     statement_list_nodecl
    255255%type<sn> selection_statement
    256 %type<sn> switch_clause_list_opt                switch_clause_list
     256%type<sn> switch_clause_list_opt                switch_clause_list                      choose_clause_list_opt          choose_clause_list
    257257%type<en> case_value
    258258%type<sn> case_clause                                   case_value_list                         case_label                                      case_label_list
     259%type<sn> fall_through                                  fall_through_opt
    259260%type<sn> iteration_statement                   jump_statement
    260261%type<sn> expression_statement                  asm_statement
     
    916917                { $$ = new StatementNode( build_if( $4, $6, $8 ) ); }
    917918        | SWITCH '(' comma_expression ')' case_clause
    918                 { $$ = new StatementNode( build_switch( true, $3, $5 ) ); }
     919                { $$ = new StatementNode( build_switch( $3, $5 ) ); }
    919920        | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
    920921                {
    921                         StatementNode *sw = new StatementNode( build_switch( true, $3, $8 ) );
     922                        StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );
    922923                        // The semantics of the declaration list is changed to include associated initialization, which is performed
    923924                        // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound
     
    928929                }
    929930        | CHOOSE '(' comma_expression ')' case_clause           // CFA
    930                 { $$ = new StatementNode( build_switch( false, $3, $5 ) ); }
    931         | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
    932                 {
    933                         StatementNode *sw = new StatementNode( build_switch( false, $3, $8 ) );
     931                { $$ = new StatementNode( build_switch( $3, $5 ) ); }
     932        | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA
     933                {
     934                        StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );
    934935                        $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
    935936                }
     
    969970        ;
    970971
    971 //label_list_opt:
    972 //      // empty
    973 //      | identifier_or_type_name ':'
    974 //      | label_list_opt identifier_or_type_name ':'
    975 //      ;
    976 
    977972case_label_list:                                                                                // CFA
    978973        case_label
     
    995990        | switch_clause_list case_label_list statement_list_nodecl
    996991                { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); }
     992        ;
     993
     994choose_clause_list_opt:                                                                 // CFA
     995        // empty
     996                { $$ = nullptr; }
     997        | choose_clause_list
     998        ;
     999
     1000choose_clause_list:                                                                             // CFA
     1001        case_label_list fall_through
     1002                { $$ = $1->append_last_case( $2 ); }
     1003        | case_label_list statement_list_nodecl fall_through_opt
     1004                { $$ = $1->append_last_case( new StatementNode( build_compound( (StatementNode *)$2->set_last( $3 ) ) ) ); }
     1005        | choose_clause_list case_label_list fall_through
     1006                { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( $3 ))); }
     1007        | choose_clause_list case_label_list statement_list_nodecl fall_through_opt
     1008                { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( (StatementNode *)$3->set_last( $4 ) ) ) ) ) ); }
     1009        ;
     1010
     1011fall_through_opt:                                                                               // CFA
     1012        // empty
     1013                { $$ = new StatementNode( build_branch( BranchStmt::Break ) ); } // insert implicit break
     1014        | fall_through
     1015        ;
     1016
     1017fall_through_name:                                                                              // CFA
     1018        FALLTHRU
     1019        | FALLTHROUGH
     1020        ;
     1021
     1022fall_through:                                                                                   // CFA
     1023        fall_through_name
     1024                { $$ = nullptr; }
     1025        | fall_through_name ';'
     1026                { $$ = nullptr; }
    9971027        ;
    9981028
     
    10201050                // whereas normal operator precedence yields goto (*i)+3;
    10211051                { $$ = new StatementNode( build_computedgoto( $3 ) ); }
    1022                 // A semantic check is required to ensure fallthru appears only in the body of a choose statement.
    1023     | fall_through_name ';'                                                             // CFA
    1024                 { $$ = new StatementNode( build_branch( BranchStmt::FallThrough ) ); }
    1025     | fall_through_name identifier_or_type_name ';'             // CFA
    1026                 { $$ = new StatementNode( build_branch( $2, BranchStmt::FallThrough ) ); }
    1027         | fall_through_name DEFAULT ';'                                         // CFA
    1028                 { $$ = new StatementNode( build_branch( BranchStmt::FallThroughDefault ) ); }
    10291052        | CONTINUE ';'
    10301053                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
     
    10531076        ;
    10541077
    1055 fall_through_name:                                                                              // CFA
    1056         FALLTHRU
    1057         | FALLTHROUGH
    1058         ;
    1059 
    10601078with_statement:
    10611079        WITH '(' tuple_expression_list ')' statement
     
    10721090
    10731091when_clause:
    1074         WHEN '(' comma_expression ')'                           { $$ = $3; }
     1092        WHEN '(' comma_expression ')'
     1093                { $$ = $3; }
    10751094        ;
    10761095
     
    10961115
    10971116timeout:
    1098         TIMEOUT '(' comma_expression ')'                        { $$ = $3; }
     1117        TIMEOUT '(' comma_expression ')'
     1118                { $$ = $3; }
    10991119        ;
    11001120
     
    11391159        //empty
    11401160                { $$ = nullptr; }
    1141         | ';' conditional_expression                            { $$ = $2; }
     1161        | ';' conditional_expression
     1162                { $$ = $2; }
    11421163        ;
    11431164
    11441165handler_key:
    1145         CATCH                                                                           { $$ = CatchStmt::Terminate; }
    1146         | CATCHRESUME                                                           { $$ = CatchStmt::Resume; }
     1166        CATCH
     1167                { $$ = CatchStmt::Terminate; }
     1168        | CATCHRESUME
     1169                { $$ = CatchStmt::Resume; }
    11471170        ;
    11481171
    11491172finally_clause:
    1150         FINALLY compound_statement                                      { $$ = new StatementNode( build_finally( $2 ) ); }
     1173        FINALLY compound_statement
     1174                {
     1175                        $$ = new StatementNode( build_finally( $2 ) );
     1176                }
    11511177        ;
    11521178
     
    23872413                        $$ = $2;
    23882414                }
    2389         | type_qualifier_list '{' external_definition_list '}'                  // CFA, namespace
     2415        | forall '{' external_definition_list '}'                       // CFA, namespace
    23902416        ;
    23912417
  • src/SynTree/Statement.cc

    r753f13c9 r3fd3bda  
    3434Statement::Statement( const std::list<Label> & labels ) : labels( labels ) {}
    3535
    36 void Statement::print( std::ostream & os, Indenter indent ) const {
     36void Statement::print( std::ostream & os, Indenter ) const {
    3737        if ( ! labels.empty() ) {
    38                 os << indent << "... Labels: {";
     38                os << "Labels: {";
    3939                for ( const Label & l : labels ) {
    4040                        os << l << ",";
     
    223223
    224224void CaseStmt::print( std::ostream &os, Indenter indent ) const {
    225         if ( isDefault() ) os << indent << "Default ";
     225        if ( isDefault() ) os << "Default ";
    226226        else {
    227                 os << indent << "Case ";
     227                os << "Case ";
    228228                condition->print( os, indent );
    229229        } // if
     
    231231
    232232        for ( Statement * stmt : stmts ) {
    233                 os << indent+1;
    234233                stmt->print( os, indent+1 );
    235234        }
     
    479478}
    480479
    481 void NullStmt::print( std::ostream &os, Indenter indent ) const {
     480void NullStmt::print( std::ostream &os, Indenter ) const {
    482481        os << "Null Statement" << endl;
    483         Statement::print( os, indent );
    484482}
    485483
  • src/SynTree/Statement.h

    r753f13c9 r3fd3bda  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar  8 14:53:02 2018
    13 // Update Count     : 78
     12// Last Modified On : Sun Sep  3 20:46:46 2017
     13// Update Count     : 77
    1414//
    1515
     
    255255class BranchStmt : public Statement {
    256256  public:
    257         enum Type { Goto = 0, Break, Continue, FallThrough, FallThroughDefault };
     257        enum Type { Goto = 0, Break, Continue };
    258258
    259259        // originalTarget kept for error messages.
  • src/tests/Makefile.am

    r753f13c9 r3fd3bda  
    110110        ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
    111111
    112 fallthrough-ERROR: fallthrough.c @CFA_BINDIR@/@CFA_NAME@
    113         ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
    114 
    115112# Constructor/destructor tests
    116113raii/dtor-early-exit-ERR1: raii/dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@
  • src/tests/Makefile.in

    r753f13c9 r3fd3bda  
    787787        ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
    788788
    789 fallthrough-ERROR: fallthrough.c @CFA_BINDIR@/@CFA_NAME@
    790         ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
    791 
    792789# Constructor/destructor tests
    793790raii/dtor-early-exit-ERR1: raii/dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@
Note: See TracChangeset for help on using the changeset viewer.