Changeset 10a9479d for src/ResolvExpr
- Timestamp:
- Nov 23, 2024, 8:28:37 PM (14 months ago)
- Branches:
- master
- Children:
- 956b389
- Parents:
- b006c51e (diff), de7b7a5 (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:
-
- 3 edited
-
CandidateFinder.cpp (modified) (1 diff)
-
ConversionCost.cpp (modified) (2 diffs)
-
Resolver.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CandidateFinder.cpp
rb006c51e r10a9479d 1220 1220 finder.allowVoid = true; 1221 1221 } 1222 if ( castExpr->kind == ast::CastExpr::Return) {1222 if ( ast::ReturnCast == castExpr->kind ) { 1223 1223 finder.strictMode = true; 1224 1224 finder.find( castExpr->arg, ResolveMode::withAdjustment() ); -
src/ResolvExpr/ConversionCost.cpp
rb006c51e r10a9479d 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 } -
src/ResolvExpr/Resolver.cpp
rb006c51e r10a9479d 201 201 && typesCompatible( castExpr->arg->result, castExpr->result ) 202 202 ) { 203 auto argAsEnum = castExpr->arg.as<ast::EnumInstType>(); 204 auto resultAsEnum = castExpr->result.as<ast::EnumInstType>(); 205 if (argAsEnum && resultAsEnum) { 206 if (argAsEnum->base->name != resultAsEnum->base->name) { 207 std::cerr << "Enum Cast: " << argAsEnum->base->name << " to " << resultAsEnum->base->name << std::endl; 208 return castExpr; 209 } 203 ast::EnumInstType const * arg, * result; 204 if ( ( result = castExpr->result.as<ast::EnumInstType>() ) && 205 ( arg = castExpr->arg.as<ast::EnumInstType>() ) && 206 arg->base->name != result->base->name) { 207 return castExpr; 210 208 } 211 209 // generated cast is the same type as its argument, remove it after keeping env … … 377 375 : public ast::WithSymbolTable, public ast::WithGuards, 378 376 public ast::WithVisitorRef<Resolver>, public ast::WithShortCircuiting, 379 public ast::WithStmtsToAdd <>{377 public ast::WithStmtsToAdd { 380 378 381 379 ast::ptr< ast::Type > functionReturn = nullptr;
Note:
See TracChangeset
for help on using the changeset viewer.