Changeset 7f6a7c9 for src/ResolvExpr/ConversionCost.cc
- Timestamp:
- Sep 21, 2022, 11:02:15 AM (3 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/ConversionCost.cc
r428adbc r7f6a7c9 22 22 #include "ResolvExpr/Cost.h" // for Cost 23 23 #include "ResolvExpr/TypeEnvironment.h" // for EqvClass, TypeEnvironment 24 #include "ResolvExpr/Unify.h" 24 25 #include "SymTab/Indexer.h" // for Indexer 25 26 #include "SynTree/Declaration.h" // for TypeDecl, NamedTypeDecl 26 27 #include "SynTree/Type.h" // for Type, BasicType, TypeInstType 27 28 #include "typeops.h" // for typesCompatibleIgnoreQualifiers 29 28 30 29 31 namespace ResolvExpr { … … 338 340 } else if ( const EnumInstType * enumInst = dynamic_cast< const EnumInstType * >( dest ) ) { 339 341 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 ) { 341 343 if ( const BasicType * enumBaseAstBasic = dynamic_cast< const BasicType *> (base) ) { 342 344 conversionCostFromBasicToBasic(basicType, enumBaseAstBasic); … … 632 634 } else if ( const ast::EnumInstType * enumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) { 633 635 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() ) { 635 639 if ( const ast::BasicType * enumTypeAsBasic = dynamic_cast<const ast::BasicType *>(enumType) ) { 636 640 conversionCostFromBasicToBasic( basicType, enumTypeAsBasic ); … … 655 659 cost = Cost::safe; 656 660 } 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 { 658 682 int assignResult = ptrsAssignable( pointerType->base, dstAsPtr->base, env ); 659 683 if ( 0 < assignResult && tq1 <= tq2 ) { … … 694 718 const ast::EnumDecl * baseEnum = enumInstType->base; 695 719 if ( const ast::Type * baseType = baseEnum->base ) { 696 cost = costCalc( baseType, dst, srcIsLvalue, symtab, env );720 costCalc( baseType, dst, srcIsLvalue, symtab, env ); 697 721 } else { 698 722 (void)enumInstType;
Note:
See TracChangeset
for help on using the changeset viewer.