Ignore:
Timestamp:
Jun 29, 2024, 7:33:28 AM (19 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
011c29e
Parents:
62a38e7 (diff), 115ac1ce (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CastCost.cpp

    r62a38e7 rbc07190  
    5353                void postvisit( const ast::EnumInstType * enumInst ) {
    5454                        cost = conversionCost( enumInst, dst, srcIsLvalue, symtab, env );
     55                        if ( enumInst->base->isTyped() ) {
     56                                auto baseConversionCost =
     57                                        castCost( enumInst->base->base, dst, srcIsLvalue, symtab, env );
     58                                cost = baseConversionCost < cost? baseConversionCost: cost;
     59                        }
     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;
    5564                }
    5665
     
    6372                                cost = conversionCost( basicType, dst, srcIsLvalue, symtab, env );
    6473                                if ( Cost::unsafe < cost ) {
    65                                         if (auto enumInst = dynamic_cast<const ast::EnumInstType *>(dst)) {
    66                                                 // Always explict cast only for typed enum
    67                                                 if (enumInst->base->isTyped) cost = Cost::unsafe;
     74                                        if ( dynamic_cast<const ast::EnumInstType *>(dst)) {
     75                                                cost = Cost::unsafe;
    6876                                        }
    6977                                }
     
    7482                        cost = conversionCost( zero, dst, srcIsLvalue, symtab, env );
    7583                        if ( Cost::unsafe < cost ) {
    76                                 if (auto enumInst = dynamic_cast<const ast::EnumInstType *>(dst)) {
    77                                         if (enumInst->base->isTyped) cost = Cost::unsafe;
     84                                if ( dynamic_cast<const ast::EnumInstType *>(dst)) {
     85                                        cost = Cost::unsafe;
    7886                                }
    7987                        }
     
    8391                        cost = conversionCost( one, dst, srcIsLvalue, symtab, env );
    8492                        if ( Cost::unsafe < cost ) {
    85                                 if (auto enumInst = dynamic_cast<const ast::EnumInstType *>(dst)) {
    86                                         if (enumInst->base->isTyped) cost = Cost::unsafe;
     93                                if ( dynamic_cast<const ast::EnumInstType *>(dst)) {
     94                                        cost = Cost::unsafe;
    8795                                }
    8896                        }
Note: See TracChangeset for help on using the changeset viewer.