Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    rc194661 ra1c9ddd  
    253253        return newnode;
    254254} // DeclarationNode::newFromTypedef
    255 
    256 DeclarationNode * DeclarationNode::newFromGlobalScope() {
    257         DeclarationNode * newnode = new DeclarationNode;
    258         newnode->type = new TypeData( TypeData::GlobalScope );
    259         return newnode;
    260 }
    261 
    262 DeclarationNode * DeclarationNode::newQualifiedType( DeclarationNode * parent, DeclarationNode * child) {
    263         DeclarationNode * newnode = new DeclarationNode;
    264         newnode->type = new TypeData( TypeData::Qualified );
    265         newnode->type->qualified.parent = parent->type;
    266         newnode->type->qualified.child = child->type;
    267         parent->type = nullptr;
    268         child->type = nullptr;
    269         delete parent;
    270         delete child;
    271         return newnode;
    272 }
    273255
    274256DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {
     
    1011993                try {
    1012994                        Declaration * decl = cur->build();
    1013                         assert( decl );
    1014                         if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * >( decl ) ) {
    1015                                 dwt->location = cur->location;
    1016                                 * out++ = dwt;
    1017                         } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) {
    1018                                 // xxx - this might be where anonymous struct members are added - should be conditional on struct name
    1019                                 StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->name );
    1020                                 auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr );
    1021                                 obj->location = cur->location;
    1022                                 * out++ = obj;
    1023                                 delete agg;
    1024                         } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) {
    1025                                 UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->name );
    1026                                 auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr );
    1027                                 obj->location = cur->location;
    1028                                 * out++ = obj;
     995                        if ( decl ) {
     996                                if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * >( decl ) ) {
     997                                        dwt->location = cur->location;
     998                                        * out++ = dwt;
     999                                } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) {
     1000                                        StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->get_name() );
     1001                                        auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr );
     1002                                        obj->location = cur->location;
     1003                                        * out++ = obj;
     1004                                        delete agg;
     1005                                } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) {
     1006                                        UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->get_name() );
     1007                                        auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr );
     1008                                        obj->location = cur->location;
     1009                                        * out++ = obj;
     1010                                } // if
    10291011                        } // if
    10301012                } catch( SemanticErrorException &e ) {
Note: See TracChangeset for help on using the changeset viewer.