Changeset 00f89a6
- Timestamp:
- Nov 12, 2024, 10:18:13 PM (9 days ago)
- Branches:
- master
- Children:
- 2325b57
- Parents:
- 47174c4
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Lvalue.cpp
r47174c4 r00f89a6 316 316 Warning::RvalueToReferenceConversion, toCString( expr->arg ) ); 317 317 318 319 // allowing conversion in the rvalue to const ref case 320 // use the referenced-to type to create temp variables 321 ast::Type const * targetType = dstType; 322 for (int i = 0; i < diff; ++i) targetType = (strict_dynamic_cast<ast::ReferenceType const *>(targetType))->base; 323 318 324 static UniqueName tmpNamer( "__ref_tmp_" ); 319 325 ast::ObjectDecl * tmp = new ast::ObjectDecl( expr->arg->location, 320 326 tmpNamer.newName(), 321 ast::deepCopy( expr->arg->result ), 327 // ast::deepCopy( expr->arg->result ), 328 ast::deepCopy (targetType), 322 329 new ast::SingleInit( expr->arg->location, expr->arg ) ); 323 330 PRINT( std::cerr << "make tmp: " << tmp << std::endl; ) -
src/ResolvExpr/ConversionCost.cpp
r47174c4 r00f89a6 250 250 newSrc = new ast::BasicType( ast::BasicKind::UnsignedInt ); 251 251 } 252 if (dstAsRef->base->is_const() ) { 253 auto cvtCost = conversionCost(newSrc, dstAsRef->base, srcIsLvalue, symtab, env) ; 254 if (cvtCost == Cost::zero) { // exact match, may use a lvalue src 255 if ( srcIsLvalue ) { 256 if ( src->qualifiers == dstAsRef->base->qualifiers ) { 257 return Cost::reference; 258 } else if ( src->qualifiers < dstAsRef->base->qualifiers ) { 259 return Cost::safe; 260 } else { 261 return Cost::unsafe; 262 } 263 } 264 else { 265 return Cost::reference; 266 } 267 } 268 else { // not exact match, conversion is needed so lvalueness of src does not matter 269 return cvtCost + Cost::reference; 270 } 271 } 252 272 if ( typesCompatibleIgnoreQualifiers( newSrc, dstAsRef->base, env ) ) { 253 273 if ( srcIsLvalue ) { … … 259 279 return Cost::unsafe; 260 280 } 261 } else if ( dstAsRef->base->is_const() ) { 262 return Cost::safe; 263 } else { 281 } else { // rvalue-to-NC-ref conversion 264 282 return Cost::unsafe; 265 283 }
Note: See TracChangeset
for help on using the changeset viewer.