Changeset 115ac1ce for src/ResolvExpr


Ignore:
Timestamp:
Jun 29, 2024, 5:29:40 AM (3 weeks ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
73d0e3f4, bc07190
Parents:
4117761
Message:

Allow explict conversion from cfa enum to int (while disallow implicit)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CastCost.cpp

    r4117761 r115ac1ce  
    5353                void postvisit( const ast::EnumInstType * enumInst ) {
    5454                        cost = conversionCost( enumInst, dst, srcIsLvalue, symtab, env );
    55 
    56                         if ( !enumInst->base->isCfa ) {
    57                                 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) };
    58                                 Cost intCost = costCalc( integer, dst, srcIsLvalue, symtab, env );
    59                                 cost = intCost < cost? intCost: cost;
    60                         } else if ( enumInst->base->isTyped() ) {
     55                        if ( enumInst->base->isTyped() ) {
    6156                                auto baseConversionCost =
    6257                                        castCost( enumInst->base->base, dst, srcIsLvalue, symtab, env );
    6358                                cost = baseConversionCost < cost? baseConversionCost: cost;
    6459                        }
     60                        static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) };
     61                        Cost intCost = costCalc( integer, dst, srcIsLvalue, symtab, env );
     62                        intCost.incSafe();
     63                        cost = intCost < cost? intCost: cost;
    6564                }
    6665
Note: See TracChangeset for help on using the changeset viewer.