Changes in src/GenPoly/Lvalue.cpp [ecf3812:ed96731]
- File:
-
- 1 edited
-
src/GenPoly/Lvalue.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Lvalue.cpp
recf3812 red96731 315 315 SemanticWarning( expr->arg->location, 316 316 Warning::RvalueToReferenceConversion, toCString( expr->arg ) ); 317 317 318 318 319 // allowing conversion in the rvalue to const ref case … … 365 366 ret = new ast::AddressExpr( ret->location, ret ); 366 367 } 367 if ( !ResolvExpr::typesCompatible( 368 srcType, 369 strict_dynamic_cast<ast::ReferenceType const *>( dstType )->base ) ) { 368 if ( expr->arg->get_lvalue() && 369 !ResolvExpr::typesCompatible( 370 srcType, 371 strict_dynamic_cast<ast::ReferenceType const *>( dstType )->base ) ) { 370 372 // Must keep cast if cast-to type is different from the actual type. 371 373 return ast::mutate_field( expr, &ast::CastExpr::arg, ret ); … … 382 384 } 383 385 // Must keep cast if types are different. 384 if ( !ResolvExpr::typesCompatible (386 if ( !ResolvExpr::typesCompatibleIgnoreQualifiers( 385 387 dstType->stripReferences(), 386 388 srcType->stripReferences() ) ) { … … 395 397 } else { 396 398 assert( 0 == diff ); 397 // Must keep cast if types are different. (Or it is explicit.)398 if ( ast::ExplicitCast == expr->isGenerated ||399 !ResolvExpr::typesCompatible(399 // Remove useless generated casts. 400 if ( expr->isGenerated == ast::GeneratedFlag::GeneratedCast && 401 ResolvExpr::typesCompatible( 400 402 expr->result, 401 403 expr->arg->result ) ) { 402 return expr; 403 } 404 PRINT( 405 std::cerr << "types are compatible, removing cast: " << expr << '\n'; 406 std::cerr << "-- " << expr->result << '\n'; 407 std::cerr << "-- " << expr->arg->result << std::endl; 408 ) 409 return ast::mutate_field( expr->arg.get(), 410 &ast::Expr::env, expr->env.get() ); 404 PRINT( 405 std::cerr << "types are compatible, removing cast: " << expr << '\n'; 406 std::cerr << "-- " << expr->result << '\n'; 407 std::cerr << "-- " << expr->arg->result << std::endl; 408 ) 409 auto argAsEnum = expr->arg.as<ast::EnumInstType>(); 410 auto resultAsEnum = expr->result.as<ast::EnumInstType>(); 411 if (argAsEnum && resultAsEnum) { 412 if (argAsEnum->base->name != resultAsEnum->base->name) { 413 return expr; 414 } 415 } 416 return ast::mutate_field( expr->arg.get(), 417 &ast::Expr::env, expr->env.get() ); 418 } 419 return expr; 411 420 } 412 421 }
Note:
See TracChangeset
for help on using the changeset viewer.