Changes in src/ResolvExpr/CastCost.cpp [115ac1ce:85855b0]
- File:
-
- 1 edited
-
src/ResolvExpr/CastCost.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CastCost.cpp
r115ac1ce r85855b0 53 53 void postvisit( const ast::EnumInstType * enumInst ) { 54 54 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;64 55 } 65 56 … … 72 63 cost = conversionCost( basicType, dst, srcIsLvalue, symtab, env ); 73 64 if ( Cost::unsafe < cost ) { 74 if ( dynamic_cast<const ast::EnumInstType *>(dst)) { 75 cost = Cost::unsafe; 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; 76 68 } 77 69 } … … 82 74 cost = conversionCost( zero, dst, srcIsLvalue, symtab, env ); 83 75 if ( Cost::unsafe < cost ) { 84 if ( dynamic_cast<const ast::EnumInstType *>(dst)) {85 cost = Cost::unsafe;76 if (auto enumInst = dynamic_cast<const ast::EnumInstType *>(dst)) { 77 if (enumInst->base->isTyped) cost = Cost::unsafe; 86 78 } 87 79 } … … 91 83 cost = conversionCost( one, dst, srcIsLvalue, symtab, env ); 92 84 if ( Cost::unsafe < cost ) { 93 if ( dynamic_cast<const ast::EnumInstType *>(dst)) {94 cost = Cost::unsafe;85 if (auto enumInst = dynamic_cast<const ast::EnumInstType *>(dst)) { 86 if (enumInst->base->isTyped) cost = Cost::unsafe; 95 87 } 96 88 }
Note:
See TracChangeset
for help on using the changeset viewer.