Ignore:
Timestamp:
Dec 15, 2024, 10:11:40 PM (2 days ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
0497b6ba
Parents:
5786403
Message:

update SuperfluousDecl? warning, update field_declaring rules, comment casts, update CFA shorthand attribute to @[...]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r5786403 ra16f2b6  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Nov 15 15:01:33 2024
    13 // Update Count     : 6915
     12// Last Modified On : Sun Dec 15 21:30:38 2024
     13// Update Count     : 6933
    1414//
    1515
     
    199199
    200200DeclarationNode * fieldDecl( DeclarationNode * typeSpec, DeclarationNode * fieldList ) {
    201         if ( nullptr == fieldList ) {
    202                 if ( !( typeSpec->type && typeSpec->type->kind == TypeData::Aggregate ) ) {
    203                         stringstream ss;
     201        if ( fieldList == nullptr ) {
     202                if ( !( typeSpec->type && typeSpec->type->kind == TypeData::Aggregate ) ) { // int; no fieldList
    204203                        // printf( "fieldDecl1 typeSpec %p\n", typeSpec ); typeSpec->type->print( std::cout );
    205                         SemanticWarning( yylloc, Warning::SuperfluousDecl, ss.str().c_str() );
     204                        SemanticWarning( yylloc, Warning::SuperfluousDecl );
    206205                        return nullptr;
    207206                } // if
    208207                // printf( "fieldDecl2 typeSpec %p\n", typeSpec ); typeSpec->type->print( std::cout );
    209                 fieldList = DeclarationNode::newName( nullptr );
     208                fieldList = DeclarationNode::newName( nullptr ); // struct S { ... } no fieldList
    210209        } // if
    211210
     
    464463// declarations
    465464%type<decl> abstract_declarator abstract_ptr abstract_array abstract_function array_dimension multi_array_dimension
    466 %type<decl> abstract_parameter_declarator_opt abstract_parameter_declarator abstract_parameter_ptr abstract_parameter_array abstract_parameter_function array_parameter_dimension array_parameter_1st_dimension
    467 %type<decl> abstract_parameter_declaration
     465%type<decl> abstract_parameter_declarator_opt abstract_parameter_declarator abstract_parameter_ptr abstract_parameter_array
     466                        abstract_parameter_function array_parameter_dimension array_parameter_1st_dimension abstract_parameter_declaration
    468467
    469468%type<aggKey> aggregate_key aggregate_data aggregate_control
     
    492491%type<decl> exception_declaration
    493492
    494 %type<decl> field_declaration_list_opt field_declaration field_declaring_list_opt field_declarator field_abstract_list_opt field_abstract
     493%type<decl> field_declaration_list_opt field_declaration field_declaring_list field_declaring_list_opt field_declarator field_abstract_list_opt field_abstract
    495494%type<expr> field field_name_list field_name fraction_constants_opt
    496495
     
    978977        | '(' VIRTUAL type_no_function ')' cast_expression      // CFA
    979978                { $$ = new ExpressionNode( new ast::VirtualCastExpr( yylloc, maybeMoveBuild( $5 ), maybeMoveBuildType( $3 ) ) ); }
    980         | '(' RETURN type_no_function ')' cast_expression       // CFA
     979        | '(' RETURN type_no_function ')' cast_expression       // CFA (ASCRIPTION)
    981980                { $$ = new ExpressionNode( build_cast( yylloc, $3, $5, ast::ReturnCast ) ); }
    982         | '(' COERCE type_no_function ')' cast_expression       // CFA
     981        | '(' COERCE type_no_function ')' cast_expression       // CFA (COERCION)
    983982                { SemanticError( yylloc, "Coerce cast is currently unimplemented." ); $$ = nullptr; }
    984         | '(' qualifier_cast_list ')' cast_expression           // CFA
     983        | '(' qualifier_cast_list ')' cast_expression           // CFA, (modify CVs of cast_expression)
    985984                { SemanticError( yylloc, "Qualifier cast is currently unimplemented." ); $$ = nullptr; }
    986985//      | '(' type_no_function ')' tuple
     
    27012700        type_specifier field_declaring_list_opt ';'
    27022701                {
    2703                         // printf( "type_specifier1 %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" );
    27042702                        $$ = fieldDecl( $1, $2 );
    2705                         // printf( "type_specifier2 %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" );
    2706                         // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
    2707                         //   printf( "\tattr %s\n", attr->name.c_str() );
    2708                         // } // for
    27092703                }
    27102704        | type_specifier field_declaring_list_opt '}'           // invalid syntax rule
     
    27412735        // empty
    27422736                { $$ = nullptr; }
    2743         | field_declarator
     2737        | field_declaring_list
     2738        ;
     2739
     2740field_declaring_list:
     2741        field_declarator
    27442742        | field_declaring_list_opt ',' attribute_list_opt field_declarator
    27452743                { $$ = $1->set_last( $4->addQualifiers( $3 ) ); }
     
    35123510        | ATTRIBUTE '(' attribute_name_list ')'                         // CFA
    35133511                { $$ = $3; }
    3514         | ATTR '(' attribute_name_list ')'                                      // CFA
    3515                 { $$ = $3; }
    3516         | C23_ATTRIBUTE
     3512        | ATTR attribute_name_list ']'                                          // CFA, @[...]
     3513                { $$ = $2; }
     3514        | C23_ATTRIBUTE                                                                         // C23, [[...]], see lexer
    35173515                { $$ = DeclarationNode::newAttribute( $1 ); }
    35183516        ;
Note: See TracChangeset for help on using the changeset viewer.