Changeset 5ccc733 for src/ResolvExpr/ConversionCost.cpp
- Timestamp:
- Jun 29, 2024, 5:02:06 AM (3 months ago)
- Branches:
- master
- Children:
- 4117761
- Parents:
- 7552fde
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/ConversionCost.cpp
r7552fde r5ccc733 235 235 return ast::Pass<ConversionCost>::read( src, dst, srcIsLvalue, symtab, env, conversionCost ); 236 236 } 237 if (const ast::EnumInstType * srcAsInst = dynamic_cast< const ast::EnumInstType * >( src )) { 238 if (srcAsInst->base && !srcAsInst->base->isCfa) { 239 static const ast::BasicType* integer = new ast::BasicType( ast::BasicKind::UnsignedInt ); 240 return ast::Pass<ConversionCost>::read( integer, dst, srcIsLvalue, symtab, env, conversionCost ); 241 } 242 } 237 243 } else { 238 244 assert( -1 == diff ); 239 245 const ast::ReferenceType * dstAsRef = dynamic_cast< const ast::ReferenceType * >( dst ); 240 246 assert( dstAsRef ); 241 if ( typesCompatibleIgnoreQualifiers( src, dstAsRef->base, env ) ) { 247 auto dstBaseType = dstAsRef->base; 248 const ast::Type * newSrc = src; 249 if ( dynamic_cast< const ast::EnumInstType * >( src ) && dstBaseType.as<ast::BasicType>() ) { 250 newSrc = new ast::BasicType( ast::BasicKind::UnsignedInt ); 251 } 252 if ( typesCompatibleIgnoreQualifiers( newSrc, dstAsRef->base, env ) ) { 242 253 if ( srcIsLvalue ) { 243 254 if ( src->qualifiers == dstAsRef->base->qualifiers ) { … … 285 296 conversionCostFromBasicToBasic( basicType, dstAsBasic ); 286 297 } else if ( auto dstAsEnumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) { 287 if ( dstAsEnumInst->base && !dstAsEnumInst->base->is Typed) {288 cost = Cost:: unsafe;298 if ( dstAsEnumInst->base && !dstAsEnumInst->base->isCfa ) { 299 cost = Cost::safe; 289 300 } 290 301 } … … 366 377 if ( auto dstInst = dynamic_cast<const ast::EnumInstType *>( dst ) ) { 367 378 cost = enumCastCost(inst, dstInst, symtab, env); 368 return; 369 } 370 371 if ( !inst->base->isTyped ) { 379 } else if ( !inst->base->isCfa ) { 372 380 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) }; 373 381 cost = costCalc( integer, dst, srcIsLvalue, symtab, env ); 374 if ( cost < Cost::unsafe ) {375 cost.incSafe();376 }377 return;378 382 } 379 383 // cost.incUnsafe(); … … 455 459 // assuming 0p is supposed to be used for pointers? 456 460 } else if ( auto dstAsEnumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) { 457 if ( dstAsEnumInst->base && !dstAsEnumInst->base->is Typed) {458 cost = Cost:: unsafe;461 if ( dstAsEnumInst->base && !dstAsEnumInst->base->isCfa ) { 462 cost = Cost::safe; 459 463 } 460 464 } … … 476 480 } 477 481 } else if ( auto dstAsEnumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) { 478 if ( dstAsEnumInst->base && !dstAsEnumInst->base->is Typed) {479 cost = Cost:: unsafe;482 if ( dstAsEnumInst->base && !dstAsEnumInst->base->isCfa ) { 483 cost = Cost::safe; 480 484 } 481 485 }
Note: See TracChangeset
for help on using the changeset viewer.