Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/StatementNode.cc

    ra01f7c94 r2065609  
    9999        } // if
    100100
    101         Expression * cond = nullptr;
    102         if ( ctl->condition ) {
    103                 // compare the provided condition against 0
    104                 cond =  notZeroExpr( maybeMoveBuild< Expression >(ctl->condition) );
    105         } else {
    106                 for ( Statement * stmt : init ) {
    107                         // build the && of all of the declared variables compared against 0
    108                         DeclStmt * declStmt = safe_dynamic_cast< DeclStmt * >( stmt );
    109                         DeclarationWithType * dwt = safe_dynamic_cast< DeclarationWithType * >( declStmt->decl );
    110                         Expression * nze = notZeroExpr( new VariableExpr( dwt ) );
    111                         cond = cond ? new LogicalExpr( cond, nze, true ) : nze;
    112                 }
    113         }
     101        Expression * cond = ctl->condition ? maybeMoveBuild< Expression >(ctl->condition) : new VariableExpr( dynamic_cast<DeclarationWithType *>( dynamic_cast<DeclStmt *>( init.back() )->decl ) );
    114102        delete ctl;
    115         return new IfStmt( noLabels, cond, thenb, elseb, init );
     103        return new IfStmt( noLabels, notZeroExpr( cond ), thenb, elseb, init );
    116104}
    117105
Note: See TracChangeset for help on using the changeset viewer.