Changeset ef5b828 for src/ResolvExpr


Ignore:
Timestamp:
Jul 12, 2019, 1:35:58 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
fce4e31
Parents:
7870799
Message:

Indexer now has const lookup by default

Location:
src/ResolvExpr
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AdjustExprType.cc

    r7870799 ref5b828  
    4747                void premutate( OneType * ) { visit_children = false; }
    4848
    49                 Type * postmutate( ArrayType *arrayType );
    50                 Type * postmutate( FunctionType *functionType );
    51                 Type * postmutate( TypeInstType *aggregateUseType );
     49                Type * postmutate( ArrayType * arrayType );
     50                Type * postmutate( FunctionType * functionType );
     51                Type * postmutate( TypeInstType * aggregateUseType );
    5252
    5353                private:
     
    6161
    6262        Type * AdjustExprType_old::postmutate( ArrayType * arrayType ) {
    63                 PointerType *pointerType = new PointerType{ arrayType->get_qualifiers(), arrayType->base };
     63                PointerType * pointerType = new PointerType{ arrayType->get_qualifiers(), arrayType->base };
    6464                arrayType->base = nullptr;
    6565                delete arrayType;
     
    7272
    7373        Type * AdjustExprType_old::postmutate( TypeInstType * typeInst ) {
    74                 if ( const EqvClass* eqvClass = env.lookup( typeInst->get_name() ) ) {
     74                if ( const EqvClass * eqvClass = env.lookup( typeInst->get_name() ) ) {
    7575                        if ( eqvClass->data.kind == TypeDecl::Ftype ) {
    7676                                return new PointerType{ Type::Qualifiers(), typeInst };
    7777                        }
    78                 } else if ( NamedTypeDecl *ntDecl = indexer.lookupType( typeInst->get_name() ) ) {
    79                         if ( TypeDecl *tyDecl = dynamic_cast< TypeDecl* >( ntDecl ) ) {
     78                } else if ( const NamedTypeDecl * ntDecl = indexer.lookupType( typeInst->get_name() ) ) {
     79                        if ( const TypeDecl * tyDecl = dynamic_cast< const TypeDecl * >( ntDecl ) ) {
    8080                                if ( tyDecl->get_kind() == TypeDecl::Ftype ) {
    8181                                        return new PointerType{ Type::Qualifiers(), typeInst };
     
    8989void adjustExprType( Type *&type, const TypeEnvironment &env, const SymTab::Indexer &indexer ) {
    9090        PassVisitor<AdjustExprType_old> adjuster( env, indexer );
    91         Type *newType = type->acceptMutator( adjuster );
     91        Type * newType = type->acceptMutator( adjuster );
    9292        type = newType;
    9393}
     
    148148} // anonymous namespace
    149149
    150 const ast::Type * adjustExprType( 
    151         const ast::Type * type, const ast::TypeEnvironment & env, const ast::SymbolTable & symtab 
     150const ast::Type * adjustExprType(
     151        const ast::Type * type, const ast::TypeEnvironment & env, const ast::SymbolTable & symtab
    152152) {
    153153        ast::Pass<AdjustExprType_new> adjuster{ env, symtab };
  • src/ResolvExpr/CastCost.cc

    r7870799 ref5b828  
    3737        struct CastCost_old : public ConversionCost {
    3838          public:
    39                 CastCost_old( const Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc );
     39                CastCost_old( const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc );
    4040
    4141                using ConversionCost::previsit;
     
    4545        };
    4646
    47         Cost castCost( const Type *src, const Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env ) {
    48                 if ( const TypeInstType *destAsTypeInst = dynamic_cast< const TypeInstType* >( dest ) ) {
    49                         if ( const EqvClass* eqvClass = env.lookup( destAsTypeInst->name ) ) {
     47        Cost castCost( const Type * src, const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env ) {
     48                if ( const TypeInstType * destAsTypeInst = dynamic_cast< const TypeInstType * >( dest ) ) {
     49                        if ( const EqvClass * eqvClass = env.lookup( destAsTypeInst->name ) ) {
    5050                                if ( eqvClass->type ) {
    5151                                        return castCost( src, eqvClass->type, indexer, env );
     
    5353                                        return Cost::infinity;
    5454                                }
    55                         } else if ( NamedTypeDecl *namedType = indexer.lookupType( destAsTypeInst->name ) ) {
     55                        } else if ( const NamedTypeDecl * namedType = indexer.lookupType( destAsTypeInst->name ) ) {
    5656                                // all typedefs should be gone by this point
    57                                 const TypeDecl * type = strict_dynamic_cast< const TypeDecl* >( namedType );
     57                                const TypeDecl * type = strict_dynamic_cast< const TypeDecl * >( namedType );
    5858                                if ( type->base ) {
    5959                                        return castCost( src, type->base, indexer, env ) + Cost::safe;
     
    7474                        PRINT( std::cerr << "compatible!" << std::endl; )
    7575                        return Cost::zero;
    76                 } else if ( dynamic_cast< const VoidType* >( dest ) ) {
     76                } else if ( dynamic_cast< const VoidType * >( dest ) ) {
    7777                        return Cost::safe;
    7878                } else if ( const ReferenceType * refType = dynamic_cast< const ReferenceType * > ( dest ) ) {
     
    9696        }
    9797
    98         CastCost_old::CastCost_old( const Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc )
     98        CastCost_old::CastCost_old( const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc )
    9999                : ConversionCost( dest, indexer, env, costFunc ) {
    100100        }
    101101
    102         void CastCost_old::postvisit( const BasicType *basicType ) {
    103                 const PointerType *destAsPointer = dynamic_cast< const PointerType* >( dest );
     102        void CastCost_old::postvisit( const BasicType * basicType ) {
     103                const PointerType * destAsPointer = dynamic_cast< const PointerType * >( dest );
    104104                if ( destAsPointer && basicType->isInteger() ) {
    105                         // necessary for, e.g. unsigned long => void*
     105                        // necessary for, e.g. unsigned long => void *
    106106                        cost = Cost::unsafe;
    107107                } else {
     
    110110        }
    111111
    112         void CastCost_old::postvisit( const PointerType *pointerType ) {
    113                 if ( const PointerType *destAsPtr = dynamic_cast< const PointerType* >( dest ) ) {
     112        void CastCost_old::postvisit( const PointerType * pointerType ) {
     113                if ( const PointerType * destAsPtr = dynamic_cast< const PointerType * >( dest ) ) {
    114114                        if ( pointerType->tq <= destAsPtr->tq && typesCompatibleIgnoreQualifiers( pointerType->base, destAsPtr->base, indexer, env ) ) {
    115115                                cost = Cost::safe;
     
    127127                } else if ( const BasicType * destAsBasic = dynamic_cast< const BasicType * >( dest ) ) {
    128128                        if ( destAsBasic->isInteger() ) {
    129                                 // necessary for, e.g. void* => unsigned long
     129                                // necessary for, e.g. void * => unsigned long
    130130                                cost = Cost::unsafe;
    131131                        } // if
  • src/ResolvExpr/CommonType.cc

    r7870799 ref5b828  
    3838namespace ResolvExpr {
    3939        struct CommonType_old : public WithShortCircuiting {
    40                 CommonType_old( Type *type2, bool widenFirst, bool widenSecond, const SymTab::Indexer &indexer, TypeEnvironment &env, const OpenVarSet &openVars );
    41                 Type *get_result() const { return result; }
     40                CommonType_old( Type * type2, bool widenFirst, bool widenSecond, const SymTab::Indexer &indexer, TypeEnvironment &env, const OpenVarSet &openVars );
     41                Type * get_result() const { return result; }
    4242
    4343                void previsit( BaseSyntaxNode * ) { visit_children = false; }
     
    6060
    6161          private:
    62                 template< typename Pointer > void getCommonWithVoidPointer( Pointer* voidPointer, Pointer* otherPointer );
    63                 template< typename RefType > void handleRefType( RefType *inst, Type *other );
    64 
    65                 Type *result;
    66                 Type *type2;                            // inherited
     62                template< typename Pointer > void getCommonWithVoidPointer( Pointer * voidPointer, Pointer * otherPointer );
     63                template< typename RefType > void handleRefType( RefType * inst, Type * other );
     64
     65                Type * result;
     66                Type * type2;                           // inherited
    6767                bool widenFirst, widenSecond;
    6868                const SymTab::Indexer &indexer;
     
    8080                                std::cerr << "unify success: " << widenFirst << " " << widenSecond << std::endl;
    8181                        )
    82                         if ( (widenFirst || t2->get_qualifiers() <= t1->get_qualifiers()) && (widenSecond || t1->get_qualifiers() <= t2->get_qualifiers()) ) {
     82                        if ( (widenFirst || t2->tq <= t1->tq) && (widenSecond || t1->tq <= t2->tq) ) {
    8383                                PRINT(
    8484                                        std::cerr << "widen okay" << std::endl;
    8585                                )
    86                                 common->get_qualifiers() |= t1->get_qualifiers();
    87                                 common->get_qualifiers() |= t2->get_qualifiers();
     86                                common->tq |= t1->tq;
     87                                common->tq |= t2->tq;
    8888                                return common;
    8989                        }
     
    9595        }
    9696
    97         Type *commonType( Type *type1, Type *type2, bool widenFirst, bool widenSecond, const SymTab::Indexer &indexer, TypeEnvironment &env, const OpenVarSet &openVars ) {
     97        Type * commonType( Type * type1, Type * type2, bool widenFirst, bool widenSecond, const SymTab::Indexer &indexer, TypeEnvironment &env, const OpenVarSet &openVars ) {
    9898                PassVisitor<CommonType_old> visitor( type2, widenFirst, widenSecond, indexer, env, openVars );
    9999
     
    127127                                                std::cerr << "formal is reference; result should be reference" << std::endl;
    128128                                        )
    129                                         result = new ReferenceType( ref1->get_qualifiers(), result );
     129                                        result = new ReferenceType( ref1->tq, result );
    130130                                }
    131131                                PRINT(
     
    138138
    139139                type1->accept( visitor );
    140                 Type *result = visitor.pass.get_result();
     140                Type * result = visitor.pass.get_result();
    141141                if ( ! result ) {
    142142                        // this appears to be handling for opaque type declarations
    143143                        if ( widenSecond ) {
    144                                 if ( TypeInstType *inst = dynamic_cast< TypeInstType* >( type2 ) ) {
    145                                         if ( NamedTypeDecl *nt = indexer.lookupType( inst->get_name() ) ) {
    146                                                 TypeDecl *type = strict_dynamic_cast< TypeDecl* >( nt );
     144                                if ( const TypeInstType * inst = dynamic_cast< const TypeInstType * >( type2 ) ) {
     145                                        if ( const NamedTypeDecl * nt = indexer.lookupType( inst->get_name() ) ) {
     146                                                const TypeDecl * type = strict_dynamic_cast< const TypeDecl * >( nt );
    147147                                                if ( type->get_base() ) {
    148                                                         Type::Qualifiers tq1 = type1->get_qualifiers(), tq2 = type2->get_qualifiers();
     148                                                        Type::Qualifiers tq1 = type1->tq, tq2 = type2->tq;
    149149                                                        AssertionSet have, need;
    150150                                                        OpenVarSet newOpen( openVars );
    151                                                         type1->get_qualifiers() = Type::Qualifiers();
    152                                                         type->get_base()->get_qualifiers() = tq1;
     151                                                        type1->tq = Type::Qualifiers();
     152                                                        type->get_base()->tq = tq1;
    153153                                                        if ( unifyExact( type1, type->get_base(), env, have, need, newOpen, indexer ) ) {
    154154                                                                result = type1->clone();
    155                                                                 result->get_qualifiers() = tq1 | tq2;
     155                                                                result->tq = tq1 | tq2;
    156156                                                        } // if
    157                                                         type1->get_qualifiers() = tq1;
    158                                                         type->get_base()->get_qualifiers() = Type::Qualifiers();
     157                                                        type1->tq = tq1;
     158                                                        type->get_base()->tq = Type::Qualifiers();
    159159                                                } // if
    160160                                        } // if
     
    190190                                 */
    191191                                  {
    192                 /*     B*/                BT Bool,                BT Char,          BT SignedChar,        BT UnsignedChar,      BT ShortSignedInt,    BT ShortUnsignedInt,
     192                /*     B */                BT Bool,                BT Char,          BT SignedChar,        BT UnsignedChar,      BT ShortSignedInt,    BT ShortUnsignedInt,
    193193                                             BT SignedInt,         BT UnsignedInt,       BT LongSignedInt,     BT LongUnsignedInt,   BT LongLongSignedInt, BT LongLongUnsignedInt,
    194194                                          BT SignedInt128,      BT UnsignedInt128,            BT uFloat16,     BT uFloat16Complex,            BT uFloat32,     BT uFloat32Complex,
     
    198198                                  },
    199199                                  {
    200                 /*     C*/                BT Char,                BT Char,          BT SignedChar,        BT UnsignedChar,      BT ShortSignedInt,    BT ShortUnsignedInt,
     200                /*     C */                BT Char,                BT Char,          BT SignedChar,        BT UnsignedChar,      BT ShortSignedInt,    BT ShortUnsignedInt,
    201201                                             BT SignedInt,         BT UnsignedInt,       BT LongSignedInt,     BT LongUnsignedInt,   BT LongLongSignedInt, BT LongLongUnsignedInt,
    202202                                          BT SignedInt128,      BT UnsignedInt128,            BT uFloat16,     BT uFloat16Complex,            BT uFloat32,     BT uFloat32Complex,
     
    206206                                  },
    207207                                  {
    208                 /*    SC*/          BT SignedChar,          BT SignedChar,          BT SignedChar,        BT UnsignedChar,      BT ShortSignedInt,    BT ShortUnsignedInt,
     208                /*    SC */          BT SignedChar,          BT SignedChar,          BT SignedChar,        BT UnsignedChar,      BT ShortSignedInt,    BT ShortUnsignedInt,
    209209                                             BT SignedInt,         BT UnsignedInt,       BT LongSignedInt,     BT LongUnsignedInt,   BT LongLongSignedInt, BT LongLongUnsignedInt,
    210210                                          BT SignedInt128,      BT UnsignedInt128,            BT uFloat16,     BT uFloat16Complex,            BT uFloat32,     BT uFloat32Complex,
     
    214214                                  },
    215215                                  {
    216                 /*    UC*/        BT UnsignedChar,        BT UnsignedChar,        BT UnsignedChar,        BT UnsignedChar,      BT ShortSignedInt,    BT ShortUnsignedInt,
     216                /*    UC */        BT UnsignedChar,        BT UnsignedChar,        BT UnsignedChar,        BT UnsignedChar,      BT ShortSignedInt,    BT ShortUnsignedInt,
    217217                                             BT SignedInt,         BT UnsignedInt,       BT LongSignedInt,     BT LongUnsignedInt,   BT LongLongSignedInt, BT LongLongUnsignedInt,
    218218                                          BT SignedInt128,      BT UnsignedInt128,            BT uFloat16,     BT uFloat16Complex,            BT uFloat32,     BT uFloat32Complex,
     
    222222                                  },
    223223                                  {
    224                 /*    SI*/      BT ShortSignedInt,      BT ShortSignedInt,      BT ShortSignedInt,      BT ShortSignedInt,      BT ShortSignedInt,    BT ShortUnsignedInt,
     224                /*    SI */      BT ShortSignedInt,      BT ShortSignedInt,      BT ShortSignedInt,      BT ShortSignedInt,      BT ShortSignedInt,    BT ShortUnsignedInt,
    225225                                             BT SignedInt,         BT UnsignedInt,       BT LongSignedInt,     BT LongUnsignedInt,   BT LongLongSignedInt, BT LongLongUnsignedInt,
    226226                                          BT SignedInt128,      BT UnsignedInt128,            BT uFloat16,     BT uFloat16Complex,            BT uFloat32,     BT uFloat32Complex,
     
    230230                                  },
    231231                                  {
    232                 /*   SUI*/    BT ShortUnsignedInt,    BT ShortUnsignedInt,    BT ShortUnsignedInt,    BT ShortUnsignedInt,    BT ShortUnsignedInt,    BT ShortUnsignedInt,
     232                /*   SUI */    BT ShortUnsignedInt,    BT ShortUnsignedInt,    BT ShortUnsignedInt,    BT ShortUnsignedInt,    BT ShortUnsignedInt,    BT ShortUnsignedInt,
    233233                                             BT SignedInt,         BT UnsignedInt,       BT LongSignedInt,     BT LongUnsignedInt,   BT LongLongSignedInt, BT LongLongUnsignedInt,
    234234                                          BT SignedInt128,      BT UnsignedInt128,            BT uFloat16,     BT uFloat16Complex,            BT uFloat32,     BT uFloat32Complex,
     
    238238                                  },
    239239                                  {
    240                 /*     I*/           BT SignedInt,           BT SignedInt,           BT SignedInt,           BT SignedInt,           BT SignedInt,           BT SignedInt,
     240                /*     I */           BT SignedInt,           BT SignedInt,           BT SignedInt,           BT SignedInt,           BT SignedInt,           BT SignedInt,
    241241                                             BT SignedInt,         BT UnsignedInt,       BT LongSignedInt,     BT LongUnsignedInt,   BT LongLongSignedInt, BT LongLongUnsignedInt,
    242242                                          BT SignedInt128,      BT UnsignedInt128,            BT uFloat16,     BT uFloat16Complex,            BT uFloat32,     BT uFloat32Complex,
     
    246246                                  },
    247247                                  {
    248                 /*    UI*/         BT UnsignedInt,         BT UnsignedInt,         BT UnsignedInt,         BT UnsignedInt,         BT UnsignedInt,         BT UnsignedInt,
     248                /*    UI */         BT UnsignedInt,         BT UnsignedInt,         BT UnsignedInt,         BT UnsignedInt,         BT UnsignedInt,         BT UnsignedInt,
    249249                                           BT UnsignedInt,         BT UnsignedInt,       BT LongSignedInt,     BT LongUnsignedInt,   BT LongLongSignedInt, BT LongLongUnsignedInt,
    250250                                          BT SignedInt128,      BT UnsignedInt128,            BT uFloat16,     BT uFloat16Complex,            BT uFloat32,     BT uFloat32Complex,
     
    254254                                  },
    255255                                  {
    256                 /*    LI*/       BT LongSignedInt,       BT LongSignedInt,       BT LongSignedInt,       BT LongSignedInt,       BT LongSignedInt,       BT LongSignedInt,
     256                /*    LI */       BT LongSignedInt,       BT LongSignedInt,       BT LongSignedInt,       BT LongSignedInt,       BT LongSignedInt,       BT LongSignedInt,
    257257                                         BT LongSignedInt,       BT LongSignedInt,       BT LongSignedInt,     BT LongUnsignedInt,   BT LongLongSignedInt, BT LongLongUnsignedInt,
    258258                                          BT SignedInt128,      BT UnsignedInt128,            BT uFloat16,     BT uFloat16Complex,            BT uFloat32,     BT uFloat32Complex,
     
    262262                                  },
    263263                                  {
    264                 /*   LUI*/     BT LongUnsignedInt,     BT LongUnsignedInt,     BT LongUnsignedInt,     BT LongUnsignedInt,     BT LongUnsignedInt,     BT LongUnsignedInt,
     264                /*   LUI */     BT LongUnsignedInt,     BT LongUnsignedInt,     BT LongUnsignedInt,     BT LongUnsignedInt,     BT LongUnsignedInt,     BT LongUnsignedInt,
    265265                                       BT LongUnsignedInt,     BT LongUnsignedInt,     BT LongUnsignedInt,     BT LongUnsignedInt,   BT LongLongSignedInt, BT LongLongUnsignedInt,
    266266                                          BT SignedInt128,      BT UnsignedInt128,            BT uFloat16,     BT uFloat16Complex,            BT uFloat32,     BT uFloat32Complex,
     
    270270                                  },
    271271                                  {
    272                 /*   LLI*/   BT LongLongSignedInt,   BT LongLongSignedInt,   BT LongLongSignedInt,   BT LongLongSignedInt,   BT LongLongSignedInt,   BT LongLongSignedInt,
     272                /*   LLI */   BT LongLongSignedInt,   BT LongLongSignedInt,   BT LongLongSignedInt,   BT LongLongSignedInt,   BT LongLongSignedInt,   BT LongLongSignedInt,
    273273                                     BT LongLongSignedInt,   BT LongLongSignedInt,   BT LongLongSignedInt,   BT LongLongSignedInt,   BT LongLongSignedInt, BT LongLongUnsignedInt,
    274274                                          BT SignedInt128,      BT UnsignedInt128,            BT uFloat16,     BT uFloat16Complex,            BT uFloat32,     BT uFloat32Complex,
     
    278278                                  },
    279279                                  {
    280                 /*  LLUI*/ BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt,
     280                /*  LLUI */ BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt,
    281281                                   BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt,
    282282                                          BT SignedInt128,      BT UnsignedInt128,            BT uFloat16,     BT uFloat16Complex,            BT uFloat32,     BT uFloat32Complex,
     
    286286                                  },
    287287                                  {
    288                 /*    IB*/        BT SignedInt128,        BT SignedInt128,        BT SignedInt128,        BT SignedInt128,        BT SignedInt128,        BT SignedInt128,
     288                /*    IB */        BT SignedInt128,        BT SignedInt128,        BT SignedInt128,        BT SignedInt128,        BT SignedInt128,        BT SignedInt128,
    289289                                          BT SignedInt128,        BT SignedInt128,        BT SignedInt128,        BT SignedInt128,        BT SignedInt128,        BT SignedInt128,
    290290                                          BT SignedInt128,      BT UnsignedInt128,            BT uFloat16,     BT uFloat16Complex,            BT uFloat32,     BT uFloat32Complex,
     
    294294                                  },
    295295                                  {
    296                 /*   UIB*/      BT UnsignedInt128,      BT UnsignedInt128,      BT UnsignedInt128,      BT UnsignedInt128,      BT UnsignedInt128,      BT UnsignedInt128,
     296                /*   UIB */      BT UnsignedInt128,      BT UnsignedInt128,      BT UnsignedInt128,      BT UnsignedInt128,      BT UnsignedInt128,      BT UnsignedInt128,
    297297                                        BT UnsignedInt128,      BT UnsignedInt128,      BT UnsignedInt128,      BT UnsignedInt128,      BT UnsignedInt128,      BT UnsignedInt128,
    298298                                        BT UnsignedInt128,      BT UnsignedInt128,            BT uFloat16,     BT uFloat16Complex,            BT uFloat32,     BT uFloat32Complex,
     
    302302                                  },
    303303                                  {
    304                 /*   _FH*/            BT uFloat16,            BT uFloat16,            BT uFloat16,            BT uFloat16,            BT uFloat16,            BT uFloat16,
     304                /*   _FH */            BT uFloat16,            BT uFloat16,            BT uFloat16,            BT uFloat16,            BT uFloat16,            BT uFloat16,
    305305                                              BT uFloat16,            BT uFloat16,            BT uFloat16,            BT uFloat16,            BT uFloat16,            BT uFloat16,
    306306                                              BT uFloat16,            BT uFloat16,            BT uFloat16,     BT uFloat16Complex,            BT uFloat32,     BT uFloat32Complex,
     
    310310                                  },
    311311                                  {
    312                 /*   _FH*/     BT uFloat16Complex,     BT uFloat16Complex,     BT uFloat16Complex,     BT uFloat16Complex,     BT uFloat16Complex,     BT uFloat16Complex,
     312                /*   _FH */     BT uFloat16Complex,     BT uFloat16Complex,     BT uFloat16Complex,     BT uFloat16Complex,     BT uFloat16Complex,     BT uFloat16Complex,
    313313                                       BT uFloat16Complex,     BT uFloat16Complex,     BT uFloat16Complex,     BT uFloat16Complex,     BT uFloat16Complex,     BT uFloat16Complex,
    314314                                       BT uFloat16Complex,     BT uFloat16Complex,     BT uFloat16Complex,     BT uFloat16Complex,     BT uFloat32Complex,     BT uFloat32Complex,
     
    318318                                  },
    319319                                  {
    320                 /*    _F*/            BT uFloat32,            BT uFloat32,            BT uFloat32,            BT uFloat32,            BT uFloat32,            BT uFloat32,
     320                /*    _F */            BT uFloat32,            BT uFloat32,            BT uFloat32,            BT uFloat32,            BT uFloat32,            BT uFloat32,
    321321                                              BT uFloat32,            BT uFloat32,            BT uFloat32,            BT uFloat32,            BT uFloat32,            BT uFloat32,
    322322                                              BT uFloat32,            BT uFloat32,            BT uFloat32,     BT uFloat32Complex,            BT uFloat32,     BT uFloat32Complex,
     
    326326                                  },
    327327                                  {
    328                 /*   _FC*/     BT uFloat32Complex,     BT uFloat32Complex,     BT uFloat32Complex,     BT uFloat32Complex,     BT uFloat32Complex,     BT uFloat32Complex,
     328                /*   _FC */     BT uFloat32Complex,     BT uFloat32Complex,     BT uFloat32Complex,     BT uFloat32Complex,     BT uFloat32Complex,     BT uFloat32Complex,
    329329                                       BT uFloat32Complex,     BT uFloat32Complex,     BT uFloat32Complex,     BT uFloat32Complex,     BT uFloat32Complex,     BT uFloat32Complex,
    330330                                       BT uFloat32Complex,     BT uFloat32Complex,     BT uFloat32Complex,     BT uFloat32Complex,     BT uFloat32Complex,     BT uFloat32Complex,
     
    334334                                  },
    335335                                  {
    336                 /*     F*/               BT Float,               BT Float,               BT Float,               BT Float,               BT Float,               BT Float,
     336                /*     F */               BT Float,               BT Float,               BT Float,               BT Float,               BT Float,               BT Float,
    337337                                                 BT Float,               BT Float,               BT Float,               BT Float,               BT Float,               BT Float,
    338338                                                 BT Float,               BT Float,               BT Float,        BT FloatComplex,               BT Float,        BT FloatComplex,
     
    342342                                  },
    343343                                  {
    344                 /*    FC*/        BT FloatComplex,        BT FloatComplex,        BT FloatComplex,        BT FloatComplex,        BT FloatComplex,        BT FloatComplex,
     344                /*    FC */        BT FloatComplex,        BT FloatComplex,        BT FloatComplex,        BT FloatComplex,        BT FloatComplex,        BT FloatComplex,
    345345                                          BT FloatComplex,        BT FloatComplex,        BT FloatComplex,        BT FloatComplex,        BT FloatComplex,        BT FloatComplex,
    346346                                          BT FloatComplex,        BT FloatComplex,        BT FloatComplex,        BT FloatComplex,        BT FloatComplex,        BT FloatComplex,
     
    350350                                  },
    351351                                  {
    352                 /*   _FX*/           BT uFloat32x,           BT uFloat32x,           BT uFloat32x,           BT uFloat32x,           BT uFloat32x,           BT uFloat32x,
     352                /*   _FX */           BT uFloat32x,           BT uFloat32x,           BT uFloat32x,           BT uFloat32x,           BT uFloat32x,           BT uFloat32x,
    353353                                             BT uFloat32x,           BT uFloat32x,           BT uFloat32x,           BT uFloat32x,           BT uFloat32x,           BT uFloat32x,
    354354                                             BT uFloat32x,           BT uFloat32x,           BT uFloat32x,    BT uFloat32xComplex,           BT uFloat32x,    BT uFloat32xComplex,
     
    358358                                  },
    359359                                  {
    360                 /*  _FXC*/    BT uFloat32xComplex,    BT uFloat32xComplex,    BT uFloat32xComplex,    BT uFloat32xComplex,    BT uFloat32xComplex,    BT uFloat32xComplex,
     360                /*  _FXC */    BT uFloat32xComplex,    BT uFloat32xComplex,    BT uFloat32xComplex,    BT uFloat32xComplex,    BT uFloat32xComplex,    BT uFloat32xComplex,
    361361                                      BT uFloat32xComplex,    BT uFloat32xComplex,    BT uFloat32xComplex,    BT uFloat32xComplex,    BT uFloat32xComplex,    BT uFloat32xComplex,
    362362                                      BT uFloat32xComplex,    BT uFloat32xComplex,    BT uFloat32xComplex,    BT uFloat32xComplex,    BT uFloat32xComplex,    BT uFloat32xComplex,
     
    366366                                  },
    367367                                  {
    368                 /*    FD*/            BT uFloat64,            BT uFloat64,            BT uFloat64,            BT uFloat64,            BT uFloat64,            BT uFloat64,
     368                /*    FD */            BT uFloat64,            BT uFloat64,            BT uFloat64,            BT uFloat64,            BT uFloat64,            BT uFloat64,
    369369                                              BT uFloat64,            BT uFloat64,            BT uFloat64,            BT uFloat64,            BT uFloat64,            BT uFloat64,
    370370                                              BT uFloat64,            BT uFloat64,            BT uFloat64,     BT uFloat64Complex,            BT uFloat64,     BT uFloat64Complex,
     
    374374                                  },
    375375                                  {
    376                 /*  _FDC*/     BT uFloat64Complex,     BT uFloat64Complex,     BT uFloat64Complex,     BT uFloat64Complex,     BT uFloat64Complex,     BT uFloat64Complex,
     376                /*  _FDC */     BT uFloat64Complex,     BT uFloat64Complex,     BT uFloat64Complex,     BT uFloat64Complex,     BT uFloat64Complex,     BT uFloat64Complex,
    377377                                       BT uFloat64Complex,     BT uFloat64Complex,     BT uFloat64Complex,     BT uFloat64Complex,     BT uFloat64Complex,     BT uFloat64Complex,
    378378                                       BT uFloat64Complex,     BT uFloat64Complex,     BT uFloat64Complex,     BT uFloat64Complex,     BT uFloat64Complex,     BT uFloat64Complex,
     
    382382                                  },
    383383                                  {
    384                 /*     D*/              BT Double,              BT Double,              BT Double,              BT Double,              BT Double,              BT Double,
     384                /*     D */              BT Double,              BT Double,              BT Double,              BT Double,              BT Double,              BT Double,
    385385                                                BT Double,              BT Double,              BT Double,              BT Double,              BT Double,              BT Double,
    386386                                                BT Double,              BT Double,              BT Double,       BT DoubleComplex,              BT Double,       BT DoubleComplex,
     
    390390                                  },
    391391                                  {
    392                 /*    DC*/       BT DoubleComplex,       BT DoubleComplex,       BT DoubleComplex,       BT DoubleComplex,       BT DoubleComplex,       BT DoubleComplex,
     392                /*    DC */       BT DoubleComplex,       BT DoubleComplex,       BT DoubleComplex,       BT DoubleComplex,       BT DoubleComplex,       BT DoubleComplex,
    393393                                         BT DoubleComplex,       BT DoubleComplex,       BT DoubleComplex,       BT DoubleComplex,       BT DoubleComplex,       BT DoubleComplex,
    394394                                         BT DoubleComplex,       BT DoubleComplex,       BT DoubleComplex,       BT DoubleComplex,       BT DoubleComplex,       BT DoubleComplex,
     
    398398                                  },
    399399                                  {
    400                 /*  F80X*/           BT uFloat64x,           BT uFloat64x,           BT uFloat64x,           BT uFloat64x,           BT uFloat64x,           BT uFloat64x,
     400                /*  F80X */           BT uFloat64x,           BT uFloat64x,           BT uFloat64x,           BT uFloat64x,           BT uFloat64x,           BT uFloat64x,
    401401                                             BT uFloat64x,           BT uFloat64x,           BT uFloat64x,           BT uFloat64x,           BT uFloat64x,           BT uFloat64x,
    402402                                             BT uFloat64x,           BT uFloat64x,           BT uFloat64x,    BT uFloat64xComplex,           BT uFloat64x,    BT uFloat64xComplex,
     
    406406                                  },
    407407                                  {
    408                 /* _FDXC*/    BT uFloat64xComplex,    BT uFloat64xComplex,    BT uFloat64xComplex,    BT uFloat64xComplex,    BT uFloat64xComplex,    BT uFloat64xComplex,
     408                /* _FDXC */    BT uFloat64xComplex,    BT uFloat64xComplex,    BT uFloat64xComplex,    BT uFloat64xComplex,    BT uFloat64xComplex,    BT uFloat64xComplex,
    409409                                      BT uFloat64xComplex,    BT uFloat64xComplex,    BT uFloat64xComplex,    BT uFloat64xComplex,    BT uFloat64xComplex,    BT uFloat64xComplex,
    410410                                      BT uFloat64xComplex,    BT uFloat64xComplex,    BT uFloat64xComplex,    BT uFloat64xComplex,    BT uFloat64xComplex,    BT uFloat64xComplex,
     
    422422                                  },
    423423                                  {
    424                 /*   _FB*/           BT uFloat128,           BT uFloat128,           BT uFloat128,           BT uFloat128,           BT uFloat128,           BT uFloat128,
     424                /*   _FB */           BT uFloat128,           BT uFloat128,           BT uFloat128,           BT uFloat128,           BT uFloat128,           BT uFloat128,
    425425                                             BT uFloat128,           BT uFloat128,           BT uFloat128,           BT uFloat128,           BT uFloat128,           BT uFloat128,
    426426                                             BT uFloat128,           BT uFloat128,           BT uFloat128,    BT uFloat128Complex,           BT uFloat128,    BT uFloat128Complex,
     
    430430                                  },
    431431                                  {
    432                 /* _FLDC*/    BT uFloat128Complex,    BT uFloat128Complex,    BT uFloat128Complex,    BT uFloat128Complex,    BT uFloat128Complex,    BT uFloat128Complex,
     432                /* _FLDC */    BT uFloat128Complex,    BT uFloat128Complex,    BT uFloat128Complex,    BT uFloat128Complex,    BT uFloat128Complex,    BT uFloat128Complex,
    433433                                      BT uFloat128Complex,    BT uFloat128Complex,    BT uFloat128Complex,    BT uFloat128Complex,    BT uFloat128Complex,    BT uFloat128Complex,
    434434                                      BT uFloat128Complex,    BT uFloat128Complex,    BT uFloat128Complex,    BT uFloat128Complex,    BT uFloat128Complex,    BT uFloat128Complex,
     
    438438                                  },
    439439                                  {
    440                 /*    FB*/          BT uuFloat128,          BT uuFloat128,          BT uuFloat128,          BT uuFloat128,          BT uuFloat128,          BT uuFloat128,
     440                /*    FB */          BT uuFloat128,          BT uuFloat128,          BT uuFloat128,          BT uuFloat128,          BT uuFloat128,          BT uuFloat128,
    441441                                            BT uuFloat128,          BT uuFloat128,          BT uuFloat128,          BT uuFloat128,          BT uuFloat128,          BT uuFloat128,
    442442                                            BT uuFloat128,          BT uuFloat128,          BT uuFloat128,    BT uFloat128Complex,          BT uuFloat128,    BT uFloat128Complex,
     
    446446                                  },
    447447                                  {
    448                 /*    LD*/          BT LongDouble,          BT LongDouble,          BT LongDouble,          BT LongDouble,          BT LongDouble,          BT LongDouble,
     448                /*    LD */          BT LongDouble,          BT LongDouble,          BT LongDouble,          BT LongDouble,          BT LongDouble,          BT LongDouble,
    449449                                            BT LongDouble,          BT LongDouble,          BT LongDouble,          BT LongDouble,          BT LongDouble,          BT LongDouble,
    450450                                            BT LongDouble,          BT LongDouble,          BT LongDouble,   BT LongDoubleComplex,          BT LongDouble,   BT LongDoubleComplex,
     
    454454                                  },
    455455                                  {
    456                 /*   LDC*/   BT LongDoubleComplex,   BT LongDoubleComplex,   BT LongDoubleComplex,   BT LongDoubleComplex,   BT LongDoubleComplex,   BT LongDoubleComplex,
     456                /*   LDC */   BT LongDoubleComplex,   BT LongDoubleComplex,   BT LongDoubleComplex,   BT LongDoubleComplex,   BT LongDoubleComplex,   BT LongDoubleComplex,
    457457                                     BT LongDoubleComplex,   BT LongDoubleComplex,   BT LongDoubleComplex,   BT LongDoubleComplex,   BT LongDoubleComplex,   BT LongDoubleComplex,
    458458                                     BT LongDoubleComplex,   BT LongDoubleComplex,   BT LongDoubleComplex,   BT LongDoubleComplex,   BT LongDoubleComplex,   BT LongDoubleComplex,
     
    462462                                  },
    463463                                  {
    464                 /*  _FBX*/          BT uFloat128x,          BT uFloat128x,          BT uFloat128x,          BT uFloat128x,          BT uFloat128x,          BT uFloat128x,
     464                /*  _FBX */          BT uFloat128x,          BT uFloat128x,          BT uFloat128x,          BT uFloat128x,          BT uFloat128x,          BT uFloat128x,
    465465                                            BT uFloat128x,          BT uFloat128x,          BT uFloat128x,          BT uFloat128x,          BT uFloat128x,          BT uFloat128x,
    466466                                            BT uFloat128x,          BT uFloat128x,          BT uFloat128x,   BT uFloat128xComplex,          BT uFloat128x,   BT uFloat128xComplex,
     
    470470                                  },
    471471                                  {
    472                 /*_FLDXC*/   BT uFloat128xComplex,   BT uFloat128xComplex,   BT uFloat128xComplex,   BT uFloat128xComplex,   BT uFloat128xComplex,   BT uFloat128xComplex,
     472                /* _FLDXC */   BT uFloat128xComplex,   BT uFloat128xComplex,   BT uFloat128xComplex,   BT uFloat128xComplex,   BT uFloat128xComplex,   BT uFloat128xComplex,
    473473                                     BT uFloat128xComplex,   BT uFloat128xComplex,   BT uFloat128xComplex,   BT uFloat128xComplex,   BT uFloat128xComplex,   BT uFloat128xComplex,
    474474                                     BT uFloat128xComplex,   BT uFloat128xComplex,   BT uFloat128xComplex,   BT uFloat128xComplex,   BT uFloat128xComplex,   BT uFloat128xComplex,
     
    481481        // GENERATED END
    482482        static_assert(
    483                 sizeof(commonTypes)/sizeof(commonTypes[0][0]) == BasicType::NUMBER_OF_BASIC_TYPES*BasicType::NUMBER_OF_BASIC_TYPES,
     483                sizeof(commonTypes)/sizeof(commonTypes[0][0]) == BasicType::NUMBER_OF_BASIC_TYPES * BasicType::NUMBER_OF_BASIC_TYPES,
    484484                "Each basic type kind should have a corresponding row in the combined type matrix"
    485485        );
    486486
    487         CommonType_old::CommonType_old( Type *type2, bool widenFirst, bool widenSecond, const SymTab::Indexer &indexer, TypeEnvironment &env, const OpenVarSet &openVars )
     487        CommonType_old::CommonType_old( Type * type2, bool widenFirst, bool widenSecond, const SymTab::Indexer &indexer, TypeEnvironment &env, const OpenVarSet &openVars )
    488488                : result( 0 ), type2( type2 ), widenFirst( widenFirst ), widenSecond( widenSecond ), indexer( indexer ), env( env ), openVars( openVars ) {
    489489        }
     
    491491        void CommonType_old::postvisit( VoidType * ) {}
    492492
    493         void CommonType_old::postvisit( BasicType *basicType ) {
    494                 if ( BasicType *otherBasic = dynamic_cast< BasicType* >( type2 ) ) {
     493        void CommonType_old::postvisit( BasicType * basicType ) {
     494                if ( BasicType * otherBasic = dynamic_cast< BasicType * >( type2 ) ) {
    495495                        BasicType::Kind newType = commonTypes[ basicType->get_kind() ][ otherBasic->get_kind() ];
    496                         if ( ( ( newType == basicType->get_kind() && basicType->get_qualifiers() >= otherBasic->get_qualifiers() ) || widenFirst ) && ( ( newType == otherBasic->get_kind() && basicType->get_qualifiers() <= otherBasic->get_qualifiers() ) || widenSecond ) ) {
    497                                 result = new BasicType( basicType->get_qualifiers() | otherBasic->get_qualifiers(), newType );
     496                        if ( ( ( newType == basicType->get_kind() && basicType->tq >= otherBasic->tq ) || widenFirst ) && ( ( newType == otherBasic->get_kind() && basicType->tq <= otherBasic->tq ) || widenSecond ) ) {
     497                                result = new BasicType( basicType->tq | otherBasic->tq, newType );
    498498                        } // if
    499                 } else if ( dynamic_cast< EnumInstType * > ( type2 ) || dynamic_cast< ZeroType* >( type2 ) || dynamic_cast< OneType* >( type2 ) ) {
     499                } else if ( dynamic_cast< EnumInstType * > ( type2 ) || dynamic_cast< ZeroType * >( type2 ) || dynamic_cast< OneType * >( type2 ) ) {
    500500                        // use signed int in lieu of the enum/zero/one type
    501501                        BasicType::Kind newType = commonTypes[ basicType->get_kind() ][ BasicType::SignedInt ];
    502                         if ( ( ( newType == basicType->get_kind() && basicType->get_qualifiers() >= type2->get_qualifiers() ) || widenFirst ) && ( ( newType != basicType->get_kind() && basicType->get_qualifiers() <= type2->get_qualifiers() ) || widenSecond ) ) {
    503                                 result = new BasicType( basicType->get_qualifiers() | type2->get_qualifiers(), newType );
     502                        if ( ( ( newType == basicType->get_kind() && basicType->tq >= type2->tq ) || widenFirst ) && ( ( newType != basicType->get_kind() && basicType->tq <= type2->tq ) || widenSecond ) ) {
     503                                result = new BasicType( basicType->tq | type2->tq, newType );
    504504                        } // if
    505505                } // if
     
    507507
    508508        template< typename Pointer >
    509         void CommonType_old::getCommonWithVoidPointer( Pointer* voidPointer, Pointer* otherPointer ) {
    510                 if ( TypeInstType* var = dynamic_cast< TypeInstType* >( otherPointer->get_base() ) ) {
     509        void CommonType_old::getCommonWithVoidPointer( Pointer * voidPointer, Pointer * otherPointer ) {
     510                if ( TypeInstType * var = dynamic_cast< TypeInstType * >( otherPointer->get_base() ) ) {
    511511                        OpenVarSet::const_iterator entry = openVars.find( var->get_name() );
    512512                        if ( entry != openVars.end() ) {
     
    517517                }
    518518                result = voidPointer->clone();
    519                 result->get_qualifiers() |= otherPointer->get_qualifiers();
    520         }
    521 
    522         void CommonType_old::postvisit( PointerType *pointerType ) {
    523                 if ( PointerType *otherPointer = dynamic_cast< PointerType* >( type2 ) ) {
     519                result->tq |= otherPointer->tq;
     520        }
     521
     522        void CommonType_old::postvisit( PointerType * pointerType ) {
     523                if ( PointerType * otherPointer = dynamic_cast< PointerType * >( type2 ) ) {
    524524                        // std::cerr << "commonType: two pointers: " << pointerType << " / " << otherPointer << std::endl;
    525                         if ( widenFirst && dynamic_cast< VoidType* >( otherPointer->get_base() ) && ! isFtype(pointerType->get_base()) ) {
     525                        if ( widenFirst && dynamic_cast< VoidType * >( otherPointer->get_base() ) && ! isFtype(pointerType->get_base()) ) {
    526526                                getCommonWithVoidPointer( otherPointer, pointerType );
    527                         } else if ( widenSecond && dynamic_cast< VoidType* >( pointerType->get_base() ) && ! isFtype(otherPointer->get_base()) ) {
     527                        } else if ( widenSecond && dynamic_cast< VoidType * >( pointerType->get_base() ) && ! isFtype(otherPointer->get_base()) ) {
    528528                                getCommonWithVoidPointer( pointerType, otherPointer );
    529                         } else if ( ( pointerType->get_base()->get_qualifiers() >= otherPointer->get_base()->get_qualifiers() || widenFirst )
    530                                            && ( pointerType->get_base()->get_qualifiers() <= otherPointer->get_base()->get_qualifiers() || widenSecond ) ) {
     529                        } else if ( ( pointerType->get_base()->tq >= otherPointer->get_base()->tq || widenFirst )
     530                                           && ( pointerType->get_base()->tq <= otherPointer->get_base()->tq || widenSecond ) ) {
    531531                                // std::cerr << "middle case" << std::endl;
    532                                 Type::Qualifiers tq1 = pointerType->get_base()->get_qualifiers(), tq2 = otherPointer->get_base()->get_qualifiers();
    533                                 pointerType->get_base()->get_qualifiers() = Type::Qualifiers();
    534                                 otherPointer->get_base()->get_qualifiers() = Type::Qualifiers();
     532                                Type::Qualifiers tq1 = pointerType->get_base()->tq, tq2 = otherPointer->get_base()->tq;
     533                                pointerType->get_base()->tq = Type::Qualifiers();
     534                                otherPointer->get_base()->tq = Type::Qualifiers();
    535535                                AssertionSet have, need;
    536536                                OpenVarSet newOpen( openVars );
     
    542542                                                result = otherPointer->clone();
    543543                                        } // if
    544                                         strict_dynamic_cast<PointerType*>(result)->base->get_qualifiers() = tq1 | tq2;
     544                                        strict_dynamic_cast<PointerType *>(result)->base->tq = tq1 | tq2;
    545545                                } else {
    546546                                        /// std::cerr << "place for ptr-to-type" << std::endl;
    547547                                } // if
    548                                 pointerType->get_base()->get_qualifiers() = tq1;
    549                                 otherPointer->get_base()->get_qualifiers() = tq2;
     548                                pointerType->get_base()->tq = tq1;
     549                                otherPointer->get_base()->tq = tq2;
    550550                        } // if
    551                 } else if ( widenSecond && dynamic_cast< ZeroType* >( type2 ) ) {
     551                } else if ( widenSecond && dynamic_cast< ZeroType * >( type2 ) ) {
    552552                        result = pointerType->clone();
    553                         result->get_qualifiers() |= type2->get_qualifiers();
     553                        result->tq |= type2->tq;
    554554                } // if
    555555        }
     
    557557        void CommonType_old::postvisit( ArrayType * ) {}
    558558
    559         void CommonType_old::postvisit( ReferenceType *refType ) {
    560                 if ( ReferenceType *otherRef = dynamic_cast< ReferenceType* >( type2 ) ) {
     559        void CommonType_old::postvisit( ReferenceType * refType ) {
     560                if ( ReferenceType * otherRef = dynamic_cast< ReferenceType * >( type2 ) ) {
    561561                        // std::cerr << "commonType: both references: " << refType << " / " << otherRef << std::endl;
    562                         // std::cerr << ( refType->get_base()->get_qualifiers() >= otherRef->get_base()->get_qualifiers() || widenFirst ) << (refType->get_base()->get_qualifiers() <= otherRef->get_base()->get_qualifiers() || widenSecond) << std::endl;
    563                         if ( widenFirst && dynamic_cast< VoidType* >( otherRef->get_base() ) && ! isFtype(refType->get_base()) ) {
     562                        // std::cerr << ( refType->get_base()->tq >= otherRef->get_base()->tq || widenFirst ) << (refType->get_base()->tq <= otherRef->get_base()->tq || widenSecond) << std::endl;
     563                        if ( widenFirst && dynamic_cast< VoidType * >( otherRef->get_base() ) && ! isFtype(refType->get_base()) ) {
    564564                                getCommonWithVoidPointer( otherRef, refType );
    565                         } else if ( widenSecond && dynamic_cast< VoidType* >( refType->get_base() ) && ! isFtype(otherRef->get_base()) ) {
     565                        } else if ( widenSecond && dynamic_cast< VoidType * >( refType->get_base() ) && ! isFtype(otherRef->get_base()) ) {
    566566                                getCommonWithVoidPointer( refType, otherRef );
    567                         } else if ( ( refType->get_base()->get_qualifiers() >= otherRef->get_base()->get_qualifiers() || widenFirst )
    568                                            && ( refType->get_base()->get_qualifiers() <= otherRef->get_base()->get_qualifiers() || widenSecond ) ) {
     567                        } else if ( ( refType->get_base()->tq >= otherRef->get_base()->tq || widenFirst )
     568                                           && ( refType->get_base()->tq <= otherRef->get_base()->tq || widenSecond ) ) {
    569569                                // std::cerr << "middle case" << std::endl;
    570                                 Type::Qualifiers tq1 = refType->get_base()->get_qualifiers(), tq2 = otherRef->get_base()->get_qualifiers();
    571                                 refType->get_base()->get_qualifiers() = Type::Qualifiers();
    572                                 otherRef->get_base()->get_qualifiers() = Type::Qualifiers();
     570                                Type::Qualifiers tq1 = refType->get_base()->tq, tq2 = otherRef->get_base()->tq;
     571                                refType->get_base()->tq = Type::Qualifiers();
     572                                otherRef->get_base()->tq = Type::Qualifiers();
    573573                                AssertionSet have, need;
    574574                                OpenVarSet newOpen( openVars );
     
    579579                                                result = otherRef->clone();
    580580                                        } // if
    581                                         strict_dynamic_cast<ReferenceType*>(result)->base->get_qualifiers() = tq1 | tq2;
     581                                        strict_dynamic_cast<ReferenceType *>(result)->base->tq = tq1 | tq2;
    582582                                } else {
    583583                                        /// std::cerr << "place for ptr-to-type" << std::endl;
    584584                                } // if
    585                                 refType->get_base()->get_qualifiers() = tq1;
    586                                 otherRef->get_base()->get_qualifiers() = tq2;
     585                                refType->get_base()->tq = tq1;
     586                                otherRef->get_base()->tq = tq2;
    587587                        } // if
    588                 } else if ( widenSecond && dynamic_cast< ZeroType* >( type2 ) ) {
     588                } else if ( widenSecond && dynamic_cast< ZeroType * >( type2 ) ) {
    589589                        result = refType->clone();
    590                         result->get_qualifiers() |= type2->get_qualifiers();
     590                        result->tq |= type2->tq;
    591591                } // if
    592592        }
     
    596596        void CommonType_old::postvisit( UnionInstType * ) {}
    597597
    598         void CommonType_old::postvisit( EnumInstType *enumInstType ) {
    599                 if ( dynamic_cast< BasicType * >( type2 ) || dynamic_cast< ZeroType* >( type2 ) || dynamic_cast< OneType* >( type2 ) ) {
     598        void CommonType_old::postvisit( EnumInstType * enumInstType ) {
     599                if ( dynamic_cast< BasicType * >( type2 ) || dynamic_cast< ZeroType * >( type2 ) || dynamic_cast< OneType * >( type2 ) ) {
    600600                        // reuse BasicType, EnumInstType code by swapping type2 with enumInstType
    601601                        result = commonType( type2, enumInstType, widenSecond, widenFirst, indexer, env, openVars );
     
    606606        }
    607607
    608         void CommonType_old::postvisit( TypeInstType *inst ) {
     608        void CommonType_old::postvisit( TypeInstType * inst ) {
    609609                if ( widenFirst ) {
    610                         NamedTypeDecl *nt = indexer.lookupType( inst->get_name() );
     610                        const NamedTypeDecl * nt = indexer.lookupType( inst->get_name() );
    611611                        if ( nt ) {
    612                                 TypeDecl *type = strict_dynamic_cast< TypeDecl* >( nt );
     612                                const TypeDecl * type = strict_dynamic_cast< const TypeDecl * >( nt );
    613613                                if ( type->get_base() ) {
    614                                         Type::Qualifiers tq1 = inst->get_qualifiers(), tq2 = type2->get_qualifiers();
     614                                        Type::Qualifiers tq1 = inst->tq, tq2 = type2->tq;
    615615                                        AssertionSet have, need;
    616616                                        OpenVarSet newOpen( openVars );
    617                                         type2->get_qualifiers() = Type::Qualifiers();
    618                                         type->get_base()->get_qualifiers() = tq1;
     617                                        type2->tq = Type::Qualifiers();
     618                                        type->get_base()->tq = tq1;
    619619                                        if ( unifyExact( type->get_base(), type2, env, have, need, newOpen, indexer ) ) {
    620620                                                result = type2->clone();
    621                                                 result->get_qualifiers() = tq1 | tq2;
     621                                                result->tq = tq1 | tq2;
    622622                                        } // if
    623                                         type2->get_qualifiers() = tq2;
    624                                         type->get_base()->get_qualifiers() = Type::Qualifiers();
     623                                        type2->tq = tq2;
     624                                        type->get_base()->tq = Type::Qualifiers();
    625625                                } // if
    626626                        } // if
     
    631631        void CommonType_old::postvisit( VarArgsType * ) {}
    632632
    633         void CommonType_old::postvisit( ZeroType *zeroType ) {
     633        void CommonType_old::postvisit( ZeroType * zeroType ) {
    634634                if ( widenFirst ) {
    635                         if ( dynamic_cast< BasicType* >( type2 ) || dynamic_cast< PointerType* >( type2 ) || dynamic_cast< EnumInstType* >( type2 ) ) {
    636                                 if ( widenSecond || zeroType->get_qualifiers() <= type2->get_qualifiers() ) {
     635                        if ( dynamic_cast< BasicType * >( type2 ) || dynamic_cast< PointerType * >( type2 ) || dynamic_cast< EnumInstType * >( type2 ) ) {
     636                                if ( widenSecond || zeroType->tq <= type2->tq ) {
    637637                                        result = type2->clone();
    638                                         result->get_qualifiers() |= zeroType->get_qualifiers();
    639                                 }
    640                         } else if ( widenSecond && dynamic_cast< OneType* >( type2 ) ) {
    641                                 result = new BasicType( zeroType->get_qualifiers(), BasicType::SignedInt );
    642                                 result->get_qualifiers() |= type2->get_qualifiers();
    643                         }
    644                 }
    645         }
    646 
    647         void CommonType_old::postvisit( OneType *oneType ) {
     638                                        result->tq |= zeroType->tq;
     639                                }
     640                        } else if ( widenSecond && dynamic_cast< OneType * >( type2 ) ) {
     641                                result = new BasicType( zeroType->tq, BasicType::SignedInt );
     642                                result->tq |= type2->tq;
     643                        }
     644                }
     645        }
     646
     647        void CommonType_old::postvisit( OneType * oneType ) {
    648648                if ( widenFirst ) {
    649                         if ( dynamic_cast< BasicType* >( type2 ) || dynamic_cast< EnumInstType* >( type2 ) ) {
    650                                 if ( widenSecond || oneType->get_qualifiers() <= type2->get_qualifiers() ) {
     649                        if ( dynamic_cast< BasicType * >( type2 ) || dynamic_cast< EnumInstType * >( type2 ) ) {
     650                                if ( widenSecond || oneType->tq <= type2->tq ) {
    651651                                        result = type2->clone();
    652                                         result->get_qualifiers() |= oneType->get_qualifiers();
    653                                 }
    654                         } else if ( widenSecond && dynamic_cast< ZeroType* >( type2 ) ) {
    655                                 result = new BasicType( oneType->get_qualifiers(), BasicType::SignedInt );
    656                                 result->get_qualifiers() |= type2->get_qualifiers();
     652                                        result->tq |= oneType->tq;
     653                                }
     654                        } else if ( widenSecond && dynamic_cast< ZeroType * >( type2 ) ) {
     655                                result = new BasicType( oneType->tq, BasicType::SignedInt );
     656                                result->tq |= type2->tq;
    657657                        }
    658658                }
     
    668668                ast::ptr< ast::Type > result;
    669669
    670                 CommonType_new( 
    671                         const ast::Type * t2, WidenMode w, const ast::SymbolTable & st, 
     670                CommonType_new(
     671                        const ast::Type * t2, WidenMode w, const ast::SymbolTable & st,
    672672                        ast::TypeEnvironment & env, const ast::OpenVarSet & o )
    673673                : type2( t2 ), widen( w ), symtab( st ), tenv( env ), open( o ), result() {}
     
    681681                                #warning remove casts when `commonTypes` moved to new AST
    682682                                ast::BasicType::Kind kind = (ast::BasicType::Kind)(int)commonTypes[ (BasicType::Kind)(int)basic->kind ][ (BasicType::Kind)(int)basic2->kind ];
    683                                 if ( 
    684                                         ( ( kind == basic->kind && basic->qualifiers >= basic2->qualifiers ) 
    685                                                 || widen.first ) 
    686                                         && ( ( kind == basic2->kind && basic->qualifiers <= basic2->qualifiers ) 
    687                                                 || widen.second ) 
     683                                if (
     684                                        ( ( kind == basic->kind && basic->qualifiers >= basic2->qualifiers )
     685                                                || widen.first )
     686                                        && ( ( kind == basic2->kind && basic->qualifiers <= basic2->qualifiers )
     687                                                || widen.second )
    688688                                ) {
    689689                                        result = new ast::BasicType{ kind, basic->qualifiers | basic2->qualifiers };
    690690                                }
    691                         } else if ( 
    692                                 dynamic_cast< const ast::EnumInstType * >( type2 ) 
     691                        } else if (
     692                                dynamic_cast< const ast::EnumInstType * >( type2 )
    693693                                || dynamic_cast< const ast::ZeroType * >( type2 )
    694694                                || dynamic_cast< const ast::OneType * >( type2 )
     
    696696                                #warning remove casts when `commonTypes` moved to new AST
    697697                                ast::BasicType::Kind kind = (ast::BasicType::Kind)(int)commonTypes[ (BasicType::Kind)(int)basic->kind ][ (BasicType::Kind)(int)ast::BasicType::SignedInt ];
    698                                 if ( 
    699                                         ( ( kind == basic->kind && basic->qualifiers >= type2->qualifiers ) 
    700                                                 || widen.first ) 
    701                                         && ( ( kind != basic->kind && basic->qualifiers <= type2->qualifiers ) 
    702                                                 || widen.second ) 
     698                                if (
     699                                        ( ( kind == basic->kind && basic->qualifiers >= type2->qualifiers )
     700                                                || widen.first )
     701                                        && ( ( kind != basic->kind && basic->qualifiers <= type2->qualifiers )
     702                                                || widen.second )
    703703                                ) {
    704704                                        result = new ast::BasicType{ kind, basic->qualifiers | type2->qualifiers };
     
    715715                                if ( entry != open.end() ) {
    716716                                        ast::AssertionSet need, have;
    717                                         if ( ! tenv.bindVar( 
    718                                                 var, voidPtr->base, entry->second, need, have, open, widen, symtab ) 
     717                                        if ( ! tenv.bindVar(
     718                                                var, voidPtr->base, entry->second, need, have, open, widen, symtab )
    719719                                        ) return;
    720720                                }
     
    727727                void postvisit( const ast::PointerType * pointer ) {
    728728                        if ( auto pointer2 = dynamic_cast< const ast::PointerType * >( type2 ) ) {
    729                                 if ( 
    730                                         widen.first 
    731                                         && pointer2->base.as< ast::VoidType >() 
    732                                         && ! ast::isFtype( pointer->base ) 
     729                                if (
     730                                        widen.first
     731                                        && pointer2->base.as< ast::VoidType >()
     732                                        && ! ast::isFtype( pointer->base )
    733733                                ) {
    734734                                        getCommonWithVoidPointer( pointer2, pointer );
    735                                 } else if ( 
    736                                         widen.second 
    737                                         && pointer->base.as< ast::VoidType >() 
    738                                         && ! ast::isFtype( pointer2->base ) 
     735                                } else if (
     736                                        widen.second
     737                                        && pointer->base.as< ast::VoidType >()
     738                                        && ! ast::isFtype( pointer2->base )
    739739                                ) {
    740740                                        getCommonWithVoidPointer( pointer, pointer2 );
     
    746746                                        ast::CV::Qualifiers q2 = pointer2->base->qualifiers;
    747747
    748                                         // force t{1,2} to be cloned if their qualifiers must be stripped, so that 
     748                                        // force t{1,2} to be cloned if their qualifiers must be stripped, so that
    749749                                        // pointer{,2}->base are unchanged
    750750                                        ast::ptr< ast::Type > t1{ pointer->base }, t2{ pointer2->base };
    751751                                        reset_qualifiers( t1 );
    752752                                        reset_qualifiers( t2 );
    753                                        
     753
    754754                                        ast::AssertionSet have, need;
    755755                                        ast::OpenVarSet newOpen{ open };
     
    758758                                                if ( q1.val != q2.val ) {
    759759                                                        // reset result->base->qualifiers to be union of two base qualifiers
    760                                                         strict_dynamic_cast< ast::PointerType * >( 
    761                                                                 result.get_and_mutate() 
     760                                                        strict_dynamic_cast< ast::PointerType * >(
     761                                                                result.get_and_mutate()
    762762                                                        )->base.get_and_mutate()->qualifiers = q1 | q2;
    763763                                                }
     
    775775                        if ( auto ref2 = dynamic_cast< const ast::ReferenceType * >( type2 ) ) {
    776776                                if (
    777                                         widen.first && ref2->base.as< ast::VoidType >() && ! ast::isFtype( ref->base ) 
     777                                        widen.first && ref2->base.as< ast::VoidType >() && ! ast::isFtype( ref->base )
    778778                                ) {
    779779                                        getCommonWithVoidPointer( ref2, ref );
    780                                 } else if ( 
    781                                         widen.second && ref->base.as< ast::VoidType>() && ! ast::isFtype( ref2->base ) 
     780                                } else if (
     781                                        widen.second && ref->base.as< ast::VoidType>() && ! ast::isFtype( ref2->base )
    782782                                ) {
    783783                                        getCommonWithVoidPointer( ref, ref2 );
     
    788788                                        ast::CV::Qualifiers q1 = ref->base->qualifiers, q2 = ref2->base->qualifiers;
    789789
    790                                         // force t{1,2} to be cloned if their qualifiers must be stripped, so that 
     790                                        // force t{1,2} to be cloned if their qualifiers must be stripped, so that
    791791                                        // ref{,2}->base are unchanged
    792792                                        ast::ptr< ast::Type > t1{ ref->base }, t2{ ref2->base };
     
    800800                                                if ( q1.val != q2.val ) {
    801801                                                        // reset result->base->qualifiers to be union of two base qualifiers
    802                                                         strict_dynamic_cast< ast::ReferenceType * >( 
    803                                                                 result.get_and_mutate() 
     802                                                        strict_dynamic_cast< ast::ReferenceType * >(
     803                                                                result.get_and_mutate()
    804804                                                        )->base.get_and_mutate()->qualifiers = q1 | q2;
    805805                                                }
     
    819819
    820820                void postvisit( const ast::EnumInstType * enumInst ) {
    821                         if ( 
    822                                 dynamic_cast< const ast::BasicType * >( type2 ) 
     821                        if (
     822                                dynamic_cast< const ast::BasicType * >( type2 )
    823823                                || dynamic_cast< const ast::ZeroType * >( type2 )
    824824                                || dynamic_cast< const ast::OneType * >( type2 )
     
    834834                        if ( ! widen.first ) return;
    835835                        if ( const ast::NamedTypeDecl * nt = symtab.lookupType( inst->name ) ) {
    836                                 if ( const ast::Type * base = 
    837                                                 strict_dynamic_cast< const ast::TypeDecl * >( nt )->base 
     836                                if ( const ast::Type * base =
     837                                                strict_dynamic_cast< const ast::TypeDecl * >( nt )->base
    838838                                ) {
    839839                                        ast::CV::Qualifiers q1 = inst->qualifiers, q2 = type2->qualifiers;
     
    860860                void postvisit( const ast::ZeroType * zero ) {
    861861                        if ( ! widen.first ) return;
    862                         if ( 
     862                        if (
    863863                                dynamic_cast< const ast::BasicType * >( type2 )
    864864                                || dynamic_cast< const ast::PointerType * >( type2 )
     
    870870                                }
    871871                        } else if ( widen.second && dynamic_cast< const ast::OneType * >( type2 ) ) {
    872                                 result = new ast::BasicType{ 
     872                                result = new ast::BasicType{
    873873                                        ast::BasicType::SignedInt, zero->qualifiers | type2->qualifiers };
    874874                        }
     
    877877                void postvisit( const ast::OneType * one ) {
    878878                        if ( ! widen.first ) return;
    879                         if ( 
     879                        if (
    880880                                dynamic_cast< const ast::BasicType * >( type2 )
    881881                                || dynamic_cast< const ast::EnumInstType * >( type2 )
     
    886886                                }
    887887                        } else if ( widen.second && dynamic_cast< const ast::ZeroType * >( type2 ) ) {
    888                                 result = new ast::BasicType{ 
     888                                result = new ast::BasicType{
    889889                                        ast::BasicType::SignedInt, one->qualifiers | type2->qualifiers };
    890890                        }
     
    894894
    895895        namespace {
    896                 ast::ptr< ast::Type > handleReference( 
    897                         const ast::ptr< ast::Type > & t1, const ast::ptr< ast::Type > & t2, WidenMode widen, 
    898                         const ast::SymbolTable & symtab, ast::TypeEnvironment & env, 
    899                         const ast::OpenVarSet & open 
     896                ast::ptr< ast::Type > handleReference(
     897                        const ast::ptr< ast::Type > & t1, const ast::ptr< ast::Type > & t2, WidenMode widen,
     898                        const ast::SymbolTable & symtab, ast::TypeEnvironment & env,
     899                        const ast::OpenVarSet & open
    900900                ) {
    901901                        ast::ptr<ast::Type> common;
     
    926926
    927927        ast::ptr< ast::Type > commonType(
    928                         const ast::ptr< ast::Type > & type1, const ast::ptr< ast::Type > & type2, 
    929                         WidenMode widen, const ast::SymbolTable & symtab, ast::TypeEnvironment & env, 
    930                         const ast::OpenVarSet & open 
     928                        const ast::ptr< ast::Type > & type1, const ast::ptr< ast::Type > & type2,
     929                        WidenMode widen, const ast::SymbolTable & symtab, ast::TypeEnvironment & env,
     930                        const ast::OpenVarSet & open
    931931        ) {
    932932                unsigned depth1 = type1->referenceDepth();
     
    940940                        const ast::ReferenceType * ref1 = type1.as< ast::ReferenceType >();
    941941                        const ast::ReferenceType * ref2 = type1.as< ast::ReferenceType >();
    942                        
     942
    943943                        if ( depth1 > depth2 ) {
    944944                                assert( ref1 );
     
    978978                                                ast::OpenVarSet newOpen{ open };
    979979
    980                                                 // force t{1,2} to be cloned if its qualifiers must be stripped, so that 
    981                                                 // type1 and type->base are left unchanged; calling convention forces 
     980                                                // force t{1,2} to be cloned if its qualifiers must be stripped, so that
     981                                                // type1 and type->base are left unchanged; calling convention forces
    982982                                                // {type1,type->base}->strong_ref >= 1
    983983                                                ast::ptr<ast::Type> t1{ type1 }, t2{ type->base };
    984984                                                reset_qualifiers( t1 );
    985985                                                reset_qualifiers( t2, q1 );
    986                                                
     986
    987987                                                if ( unifyExact( t1, t2, env, have, need, newOpen, noWiden(), symtab ) ) {
    988988                                                        result = t1;
  • src/ResolvExpr/ConversionCost.cc

    r7870799 ref5b828  
    4949                if ( const TypeInstType * destAsTypeInst = dynamic_cast< const TypeInstType * >( dest ) ) {
    5050                        PRINT( std::cerr << "type inst " << destAsTypeInst->name; )
    51                         if ( const EqvClass* eqvClass = env.lookup( destAsTypeInst->name ) ) {
     51                        if ( const EqvClass * eqvClass = env.lookup( destAsTypeInst->name ) ) {
    5252                                if ( eqvClass->type ) {
    5353                                        return conversionCost( src, eqvClass->type, indexer, env );
     
    5757                        } else if ( const NamedTypeDecl * namedType = indexer.lookupType( destAsTypeInst->name ) ) {
    5858                                PRINT( std::cerr << " found" << std::endl; )
    59                                 const TypeDecl *type = dynamic_cast< const TypeDecl* >( namedType );
     59                                const TypeDecl * type = dynamic_cast< const TypeDecl * >( namedType );
    6060                                // all typedefs should be gone by this point
    6161                                assert( type );
     
    8787                        PassVisitor<ConversionCost> converter(
    8888                                dest, indexer, env,
    89                                 (Cost (*)(const Type*, const Type*, const SymTab::Indexer&, const TypeEnvironment&))
     89                                (Cost (*)(const Type *, const Type *, const SymTab::Indexer&, const TypeEnvironment&))
    9090                                        conversionCost );
    9191                        src->accept( converter );
     
    139139                                PassVisitor<ConversionCost> converter(
    140140                                        dest, indexer, env,
    141                                         (Cost (*)(const Type*, const Type*, const SymTab::Indexer&, const TypeEnvironment&))
     141                                        (Cost (*)(const Type *, const Type *, const SymTab::Indexer&, const TypeEnvironment&))
    142142                                                conversionCost );
    143143                                src->accept( converter );
     
    185185        }
    186186
    187         ConversionCost::ConversionCost( const Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc )
     187        ConversionCost::ConversionCost( const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc )
    188188                : dest( dest ), indexer( indexer ), cost( Cost::infinity ), env( env ), costFunc( costFunc ) {
    189189        }
     
    218218        static const int costMatrix[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // path length from root to node
    219219                /*             B    C   SC   UC   SI  SUI    I   UI   LI  LUI  LLI LLUI   IB  UIB  _FH  _FH   _F  _FC    F   FC  _FX _FXC   FD _FDC    D   DC F80X_FDXC  F80  _FB_FLDC   FB   LD  LDC _FBX_FLDXC */
    220                 /*     B*/ {   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  12,  13,  13,  14,  14,  15,  15,  16,  17,  16,  18,  17, },
    221                 /*     C*/ {  -1,   0,   1,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  12,  13,  13,  14,  14,  15,  16,  15,  17,  16, },
    222                 /*    SC*/ {  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  12,  13,  13,  14,  14,  15,  16,  15,  17,  16, },
    223                 /*    UC*/ {  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  12,  13,  13,  14,  14,  15,  16,  15,  17,  16, },
    224                 /*    SI*/ {  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  12,  13,  13,  14,  15,  14,  16,  15, },
    225                 /*   SUI*/ {  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  12,  13,  13,  14,  15,  14,  16,  15, },
    226                 /*     I*/ {  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  12,  13,  14,  13,  15,  14, },
    227                 /*    UI*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  12,  13,  14,  13,  15,  14, },
    228                 /*    LI*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  13,  12,  14,  13, },
    229                 /*   LUI*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  13,  12,  14,  13, },
    230                 /*   LLI*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  12,  11,  13,  12, },
    231                 /*  LLUI*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  12,  11,  13,  12, },
    232                 /*    IB*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  11,  10,  12,  11, },
    233                 /*   UIB*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  11,  10,  12,  11, },
    234                 /*   _FH*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,  10,   9,  11,  10, },
    235                 /*   _FH*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   1,  -1,   2,  -1,   3,  -1,   4,  -1,   5,  -1,   6,  -1,  -1,   7,  -1,  -1,   8,  -1,   9, },
    236                 /*    _F*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   9,   8,  10,   9, },
    237                 /*   _FC*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   1,  -1,   2,  -1,   3,  -1,   4,  -1,   5,  -1,  -1,   6,  -1,  -1,   7,  -1,   8, },
    238                 /*     F*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   8,   7,   9,   8, },
    239                 /*    FC*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   1,  -1,   2,  -1,   3,  -1,   4,  -1,  -1,   5,  -1,  -1,   6,  -1,   7, },
    240                 /*   _FX*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   7,   6,   8,   7, },
    241                 /*  _FXC*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   1,  -1,   2,  -1,   3,  -1,  -1,   4,  -1,  -1,   5,  -1,   6, },
    242                 /*    FD*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   6,   5,   7,   6, },
    243                 /*  _FDC*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   1,  -1,   2,  -1,  -1,   3,  -1,  -1,   4,  -1,   5, },
    244                 /*     D*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   5,   4,   6,   5, },
    245                 /*    DC*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   1,  -1,  -1,   2,  -1,  -1,   3,  -1,   4, },
    246                 /*  F80X*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   4,   3,   5,   4, },
    247                 /* _FDXC*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,  -1,   1,  -1,  -1,   2,  -1,   3, },
     220                /*     B */ {   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  12,  13,  13,  14,  14,  15,  15,  16,  17,  16,  18,  17, },
     221                /*     C */ {  -1,   0,   1,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  12,  13,  13,  14,  14,  15,  16,  15,  17,  16, },
     222                /*    SC */ {  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  12,  13,  13,  14,  14,  15,  16,  15,  17,  16, },
     223                /*    UC */ {  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  12,  13,  13,  14,  14,  15,  16,  15,  17,  16, },
     224                /*    SI */ {  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  12,  13,  13,  14,  15,  14,  16,  15, },
     225                /*   SUI */ {  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  12,  13,  13,  14,  15,  14,  16,  15, },
     226                /*     I */ {  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  12,  13,  14,  13,  15,  14, },
     227                /*    UI */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  12,  13,  14,  13,  15,  14, },
     228                /*    LI */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  13,  12,  14,  13, },
     229                /*   LUI */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  13,  12,  14,  13, },
     230                /*   LLI */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  12,  11,  13,  12, },
     231                /*  LLUI */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  12,  11,  13,  12, },
     232                /*    IB */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  11,  10,  12,  11, },
     233                /*   UIB */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  11,  10,  12,  11, },
     234                /*   _FH */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,  10,   9,  11,  10, },
     235                /*   _FH */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   1,  -1,   2,  -1,   3,  -1,   4,  -1,   5,  -1,   6,  -1,  -1,   7,  -1,  -1,   8,  -1,   9, },
     236                /*    _F */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   9,   8,  10,   9, },
     237                /*   _FC */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   1,  -1,   2,  -1,   3,  -1,   4,  -1,   5,  -1,  -1,   6,  -1,  -1,   7,  -1,   8, },
     238                /*     F */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   8,   7,   9,   8, },
     239                /*    FC */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   1,  -1,   2,  -1,   3,  -1,   4,  -1,  -1,   5,  -1,  -1,   6,  -1,   7, },
     240                /*   _FX */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   7,   6,   8,   7, },
     241                /*  _FXC */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   1,  -1,   2,  -1,   3,  -1,  -1,   4,  -1,  -1,   5,  -1,   6, },
     242                /*    FD */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   6,   5,   7,   6, },
     243                /*  _FDC */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   1,  -1,   2,  -1,  -1,   3,  -1,  -1,   4,  -1,   5, },
     244                /*     D */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3,   4,   5,   4,   6,   5, },
     245                /*    DC */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   1,  -1,  -1,   2,  -1,  -1,   3,  -1,   4, },
     246                /*  F80X */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   4,   3,   5,   4, },
     247                /* _FDXC */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,  -1,   1,  -1,  -1,   2,  -1,   3, },
    248248                /*   F80*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   1,   0,   1,   2,   2,   3,   3,   4,   4, },
    249                 /*   _FB*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3, },
    250                 /* _FLDC*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,  -1,   1,  -1,   2, },
    251                 /*    FB*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   1,   0,   1,   2,   2,   3, },
    252                 /*    LD*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2, },
    253                 /*   LDC*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   1, },
    254                 /*  _FBX*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1, },
    255                 /*_FLDXC*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0, },
     249                /*   _FB */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2,   2,   3,   3, },
     250                /* _FLDC */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,  -1,   1,  -1,   2, },
     251                /*    FB */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   1,   0,   1,   2,   2,   3, },
     252                /*    LD */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   2, },
     253                /*   LDC */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   1, },
     254                /*  _FBX */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1, },
     255                /* _FLDXC */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0, },
    256256        }; // costMatrix
    257257        static const int maxIntCost = 15;
    258258        // GENERATED END
    259259        static_assert(
    260                 sizeof(costMatrix)/sizeof(costMatrix[0][0]) == BasicType::NUMBER_OF_BASIC_TYPES*BasicType::NUMBER_OF_BASIC_TYPES,
     260                sizeof(costMatrix)/sizeof(costMatrix[0][0]) == BasicType::NUMBER_OF_BASIC_TYPES * BasicType::NUMBER_OF_BASIC_TYPES,
    261261                "Missing row in the cost matrix"
    262262        );
     
    266266        static const int signMatrix[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion
    267267                /*             B    C   SC   UC   SI  SUI    I   UI   LI  LUI  LLI LLUI   IB  UIB  _FH  _FH   _F  _FC    F   FC  _FX _FXC   FD _FDC    D   DC F80X_FDXC  F80  _FB_FLDC   FB   LD  LDC _FBX_FLDXC */
    268                 /*     B*/ {   0,   0,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    269                 /*     C*/ {  -1,   0,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    270                 /*    SC*/ {  -1,  -1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    271                 /*    UC*/ {  -1,  -1,  -1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    272                 /*    SI*/ {  -1,  -1,  -1,  -1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    273                 /*   SUI*/ {  -1,  -1,  -1,  -1,  -1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    274                 /*     I*/ {  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    275                 /*    UI*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    276                 /*    LI*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    277                 /*   LUI*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    278                 /*   LLI*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    279                 /*  LLUI*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    280                 /*    IB*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    281                 /*   UIB*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    282                 /*   _FH*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    283                 /*   _FH*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,  -1,   0,  -1,  -1,   0,  -1,   0, },
    284                 /*    _F*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    285                 /*   _FC*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,  -1,   0,  -1,  -1,   0,  -1,   0, },
    286                 /*     F*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    287                 /*    FC*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,  -1,   0,  -1,  -1,   0,  -1,   0, },
    288                 /*   _FX*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    289                 /*  _FXC*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,  -1,   0,  -1,  -1,   0,  -1,   0, },
    290                 /*    FD*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    291                 /*  _FDC*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   0,  -1,   0,  -1,  -1,   0,  -1,  -1,   0,  -1,   0, },
    292                 /*     D*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    293                 /*    DC*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   0,  -1,  -1,   0,  -1,  -1,   0,  -1,   0, },
    294                 /*  F80X*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    295                 /* _FDXC*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,  -1,   0,  -1,  -1,   0,  -1,   0, },
     268                /*     B */ {   0,   0,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     269                /*     C */ {  -1,   0,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     270                /*    SC */ {  -1,  -1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     271                /*    UC */ {  -1,  -1,  -1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     272                /*    SI */ {  -1,  -1,  -1,  -1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     273                /*   SUI */ {  -1,  -1,  -1,  -1,  -1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     274                /*     I */ {  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     275                /*    UI */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     276                /*    LI */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     277                /*   LUI */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     278                /*   LLI */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     279                /*  LLUI */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     280                /*    IB */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     281                /*   UIB */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     282                /*   _FH */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     283                /*   _FH */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,  -1,   0,  -1,  -1,   0,  -1,   0, },
     284                /*    _F */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     285                /*   _FC */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,  -1,   0,  -1,  -1,   0,  -1,   0, },
     286                /*     F */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     287                /*    FC */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,  -1,   0,  -1,  -1,   0,  -1,   0, },
     288                /*   _FX */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     289                /*  _FXC */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   0,  -1,   0,  -1,   0,  -1,  -1,   0,  -1,  -1,   0,  -1,   0, },
     290                /*    FD */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     291                /*  _FDC */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   0,  -1,   0,  -1,  -1,   0,  -1,  -1,   0,  -1,   0, },
     292                /*     D */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     293                /*    DC */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   0,  -1,  -1,   0,  -1,  -1,   0,  -1,   0, },
     294                /*  F80X */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     295                /* _FDXC */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,  -1,   0,  -1,  -1,   0,  -1,   0, },
    296296                /*   F80*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
    297                 /*   _FB*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0,   0, },
    298                 /* _FLDC*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,  -1,   0,  -1,   0, },
    299                 /*    FB*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0, },
    300                 /*    LD*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0, },
    301                 /*   LDC*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   0, },
    302                 /*  _FBX*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0, },
    303                 /*_FLDXC*/ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0, },
     297                /*   _FB */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0,   0, },
     298                /* _FLDC */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,  -1,   0,  -1,   0, },
     299                /*    FB */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0,   0,   0, },
     300                /*    LD */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0,   0,   0, },
     301                /*   LDC */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   0, },
     302                /*  _FBX */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   0, },
     303                /* _FLDXC */ {  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0, },
    304304        }; // signMatrix
    305305        // GENERATED END
    306306        static_assert(
    307                 sizeof(signMatrix)/sizeof(signMatrix[0][0]) == BasicType::NUMBER_OF_BASIC_TYPES*BasicType::NUMBER_OF_BASIC_TYPES,
     307                sizeof(signMatrix)/sizeof(signMatrix[0][0]) == BasicType::NUMBER_OF_BASIC_TYPES * BasicType::NUMBER_OF_BASIC_TYPES,
    308308                "Missing row in the sign matrix"
    309309        );
     
    313313        }
    314314
    315         void ConversionCost::postvisit(const BasicType *basicType) {
    316                 if ( const BasicType * destAsBasic = dynamic_cast< const BasicType* >( dest ) ) {
     315        void ConversionCost::postvisit(const BasicType * basicType) {
     316                if ( const BasicType * destAsBasic = dynamic_cast< const BasicType * >( dest ) ) {
    317317                        int tableResult = costMatrix[ basicType->kind ][ destAsBasic->kind ];
    318318                        if ( tableResult == -1 ) {
     
    331331
    332332        void ConversionCost::postvisit( const PointerType * pointerType ) {
    333                 if ( const PointerType *destAsPtr = dynamic_cast< const PointerType * >( dest ) ) {
     333                if ( const PointerType * destAsPtr = dynamic_cast< const PointerType * >( dest ) ) {
    334334                        PRINT( std::cerr << pointerType << " ===> " << destAsPtr << std::endl; )
    335335                        Type::Qualifiers tq1 = pointerType->base->tq;
     
    385385
    386386        void ConversionCost::postvisit( const StructInstType * inst ) {
    387                 if ( const StructInstType *destAsInst = dynamic_cast< const StructInstType * >( dest ) ) {
     387                if ( const StructInstType * destAsInst = dynamic_cast< const StructInstType * >( dest ) ) {
    388388                        if ( inst->name == destAsInst->name ) {
    389389                                cost = Cost::zero;
     
    393393
    394394        void ConversionCost::postvisit( const UnionInstType * inst ) {
    395                 if ( const UnionInstType *destAsInst = dynamic_cast< const UnionInstType * >( dest ) ) {
     395                if ( const UnionInstType * destAsInst = dynamic_cast< const UnionInstType * >( dest ) ) {
    396396                        if ( inst->name == destAsInst->name ) {
    397397                                cost = Cost::zero;
     
    411411        void ConversionCost::postvisit( const TraitInstType * ) {}
    412412
    413         void ConversionCost::postvisit( const TypeInstType *inst ) {
    414                 if ( const EqvClass *eqvClass = env.lookup( inst->name ) ) {
     413        void ConversionCost::postvisit( const TypeInstType * inst ) {
     414                if ( const EqvClass * eqvClass = env.lookup( inst->name ) ) {
    415415                        cost = costFunc( eqvClass->type, dest, indexer, env );
    416                 } else if ( const TypeInstType *destAsInst = dynamic_cast< const TypeInstType* >( dest ) ) {
     416                } else if ( const TypeInstType * destAsInst = dynamic_cast< const TypeInstType * >( dest ) ) {
    417417                        if ( inst->name == destAsInst->name ) {
    418418                                cost = Cost::zero;
    419419                        }
    420                 } else if ( NamedTypeDecl *namedType = indexer.lookupType( inst->name ) ) {
    421                         const TypeDecl *type = dynamic_cast< const TypeDecl* >( namedType );
     420                } else if ( const NamedTypeDecl * namedType = indexer.lookupType( inst->name ) ) {
     421                        const TypeDecl * type = dynamic_cast< const TypeDecl * >( namedType );
    422422                        // all typedefs should be gone by this point
    423423                        assert( type );
     
    434434                        std::list< Type * >::const_iterator destIt = destAsTuple->types.begin();
    435435                        while ( srcIt != tupleType->types.end() && destIt != destAsTuple->types.end() ) {
    436                                 Cost newCost = costFunc( *srcIt++, *destIt++, indexer, env );
     436                                Cost newCost = costFunc( * srcIt++, * destIt++, indexer, env );
    437437                                if ( newCost == Cost::infinity ) {
    438438                                        return;
     
    449449
    450450        void ConversionCost::postvisit( const VarArgsType * ) {
    451                 if ( dynamic_cast< const VarArgsType* >( dest ) ) {
     451                if ( dynamic_cast< const VarArgsType * >( dest ) ) {
    452452                        cost = Cost::zero;
    453453                }
     
    457457                if ( dynamic_cast< const ZeroType * >( dest ) ) {
    458458                        cost = Cost::zero;
    459                 } else if ( const BasicType *destAsBasic = dynamic_cast< const BasicType* >( dest ) ) {
    460                         // copied from visit(BasicType*) for signed int, but +1 for safe conversions
     459                } else if ( const BasicType * destAsBasic = dynamic_cast< const BasicType * >( dest ) ) {
     460                        // copied from visit(BasicType *) for signed int, but +1 for safe conversions
    461461                        int tableResult = costMatrix[ BasicType::SignedInt ][ destAsBasic->kind ];
    462462                        if ( tableResult == -1 ) {
     
    467467                                cost.incSign( signMatrix[ BasicType::SignedInt ][ destAsBasic->kind ] );
    468468                        } // if
    469                 } else if ( dynamic_cast< const PointerType* >( dest ) ) {
     469                } else if ( dynamic_cast< const PointerType * >( dest ) ) {
    470470                        cost = Cost::zero;
    471471                        cost.incSafe( maxIntCost + 2 ); // +1 for zero_t -> int, +1 for disambiguation
     
    477477                        cost = Cost::zero;
    478478                } else if ( const BasicType * destAsBasic = dynamic_cast< const BasicType * >( dest ) ) {
    479                         // copied from visit(BasicType*) for signed int, but +1 for safe conversions
     479                        // copied from visit(BasicType *) for signed int, but +1 for safe conversions
    480480                        int tableResult = costMatrix[ BasicType::SignedInt ][ destAsBasic->kind ];
    481481                        if ( tableResult == -1 ) {
     
    729729                auto dstEnd = dstAsTuple->types.end();
    730730                while ( srcIt != srcEnd && dstIt != dstEnd ) {
    731                         Cost newCost = costCalc( *srcIt++, *dstIt++, symtab, env );
     731                        Cost newCost = costCalc( * srcIt++, * dstIt++, symtab, env );
    732732                        if ( newCost == Cost::infinity ) {
    733733                                return;
  • src/ResolvExpr/Resolver.cc

    r7870799 ref5b828  
    562562                // TODO: Replace *exception type with &exception type.
    563563                if ( throwStmt->get_expr() ) {
    564                         StructDecl * exception_decl =
    565                                 indexer.lookupStruct( "__cfaabi_ehm__base_exception_t" );
     564                        StructDecl * exception_decl = indexer.lookupMutableStruct( "__cfaabi_ehm__base_exception_t" );
    566565                        assert( exception_decl );
    567566                        Type * exceptType = new PointerType( noQualifiers, new StructInstType( noQualifiers, exception_decl ) );
     
    972971                /// Calls the CandidateFinder and finds the single best candidate
    973972                CandidateRef findUnfinishedKindExpression(
    974                         const ast::Expr * untyped, const ast::SymbolTable & symtab, const std::string & kind, 
     973                        const ast::Expr * untyped, const ast::SymbolTable & symtab, const std::string & kind,
    975974                        std::function<bool(const Candidate &)> pred = anyCandidate, ResolvMode mode = {}
    976975                ) {
     
    994993                        // produce invalid error if no candidates
    995994                        if ( candidates.empty() ) {
    996                                 SemanticError( untyped, 
    997                                         toString( "No reasonable alternatives for ", kind, (kind != "" ? " " : ""), 
     995                                SemanticError( untyped,
     996                                        toString( "No reasonable alternatives for ", kind, (kind != "" ? " " : ""),
    998997                                        "expression: ") );
    999998                        }
     
    10311030                        if ( winners.size() != 1 ) {
    10321031                                std::ostringstream stream;
    1033                                 stream << "Cannot choose between " << winners.size() << " alternatives for " 
     1032                                stream << "Cannot choose between " << winners.size() << " alternatives for "
    10341033                                        << kind << (kind != "" ? " " : "") << "expression\n";
    10351034                                ast::print( stream, untyped );
     
    10541053                struct StripCasts_new final {
    10551054                        const ast::Expr * postmutate( const ast::CastExpr * castExpr ) {
    1056                                 if ( 
    1057                                         castExpr->isGenerated 
    1058                                         && typesCompatible( castExpr->arg->result, castExpr->result ) 
     1055                                if (
     1056                                        castExpr->isGenerated
     1057                                        && typesCompatible( castExpr->arg->result, castExpr->result )
    10591058                                ) {
    10601059                                        // generated cast is the same type as its argument, remove it after keeping env
    1061                                         return ast::mutate_field( 
     1060                                        return ast::mutate_field(
    10621061                                                castExpr->arg.get(), &ast::Expr::env, castExpr->env );
    10631062                                }
     
    10881087
    10891088                /// Establish post-resolver invariants for expressions
    1090                 void finishExpr( 
    1091                         ast::ptr< ast::Expr > & expr, const ast::TypeEnvironment & env, 
     1089                void finishExpr(
     1090                        ast::ptr< ast::Expr > & expr, const ast::TypeEnvironment & env,
    10921091                        const ast::TypeSubstitution * oldenv = nullptr
    10931092                ) {
    10941093                        // set up new type substitution for expression
    1095                         ast::ptr< ast::TypeSubstitution > newenv = 
     1094                        ast::ptr< ast::TypeSubstitution > newenv =
    10961095                                 oldenv ? oldenv : new ast::TypeSubstitution{};
    10971096                        env.writeToSubstitution( *newenv.get_and_mutate() );
     
    11021101        } // anonymous namespace
    11031102
    1104                
     1103
    11051104        ast::ptr< ast::Expr > resolveInVoidContext(
    11061105                const ast::Expr * expr, const ast::SymbolTable & symtab, ast::TypeEnvironment & env
    11071106        ) {
    11081107                assertf( expr, "expected a non-null expression" );
    1109                
     1108
    11101109                // set up and resolve expression cast to void
    11111110                ast::CastExpr * untyped = new ast::CastExpr{ expr };
    1112                 CandidateRef choice = findUnfinishedKindExpression( 
     1111                CandidateRef choice = findUnfinishedKindExpression(
    11131112                        untyped, symtab, "", anyCandidate, ResolvMode::withAdjustment() );
    1114                
     1113
    11151114                // a cast expression has either 0 or 1 interpretations (by language rules);
    11161115                // if 0, an exception has already been thrown, and this code will not run
     
    11221121
    11231122        namespace {
    1124                 /// Resolve `untyped` to the expression whose candidate is the best match for a `void` 
     1123                /// Resolve `untyped` to the expression whose candidate is the best match for a `void`
    11251124                /// context.
    1126                 ast::ptr< ast::Expr > findVoidExpression( 
     1125                ast::ptr< ast::Expr > findVoidExpression(
    11271126                        const ast::Expr * untyped, const ast::SymbolTable & symtab
    11281127                ) {
     
    11341133                }
    11351134
    1136                 /// resolve `untyped` to the expression whose candidate satisfies `pred` with the 
     1135                /// resolve `untyped` to the expression whose candidate satisfies `pred` with the
    11371136                /// lowest cost, returning the resolved version
    11381137                ast::ptr< ast::Expr > findKindExpression(
    1139                         const ast::Expr * untyped, const ast::SymbolTable & symtab, 
    1140                         std::function<bool(const Candidate &)> pred = anyCandidate, 
     1138                        const ast::Expr * untyped, const ast::SymbolTable & symtab,
     1139                        std::function<bool(const Candidate &)> pred = anyCandidate,
    11411140                        const std::string & kind = "", ResolvMode mode = {}
    11421141                ) {
    11431142                        if ( ! untyped ) return {};
    1144                         CandidateRef choice = 
     1143                        CandidateRef choice =
    11451144                                findUnfinishedKindExpression( untyped, symtab, kind, pred, mode );
    11461145                        finishExpr( choice->expr, choice->env, untyped->env );
     
    11491148
    11501149                /// Resolve `untyped` to the single expression whose candidate is the best match
    1151                 ast::ptr< ast::Expr > findSingleExpression( 
    1152                         const ast::Expr * untyped, const ast::SymbolTable & symtab 
     1150                ast::ptr< ast::Expr > findSingleExpression(
     1151                        const ast::Expr * untyped, const ast::SymbolTable & symtab
    11531152                ) {
    11541153                        return findKindExpression( untyped, symtab );
     
    11701169                bool hasIntegralType( const Candidate & i ) {
    11711170                        const ast::Type * type = i.expr->result;
    1172                        
     1171
    11731172                        if ( auto bt = dynamic_cast< const ast::BasicType * >( type ) ) {
    11741173                                return bt->isInteger();
    1175                         } else if ( 
    1176                                 dynamic_cast< const ast::EnumInstType * >( type ) 
     1174                        } else if (
     1175                                dynamic_cast< const ast::EnumInstType * >( type )
    11771176                                || dynamic_cast< const ast::ZeroType * >( type )
    11781177                                || dynamic_cast< const ast::OneType * >( type )
     
    11831182
    11841183                /// Resolve `untyped` as an integral expression, returning the resolved version
    1185                 ast::ptr< ast::Expr > findIntegralExpression( 
    1186                         const ast::Expr * untyped, const ast::SymbolTable & symtab 
     1184                ast::ptr< ast::Expr > findIntegralExpression(
     1185                        const ast::Expr * untyped, const ast::SymbolTable & symtab
    11871186                ) {
    11881187                        return findKindExpression( untyped, symtab, hasIntegralType, "condition" );
     
    11921191                bool isCharType( const ast::Type * t ) {
    11931192                        if ( auto bt = dynamic_cast< const ast::BasicType * >( t ) ) {
    1194                                 return bt->kind == ast::BasicType::Char 
    1195                                         || bt->kind == ast::BasicType::SignedChar 
     1193                                return bt->kind == ast::BasicType::Char
     1194                                        || bt->kind == ast::BasicType::SignedChar
    11961195                                        || bt->kind == ast::BasicType::UnsignedChar;
    11971196                        }
     
    12531252        }
    12541253
    1255         ast::ptr< ast::Init > resolveCtorInit( 
    1256                 const ast::ConstructorInit * ctorInit, const ast::SymbolTable & symtab 
     1254        ast::ptr< ast::Init > resolveCtorInit(
     1255                const ast::ConstructorInit * ctorInit, const ast::SymbolTable & symtab
    12571256        ) {
    12581257                assert( ctorInit );
     
    12611260        }
    12621261
    1263         ast::ptr< ast::Expr > resolveStmtExpr( 
    1264                 const ast::StmtExpr * stmtExpr, const ast::SymbolTable & symtab 
     1262        ast::ptr< ast::Expr > resolveStmtExpr(
     1263                const ast::StmtExpr * stmtExpr, const ast::SymbolTable & symtab
    12651264        ) {
    12661265                assert( stmtExpr );
     
    13031302
    13041303        void Resolver_new::previsit( const ast::ObjectDecl * objectDecl ) {
    1305                 // To handle initialization of routine pointers [e.g. int (*fp)(int) = foo()], 
    1306                 // class-variable `initContext` is changed multiple times because the LHS is analyzed 
    1307                 // twice. The second analysis changes `initContext` because a function type can contain 
    1308                 // object declarations in the return and parameter types. Therefore each value of 
    1309                 // `initContext` is retained so the type on the first analysis is preserved and used for 
     1304                // To handle initialization of routine pointers [e.g. int (*fp)(int) = foo()],
     1305                // class-variable `initContext` is changed multiple times because the LHS is analyzed
     1306                // twice. The second analysis changes `initContext` because a function type can contain
     1307                // object declarations in the return and parameter types. Therefore each value of
     1308                // `initContext` is retained so the type on the first analysis is preserved and used for
    13101309                // selecting the RHS.
    13111310                GuardValue( currentObject );
    13121311                currentObject = ast::CurrentObject{ objectDecl->location, objectDecl->get_type() };
    13131312                if ( inEnumDecl && dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() ) ) {
    1314                         // enumerator initializers should not use the enum type to initialize, since the 
     1313                        // enumerator initializers should not use the enum type to initialize, since the
    13151314                        // enum type is still incomplete at this point. Use `int` instead.
    1316                         currentObject = ast::CurrentObject{ 
     1315                        currentObject = ast::CurrentObject{
    13171316                                objectDecl->location, new ast::BasicType{ ast::BasicType::SignedInt } };
    13181317                }
     
    13251324        }
    13261325
    1327         const ast::StaticAssertDecl * Resolver_new::previsit( 
    1328                 const ast::StaticAssertDecl * assertDecl 
     1326        const ast::StaticAssertDecl * Resolver_new::previsit(
     1327                const ast::StaticAssertDecl * assertDecl
    13291328        ) {
    1330                 return ast::mutate_field( 
    1331                         assertDecl, &ast::StaticAssertDecl::cond, 
     1329                return ast::mutate_field(
     1330                        assertDecl, &ast::StaticAssertDecl::cond,
    13321331                        findIntegralExpression( assertDecl->cond, symtab ) );
    13331332        }
     
    13381337                        #warning should use new equivalent to Validate::SizeType rather than sizeType here
    13391338                        ast::ptr< ast::Type > sizeType = new ast::BasicType{ ast::BasicType::LongUnsignedInt };
    1340                         ast::mutate_field( 
    1341                                 type, &PtrType::dimension, 
     1339                        ast::mutate_field(
     1340                                type, &PtrType::dimension,
    13421341                                findSingleExpression( type->dimension, sizeType, symtab ) );
    13431342                }
     
    13561355                visit_children = false;
    13571356                assertf( exprStmt->expr, "ExprStmt has null expression in resolver" );
    1358                
    1359                 return ast::mutate_field( 
     1357
     1358                return ast::mutate_field(
    13601359                        exprStmt, &ast::ExprStmt::expr, findVoidExpression( exprStmt->expr, symtab ) );
    13611360        }
     
    13641363                visit_children = false;
    13651364
    1366                 asmExpr = ast::mutate_field( 
     1365                asmExpr = ast::mutate_field(
    13671366                        asmExpr, &ast::AsmExpr::operand, findVoidExpression( asmExpr->operand, symtab ) );
    1368                
     1367
    13691368                if ( asmExpr->inout ) {
    13701369                        asmExpr = ast::mutate_field(
    13711370                                asmExpr, &ast::AsmExpr::inout, findVoidExpression( asmExpr->inout, symtab ) );
    13721371                }
    1373                
     1372
    13741373                return asmExpr;
    13751374        }
     
    13881387
    13891388        const ast::WhileStmt * Resolver_new::previsit( const ast::WhileStmt * whileStmt ) {
    1390                 return ast::mutate_field( 
     1389                return ast::mutate_field(
    13911390                        whileStmt, &ast::WhileStmt::cond, findIntegralExpression( whileStmt->cond, symtab ) );
    13921391        }
     
    14091408                GuardValue( currentObject );
    14101409                switchStmt = ast::mutate_field(
    1411                         switchStmt, &ast::SwitchStmt::cond, 
     1410                        switchStmt, &ast::SwitchStmt::cond,
    14121411                        findIntegralExpression( switchStmt->cond, symtab ) );
    14131412                currentObject = ast::CurrentObject{ switchStmt->location, switchStmt->cond->result };
     
    14201419                        assertf( initAlts.size() == 1, "SwitchStmt did not correctly resolve an integral "
    14211420                                "expression." );
    1422                        
    1423                         ast::ptr< ast::Expr > untyped = 
     1421
     1422                        ast::ptr< ast::Expr > untyped =
    14241423                                new ast::CastExpr{ caseStmt->location, caseStmt->cond, initAlts.front().type };
    14251424                        ast::ptr< ast::Expr > newExpr = findSingleExpression( untyped, symtab );
    1426                        
    1427                         // case condition cannot have a cast in C, so it must be removed here, regardless of 
     1425
     1426                        // case condition cannot have a cast in C, so it must be removed here, regardless of
    14281427                        // whether it would perform a conversion.
    14291428                        if ( const ast::CastExpr * castExpr = newExpr.as< ast::CastExpr >() ) {
    14301429                                swap_and_save_env( newExpr, castExpr->arg );
    14311430                        }
    1432                        
     1431
    14331432                        caseStmt = ast::mutate_field( caseStmt, &ast::CaseStmt::cond, newExpr );
    14341433                }
     
    14431442                        ast::ptr< ast::Type > target = new ast::PointerType{ new ast::VoidType{} };
    14441443                        branchStmt = ast::mutate_field(
    1445                                 branchStmt, &ast::BranchStmt::computedTarget, 
     1444                                branchStmt, &ast::BranchStmt::computedTarget,
    14461445                                findSingleExpression( branchStmt->computedTarget, target, symtab ) );
    14471446                }
     
    14531452                if ( returnStmt->expr ) {
    14541453                        returnStmt = ast::mutate_field(
    1455                                 returnStmt, &ast::ReturnStmt::expr, 
     1454                                returnStmt, &ast::ReturnStmt::expr,
    14561455                                findSingleExpression( returnStmt->expr, functionReturn, symtab ) );
    14571456                }
     
    14621461                visit_children = false;
    14631462                if ( throwStmt->expr ) {
    1464                         const ast::StructDecl * exceptionDecl = 
     1463                        const ast::StructDecl * exceptionDecl =
    14651464                                symtab.lookupStruct( "__cfaabi_ehm__base_exception_t" );
    14661465                        assert( exceptionDecl );
    1467                         ast::ptr< ast::Type > exceptType = 
     1466                        ast::ptr< ast::Type > exceptType =
    14681467                                new ast::PointerType{ new ast::StructInstType{ exceptionDecl } };
    14691468                        throwStmt = ast::mutate_field(
    1470                                 throwStmt, &ast::ThrowStmt::expr, 
     1469                                throwStmt, &ast::ThrowStmt::expr,
    14711470                                findSingleExpression( throwStmt->expr, exceptType, symtab ) );
    14721471                }
     
    14771476                if ( catchStmt->cond ) {
    14781477                        ast::ptr< ast::Type > boolType = new ast::BasicType{ ast::BasicType::Bool };
    1479                         catchStmt = ast::mutate_field( 
    1480                                 catchStmt, &ast::CatchStmt::cond, 
     1478                        catchStmt = ast::mutate_field(
     1479                                catchStmt, &ast::CatchStmt::cond,
    14811480                                findSingleExpression( catchStmt->cond, boolType, symtab ) );
    14821481                }
     
    15061505
    15071506                        if ( clause.target.args.empty() ) {
    1508                                 SemanticError( stmt->location, 
     1507                                SemanticError( stmt->location,
    15091508                                        "Waitfor clause must have at least one mutex parameter");
    15101509                        }
    15111510
    15121511                        // Find all alternatives for all arguments in canonical form
    1513                         std::vector< CandidateFinder > argFinders = 
     1512                        std::vector< CandidateFinder > argFinders =
    15141513                                funcFinder.findSubExprs( clause.target.args );
    1515                        
     1514
    15161515                        // List all combinations of arguments
    15171516                        std::vector< CandidateList > possibilities;
     
    15191518
    15201519                        // For every possible function:
    1521                         // * try matching the arguments to the parameters, not the other way around because 
     1520                        // * try matching the arguments to the parameters, not the other way around because
    15221521                        //   more arguments than parameters
    15231522                        CandidateList funcCandidates;
     
    15261525                        for ( CandidateRef & func : funcFinder.candidates ) {
    15271526                                try {
    1528                                         auto pointerType = dynamic_cast< const ast::PointerType * >( 
     1527                                        auto pointerType = dynamic_cast< const ast::PointerType * >(
    15291528                                                func->expr->result->stripReferences() );
    15301529                                        if ( ! pointerType ) {
    1531                                                 SemanticError( stmt->location, func->expr->result.get(), 
     1530                                                SemanticError( stmt->location, func->expr->result.get(),
    15321531                                                        "candidate not viable: not a pointer type\n" );
    15331532                                        }
     
    15351534                                        auto funcType = pointerType->base.as< ast::FunctionType >();
    15361535                                        if ( ! funcType ) {
    1537                                                 SemanticError( stmt->location, func->expr->result.get(), 
     1536                                                SemanticError( stmt->location, func->expr->result.get(),
    15381537                                                        "candidate not viable: not a function type\n" );
    15391538                                        }
     
    15441543
    15451544                                                if( ! nextMutex( param, paramEnd ) ) {
    1546                                                         SemanticError( stmt->location, funcType, 
     1545                                                        SemanticError( stmt->location, funcType,
    15471546                                                                "candidate function not viable: no mutex parameters\n");
    15481547                                                }
     
    15601559                                                        ast::AssertionSet need, have;
    15611560                                                        ast::TypeEnvironment resultEnv{ func->env };
    1562                                                         // Add all type variables as open so that those not used in the 
     1561                                                        // Add all type variables as open so that those not used in the
    15631562                                                        // parameter list are still considered open
    15641563                                                        resultEnv.add( funcType->forall );
     
    15801579                                                        unsigned n_mutex_param = 0;
    15811580
    1582                                                         // For every argument of its set, check if it matches one of the 
     1581                                                        // For every argument of its set, check if it matches one of the
    15831582                                                        // parameters. The order is important
    15841583                                                        for ( auto & arg : argsList ) {
     
    15871586                                                                        // We ran out of parameters but still have arguments.
    15881587                                                                        // This function doesn't match
    1589                                                                         SemanticError( stmt->location, funcType, 
     1588                                                                        SemanticError( stmt->location, funcType,
    15901589                                                                                toString("candidate function not viable: too many mutex "
    15911590                                                                                "arguments, expected ", n_mutex_param, "\n" ) );
     
    15941593                                                                ++n_mutex_param;
    15951594
    1596                                                                 // Check if the argument matches the parameter type in the current 
     1595                                                                // Check if the argument matches the parameter type in the current
    15971596                                                                // scope
    15981597                                                                ast::ptr< ast::Type > paramType = (*param)->get_type();
    1599                                                                 if ( 
    1600                                                                         ! unify( 
    1601                                                                                 arg->expr->result, paramType, resultEnv, need, have, open, 
    1602                                                                                 symtab ) 
     1598                                                                if (
     1599                                                                        ! unify(
     1600                                                                                arg->expr->result, paramType, resultEnv, need, have, open,
     1601                                                                                symtab )
    16031602                                                                ) {
    16041603                                                                        // Type doesn't match
     
    16271626                                                                } while ( nextMutex( param, paramEnd ) );
    16281627
    1629                                                                 // We ran out of arguments but still have parameters left; this 
     1628                                                                // We ran out of arguments but still have parameters left; this
    16301629                                                                // function doesn't match
    1631                                                                 SemanticError( stmt->location, funcType, 
     1630                                                                SemanticError( stmt->location, funcType,
    16321631                                                                        toString( "candidate function not viable: too few mutex "
    16331632                                                                        "arguments, expected ", n_mutex_param, "\n" ) );
     
    16571656                        // Make sure correct number of arguments
    16581657                        if( funcCandidates.empty() ) {
    1659                                 SemanticErrorException top( stmt->location, 
     1658                                SemanticErrorException top( stmt->location,
    16601659                                        "No alternatives for function in call to waitfor" );
    16611660                                top.append( errors );
     
    16641663
    16651664                        if( argsCandidates.empty() ) {
    1666                                 SemanticErrorException top( stmt->location, 
    1667                                         "No alternatives for arguments in call to waitfor" ); 
     1665                                SemanticErrorException top( stmt->location,
     1666                                        "No alternatives for arguments in call to waitfor" );
    16681667                                top.append( errors );
    16691668                                throw top;
     
    16711670
    16721671                        if( funcCandidates.size() > 1 ) {
    1673                                 SemanticErrorException top( stmt->location, 
     1672                                SemanticErrorException top( stmt->location,
    16741673                                        "Ambiguous function in call to waitfor" );
    16751674                                top.append( errors );
     
    16861685                        // build new clause
    16871686                        ast::WaitForStmt::Clause clause2;
    1688                        
     1687
    16891688                        clause2.target.func = funcCandidates.front()->expr;
    1690                        
     1689
    16911690                        clause2.target.args.reserve( clause.target.args.size() );
    16921691                        for ( auto arg : argsCandidates.front() ) {
     
    17081707                        ast::WaitForStmt::Timeout timeout2;
    17091708
    1710                         ast::ptr< ast::Type > target = 
     1709                        ast::ptr< ast::Type > target =
    17111710                                new ast::BasicType{ ast::BasicType::LongLongUnsignedInt };
    17121711                        timeout2.time = findSingleExpression( stmt->timeout.time, target, symtab );
     
    17401739        const ast::SingleInit * Resolver_new::previsit( const ast::SingleInit * singleInit ) {
    17411740                visit_children = false;
    1742                 // resolve initialization using the possibilities as determined by the `currentObject` 
     1741                // resolve initialization using the possibilities as determined by the `currentObject`
    17431742                // cursor.
    1744                 ast::ptr< ast::Expr > untyped = new ast::UntypedInitExpr{ 
     1743                ast::ptr< ast::Expr > untyped = new ast::UntypedInitExpr{
    17451744                        singleInit->location, singleInit->value, currentObject.getOptions() };
    17461745                ast::ptr<ast::Expr> newExpr = findSingleExpression( untyped, symtab );
     
    17511750
    17521751                // discard InitExpr wrapper and retain relevant pieces.
    1753                 // `initExpr` may have inferred params in the case where the expression specialized a 
    1754                 // function pointer, and newExpr may already have inferParams of its own, so a simple 
     1752                // `initExpr` may have inferred params in the case where the expression specialized a
     1753                // function pointer, and newExpr may already have inferParams of its own, so a simple
    17551754                // swap is not sufficient
    17561755                ast::Expr::InferUnion inferred = initExpr->inferred;
     
    17581757                newExpr.get_and_mutate()->inferred.splice( std::move(inferred) );
    17591758
    1760                 // get the actual object's type (may not exactly match what comes back from the resolver 
     1759                // get the actual object's type (may not exactly match what comes back from the resolver
    17611760                // due to conversions)
    17621761                const ast::Type * initContext = currentObject.getCurrentType();
     
    17701769                                if ( auto pt = newExpr->result.as< ast::PointerType >() ) {
    17711770                                        if ( isCharType( pt->base ) ) {
    1772                                                 // strip cast if we're initializing a char[] with a char* 
     1771                                                // strip cast if we're initializing a char[] with a char*
    17731772                                                // e.g. char x[] = "hello"
    17741773                                                if ( auto ce = newExpr.as< ast::CastExpr >() ) {
     
    17931792                assert( listInit->designations.size() == listInit->initializers.size() );
    17941793                for ( unsigned i = 0; i < listInit->designations.size(); ++i ) {
    1795                         // iterate designations and initializers in pairs, moving the cursor to the current 
     1794                        // iterate designations and initializers in pairs, moving the cursor to the current
    17961795                        // designated object and resolving the initializer against that object
    17971796                        listInit = ast::mutate_field_index(
    1798                                 listInit, &ast::ListInit::designations, i, 
     1797                                listInit, &ast::ListInit::designations, i,
    17991798                                currentObject.findNext( listInit->designations[i] ) );
    18001799                        listInit = ast::mutate_field_index(
     
    18181817                ctorInit = ast::mutate_field( ctorInit, &ast::ConstructorInit::init, nullptr );
    18191818
    1820                 // intrinsic single-parameter constructors and destructors do nothing. Since this was 
    1821                 // implicitly generated, there's no way for it to have side effects, so get rid of it to 
     1819                // intrinsic single-parameter constructors and destructors do nothing. Since this was
     1820                // implicitly generated, there's no way for it to have side effects, so get rid of it to
    18221821                // clean up generated code
    18231822                if ( InitTweak::isIntrinsicSingleArgCallStmt( ctorInit->ctor ) ) {
Note: See TracChangeset for help on using the changeset viewer.