Changeset 6dfa2e1 for src/InitTweak


Ignore:
Timestamp:
Dec 22, 2017, 1:49:14 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
05a0ff2
Parents:
9fe33947
Message:

Do not attempt to construct/destruct StmtExprs? of non-constructable types

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    r9fe33947 r6dfa2e1  
    480480                                static UniqueName retNamer("_tmp_stmtexpr_ret");
    481481
    482                                 // create variable that will hold the result of the stmt expr
    483482                                result = result->clone();
    484483                                env->apply( result );
     484                                if ( ! InitTweak::isConstructable( result ) ) {
     485                                        delete result;
     486                                        return;
     487                                }
     488
     489                                // create variable that will hold the result of the stmt expr
    485490                                ObjectDecl * ret = ObjectDecl::newObject( retNamer.newName(), result, nullptr );
    486491                                ret->type->set_const( false );
     
    611616                                // must have a non-empty body, otherwise it wouldn't have a result
    612617                                assert( ! stmts.empty() );
    613                                 assertf( ! stmtExpr->get_returnDecls().empty(), "StmtExpr returns non-void, but no return decls: %s", toString( stmtExpr ).c_str() );
    614                                 stmts.push_back( new ExprStmt( new VariableExpr( stmtExpr->returnDecls.front() ) ) );
     618                                assertf( ! stmtExpr->returnDecls.empty() || stmtExpr->dtors.empty(), "StmtExpr returns non-void, but no return decls: %s", toString( stmtExpr ).c_str() );
     619                                // if there is a return decl, add a use as the last statement; will not have return decl on non-constructable returns
     620                                if ( ! stmtExpr->returnDecls.empty() ) {
     621                                        stmts.push_back( new ExprStmt( new VariableExpr( stmtExpr->returnDecls.front() ) ) );
     622                                }
    615623                                stmtExpr->returnDecls.clear();
    616624                                stmtExpr->dtors.clear();
Note: See TracChangeset for help on using the changeset viewer.