Ignore:
Timestamp:
Apr 27, 2018, 2:35:11 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, 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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Lvalue.cc

    rb9f383f r5527759  
    211211                                                )
    212212                                                // TODO: it's likely that the second condition should be ... && ! isIntrinsicReference( arg ), but this requires investigation.
     213
    213214                                                if ( function->get_linkage() != LinkageSpec::Intrinsic && isIntrinsicReference( arg ) ) {
     215                                                        // needed for definition of prelude functions, etc.
    214216                                                        // if argument is dereference or array subscript, the result isn't REALLY a reference, but non-intrinsic functions expect a reference: take address
    215217
     
    225227                                                        )
    226228                                                        arg = new AddressExpr( arg );
     229                                                // } else if ( function->get_linkage() == LinkageSpec::Intrinsic && InitTweak::getPointerBase( arg->result ) ) {
    227230                                                } else if ( function->get_linkage() == LinkageSpec::Intrinsic && arg->result->referenceDepth() != 0 ) {
    228231                                                        // argument is a 'real' reference, but function expects a C lvalue: add a dereference to the reference-typed argument
     
    234237                                                        PointerType * ptrType = new PointerType( Type::Qualifiers(), baseType->clone() );
    235238                                                        delete arg->result;
    236                                                         arg->set_result( ptrType );
     239                                                        arg->result = ptrType;
    237240                                                        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 ) );
    239242                                                }
    240243                                        }
     
    298301                                }
    299302
    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; )
    302311                                        return new CastExpr( ret, addrExpr->result->clone() );
    303312                                }
     
    413422                                for ( int i = 0; i < diff; ++i ) {
    414423                                        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.
    415425                                }
    416426                                if ( ! ResolvExpr::typesCompatibleIgnoreQualifiers( destType->stripReferences(), srcType->stripReferences(), SymTab::Indexer() ) ) {
Note: See TracChangeset for help on using the changeset viewer.