Changeset 87c3bef


Ignore:
Timestamp:
Mar 8, 2017, 3:21:15 PM (7 years ago)
Author:
Aaron Moss <a3moss@…>
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, resolv-new, with_gc
Children:
be8bd88
Parents:
69d8a9a
Message:

Fix bug with generated structs for pointer-to-polymorphic types

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/InstantiateGeneric.cc

    r69d8a9a r87c3bef  
    226226
    227227                        if ( (*baseParam)->isComplete() ) {
    228                                 // substitute parameter for complete (otype or sized dtype) type; makes the struct concrete or dynamic depending on the parameter
    229                                 out.push_back( paramType->clone() );
     228                                // substitute parameter for complete (otype or sized dtype) type
     229                                int pointerLevels = 0;
     230                                if ( hasPolyBase( paramType->get_type(), &pointerLevels ) && pointerLevels > 0 ) {
     231                                        // Make a void* with equivalent nesting
     232                                        Type* voidPtr = new VoidType( Type::Qualifiers() );
     233                                        while ( pointerLevels > 0 ) {
     234                                                // Just about data layout, so qualifiers *shouldn't* matter
     235                                                voidPtr = new PointerType( Type::Qualifiers(), voidPtr );
     236                                                --pointerLevels;
     237                                        }
     238                                        out.push_back( new TypeExpr( voidPtr ) );
     239                                } else {
     240                                        // Just clone parameter type
     241                                        out.push_back( paramType->clone() );
     242                                }
     243                                // make the struct concrete or dynamic depending on the parameter
    230244                                gt |= isPolyType( paramType->get_type() ) ? genericType::dynamic : genericType::concrete;
    231245                        } else switch ( (*baseParam)->get_kind() ) {
Note: See TracChangeset for help on using the changeset viewer.