Changeset 121ac13 for src/ResolvExpr


Ignore:
Timestamp:
Nov 6, 2017, 10:28:17 AM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
bbeb908
Parents:
59a0bde (diff), 9f4524b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/ResolvExpr
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AdjustExprType.cc

    r59a0bde r121ac13  
    2828                void premutate( BasicType * ) { visit_children = false; }
    2929                void premutate( PointerType * ) { visit_children = false; }
     30                void premutate( ArrayType * ) { visit_children = false; }
    3031                void premutate( FunctionType * ) { visit_children = false; }
    3132                void premutate( StructInstType * ) { visit_children = false; }
     
    5960
    6061        Type * AdjustExprType::postmutate( ArrayType * arrayType ) {
    61                 // need to recursively mutate the base type in order for multi-dimensional arrays to work.
    6262                PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->base );
    6363                arrayType->base = nullptr;
  • src/ResolvExpr/AlternativeFinder.cc

    r59a0bde r121ac13  
    122122                                                )
    123123                                                mapPlace->second.isAmbiguous = true;
     124                                        } else {
     125                                                PRINT(
     126                                                        std::cerr << "cost " << candidate->cost << " loses to " << mapPlace->second.candidate->cost << std::endl;
     127                                                )
    124128                                        }
    125129                                } else {
     
    127131                                }
    128132                        }
    129 
    130                         PRINT(
    131                                 std::cerr << "there are " << selected.size() << " alternatives before elimination" << std::endl;
    132                         )
    133133
    134134                        // accept the alternatives that were unambiguous
     
    180180                        throw SemanticError( "No reasonable alternatives for expression ", expr );
    181181                }
    182                 for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i ) {
    183                         if ( adjust ) {
    184                                 adjustExprType( i->expr->get_result(), i->env, indexer );
    185                         }
    186                 }
    187182                if ( prune ) {
     183                        auto oldsize = alternatives.size();
    188184                        PRINT(
    189185                                std::cerr << "alternatives before prune:" << std::endl;
     
    204200                        alternatives.erase( oldBegin, alternatives.end() );
    205201                        PRINT(
     202                                std::cerr << "there are " << oldsize << " alternatives before elimination" << std::endl;
     203                        )
     204                        PRINT(
    206205                                std::cerr << "there are " << alternatives.size() << " alternatives after elimination" << std::endl;
    207206                        )
     207                }
     208                // adjust types after pruning so that types substituted by pruneAlternatives are correctly adjusted
     209                for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i ) {
     210                        if ( adjust ) {
     211                                adjustExprType( i->expr->get_result(), i->env, indexer );
     212                        }
    208213                }
    209214
     
    318323        Cost computeExpressionConversionCost( Expression *& actualExpr, Type * formalType, const SymTab::Indexer &indexer, const TypeEnvironment & env ) {
    319324                Cost convCost = computeConversionCost( actualExpr->result, formalType, indexer, env );
    320                 // if ( convCost != Cost::zero ) {
    321 
    322                 // xxx - temporary -- ignore poly cost, since this causes some polymorphic functions to be cast, which causes the specialize
    323                 // pass to try to specialize them, which currently does not work. Once that is fixed, remove the next 3 lines and uncomment the
    324                 // previous line.
     325
     326                // if there is a non-zero conversion cost, ignoring poly cost, then the expression requires conversion.
     327                // ignore poly cost for now, since this requires resolution of the cast to infer parameters and this
     328                // does not currently work for the reason stated below.
    325329                Cost tmpCost = convCost;
    326330                tmpCost.incPoly( -tmpCost.get_polyCost() );
    327331                if ( tmpCost != Cost::zero ) {
     332                // if ( convCost != Cost::zero ) {
    328333                        Type *newType = formalType->clone();
    329334                        env.apply( newType );
     
    631636                                        std::cerr << std::endl;
    632637                                )
    633                                 ApplicationExpr *appExpr = static_cast< ApplicationExpr* >( newerAlt.expr );
    634638                                // follow the current assertion's ID chain to find the correct set of inferred parameters to add the candidate to (i.e. the set of inferred parameters belonging to the entity which requested the assertion parameter).
    635                                 InferredParams * inferParameters = &appExpr->get_inferParams();
     639                                InferredParams * inferParameters = &newerAlt.expr->get_inferParams();
    636640                                for ( UniqueId id : cur->second.idChain ) {
    637641                                        inferParameters = (*inferParameters)[ id ].inferParams.get();
     
    680684                OpenVarSet openVars;
    681685                AssertionSet resultNeed, resultHave;
    682                 TypeEnvironment resultEnv;
     686                TypeEnvironment resultEnv( func.env );
    683687                makeUnifiableVars( funcType, openVars, resultNeed );
    684688                resultEnv.add( funcType->get_forall() ); // add all type variables as open variables now so that those not used in the parameter list are still considered open
     
    914918                                thisCost.incSafe( discardedValues );
    915919                                Alternative newAlt( restructureCast( i->expr->clone(), toType ), i->env, i->cost, thisCost );
    916                                 // xxx - this doesn't work at the moment, since inferParameters requires an ApplicationExpr as the alternative.
    917                                 // Once this works, it should be possible to infer parameters on a cast expression and specialize any function.
    918 
    919                                 // inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( candidates ) );
    920                                 candidates.emplace_back( std::move( newAlt ) );
     920                                inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( candidates ) );
    921921                        } // if
    922922                } // for
     
    12971297                                        // count one safe conversion for each value that is thrown away
    12981298                                        thisCost.incSafe( discardedValues );
    1299                                         candidates.push_back( Alternative( new InitExpr( restructureCast( alt.expr->clone(), toType ), initAlt.designation->clone() ), newEnv, alt.cost, thisCost ) );
     1299                                        Alternative newAlt( new InitExpr( restructureCast( alt.expr->clone(), toType ), initAlt.designation->clone() ), newEnv, alt.cost, thisCost );
     1300                                        inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( candidates ) );
    13001301                                }
    13011302                        }
  • src/ResolvExpr/CommonType.cc

    r59a0bde r121ac13  
    6161        };
    6262
    63         Type * handleReference( ReferenceType * refType, Type * other, bool widenFirst, bool widenSecond, const SymTab::Indexer &indexer, TypeEnvironment & env, const OpenVarSet &openVars ) {
    64                 Type * result = nullptr, * common = nullptr;
     63        Type * handleReference( Type * t1, Type * t2, bool widenFirst, bool widenSecond, const SymTab::Indexer &indexer, TypeEnvironment & env, const OpenVarSet &openVars ) {
     64                Type * common = nullptr;
    6565                AssertionSet have, need;
    6666                OpenVarSet newOpen( openVars );
    6767                // need unify to bind type variables
    68                 if ( unify( refType->get_base(), other, env, have, need, newOpen, indexer, common ) ) {
    69                         // std::cerr << "unify success" << std::endl;
    70                         if ( widenSecond ) {
    71                                 // std::cerr << "widen second" << std::endl;
    72                                 if ( widenFirst || other->get_qualifiers() <= refType->get_qualifiers() ) {
    73                                         result = new ReferenceType( refType->get_qualifiers(), common ); // refType->clone();
    74                                         result->get_qualifiers() |= other->get_qualifiers();
    75                                 }
    76                         } else if ( widenFirst ) {
    77                                 // std::cerr << "widen first" << std::endl;
    78                                 if ( widenSecond || refType->get_qualifiers() <= other->get_qualifiers() ) {
    79                                         result = common;
    80                                         result->get_qualifiers() |= refType->get_qualifiers();
    81                                 }
    82                         }
    83                 } else {
    84                         // std::cerr << "exact unify failed: " << refType << " " << other << std::endl;
    85                 }
    86                 // std::cerr << "common type of reference [" << refType << "] and non-reference [" << other << "] is [" << result << "]" << std::endl;
    87                 return result;
     68                if ( unify( t1, t2, env, have, need, newOpen, indexer, common ) ) {
     69                        // std::cerr << "unify success: " << widenFirst << " " << widenSecond << std::endl;
     70                        if ( (widenFirst || t2->get_qualifiers() <= t1->get_qualifiers()) && (widenSecond || t1->get_qualifiers() <= t2->get_qualifiers()) ) {
     71                                // std::cerr << "widen okay" << std::endl;
     72                                common->get_qualifiers() |= t1->get_qualifiers();
     73                                common->get_qualifiers() |= t2->get_qualifiers();
     74                                return common;
     75                        }
     76                }
     77                // std::cerr << "exact unify failed: " << t1 << " " << t2 << std::endl;
     78                return nullptr;
    8879        }
    8980
     
    9990
    10091                        // special case where one type has a reference depth of 1 larger than the other
    101                         if ( diff > 0 ) {
    102                                 return handleReference( strict_dynamic_cast<ReferenceType *>( type1 ), type2, widenFirst, widenSecond, indexer, env, openVars );
    103                         } else if ( diff < 0 ) {
    104                                 return handleReference( strict_dynamic_cast<ReferenceType *>( type2 ), type1, widenSecond, widenFirst, indexer, env, openVars );
     92                        if ( diff > 0 || diff < 0 ) {
     93                                Type * result = nullptr;
     94                                if ( ReferenceType * ref1 = dynamic_cast< ReferenceType * >( type1 ) ) {
     95                                        // formal is reference, so result should be reference
     96                                        result = handleReference( ref1->base, type2, widenFirst, widenSecond, indexer, env, openVars );
     97                                        if ( result ) result = new ReferenceType( ref1->get_qualifiers(), result );
     98                                } else {
     99                                        // formal is value, so result should be value
     100                                        ReferenceType * ref2 = strict_dynamic_cast< ReferenceType * > ( type2 );
     101                                        result = handleReference( type1, ref2->base, widenFirst, widenSecond, indexer, env, openVars );
     102                                }
     103                                // std::cerr << "common type of reference [" << type1 << "] and [" << type2 << "] is [" << result << "]" << std::endl;
     104                                return result;
    105105                        }
    106106                        // otherwise, both are reference types of the same depth and this is handled by the CommonType visitor.
  • src/ResolvExpr/ConversionCost.cc

    r59a0bde r121ac13  
    2828
    2929namespace ResolvExpr {
    30         const Cost Cost::zero = Cost( 0, 0, 0, 0 );
    31         const Cost Cost::infinity = Cost( -1, -1, -1, -1 );
    32         const Cost Cost::unsafe = Cost( 1, 0, 0, 0 );
    33         const Cost Cost::poly = Cost( 0, 1, 0, 0 );
    34         const Cost Cost::safe = Cost( 0, 0, 1, 0 );
    35         const Cost Cost::reference = Cost( 0, 0, 0, 1 );
     30        const Cost Cost::zero =      Cost(  0,  0,  0, 0 );
     31        const Cost Cost::infinity =  Cost( -1, -1, -1, -1 );
     32        const Cost Cost::unsafe =    Cost(  1,  0,  0, 0 );
     33        const Cost Cost::poly =      Cost(  0,  1,  0, 0 );
     34        const Cost Cost::safe =      Cost(  0,  0,  1, 0 );
     35        const Cost Cost::reference = Cost(  0,  0,  0, 1 );
    3636
    3737#if 0
     
    113113                                        int assignResult = func( srcAsRef->get_base(), destAsRef->get_base(), env, indexer );
    114114                                        PRINT( std::cerr << "comparing references: " << assignResult << " " << srcAsRef << " " << destAsRef << std::endl; )
    115                                         if ( assignResult < 0 ) {
     115                                        if ( assignResult > 0 ) {
    116116                                                return Cost::safe;
    117                                         } else if ( assignResult > 0 ) {
     117                                        } else if ( assignResult < 0 ) {
    118118                                                return Cost::unsafe;
    119119                                        } // if
     
    269269        }
    270270
    271         void ConversionCost::visit(PointerType *pointerType) {
     271        void ConversionCost::visit( PointerType * pointerType ) {
    272272                if ( PointerType *destAsPtr = dynamic_cast< PointerType* >( dest ) ) {
    273273                        PRINT( std::cerr << pointerType << " ===> " << destAsPtr; )
     
    284284                                }
    285285                        } else {  // xxx - this discards qualifiers from consideration -- reducing qualifiers is a safe conversion; is this right?
    286                                 int assignResult = ptrsAssignable( pointerType->get_base(), destAsPtr->get_base(), env );
     286                                int assignResult = ptrsAssignable( pointerType->base, destAsPtr->base, env );
    287287                                PRINT( std::cerr << " :: " << assignResult << std::endl; )
    288                                 if ( assignResult < 0 && pointerType->get_base()->get_qualifiers() <= destAsPtr->get_qualifiers() ) {
     288                                if ( assignResult > 0 && pointerType->get_base()->get_qualifiers() <= destAsPtr->get_qualifiers() ) {
    289289                                        cost = Cost::safe;
    290                                 } else if ( assignResult > 0 ) {
     290                                } else if ( assignResult < 0 ) {
    291291                                        cost = Cost::unsafe;
    292292                                } // if
    293293                                // assignResult == 0 means Cost::Infinity
    294294                        } // if
    295                 } else if ( dynamic_cast< ZeroType* >( dest ) != nullptr || dynamic_cast< OneType* >( dest ) != nullptr ) {
     295                } else if ( dynamic_cast< ZeroType * >( dest ) ) {
    296296                        cost = Cost::unsafe;
    297297                } // if
    298298        }
    299299
    300         void ConversionCost::visit(__attribute((unused)) ArrayType *arrayType) {}
    301 
    302         void ConversionCost::visit(ReferenceType *refType) {
     300        void ConversionCost::visit( ArrayType * ) {}
     301
     302        void ConversionCost::visit( ReferenceType * refType ) {
    303303                // Note: dest can never be a reference, since it would have been caught in an earlier check
    304304                assert( ! dynamic_cast< ReferenceType * >( dest ) );
     
    317317        }
    318318
    319         void ConversionCost::visit(__attribute((unused)) FunctionType *functionType) {}
    320 
    321         void ConversionCost::visit(StructInstType *inst) {
     319        void ConversionCost::visit( FunctionType * ) {}
     320
     321        void ConversionCost::visit( StructInstType * inst ) {
    322322                if ( StructInstType *destAsInst = dynamic_cast< StructInstType* >( dest ) ) {
    323323                        if ( inst->name == destAsInst->name ) {
     
    327327        }
    328328
    329         void ConversionCost::visit(UnionInstType *inst) {
     329        void ConversionCost::visit( UnionInstType * inst ) {
    330330                if ( UnionInstType *destAsInst = dynamic_cast< UnionInstType* >( dest ) ) {
    331331                        if ( inst->name == destAsInst->name ) {
     
    335335        }
    336336
    337         void ConversionCost::visit( __attribute((unused)) EnumInstType *inst ) {
     337        void ConversionCost::visit( EnumInstType * ) {
    338338                static Type::Qualifiers q;
    339339                static BasicType integer( q, BasicType::SignedInt );
     
    344344        }
    345345
    346         void ConversionCost::visit( __attribute((unused)) TraitInstType *inst) {
    347         }
    348 
    349         void ConversionCost::visit(TypeInstType *inst) {
     346        void ConversionCost::visit( TraitInstType * ) {}
     347
     348        void ConversionCost::visit( TypeInstType *inst ) {
    350349                EqvClass eqvClass;
    351350                NamedTypeDecl *namedType;
     
    366365        }
    367366
    368         void ConversionCost::visit( __attribute((unused)) TupleType *tupleType) {
     367        void ConversionCost::visit( TupleType * tupleType ) {
    369368                Cost c = Cost::zero;
    370                 if ( TupleType *destAsTuple = dynamic_cast< TupleType* >( dest ) ) {
    371                         std::list< Type* >::const_iterator srcIt = tupleType->get_types().begin();
    372                         std::list< Type* >::const_iterator destIt = destAsTuple->get_types().begin();
     369                if ( TupleType * destAsTuple = dynamic_cast< TupleType * >( dest ) ) {
     370                        std::list< Type * >::const_iterator srcIt = tupleType->get_types().begin();
     371                        std::list< Type * >::const_iterator destIt = destAsTuple->get_types().begin();
    373372                        while ( srcIt != tupleType->get_types().end() && destIt != destAsTuple->get_types().end() ) {
    374373                                Cost newCost = conversionCost( *srcIt++, *destIt++, indexer, env );
     
    386385        }
    387386
    388         void ConversionCost::visit( __attribute((unused)) VarArgsType *varArgsType) {
     387        void ConversionCost::visit( VarArgsType * ) {
    389388                if ( dynamic_cast< VarArgsType* >( dest ) ) {
    390389                        cost = Cost::zero;
     
    392391        }
    393392
    394         void ConversionCost::visit( __attribute((unused)) ZeroType *zeroType) {
    395                 if ( dynamic_cast< ZeroType* >( dest ) ) {
     393        void ConversionCost::visit( ZeroType * ) {
     394                if ( dynamic_cast< ZeroType * >( dest ) ) {
    396395                        cost = Cost::zero;
    397396                } else if ( BasicType *destAsBasic = dynamic_cast< BasicType* >( dest ) ) {
     
    409408        }
    410409
    411         void ConversionCost::visit( __attribute((unused)) OneType *oneType) {
    412                 if ( dynamic_cast< OneType* >( dest ) ) {
     410        void ConversionCost::visit( OneType * ) {
     411                if ( dynamic_cast< OneType * >( dest ) ) {
    413412                        cost = Cost::zero;
    414413                } else if ( BasicType *destAsBasic = dynamic_cast< BasicType* >( dest ) ) {
  • src/ResolvExpr/PolyCost.cc

    r59a0bde r121ac13  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // PolyCost.cc -- 
     7// PolyCost.cc --
    88//
    99// Author           : Richard C. Bilson
     
    3131        };
    3232
    33         int polyCost( Type *type, const TypeEnvironment &env, const SymTab::Indexer &indexer ) {
     33        int polyCost( Type *type, const TypeEnvironment & env, const SymTab::Indexer &indexer ) {
    3434                PolyCost coster( env, indexer );
    3535                type->accept( coster );
     
    3737        }
    3838
    39         PolyCost::PolyCost( const TypeEnvironment &env, const SymTab::Indexer &indexer ) : result( 0 ), env( env ), indexer( indexer ) {
     39        PolyCost::PolyCost( const TypeEnvironment & env, const SymTab::Indexer & indexer ) : result( 0 ), env( env ), indexer( indexer ) {
    4040        }
    4141
    42         void PolyCost::visit(TypeInstType *typeInst) {
     42        void PolyCost::visit(TypeInstType * typeInst) {
    4343                EqvClass eqvClass;
    44                 if ( env.lookup( typeInst->get_name(), eqvClass ) ) {
     44                if ( env.lookup( typeInst->name, eqvClass ) ) {
    4545                        if ( eqvClass.type ) {
    46                                 if ( TypeInstType *otherTypeInst = dynamic_cast< TypeInstType* >( eqvClass.type ) ) {
    47                                         if ( indexer.lookupType( otherTypeInst->get_name() ) ) {
     46                                if ( TypeInstType * otherTypeInst = dynamic_cast< TypeInstType* >( eqvClass.type ) ) {
     47                                        if ( indexer.lookupType( otherTypeInst->name ) ) {
     48                                                // bound to opaque type
    4849                                                result += 1;
    4950                                        } // if
    5051                                } else {
     52                                        // bound to concrete type
    5153                                        result += 1;
    5254                                } // if
  • src/ResolvExpr/PtrsAssignable.cc

    r59a0bde r121ac13  
    4747
    4848        int ptrsAssignable( Type *src, Type *dest, const TypeEnvironment &env ) {
     49                // std::cerr << "assignable: " << src << " | " << dest << std::endl;
    4950                if ( TypeInstType *destAsTypeInst = dynamic_cast< TypeInstType* >( dest ) ) {
    5051                        EqvClass eqvClass;
     
    5455                } // if
    5556                if ( dynamic_cast< VoidType* >( dest ) ) {
    56                         return 1;
     57                        // void * = T * for any T is unsafe
     58                        // xxx - this should be safe, but that currently breaks the build
     59                        return -1;
    5760                } else {
    5861                        PtrsAssignable ptrs( dest, env );
     
    6568
    6669        void PtrsAssignable::visit( __attribute((unused)) VoidType *voidType ) {
    67                 if ( dynamic_cast< FunctionType* >( dest ) ) {
    68                         result = 0;
    69                 } else {
    70                         result = -1;
     70                if ( ! dynamic_cast< FunctionType* >( dest ) ) {
     71                        // T * = void * is safe for any T that is not a function type.
     72                        // xxx - this should be unsafe...
     73                        result = 1;
    7174                } // if
    7275        }
     
    7578        void PtrsAssignable::visit( __attribute__((unused)) PointerType *pointerType ) {}
    7679        void PtrsAssignable::visit( __attribute__((unused)) ArrayType *arrayType ) {}
    77         void PtrsAssignable::visit( __attribute__((unused)) FunctionType *functionType ) {
    78                 result = -1;
    79         }
     80        void PtrsAssignable::visit( __attribute__((unused)) FunctionType *functionType ) {}
    8081
    8182        void PtrsAssignable::visit(  __attribute__((unused)) StructInstType *inst ) {}
     
    8384
    8485        void PtrsAssignable::visit( EnumInstType * ) {
    85                 if ( dynamic_cast< EnumInstType* >( dest ) ) {
     86                if ( dynamic_cast< BasicType* >( dest ) ) {
     87                        // int * = E *, etc. is safe. This isn't technically correct, as each
     88                        // enum has one basic type that it is compatible with, an that type can
     89                        // differ from enum to enum. Without replicating GCC's internal logic,
     90                        // there is no way to know which type this particular enum is compatible
     91                        // with, so punt on this for now.
    8692                        result = 1;
    87                 } else if ( BasicType *bt = dynamic_cast< BasicType* >( dest ) ) {
    88                         result = bt->get_kind() == BasicType::SignedInt;
    8993                }
    9094        }
     
    9498                EqvClass eqvClass;
    9599                if ( env.lookup( inst->get_name(), eqvClass ) && eqvClass.type ) {
     100                        // T * = S * for any S depends on the type bound to T
    96101                        result = ptrsAssignable( eqvClass.type, dest, env );
    97                 } else {
    98                         result = 0;
    99102                } // if
    100103        }
  • src/ResolvExpr/PtrsCastable.cc

    r59a0bde r121ac13  
    5050        };
    5151
    52         int objectCast( Type *src, const TypeEnvironment &env, const SymTab::Indexer &indexer ) {
    53                 if ( dynamic_cast< FunctionType* >( src ) ) {
    54                         return -1;
    55                 } else if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( src ) ) {
    56                         EqvClass eqvClass;
    57                         if ( NamedTypeDecl *ntDecl = indexer.lookupType( typeInst->get_name() ) ) {
    58                                 if ( TypeDecl *tyDecl = dynamic_cast< TypeDecl* >( ntDecl ) ) {
    59                                         if ( tyDecl->get_kind() == TypeDecl::Ftype ) {
     52        namespace {
     53                int objectCast( Type *src, const TypeEnvironment &env, const SymTab::Indexer &indexer ) {
     54                        if ( dynamic_cast< FunctionType* >( src ) ) {
     55                                return -1;
     56                        } else if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( src ) ) {
     57                                EqvClass eqvClass;
     58                                if ( NamedTypeDecl *ntDecl = indexer.lookupType( typeInst->get_name() ) ) {
     59                                        if ( TypeDecl *tyDecl = dynamic_cast< TypeDecl* >( ntDecl ) ) {
     60                                                if ( tyDecl->get_kind() == TypeDecl::Ftype ) {
     61                                                        return -1;
     62                                                } // if
     63                                        } //if
     64                                } else if ( env.lookup( typeInst->get_name(), eqvClass ) ) {
     65                                        if ( eqvClass.data.kind == TypeDecl::Ftype ) {
    6066                                                return -1;
    6167                                        } // if
    62                                 } //if
    63                         } else if ( env.lookup( typeInst->get_name(), eqvClass ) ) {
    64                                 if ( eqvClass.data.kind == TypeDecl::Ftype ) {
    65                                         return -1;
    6668                                } // if
    67                         } // if
    68                 } //if
    69                 return 1;
    70         }
    71         int functionCast( Type *src, const TypeEnvironment &env, const SymTab::Indexer &indexer ) {
    72                 return -1 * objectCast( src, env, indexer );  // reverse the sense of objectCast
     69                        } //if
     70                        return 1;
     71                }
     72                int functionCast( Type *src, const TypeEnvironment &env, const SymTab::Indexer &indexer ) {
     73                        return -1 * objectCast( src, env, indexer );  // reverse the sense of objectCast
     74                }
    7375        }
    7476
     
    9395        }
    9496
    95         void PtrsCastable::visit( __attribute__((unused)) VoidType *voidType) {
     97        void PtrsCastable::visit( VoidType * ) {
    9698                result = objectCast( dest, env, indexer );
    9799        }
    98100
    99         void PtrsCastable::visit( __attribute__((unused)) BasicType *basicType) {
     101        void PtrsCastable::visit( BasicType * ) {
    100102                result = objectCast( dest, env, indexer );
    101103        }
    102104
    103         void PtrsCastable::visit( __attribute__((unused)) PointerType *pointerType) {
     105        void PtrsCastable::visit( PointerType * ) {
    104106                result = objectCast( dest, env, indexer );
    105107        }
    106108
    107         void PtrsCastable::visit( __attribute__((unused)) ArrayType *arrayType) {
     109        void PtrsCastable::visit( ArrayType * ) {
    108110                result = objectCast( dest, env, indexer );
    109111        }
    110112
    111         void PtrsCastable::visit( __attribute__((unused)) FunctionType *functionType) {
     113        void PtrsCastable::visit( FunctionType * ) {
    112114                // result = -1;
    113115                result = functionCast( dest, env, indexer );
    114116        }
    115117
    116         void PtrsCastable::visit( __attribute__((unused)) StructInstType *inst) {
     118        void PtrsCastable::visit( StructInstType * ) {
    117119                result = objectCast( dest, env, indexer );
    118120        }
    119121
    120         void PtrsCastable::visit( __attribute__((unused)) UnionInstType *inst) {
     122        void PtrsCastable::visit( UnionInstType * ) {
    121123                result = objectCast( dest, env, indexer );
    122124        }
    123125
    124         void PtrsCastable::visit( __attribute__((unused)) EnumInstType *inst) {
     126        void PtrsCastable::visit( EnumInstType * ) {
    125127                if ( dynamic_cast< EnumInstType* >( dest ) ) {
    126128                        result = 1;
     
    136138        }
    137139
    138         void PtrsCastable::visit( __attribute__((unused)) TraitInstType *inst ) {}
     140        void PtrsCastable::visit( TraitInstType * ) {}
    139141
    140142        void PtrsCastable::visit(TypeInstType *inst) {
     
    143145        }
    144146
    145         void PtrsCastable::visit( __attribute__((unused)) TupleType *tupleType) {
     147        void PtrsCastable::visit( TupleType * ) {
    146148                result = objectCast( dest, env, indexer );
    147149        }
    148150
    149         void PtrsCastable::visit( __attribute__((unused)) VarArgsType *varArgsType) {
     151        void PtrsCastable::visit( VarArgsType * ) {
    150152                result = objectCast( dest, env, indexer );
    151153        }
    152154
    153         void PtrsCastable::visit( __attribute__((unused)) ZeroType *zeroType) {
     155        void PtrsCastable::visit( ZeroType * ) {
    154156                result = objectCast( dest, env, indexer );
    155157        }
    156158
    157         void PtrsCastable::visit( __attribute__((unused)) OneType *oneType) {
     159        void PtrsCastable::visit( OneType * ) {
    158160                result = objectCast( dest, env, indexer );
    159161        }
  • src/ResolvExpr/Resolver.cc

    r59a0bde r121ac13  
    593593                initExpr->expr = nullptr;
    594594                std::swap( initExpr->env, newExpr->env );
     595                std::swap( initExpr->inferParams, newExpr->inferParams ) ;
    595596                delete initExpr;
    596597
  • src/ResolvExpr/Unify.cc

    r59a0bde r121ac13  
    1717#include <iterator>               // for back_insert_iterator, back_inserter
    1818#include <map>                    // for _Rb_tree_const_iterator, _Rb_tree_i...
    19 #include <memory>                 // for unique_ptr, auto_ptr
     19#include <memory>                 // for unique_ptr
    2020#include <set>                    // for set
    2121#include <string>                 // for string, operator==, operator!=, bas...
     
    138138        bool tyVarCompatible( const TypeDecl::Data & data, Type *type ) {
    139139                switch ( data.kind ) {
    140                   case TypeDecl::Any:
    141140                  case TypeDecl::Dtype:
    142141                        // to bind to an object type variable, the type must not be a function type.
     
    170169                                Type *common = 0;
    171170                                // attempt to unify equivalence class type (which has qualifiers stripped, so they must be restored) with the type to bind to
    172                                 std::auto_ptr< Type > newType( curClass.type->clone() );
     171                                std::unique_ptr< Type > newType( curClass.type->clone() );
    173172                                newType->get_qualifiers() = typeInst->get_qualifiers();
    174173                                if ( unifyInexact( newType.get(), other, env, needAssertions, haveAssertions, openVars, widenMode & WidenMode( curClass.allowWidening, true ), indexer, common ) ) {
     
    459458                if ( otherArray && arrayType->get_isVarLen() == otherArray->get_isVarLen() ) {
    460459
    461                         // not positive this is correct in all cases, but it's needed for typedefs
    462                         if ( arrayType->get_isVarLen() || otherArray->get_isVarLen() ) {
    463                                 return;
    464                         }
    465 
    466460                        if ( ! arrayType->get_isVarLen() && ! otherArray->get_isVarLen() &&
    467461                                arrayType->get_dimension() != 0 && otherArray->get_dimension() != 0 ) {
Note: See TracChangeset for help on using the changeset viewer.