Changeset 5527759 for src/GenPoly
- Timestamp:
- Apr 27, 2018, 2:35:11 PM (8 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:
- 399a908, a0c7d5cc
- Parents:
- b9f383f (diff), 9d5fb67 (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. - File:
-
- 1 edited
-
src/GenPoly/Lvalue.cc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Lvalue.cc
rb9f383f r5527759 211 211 ) 212 212 // TODO: it's likely that the second condition should be ... && ! isIntrinsicReference( arg ), but this requires investigation. 213 213 214 if ( function->get_linkage() != LinkageSpec::Intrinsic && isIntrinsicReference( arg ) ) { 215 // needed for definition of prelude functions, etc. 214 216 // if argument is dereference or array subscript, the result isn't REALLY a reference, but non-intrinsic functions expect a reference: take address 215 217 … … 225 227 ) 226 228 arg = new AddressExpr( arg ); 229 // } else if ( function->get_linkage() == LinkageSpec::Intrinsic && InitTweak::getPointerBase( arg->result ) ) { 227 230 } else if ( function->get_linkage() == LinkageSpec::Intrinsic && arg->result->referenceDepth() != 0 ) { 228 231 // argument is a 'real' reference, but function expects a C lvalue: add a dereference to the reference-typed argument … … 234 237 PointerType * ptrType = new PointerType( Type::Qualifiers(), baseType->clone() ); 235 238 delete arg->result; 236 arg-> set_result( ptrType );239 arg->result = ptrType; 237 240 arg = mkDeref( arg ); 238 assertf( arg->result->referenceDepth() == 0, "Reference types should have been eliminated from intrinsic function calls, but weren't: %s", toCString( arg->result ) );241 // assertf( arg->result->referenceDepth() == 0, "Reference types should have been eliminated from intrinsic function calls, but weren't: %s", toCString( arg->result ) ); 239 242 } 240 243 } … … 298 301 } 299 302 300 if ( addCast ) { 301 PRINT( std::cerr << "adding cast..." << std::endl; ) 303 // if addrExpr depth is 0, then the result is a pointer because the arg was depth 1 and not lvalue. 304 // This means the dereference result is not a reference, is lvalue, and one less pointer depth than 305 // the addrExpr. Thus the cast is meaningless. 306 // TODO: One thing to double check is whether it is possible for the types to differ outside of the single 307 // pointer level (i.e. can the base type of addrExpr differ from the type of addrExpr-arg?). 308 // If so then the cast might need to be added, conditional on a more sophisticated check. 309 if ( addCast && addrExpr->result->referenceDepth() != 0 ) { 310 PRINT( std::cerr << "adding cast to " << addrExpr->result << std::endl; ) 302 311 return new CastExpr( ret, addrExpr->result->clone() ); 303 312 } … … 413 422 for ( int i = 0; i < diff; ++i ) { 414 423 ret = mkDeref( ret ); 424 // xxx - try removing one reference here? actually, looks like mkDeref already does this, so more closely look at the types generated. 415 425 } 416 426 if ( ! ResolvExpr::typesCompatibleIgnoreQualifiers( destType->stripReferences(), srcType->stripReferences(), SymTab::Indexer() ) ) {
Note:
See TracChangeset
for help on using the changeset viewer.