Ignore:
Timestamp:
Sep 21, 2022, 11:02:15 AM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master, pthread-emulation
Children:
95dab9e
Parents:
428adbc (diff), 0bd46fd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into pthread-emulation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/ConversionCost.cc

    r428adbc r7f6a7c9  
    2222#include "ResolvExpr/Cost.h"             // for Cost
    2323#include "ResolvExpr/TypeEnvironment.h"  // for EqvClass, TypeEnvironment
     24#include "ResolvExpr/Unify.h"
    2425#include "SymTab/Indexer.h"              // for Indexer
    2526#include "SynTree/Declaration.h"         // for TypeDecl, NamedTypeDecl
    2627#include "SynTree/Type.h"                // for Type, BasicType, TypeInstType
    2728#include "typeops.h"                     // for typesCompatibleIgnoreQualifiers
     29
    2830
    2931namespace ResolvExpr {
     
    338340                } else if ( const EnumInstType * enumInst = dynamic_cast< const EnumInstType * >( dest ) ) {
    339341                        const EnumDecl * base_enum = enumInst->baseEnum;
    340                         if ( const Type * base = base_enum->base ) { // if the base enum has a base (if it is typed)
     342                        if ( const Type * base = base_enum->base ) {
    341343                                if ( const BasicType * enumBaseAstBasic = dynamic_cast< const BasicType *> (base) ) {
    342344                                        conversionCostFromBasicToBasic(basicType, enumBaseAstBasic);
     
    632634        } else if ( const ast::EnumInstType * enumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) {
    633635                const ast::EnumDecl * enumDecl = enumInst->base.get();
    634                 if ( const ast::Type * enumType = enumDecl->base.get() ) {
     636                if ( enumDecl->isTyped && !enumDecl->base.get() ) {
     637                        cost = Cost::infinity;
     638                } else if ( const ast::Type * enumType = enumDecl->base.get() ) {
    635639                        if ( const ast::BasicType * enumTypeAsBasic = dynamic_cast<const ast::BasicType *>(enumType) ) {
    636640                                conversionCostFromBasicToBasic( basicType, enumTypeAsBasic );
     
    655659                                cost = Cost::safe;
    656660                        }
    657                 } else {
     661                }
     662                /*
     663                else if ( const ast::FunctionType * dstFunc = dstAsPtr->base.as<ast::FunctionType>()) {
     664                        if (const ast::FunctionType * srcFunc = pointerType->base.as<ast::FunctionType>()) {
     665                                if (dstFunc->params.empty() && dstFunc->isVarArgs ) {
     666                                        cost = Cost::unsafe; // assign any function to variadic fptr
     667                                }
     668                        }
     669                        else {
     670                                ast::AssertionSet need, have; // unused
     671                                ast::OpenVarSet open;
     672                                env.extractOpenVars(open);
     673                                ast::TypeEnvironment tenv = env;
     674                                if ( unify(dstAsPtr->base, pointerType->base, tenv, need, have, open, symtab) ) {
     675                                        cost = Cost::safe;
     676                                }
     677                        }
     678                        // else infinity
     679                }
     680                */
     681                else {
    658682                        int assignResult = ptrsAssignable( pointerType->base, dstAsPtr->base, env );
    659683                        if ( 0 < assignResult && tq1 <= tq2 ) {
     
    694718        const ast::EnumDecl * baseEnum = enumInstType->base;
    695719        if ( const ast::Type * baseType = baseEnum->base ) {
    696                 cost = costCalc( baseType, dst, srcIsLvalue, symtab, env );
     720                costCalc( baseType, dst, srcIsLvalue, symtab, env );
    697721        } else {
    698722                (void)enumInstType;
Note: See TracChangeset for help on using the changeset viewer.