Changeset da7fe39 for src/ResolvExpr
- Timestamp:
- Apr 23, 2018, 12:57:46 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
- Children:
- 57acae0
- Parents:
- ba89e9b7 (diff), c8ad5d9 (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. - Location:
- src/ResolvExpr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
rba89e9b7 rda7fe39 1247 1247 } 1248 1248 1249 Expression * restructureCast( Expression * argExpr, Type * toType ) {1249 Expression * restructureCast( Expression * argExpr, Type * toType, bool isGenerated ) { 1250 1250 if ( argExpr->get_result()->size() > 1 && ! toType->isVoid() && ! dynamic_cast<ReferenceType *>( toType ) ) { 1251 1251 // Argument expression is a tuple and the target type is not void and not a reference type. … … 1262 1262 // cast each component 1263 1263 TupleIndexExpr * idx = new TupleIndexExpr( argExpr->clone(), i ); 1264 componentExprs.push_back( restructureCast( idx, toType->getComponent( i ) ) );1264 componentExprs.push_back( restructureCast( idx, toType->getComponent( i ), isGenerated ) ); 1265 1265 } 1266 1266 delete argExpr; … … 1270 1270 } else { 1271 1271 // handle normally 1272 return new CastExpr( argExpr, toType->clone() ); 1272 CastExpr * ret = new CastExpr( argExpr, toType->clone() ); 1273 ret->isGenerated = isGenerated; 1274 return ret; 1273 1275 } 1274 1276 } … … 1314 1316 // count one safe conversion for each value that is thrown away 1315 1317 thisCost.incSafe( discardedValues ); 1316 Alternative newAlt( restructureCast( alt.expr->clone(), toType ), alt.env,1318 Alternative newAlt( restructureCast( alt.expr->clone(), toType, castExpr->isGenerated ), alt.env, 1317 1319 alt.cost, thisCost ); 1318 1320 inferParameters( needAssertions, haveAssertions, newAlt, openVars, … … 1730 1732 // count one safe conversion for each value that is thrown away 1731 1733 thisCost.incSafe( discardedValues ); 1732 Alternative newAlt( new InitExpr( restructureCast( alt.expr->clone(), toType ), initAlt.designation->clone() ), newEnv, alt.cost, thisCost );1734 Alternative newAlt( new InitExpr( restructureCast( alt.expr->clone(), toType, true ), initAlt.designation->clone() ), newEnv, alt.cost, thisCost ); 1733 1735 inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( candidates ) ); 1734 1736 } -
src/ResolvExpr/ConversionCost.cc
rba89e9b7 rda7fe39 275 275 // xxx - not positive this is correct, but appears to allow casting int => enum 276 276 cost = Cost::unsafe; 277 } else if ( dynamic_cast< ZeroType* >( dest ) != nullptr || dynamic_cast< OneType* >( dest ) != nullptr ) { 278 cost = Cost::unsafe; 279 } // if 277 } // if 278 // no cases for zero_t/one_t because it should not be possible to convert int, etc. to zero_t/one_t. 280 279 } 281 280 … … 309 308 // assignResult == 0 means Cost::Infinity 310 309 } // if 311 } else if ( dynamic_cast< ZeroType * >( dest ) ) { 312 cost = Cost::unsafe; 310 // case case for zero_t because it should not be possible to convert pointers to zero_t. 313 311 } // if 314 312 }
Note: See TracChangeset
for help on using the changeset viewer.