Changeset 4067aa8


Ignore:
Timestamp:
Feb 23, 2016, 4:32:15 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, string, with_gc
Children:
b502055
Parents:
dc12481
Message:

Fix non-polymorphic members of polymorphic types (general case of Thierry's pointer bug)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    rdc12481 r4067aa8  
    14481448                        assert( newMemberExpr );
    14491449
    1450                         // wrap pointer members in appropriate cast
    1451                         if ( dynamic_cast< PointerType* >( memberExpr->get_member()->get_type() ) ) {
    1452                                 CastExpr *ptrCastExpr = new CastExpr( newMemberExpr, new PointerType( Type::Qualifiers(), new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ) ) );
     1450                        Type *memberType = memberExpr->get_member()->get_type();
     1451                        if ( ! isPolyType( memberType, scopeTyVars ) ) {
     1452                                // Not all members of a polymorphic type are themselves of polymorphic type; in this case the member expression should be wrapped and dereferenced to form an lvalue
     1453                                CastExpr *ptrCastExpr = new CastExpr( newMemberExpr, new PointerType( Type::Qualifiers(), memberType->clone() ) );
    14531454                                UntypedExpr *derefExpr = new UntypedExpr( new NameExpr( "*?" ) );
    14541455                                derefExpr->get_args().push_back( ptrCastExpr );
Note: See TracChangeset for help on using the changeset viewer.