Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r446740a r42422fb  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar 11 18:30:03 2024
    13 // Update Count     : 6589
     12// Last Modified On : Sat Mar 16 18:19:23 2024
     13// Update Count     : 6617
    1414//
    1515
     
    485485%type<decl> elaborated_type elaborated_type_nobody
    486486
    487 %type<decl> enumerator_list enum_type enum_type_nobody
     487%type<decl> enumerator_list enum_type enum_type_nobody enumerator_type
    488488%type<init> enumerator_value_opt
    489489
     
    27422742
    27432743enum_type:
    2744         ENUM attribute_list_opt '{' enumerator_list comma_opt '}'
    2745                 { $$ = DeclarationNode::newEnum( nullptr, $4, true, false )->addQualifiers( $2 ); }
    2746         | ENUM attribute_list_opt '!' '{' enumerator_list comma_opt '}' // invalid syntax rule
    2747                 { SemanticError( yylloc, "syntax error, hiding ('!') the enumerator names of an anonymous enumeration means the names are inaccessible." ); $$ = nullptr; }
     2744                // anonymous, no type name
     2745        ENUM attribute_list_opt hide_opt '{' enumerator_list comma_opt '}'
     2746                {
     2747                        if ( $3 == EnumHiding::Hide ) {
     2748                                SemanticError( yylloc, "syntax error, hiding ('!') the enumerator names of an anonymous enumeration means the names are inaccessible." ); $$ = nullptr;
     2749                        } // if
     2750                        $$ = DeclarationNode::newEnum( nullptr, $5, true, false )->addQualifiers( $2 );
     2751                }
     2752        | ENUM enumerator_type attribute_list_opt hide_opt '{' enumerator_list comma_opt '}'
     2753                {
     2754                        if ( $2 && ($2->storageClasses.val != 0 || $2->type->qualifiers.any()) ) {
     2755                                SemanticError( yylloc, "syntax error, storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." );
     2756                        }
     2757                        if ( $4 == EnumHiding::Hide ) {
     2758                                SemanticError( yylloc, "syntax error, hiding ('!') the enumerator names of an anonymous enumeration means the names are inaccessible." ); $$ = nullptr;
     2759                        } // if
     2760                        $$ = DeclarationNode::newEnum( nullptr, $6, true, true, $2 )->addQualifiers( $3 );
     2761                }
     2762
     2763                // named type
    27482764        | ENUM attribute_list_opt identifier
    27492765                { typedefTable.makeTypedef( *$3, "enum_type 1" ); }
     
    27522768        | ENUM attribute_list_opt typedef_name hide_opt '{' enumerator_list comma_opt '}' // unqualified type name
    27532769                { $$ = DeclarationNode::newEnum( $3->name, $6, true, false, nullptr, $4 )->addQualifiers( $2 ); }
    2754         | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}'
    2755                 {
    2756                         if ( $3->storageClasses.val != 0 || $3->type->qualifiers.any() ) {
     2770        | ENUM enumerator_type attribute_list_opt identifier attribute_list_opt
     2771                {
     2772                        if ( $2 && ($2->storageClasses.any() || $2->type->qualifiers.val != 0) ) {
    27572773                                SemanticError( yylloc, "syntax error, storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." );
    27582774                        }
    2759                         $$ = DeclarationNode::newEnum( nullptr, $7, true, true, $3 )->addQualifiers( $5 );
    2760                 }
    2761         | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '!' '{' enumerator_list comma_opt '}' // unqualified type name
    2762                 { SemanticError( yylloc, "syntax error, hiding ('!') the enumerator names of an anonymous enumeration means the names are inaccessible." ); $$ = nullptr; }
    2763         | ENUM '(' ')' attribute_list_opt '{' enumerator_list comma_opt '}'
    2764                 {
    2765                         $$ = DeclarationNode::newEnum( nullptr, $6, true, true )->addQualifiers( $4 );
    2766                 }
    2767         | ENUM '(' ')' attribute_list_opt '!' '{' enumerator_list comma_opt '}' // invalid syntax rule
    2768                 { SemanticError( yylloc, "syntax error, hiding ('!') the enumerator names of an anonymous enumeration means the names are inaccessible." ); $$ = nullptr; }
    2769         | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt
    2770                 {
    2771                         if ( $3 && ($3->storageClasses.any() || $3->type->qualifiers.val != 0) ) {
    2772                                 SemanticError( yylloc, "syntax error, storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." );
    2773                         }
    2774                         typedefTable.makeTypedef( *$6, "enum_type 2" );
     2775                        typedefTable.makeTypedef( *$4, "enum_type 2" );
    27752776                }
    27762777          hide_opt '{' enumerator_list comma_opt '}'
    2777                 {
    2778                         $$ = DeclarationNode::newEnum( $6, $11, true, true, $3, $9 )->addQualifiers( $5 )->addQualifiers( $7 );
    2779                 }
    2780         | ENUM '(' ')' attribute_list_opt identifier attribute_list_opt hide_opt '{' enumerator_list comma_opt '}'
    2781                 {
    2782                         $$ = DeclarationNode::newEnum( $5, $9, true, true, nullptr, $7 )->addQualifiers( $4 )->addQualifiers( $6 );
    2783                 }
    2784         | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt hide_opt '{' enumerator_list comma_opt '}'
    2785                 {
    2786                         $$ = DeclarationNode::newEnum( $6->name, $10, true, true, $3, $8 )->addQualifiers( $5 )->addQualifiers( $7 );
    2787                 }
    2788         | ENUM '(' ')' attribute_list_opt typedef_name attribute_list_opt hide_opt '{' enumerator_list comma_opt '}'
    2789                 {
    2790                         $$ = DeclarationNode::newEnum( $5->name, $9, true, true, nullptr, $7 )->addQualifiers( $4 )->addQualifiers( $6 );
    2791                 }
     2778                { $$ = DeclarationNode::newEnum( $4, $9, true, true, $2, $7 )->addQualifiers( $3 )->addQualifiers( $5 ); }
     2779        | ENUM enumerator_type attribute_list_opt typedef_name attribute_list_opt hide_opt '{' enumerator_list comma_opt '}'
     2780                { $$ = DeclarationNode::newEnum( $4->name, $8, true, true, $2, $6 )->addQualifiers( $3 )->addQualifiers( $5 ); }
     2781
     2782                // forward declaration
    27922783        | enum_type_nobody
     2784        ;
     2785
     2786enumerator_type:
     2787        '(' ')'                                                                                         // pure enumeration
     2788                { $$ = nullptr; }
     2789        | '(' cfa_abstract_parameter_declaration ')'            // typed enumeration
     2790                { $$ = $2; }
    27932791        ;
    27942792
Note: See TracChangeset for help on using the changeset viewer.