Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r78e2fca r692c1cc  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Feb 24 11:10:03 2023
    13 // Update Count     : 1400
     12// Last Modified On : Thu Feb 16 14:12:03 2023
     13// Update Count     : 1388
    1414//
    1515
     
    6161        variable.initializer = nullptr;
    6262
     63//      attr.name = nullptr;
     64        attr.expr = nullptr;
     65        attr.type = nullptr;
     66
    6367        assert.condition = nullptr;
    6468        assert.message = nullptr;
     
    6670
    6771DeclarationNode::~DeclarationNode() {
     72//      delete attr.name;
     73        delete attr.expr;
     74        delete attr.type;
     75
    6876//      delete variable.name;
    6977        delete variable.assertions;
     
    107115        newnode->variable.initializer = maybeClone( variable.initializer );
    108116
     117//      newnode->attr.name = attr.name ? new string( *attr.name ) : nullptr;
     118        newnode->attr.expr = maybeClone( attr.expr );
     119        newnode->attr.type = maybeClone( attr.type );
     120
    109121        newnode->assert.condition = maybeClone( assert.condition );
    110122        newnode->assert.message = maybeClone( assert.message );
     
    254266        newnode->type->enumeration.typed = typed;
    255267        newnode->type->enumeration.hiding = hiding;
    256         if ( base && base->type )  {
     268        if ( base && base->type)  {
    257269                newnode->type->base = base->type;
    258270        } // if
     
    567579
    568580        checkQualifiers( type, q->type );
    569         if ( (builtin == Zero || builtin == One) && q->type->qualifiers.any() && error.length() == 0 ) {
     581        if ( (builtin == Zero || builtin == One) && q->type->qualifiers.val != 0 && error.length() == 0 ) {
    570582                SemanticWarning( yylloc, Warning::BadQualifiersZeroOne, Type::QualifiersNames[ilog2( q->type->qualifiers.val )], builtinTypeNames[builtin] );
    571583        } // if
     
    984996
    985997                        if ( DeclarationNode * extr = cur->extractAggregate() ) {
    986                                 // Handle the case where a SUE declaration is contained within an object or type declaration.
    987 
    988                                 assert( cur->type );
    989                                 // Replace anonymous SUE name with typedef name to prevent anonymous naming problems across translation units.
    990                                 if ( cur->type->kind == TypeData::Symbolic && cur->type->symbolic.isTypedef ) {
    991                                         assert( extr->type );
    992                                         // Handle anonymous aggregates: typedef struct { int i; } foo
    993                                         extr->type->qualifiers.reset();         // clear any CVs associated with the aggregate
    994                                         if ( extr->type->kind == TypeData::Aggregate && extr->type->aggregate.anon ) {
    995                                                 delete extr->type->aggregate.name;
    996                                                 extr->type->aggregate.name = new string( "__anonymous_" + *cur->name );
    997                                                 extr->type->aggregate.anon = false;
    998                                                 assert( cur->type->base );
    999                                                 if ( cur->type->base ) {
    1000                                                         delete cur->type->base->aggInst.aggregate->aggregate.name;
    1001                                                         cur->type->base->aggInst.aggregate->aggregate.name = new string( "__anonymous_" + *cur->name );
    1002                                                         cur->type->base->aggInst.aggregate->aggregate.anon = false;
    1003                                                         cur->type->base->aggInst.aggregate->qualifiers.reset();
    1004                                                 } // if
    1005                                         } // if
    1006                                         // Handle anonymous enumeration: typedef enum { A, B, C } foo
    1007                                         if ( extr->type->kind == TypeData::Enum && extr->type->enumeration.anon ) {
    1008                                                 delete extr->type->enumeration.name;
    1009                                                 extr->type->enumeration.name = new string( "__anonymous_" + *cur->name );
    1010                                                 extr->type->enumeration.anon = false;
    1011                                                 assert( cur->type->base );
    1012                                                 if ( cur->type->base ) {
    1013                                                         delete cur->type->base->aggInst.aggregate->enumeration.name;
    1014                                                         cur->type->base->aggInst.aggregate->enumeration.name = new string( "__anonymous_" + *cur->name );
    1015                                                         cur->type->base->aggInst.aggregate->enumeration.anon = false;
    1016                                                 } // if
    1017                                         } // if
    1018                                 } // if
     998                                // handle the case where a structure declaration is contained within an object or type declaration
    1019999
    10201000                                Declaration * decl = extr->build();
     
    12331213        assert( type );
    12341214
     1215        if ( attr.expr ) {
     1216                return new AttrType( buildQualifiers( type ), *name, attr.expr->build(), attributes );
     1217        } else if ( attr.type ) {
     1218                return new AttrType( buildQualifiers( type ), *name, attr.type->buildType(), attributes );
     1219        } // if
     1220
    12351221        switch ( type->kind ) {
    12361222          case TypeData::Enum:
Note: See TracChangeset for help on using the changeset viewer.