Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r906e24d r1ba88a0  
    1919#include "RenameVars.h"
    2020#include "ResolveTypeof.h"
    21 #include "typeops.h"
    2221#include "SynTree/Statement.h"
    2322#include "SynTree/Type.h"
     
    6867          void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & );
    6968          void fallbackInit( ConstructorInit * ctorInit );
    70                 Type * functionReturn;
     69                std::list< Type * > functionReturn;
    7170                Type *initContext;
    7271                Type *switchType;
     
    156155                        const TypeEnvironment *newEnv = 0;
    157156                        for ( AltList::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
    158                                 if ( i->expr->get_result()->size() == 1 && isIntegralType( i->expr->get_result() ) ) {
     157                                if ( i->expr->get_results().size() == 1 && isIntegralType( i->expr->get_results().front() ) ) {
    159158                                        if ( newExpr ) {
    160159                                                throw SemanticError( "Too many interpretations for case control expression", untyped );
     
    233232                Type *new_type = resolveTypeof( functionDecl->get_type(), *this );
    234233                functionDecl->set_type( new_type );
    235                 ValueGuard< Type * > oldFunctionReturn( functionReturn );
    236                 functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() );
     234                std::list< Type * > oldFunctionReturn = functionReturn;
     235                functionReturn.clear();
     236                for ( std::list< DeclarationWithType * >::const_iterator i = functionDecl->get_functionType()->get_returnVals().begin(); i != functionDecl->get_functionType()->get_returnVals().end(); ++i ) {
     237                        functionReturn.push_back( (*i)->get_type() );
     238                } // for
    237239                SymTab::Indexer::visit( functionDecl );
     240                functionReturn = oldFunctionReturn;
    238241        }
    239242
     
    333336        void Resolver::visit( ReturnStmt *returnStmt ) {
    334337                if ( returnStmt->get_expr() ) {
    335                         CastExpr *castExpr = new CastExpr( returnStmt->get_expr(), functionReturn->clone() );
     338                        CastExpr *castExpr = new CastExpr( returnStmt->get_expr() );
     339                        cloneAll( functionReturn, castExpr->get_results() );
    336340                        Expression *newExpr = findSingleExpression( castExpr, *this );
    337341                        delete castExpr;
     
    378382                                if ( isCharType( at->get_base() ) ) {
    379383                                        // check if the resolved type is char *
    380                                         if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) {
     384                                        if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_results().front() ) ) {
    381385                                                if ( isCharType( pt->get_base() ) ) {
    382386                                                        // strip cast if we're initializing a char[] with a char *, e.g.  char x[] = "hello";
Note: See TracChangeset for help on using the changeset viewer.