Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r5f5083e r62e5546  
    1919#include "RenameVars.h"
    2020#include "ResolveTypeof.h"
    21 #include "typeops.h"
    2221#include "SynTree/Statement.h"
    2322#include "SynTree/Type.h"
     
    6968          void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & );
    7069          void fallbackInit( ConstructorInit * ctorInit );
    71 
    72                 Type * functionReturn = nullptr;
    73                 Type *initContext = nullptr;
     70                std::list< Type * > functionReturn;
     71                Type *initContext;
    7472                bool inEnumDecl = false;
    7573        };
     
    159157                        const TypeEnvironment *newEnv = 0;
    160158                        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() ) ) {
    162160                                        if ( newExpr ) {
    163161                                                throw SemanticError( "Too many interpretations for case control expression", untyped );
     
    236234                Type *new_type = resolveTypeof( functionDecl->get_type(), *this );
    237235                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
    240241                SymTab::Indexer::visit( functionDecl );
     242                functionReturn = oldFunctionReturn;
    241243        }
    242244
     
    336338        void Resolver::visit( ReturnStmt *returnStmt ) {
    337339                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() );
    339342                        Expression *newExpr = findSingleExpression( castExpr, *this );
    340343                        delete castExpr;
     
    381384                                if ( isCharType( at->get_base() ) ) {
    382385                                        // 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() ) ) {
    384387                                                if ( isCharType( pt->get_base() ) ) {
    385388                                                        // strip cast if we're initializing a char[] with a char *, e.g.  char x[] = "hello";
     
    443446                                (*iter)->accept( *this );
    444447                        } // 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                         }
    451448                } else if ( StructInstType * st = dynamic_cast< StructInstType * >( initContext ) ) {
    452449                        resolveAggrInit( st->get_baseStruct(), iter, end );
Note: See TracChangeset for help on using the changeset viewer.