Changes in src/ResolvExpr/Resolver.cc [62e5546:5f5083e]
- File:
-
- 1 edited
-
src/ResolvExpr/Resolver.cc (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Resolver.cc
r62e5546 r5f5083e 19 19 #include "RenameVars.h" 20 20 #include "ResolveTypeof.h" 21 #include "typeops.h" 21 22 #include "SynTree/Statement.h" 22 23 #include "SynTree/Type.h" … … 68 69 void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & ); 69 70 void fallbackInit( ConstructorInit * ctorInit ); 70 std::list< Type * > functionReturn; 71 Type *initContext; 71 72 Type * functionReturn = nullptr; 73 Type *initContext = nullptr; 72 74 bool inEnumDecl = false; 73 75 }; … … 157 159 const TypeEnvironment *newEnv = 0; 158 160 for ( AltList::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) { 159 if ( i->expr->get_result s().size() == 1 && isIntegralType( i->expr->get_results().front() ) ) {161 if ( i->expr->get_result()->size() == 1 && isIntegralType( i->expr->get_result() ) ) { 160 162 if ( newExpr ) { 161 163 throw SemanticError( "Too many interpretations for case control expression", untyped ); … … 234 236 Type *new_type = resolveTypeof( functionDecl->get_type(), *this ); 235 237 functionDecl->set_type( new_type ); 236 std::list< Type * > oldFunctionReturn = functionReturn; 237 functionReturn.clear(); 238 for ( std::list< DeclarationWithType * >::const_iterator i = functionDecl->get_functionType()->get_returnVals().begin(); i != functionDecl->get_functionType()->get_returnVals().end(); ++i ) { 239 functionReturn.push_back( (*i)->get_type() ); 240 } // for 238 ValueGuard< Type * > oldFunctionReturn( functionReturn ); 239 functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() ); 241 240 SymTab::Indexer::visit( functionDecl ); 242 functionReturn = oldFunctionReturn;243 241 } 244 242 … … 338 336 void Resolver::visit( ReturnStmt *returnStmt ) { 339 337 if ( returnStmt->get_expr() ) { 340 CastExpr *castExpr = new CastExpr( returnStmt->get_expr() ); 341 cloneAll( functionReturn, castExpr->get_results() ); 338 CastExpr *castExpr = new CastExpr( returnStmt->get_expr(), functionReturn->clone() ); 342 339 Expression *newExpr = findSingleExpression( castExpr, *this ); 343 340 delete castExpr; … … 384 381 if ( isCharType( at->get_base() ) ) { 385 382 // check if the resolved type is char * 386 if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result s().front() ) ) {383 if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) { 387 384 if ( isCharType( pt->get_base() ) ) { 388 385 // strip cast if we're initializing a char[] with a char *, e.g. char x[] = "hello"; … … 446 443 (*iter)->accept( *this ); 447 444 } // for 445 } else if ( TupleType * tt = dynamic_cast< TupleType * > ( initContext ) ) { 446 for ( Type * t : *tt ) { 447 if ( iter == end ) break; 448 initContext = t; 449 (*iter++)->accept( *this ); 450 } 448 451 } else if ( StructInstType * st = dynamic_cast< StructInstType * >( initContext ) ) { 449 452 resolveAggrInit( st->get_baseStruct(), iter, end );
Note:
See TracChangeset
for help on using the changeset viewer.