Changeset 326338ae


Ignore:
Timestamp:
Aug 31, 2017, 3:33:05 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
fbcb354
Parents:
be9036d
Message:

Copy function alternative before reference-to-rvalue conversion to prevent unwanted side-effects

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    rbe9036d r326338ae  
    749749                                if ( PointerType *pointer = dynamic_cast< PointerType* >( func->expr->get_result()->stripReferences() ) ) {
    750750                                        if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) {
    751                                                 referenceToRvalueConversion( func->expr );
     751                                                Alternative newFunc( *func );
     752                                                referenceToRvalueConversion( newFunc.expr );
    752753                                                for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) {
    753754                                                        // XXX
    754755                                                        //Designators::check_alternative( function, *actualAlt );
    755                                                         makeFunctionAlternatives( *func, function, *actualAlt, std::back_inserter( candidates ) );
     756                                                        makeFunctionAlternatives( newFunc, function, *actualAlt, std::back_inserter( candidates ) );
    756757                                                }
    757758                                        }
    758759                                } else if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( func->expr->get_result()->stripReferences() ) ) { // handle ftype (e.g. *? on function pointer)
    759                                         referenceToRvalueConversion( func->expr );
    760760                                        EqvClass eqvClass;
    761761                                        if ( func->env.lookup( typeInst->get_name(), eqvClass ) && eqvClass.type ) {
    762762                                                if ( FunctionType *function = dynamic_cast< FunctionType* >( eqvClass.type ) ) {
     763                                                        Alternative newFunc( *func );
     764                                                        referenceToRvalueConversion( newFunc.expr );
    763765                                                        for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) {
    764                                                                 makeFunctionAlternatives( *func, function, *actualAlt, std::back_inserter( candidates ) );
     766                                                                makeFunctionAlternatives( newFunc, function, *actualAlt, std::back_inserter( candidates ) );
    765767                                                        } // for
    766768                                                } // if
     
    773775                                        if ( PointerType *pointer = dynamic_cast< PointerType* >( funcOp->expr->get_result()->stripReferences() ) ) {
    774776                                                if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) {
    775                                                         referenceToRvalueConversion( funcOp->expr );
     777                                                        Alternative newFunc( *funcOp );
     778                                                        referenceToRvalueConversion( newFunc.expr );
    776779                                                        for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) {
    777780                                                                AltList currentAlt;
    778781                                                                currentAlt.push_back( *func );
    779782                                                                currentAlt.insert( currentAlt.end(), actualAlt->begin(), actualAlt->end() );
    780                                                                 makeFunctionAlternatives( *funcOp, function, currentAlt, std::back_inserter( candidates ) );
     783                                                                makeFunctionAlternatives( newFunc, function, currentAlt, std::back_inserter( candidates ) );
    781784                                                        } // for
    782785                                                } // if
Note: See TracChangeset for help on using the changeset viewer.