Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r906e24d r89e6ffc  
    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;
     
    134133                        } else if ( BasicType *bt = dynamic_cast< BasicType * >( type ) ) {
    135134                                return bt->isInteger();
     135                        } else if ( dynamic_cast< ZeroType* >( type ) != nullptr || dynamic_cast< OneType* >( type ) != nullptr ) {
     136                                return true;
    136137                        } else {
    137138                                return false;
     
    156157                        const TypeEnvironment *newEnv = 0;
    157158                        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() ) ) {
     159                                if ( i->expr->get_results().size() == 1 && isIntegralType( i->expr->get_results().front() ) ) {
    159160                                        if ( newExpr ) {
    160161                                                throw SemanticError( "Too many interpretations for case control expression", untyped );
     
    233234                Type *new_type = resolveTypeof( functionDecl->get_type(), *this );
    234235                functionDecl->set_type( new_type );
    235                 ValueGuard< Type * > oldFunctionReturn( functionReturn );
    236                 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
    237241                SymTab::Indexer::visit( functionDecl );
     242                functionReturn = oldFunctionReturn;
    238243        }
    239244
     
    333338        void Resolver::visit( ReturnStmt *returnStmt ) {
    334339                if ( returnStmt->get_expr() ) {
    335                         CastExpr *castExpr = new CastExpr( returnStmt->get_expr(), functionReturn->clone() );
     340                        CastExpr *castExpr = new CastExpr( returnStmt->get_expr() );
     341                        cloneAll( functionReturn, castExpr->get_results() );
    336342                        Expression *newExpr = findSingleExpression( castExpr, *this );
    337343                        delete castExpr;
     
    378384                                if ( isCharType( at->get_base() ) ) {
    379385                                        // check if the resolved type is char *
    380                                         if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) {
     386                                        if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_results().front() ) ) {
    381387                                                if ( isCharType( pt->get_base() ) ) {
    382388                                                        // strip cast if we're initializing a char[] with a char *, e.g.  char x[] = "hello";
     
    455461                        }
    456462                } else {
    457                         assert( dynamic_cast< BasicType * >( initContext ) || dynamic_cast< PointerType * >( initContext ) );
     463                        assert( dynamic_cast< BasicType * >( initContext ) || dynamic_cast< PointerType * >( initContext )
     464                                || dynamic_cast< ZeroType * >( initContext ) || dynamic_cast< OneType * >( initContext ) );
    458465                        // basic types are handled here
    459466                        Visitor::visit( listInit );
Note: See TracChangeset for help on using the changeset viewer.