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