Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r3d937e2 r0bcd707  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb 25 13:23:16 2023
    13 // Update Count     : 5989
     12// Last Modified On : Mon Feb 20 11:31:26 2023
     13// Update Count     : 5896
    1414//
    1515
     
    11731173        comma_expression_opt ';'
    11741174                { $$ = new StatementNode( build_expr( $1 ) ); }
     1175        | MUTEX '(' ')' comma_expression ';'
     1176                { $$ = new StatementNode( build_mutex( nullptr, new StatementNode( build_expr( $4 ) ) ) ); }
    11751177        ;
    11761178
     
    12801282                {
    12811283                        $$ = new StatementNode( build_while( new CondCtl( nullptr, NEW_ONE ), maybe_build_compound( $4 ) ) );
    1282                         SemanticWarning( yylloc, Warning::SuperfluousElse );
     1284                        SemanticWarning( yylloc, Warning::SuperfluousElse, "" );
    12831285                }
    12841286        | WHILE '(' conditional_declaration ')' statement       %prec THEN
     
    12911293                {
    12921294                        $$ = new StatementNode( build_do_while( NEW_ONE, maybe_build_compound( $2 ) ) );
    1293                         SemanticWarning( yylloc, Warning::SuperfluousElse );
     1295                        SemanticWarning( yylloc, Warning::SuperfluousElse, "" );
    12941296                }
    12951297        | DO statement WHILE '(' comma_expression ')' ';'
     
    13021304                {
    13031305                        $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), maybe_build_compound( $4 ) ) );
    1304                         SemanticWarning( yylloc, Warning::SuperfluousElse );
     1306                        SemanticWarning( yylloc, Warning::SuperfluousElse, "" );
    13051307                }
    13061308        | FOR '(' for_control_expression_list ')' statement     %prec THEN
     
    15821584        ;
    15831585
    1584 // If MUTEX becomes a general qualifier, there are shift/reduce conflicts, so possibly change syntax to "with mutex".
     1586// If MUTEX becomes a general qualifier, there are shift/reduce conflicts, so change syntax to "with mutex".
    15851587mutex_statement:
    1586         MUTEX '(' argument_expression_list_opt ')' statement
    1587                 {
    1588                         if ( ! $3 ) { SemanticError( yylloc, "mutex argument list cannot be empty." ); $$ = nullptr; }
    1589                         $$ = new StatementNode( build_mutex( $3, $5 ) );
    1590                 }
     1588        MUTEX '(' argument_expression_list ')' statement
     1589                { $$ = new StatementNode( build_mutex( $3, $5 ) ); }
    15911590        ;
    15921591
     
    19421941                        // if type_specifier is an anon aggregate => name
    19431942                        typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "4" );
    1944                         $$ = $3->addType( $2 )->addTypedef();           // watchout frees $2 and $3
     1943                        $$ = $3->addType( $2 )->addTypedef();
    19451944                }
    19461945        | typedef_declaration pop ',' push declarator
     
    19861985                {
    19871986                        assert( $1->type );
    1988                         if ( $1->type->qualifiers.any() ) {                     // CV qualifiers ?
    1989                                 SemanticError( yylloc, "Useless type qualifier(s) in empty declaration." ); $$ = nullptr;
    1990                         }
    1991                         // enums are never empty declarations because there must have at least one enumeration.
    1992                         if ( $1->type->kind == TypeData::AggregateInst && $1->storageClasses.any() ) { // storage class ?
    1993                                 SemanticError( yylloc, "Useless storage qualifier(s) in empty aggregate declaration." ); $$ = nullptr;
     1987                        if ( $1->type->qualifiers.val != 0 ) {
     1988                                SemanticError( yylloc, "Useless type qualifier in empty declaration." ); $$ = nullptr;
    19941989                        }
    19951990                }
     
    20112006        | sue_declaration_specifier invalid_types
    20122007                {
    2013                         SemanticError( yylloc, ::toString( "Missing ';' after end of ",
    2014                                 $1->type->enumeration.name ? "enum" : AggregateDecl::aggrString( $1->type->aggregate.kind ),
    2015                                 " declaration" ) );
     2008                        SemanticError( yylloc,
     2009                                                  ::toString( "Missing ';' after end of ",
     2010                                                                          $1->type->enumeration.name ? "enum" : AggregateDecl::aggrString( $1->type->aggregate.kind ),
     2011                                                                          " declaration" ) );
    20162012                        $$ = nullptr;
    20172013                }
     
    25922588        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}'
    25932589                {
    2594                         if ( $3->storageClasses.val != 0 || $3->type->qualifiers.any() )
     2590                        if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 )
    25952591                        { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); }
    25962592
     
    26032599        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt
    26042600                {
    2605                         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." ); }
     2601                        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." ); }
    26062602                        typedefTable.makeTypedef( *$6 );
    26072603                }
     
    29902986        TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' '}'
    29912987                {
    2992                         SemanticWarning( yylloc, Warning::DeprecTraitSyntax );
     2988                        SemanticWarning( yylloc, Warning::DeprecTraitSyntax, "" );
    29932989                        $$ = DeclarationNode::newTrait( $2, $4, nullptr );
    29942990                }
     
    29972993        | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}'
    29982994                {
    2999                         SemanticWarning( yylloc, Warning::DeprecTraitSyntax );
     2995                        SemanticWarning( yylloc, Warning::DeprecTraitSyntax, "" );
    30002996                        $$ = DeclarationNode::newTrait( $2, $4, $8 );
    30012997                }
     
    30623058                { $$ = DeclarationNode::newDirectiveStmt( new StatementNode( build_directive( $1 ) ) ); }
    30633059        | declaration
    3064                 {
    3065                         // Variable declarations of anonymous types requires creating a unique type-name across multiple translation
    3066                         // unit, which is a dubious task, especially because C uses name rather than structural typing; hence it is
    3067                         // disallowed at the moment.
    3068                         if ( $1->linkage == LinkageSpec::Cforall && ! $1->storageClasses.is_static && $1->type && $1->type->kind == TypeData::AggregateInst ) {
    3069                                 if ( $1->type->aggInst.aggregate->kind == TypeData::Enum && $1->type->aggInst.aggregate->enumeration.anon ) {
    3070                                         SemanticError( yylloc, "extern anonymous enumeration is currently unimplemented." ); $$ = nullptr;
    3071                                 } else if ( $1->type->aggInst.aggregate->aggregate.anon ) { // handles struct or union
    3072                                         SemanticError( yylloc, "extern anonymous struct/union is currently unimplemented." ); $$ = nullptr;
    3073                                 }
    3074                         }
    3075                 }
    30763060        | IDENTIFIER IDENTIFIER
    30773061                { IdentifierBeforeIdentifier( *$1.str, *$2.str, " declaration" ); $$ = nullptr; }
     
    31193103        | type_qualifier_list
    31203104                {
    3121                         if ( $1->type->qualifiers.any() ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
     3105                        if ( $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
    31223106                        if ( $1->type->forall ) forall = true;          // remember generic type
    31233107                }
     
    31303114        | declaration_qualifier_list
    31313115                {
    3132                         if ( $1->type && $1->type->qualifiers.any() ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
     3116                        if ( $1->type && $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
    31333117                        if ( $1->type && $1->type->forall ) forall = true; // remember generic type
    31343118                }
     
    31413125        | declaration_qualifier_list type_qualifier_list
    31423126                {
    3143                         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." ); }
     3127                        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." ); }
    31443128                        if ( ($1->type && $1->type->forall) || ($2->type && $2->type->forall) ) forall = true; // remember generic type
    31453129                }
Note: See TracChangeset for help on using the changeset viewer.