Changeset ddae809


Ignore:
Timestamp:
Nov 2, 2017, 3:34:40 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
f9941ff
Parents:
000178a
Message:

Silence warnings for tuple assignment

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    r000178a rddae809  
    501501                }
    502502
     503                // to prevent warnings (‘_unq0’ may be used uninitialized in this function),
     504                // insert an appropriate zero initializer for UniqueExpr temporaries.
     505                Initializer * makeInit( Type * t ) {
     506                        if ( StructInstType * inst = dynamic_cast< StructInstType * >( t ) ) {
     507                                // initizer for empty struct must be empty
     508                                if ( inst->baseStruct->members.empty() ) return new ListInit({});
     509                        } else if ( UnionInstType * inst = dynamic_cast< UnionInstType * >( t ) ) {
     510                                // initizer for empty union must be empty
     511                                if ( inst->baseUnion->members.empty() ) return new ListInit({});
     512                        }
     513
     514                        return new ListInit( { new SingleInit( new ConstantExpr( Constant::from_int( 0 ) ) ) } );
     515                }
     516
    503517                void ResolveCopyCtors::postvisit( UniqueExpr * unqExpr ) {
    504518                        if ( vars.count( unqExpr->get_id() ) ) {
     
    515529                        } else {
    516530                                // expr isn't a call expr, so create a new temporary variable to use to hold the value of the unique expression
    517                                 unqExpr->set_object( ObjectDecl::newObject( toString("_unq", unqExpr->get_id()), unqExpr->get_result()->clone(), nullptr ) );
     531                                unqExpr->set_object( ObjectDecl::newObject( toString("_unq", unqExpr->get_id()), unqExpr->get_result()->clone(), makeInit( unqExpr->get_result() ) ) );
    518532                                unqExpr->set_var( new VariableExpr( unqExpr->get_object() ) );
    519533                        }
Note: See TracChangeset for help on using the changeset viewer.