Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r5e2c348 r0690350  
    597597
    598598StmtExpr::StmtExpr( CompoundStmt *statements ) : statements( statements ) {
    599         computeResult();
     599        assert( statements );
     600        std::list< Statement * > & body = statements->get_kids();
     601        if ( ! body.empty() ) {
     602                if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( body.back() ) ) {
     603                        result = maybeClone( exprStmt->expr->result );
     604                }
     605        }
     606        // ensure that StmtExpr has a result type
     607        if ( ! result ) {
     608                result = new VoidType( Type::Qualifiers() );
     609        }
    600610}
    601611StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) {
     
    607617        deleteAll( dtors );
    608618        deleteAll( returnDecls );
    609 }
    610 void StmtExpr::computeResult() {
    611         assert( statements );
    612         std::list< Statement * > & body = statements->kids;
    613         delete result;
    614         result = nullptr;
    615         if ( ! body.empty() ) {
    616                 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( body.back() ) ) {
    617                         result = maybeClone( exprStmt->expr->result );
    618                 }
    619         }
    620         // ensure that StmtExpr has a result type
    621         if ( ! result ) {
    622                 result = new VoidType( Type::Qualifiers() );
    623         }
    624619}
    625620void StmtExpr::print( std::ostream &os, Indenter indent ) const {
Note: See TracChangeset for help on using the changeset viewer.