Changeset ae267366 for src/Parser


Ignore:
Timestamp:
Feb 24, 2023, 3:31:50 PM (3 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, master
Children:
2e77837
Parents:
f883ef1 (diff), f2a1cd2 (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:

fix merge conflict

Location:
src/Parser
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    rf883ef1 rae267366  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 16 14:12:03 2023
    13 // Update Count     : 1388
     12// Last Modified On : Fri Feb 24 11:10:03 2023
     13// Update Count     : 1400
    1414//
    1515
     
    6161        variable.initializer = nullptr;
    6262
    63 //      attr.name = nullptr;
    64         attr.expr = nullptr;
    65         attr.type = nullptr;
    66 
    6763        assert.condition = nullptr;
    6864        assert.message = nullptr;
     
    7066
    7167DeclarationNode::~DeclarationNode() {
    72 //      delete attr.name;
    73         delete attr.expr;
    74         delete attr.type;
    75 
    7668//      delete variable.name;
    7769        delete variable.assertions;
     
    115107        newnode->variable.initializer = maybeClone( variable.initializer );
    116108
    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 
    121109        newnode->assert.condition = maybeClone( assert.condition );
    122110        newnode->assert.message = maybeClone( assert.message );
     
    266254        newnode->type->enumeration.typed = typed;
    267255        newnode->type->enumeration.hiding = hiding;
    268         if ( base && base->type)  {
     256        if ( base && base->type )  {
    269257                newnode->type->base = base->type;
    270258        } // if
     
    579567
    580568        checkQualifiers( type, q->type );
    581         if ( (builtin == Zero || builtin == One) && q->type->qualifiers.val != 0 && error.length() == 0 ) {
     569        if ( (builtin == Zero || builtin == One) && q->type->qualifiers.any() && error.length() == 0 ) {
    582570                SemanticWarning( yylloc, Warning::BadQualifiersZeroOne, Type::QualifiersNames[ilog2( q->type->qualifiers.val )], builtinTypeNames[builtin] );
    583571        } // if
     
    996984
    997985                        if ( DeclarationNode * extr = cur->extractAggregate() ) {
    998                                 // handle the case where a structure declaration is contained within an object or type declaration
     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
    9991019
    10001020                                Declaration * decl = extr->build();
     
    12131233        assert( type );
    12141234
    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 
    12211235        switch ( type->kind ) {
    12221236          case TypeData::Enum:
  • src/Parser/ParseNode.h

    rf883ef1 rae267366  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Nov  2 21:27:07 2022
    13 // Update Count     : 939
     12// Last Modified On : Sun Feb 19 09:02:37 2023
     13// Update Count     : 940
    1414//
    1515
     
    325325        Variable_t variable;
    326326
    327         struct Attr_t {
    328 //              const std::string * name;
    329                 ExpressionNode * expr;
    330                 DeclarationNode * type;
    331         };
    332         Attr_t attr;
    333 
    334327        struct StaticAssert_t {
    335328                ExpressionNode * condition;
     
    343336
    344337        bool inLine = false;
    345         bool enumInLine = false; 
     338        bool enumInLine = false;
    346339        Type::FuncSpecifiers funcSpecs;
    347340        Type::StorageClasses storageClasses;
  • src/Parser/TypeData.cc

    rf883ef1 rae267366  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 10 22:36:52 2022
    13 // Update Count     : 677
     12// Last Modified On : Sun Feb 19 11:00:46 2023
     13// Update Count     : 679
    1414//
    1515
     
    375375                break;
    376376          case Enum:
    377                 os << "enumeration ";
     377                os << "enumeration " << *enumeration.name << endl;;
    378378                if ( enumeration.constants ) {
    379379                        os << "with constants" << endl;
  • src/Parser/TypeData.h

    rf883ef1 rae267366  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 10 22:18:49 2022
    13 // Update Count     : 203
     12// Last Modified On : Fri Feb 24 14:25:02 2023
     13// Update Count     : 205
    1414//
    1515
     
    3737                bool body;
    3838                bool anon;
    39 
    4039                bool tagged;
    4140                const std::string * parent = nullptr;
    4241        };
    4342
    44         struct AggInst_t {
     43        struct AggInst_t {                                                                      // handles SUE
    4544                TypeData * aggregate = nullptr;
    4645                ExpressionNode * params = nullptr;
  • src/Parser/parser.yy

    rf883ef1 rae267366  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb 14 21:11:39 2023
    13 // Update Count     : 5893
     12// Last Modified On : Fri Feb 24 14:46:55 2023
     13// Update Count     : 5983
    1414//
    1515
     
    19411941                        // if type_specifier is an anon aggregate => name
    19421942                        typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "4" );
    1943                         $$ = $3->addType( $2 )->addTypedef();
     1943                        $$ = $3->addType( $2 )->addTypedef();           // watchout frees $2 and $3
    19441944                }
    19451945        | typedef_declaration pop ',' push declarator
     
    19831983        | typedef_expression                                                            // deprecated GCC, naming expression type
    19841984        | sue_declaration_specifier
     1985                {
     1986                        assert( $1->type );
     1987                        if ( $1->type->qualifiers.any() ) {                     // CV qualifiers ?
     1988                                SemanticError( yylloc, "Useless type qualifier(s) in empty declaration." ); $$ = nullptr;
     1989                        }
     1990                        // enums are never empty declarations because there must have at least one enumeration.
     1991                        if ( $1->type->kind == TypeData::AggregateInst && $1->storageClasses.any() ) { // storage class ?
     1992                                SemanticError( yylloc, "Useless storage qualifier(s) in empty aggregate declaration." ); $$ = nullptr;
     1993                        }
     1994                }
    19851995        ;
    19861996
     
    20002010        | sue_declaration_specifier invalid_types
    20012011                {
    2002                         SemanticError( yylloc,
    2003                                                   ::toString( "Missing ';' after end of ",
    2004                                                                           $1->type->enumeration.name ? "enum" : AggregateDecl::aggrString( $1->type->aggregate.kind ),
    2005                                                                           " declaration" ) );
     2012                        SemanticError( yylloc, ::toString( "Missing ';' after end of ",
     2013                                $1->type->enumeration.name ? "enum" : AggregateDecl::aggrString( $1->type->aggregate.kind ),
     2014                                " declaration" ) );
    20062015                        $$ = nullptr;
    20072016                }
     
    25822591        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}'
    25832592                {
    2584                         if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 )
     2593                        if ( $3->storageClasses.val != 0 || $3->type->qualifiers.any() )
    25852594                        { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); }
    25862595
     
    25932602        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt
    25942603                {
    2595                         if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); }
     2604                        if ( $3->storageClasses.any() || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); }
    25962605                        typedefTable.makeTypedef( *$6 );
    25972606                }
     
    30523061                { $$ = DeclarationNode::newDirectiveStmt( new StatementNode( build_directive( $1 ) ) ); }
    30533062        | declaration
     3063                {
     3064                        // Variable declarations of anonymous types requires creating a unique type-name across multiple translation
     3065                        // unit, which is a dubious task, especially because C uses name rather than structural typing; hence it is
     3066                        // disallowed at the moment.
     3067                        if ( $1->linkage == LinkageSpec::Cforall && ! $1->storageClasses.is_static && $1->type && $1->type->kind == TypeData::AggregateInst ) {
     3068                                if ( $1->type->aggInst.aggregate->kind == TypeData::Enum && $1->type->aggInst.aggregate->enumeration.anon ) {
     3069                                        SemanticError( yylloc, "extern anonymous enumeration is currently unimplemented." ); $$ = nullptr;
     3070                                } else if ( $1->type->aggInst.aggregate->aggregate.anon ) { // handles struct or union
     3071                                        SemanticError( yylloc, "extern anonymous struct/union is currently unimplemented." ); $$ = nullptr;
     3072                                }
     3073                        }
     3074                }
    30543075        | IDENTIFIER IDENTIFIER
    30553076                { IdentifierBeforeIdentifier( *$1.str, *$2.str, " declaration" ); $$ = nullptr; }
     
    30973118        | type_qualifier_list
    30983119                {
    3099                         if ( $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
     3120                        if ( $1->type->qualifiers.any() ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
    31003121                        if ( $1->type->forall ) forall = true;          // remember generic type
    31013122                }
     
    31083129        | declaration_qualifier_list
    31093130                {
    3110                         if ( $1->type && $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
     3131                        if ( $1->type && $1->type->qualifiers.any() ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
    31113132                        if ( $1->type && $1->type->forall ) forall = true; // remember generic type
    31123133                }
     
    31193140        | declaration_qualifier_list type_qualifier_list
    31203141                {
    3121                         if ( ($1->type && $1->type->qualifiers.val) || ($2->type && $2->type->qualifiers.val) ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
     3142                        if ( ($1->type && $1->type->qualifiers.any()) || ($2->type && $2->type->qualifiers.any()) ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
    31223143                        if ( ($1->type && $1->type->forall) || ($2->type && $2->type->forall) ) forall = true; // remember generic type
    31233144                }
Note: See TracChangeset for help on using the changeset viewer.