Changeset 630bcb5 for src


Ignore:
Timestamp:
Jun 6, 2018, 4:54:18 PM (6 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, with_gc
Children:
2a6c115
Parents:
214e8da
Message:

Fix pruneAlternatives so that deleted expressions are no longer ambiguous

Location:
src/ResolvExpr
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    r214e8da r630bcb5  
    176176                                                selected[ mangleName ] = current;
    177177                                        } else if ( candidate->cost == mapPlace->second.candidate->cost ) {
    178                                                 PRINT(
    179                                                         std::cerr << "marking ambiguous" << std::endl;
    180                                                 )
    181                                                 mapPlace->second.isAmbiguous = true;
     178                                                // if one of the candidates contains a deleted identifier, can pick the other, since
     179                                                // deleted expressions should not be ambiguous if there is another option that is at least as good
     180                                                if ( findDeletedExpr( candidate->expr ) ) {
     181                                                        // do nothing
     182                                                        PRINT( std::cerr << "candidate is deleted" << std::endl; )
     183                                                } else if ( findDeletedExpr( mapPlace->second.candidate->expr ) ) {
     184                                                        PRINT( std::cerr << "current is deleted" << std::endl; )
     185                                                        selected[ mangleName ] = current;
     186                                                } else {
     187                                                        PRINT(
     188                                                                std::cerr << "marking ambiguous" << std::endl;
     189                                                        )
     190                                                        mapPlace->second.isAmbiguous = true;
     191                                                }
    182192                                        } else {
    183193                                                PRINT(
     
    611621        ConstantExpr* getDefaultValue( Initializer* init ) {
    612622                if ( SingleInit* si = dynamic_cast<SingleInit*>( init ) ) {
    613                         if ( CastExpr* ce = dynamic_cast<CastExpr*>( si->get_value() ) ) {
    614                                 return dynamic_cast<ConstantExpr*>( ce->get_arg() );
     623                        if ( CastExpr* ce = dynamic_cast<CastExpr*>( si->value ) ) {
     624                                return dynamic_cast<ConstantExpr*>( ce->arg );
     625                        } else {
     626                                return dynamic_cast<ConstantExpr*>( si->value );
    615627                        }
    616628                }
     
    10651077                funcFinder.findWithAdjustment( untypedExpr->function );
    10661078                // if there are no function alternatives, then proceeding is a waste of time.
     1079                // xxx - findWithAdjustment throws, so this check and others like it shouldn't be necessary.
    10671080                if ( funcFinder.alternatives.empty() ) return;
    10681081
  • src/ResolvExpr/Resolver.h

    r214e8da r630bcb5  
    3636        void resolveCtorInit( ConstructorInit * ctorInit, const SymTab::Indexer & indexer );
    3737        void resolveStmtExpr( StmtExpr * stmtExpr, const SymTab::Indexer & indexer );
     38        /// Searches expr and returns the first DeletedExpr found, otherwise nullptr
     39        DeletedExpr * findDeletedExpr( Expression * expr );
    3840} // namespace ResolvExpr
    3941
Note: See TracChangeset for help on using the changeset viewer.