Changeset b21c77a for src/GenPoly
- Timestamp:
- Jun 29, 2018, 4:14:15 PM (6 years ago)
- Branches:
- new-env
- Children:
- 184557e
- Parents:
- 97397a26 (diff), 28f3a19 (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
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Lvalue.cc
r97397a26 rb21c77a 145 145 146 146 namespace { 147 // true for intrinsic function calls that return a reference147 // true for intrinsic function calls that return an lvalue in C 148 148 bool isIntrinsicReference( Expression * expr ) { 149 // known intrinsic-reference prelude functions 150 static std::set<std::string> lvalueFunctions = { "*?", "?[?]" }; 149 151 if ( UntypedExpr * untyped = dynamic_cast< UntypedExpr * >( expr ) ) { 150 152 std::string fname = InitTweak::getFunctionName( untyped ); 151 // known intrinsic-reference prelude functions 152 return fname == "*?" || fname == "?[?]"; 153 return lvalueFunctions.count(fname); 153 154 } else if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * > ( expr ) ) { 154 155 if ( DeclarationWithType * func = InitTweak::getFunction( appExpr ) ) { 155 // use type of return variable rather than expr result type, since it may have been changed to a pointer type 156 FunctionType * ftype = GenPoly::getFunctionType( func->get_type() ); 157 Type * ret = ftype->returnVals.empty() ? nullptr : ftype->returnVals.front()->get_type(); 158 return func->linkage == LinkageSpec::Intrinsic && dynamic_cast<ReferenceType *>( ret ); 156 return func->linkage == LinkageSpec::Intrinsic && lvalueFunctions.count(func->name); 159 157 } 160 158 } … … 210 208 // TODO: it's likely that the second condition should be ... && ! isIntrinsicReference( arg ), but this requires investigation. 211 209 212 if ( function-> get_linkage()!= LinkageSpec::Intrinsic && isIntrinsicReference( arg ) ) {210 if ( function->linkage != LinkageSpec::Intrinsic && isIntrinsicReference( arg ) ) { 213 211 // needed for definition of prelude functions, etc. 214 212 // if argument is dereference or array subscript, the result isn't REALLY a reference, but non-intrinsic functions expect a reference: take address … … 226 224 arg = new AddressExpr( arg ); 227 225 // } else if ( function->get_linkage() == LinkageSpec::Intrinsic && InitTweak::getPointerBase( arg->result ) ) { 228 } else if ( function-> get_linkage()== LinkageSpec::Intrinsic && arg->result->referenceDepth() != 0 ) {226 } else if ( function->linkage == LinkageSpec::Intrinsic && arg->result->referenceDepth() != 0 ) { 229 227 // argument is a 'real' reference, but function expects a C lvalue: add a dereference to the reference-typed argument 230 228 PRINT(
Note: See TracChangeset
for help on using the changeset viewer.