Ignore:
Timestamp:
Oct 19, 2022, 4:43:26 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master
Children:
1a45263
Parents:
9cd5bd2 (diff), 135143ba (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:

Merge branch 'master' into pthread-emulation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r9cd5bd2 rdf6cc9d  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Aug 27 13:21:28 2022
    13 // Update Count     : 5661
     12// Last Modified On : Fri Oct 14 14:04:43 2022
     13// Update Count     : 5751
    1414//
    1515
     
    103103        // distribute declaration_specifier across all declared variables, e.g., static, const, but not __attribute__.
    104104        assert( declList );
    105 //      printf( "distAttr1 typeSpec %p\n", typeSpec ); typeSpec->print( std::cout );
     105        // printf( "distAttr1 typeSpec %p\n", typeSpec ); typeSpec->print( std::cout );
    106106        DeclarationNode * cur = declList, * cl = (new DeclarationNode)->addType( typeSpec );
    107 //      printf( "distAttr2 cl %p\n", cl ); cl->type->print( std::cout );
    108 //      cl->type->aggregate.name = cl->type->aggInst.aggregate->aggregate.name;
     107        // printf( "distAttr2 cl %p\n", cl ); cl->type->print( std::cout );
     108        // cl->type->aggregate.name = cl->type->aggInst.aggregate->aggregate.name;
    109109
    110110        for ( cur = dynamic_cast<DeclarationNode *>( cur->get_next() ); cur != nullptr; cur = dynamic_cast<DeclarationNode *>( cur->get_next() ) ) {
     
    112112        } // for
    113113        declList->addType( cl );
    114 //      printf( "distAttr3 declList %p\n", declList ); declList->print( std::cout, 0 );
     114        // printf( "distAttr3 declList %p\n", declList ); declList->print( std::cout, 0 );
    115115        return declList;
    116116} // distAttr
     
    248248} // forCtrl
    249249
     250static void IdentifierBeforeIdentifier( string & identifier1, string & identifier2, const char * kind ) {
     251        SemanticError( yylloc, ::toString( "Adjacent identifiers \"", identifier1, "\" and \"", identifier2, "\" are not meaningful in a", kind, ".\n"
     252                                   "Possible cause is misspelled type name or missing generic parameter." ) );
     253} // IdentifierBeforeIdentifier
     254
     255static void IdentifierBeforeType( string & identifier, const char * kind ) {
     256        SemanticError( yylloc, ::toString( "Identifier \"", identifier, "\" cannot appear before a ", kind, ".\n"
     257                                   "Possible cause is misspelled storage/CV qualifier, misspelled typename, or missing generic parameter." ) );
     258} // IdentifierBeforeType
     259
    250260bool forall = false;                                                                    // aggregate have one or more forall qualifiers ?
    251261
     
    295305%token TYPEDEF
    296306%token EXTERN STATIC AUTO REGISTER
    297 %token THREADLOCALGCC THREADLOCALC11                                            // GCC, C11
     307%token THREADLOCALGCC THREADLOCALC11                                    // GCC, C11
    298308%token INLINE FORTRAN                                                                   // C99, extension ISO/IEC 9899:1999 Section J.5.9(1)
    299309%token NORETURN                                                                                 // C11
     
    308318%token DECIMAL32 DECIMAL64 DECIMAL128                                   // GCC
    309319%token ZERO_T ONE_T                                                                             // CFA
    310 %token SIZEOF TYPEOF VALIST AUTO_TYPE                                   // GCC
     320%token SIZEOF TYPEOF VA_LIST VA_ARG AUTO_TYPE                   // GCC
    311321%token OFFSETOF BASETYPEOF TYPEID                                               // CFA
    312322%token ENUM STRUCT UNION
     
    399409// declarations
    400410%type<decl> abstract_declarator abstract_ptr abstract_array abstract_function array_dimension multi_array_dimension
    401 %type<decl> abstract_parameter_declarator abstract_parameter_ptr abstract_parameter_array abstract_parameter_function array_parameter_dimension array_parameter_1st_dimension
     411%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
    402412%type<decl> abstract_parameter_declaration
    403413
     
    651661        //      { SemanticError( yylloc, "Resume expression is currently unimplemented." ); $$ = nullptr; }
    652662        | IDENTIFIER IDENTIFIER                                                         // syntax error
    653                 {
    654                         SemanticError( yylloc, ::toString( "Adjacent identifiers are not meaningful in an expression. "
    655                                                                                            "Possible problem is identifier \"", *$1.str,
    656                                                                                            "\" is a misspelled typename or an incorrectly specified type name, "
    657                                                                                            "e.g., missing generic parameter or missing struct/union/enum before typename." ) );
    658                         $$ = nullptr;
    659                 }
    660         | IDENTIFIER direct_type                                                        // syntax error
    661                 {
    662                         SemanticError( yylloc, ::toString( "Identifier \"", *$1.str, "\" cannot appear before a type. "
    663                                                                                            "Possible problem is misspelled storage or CV qualifier." ) );
    664                         $$ = nullptr;
    665                 }
     663                { IdentifierBeforeIdentifier( *$1.str, *$2.str, "n expression" ); $$ = nullptr; }
     664        | IDENTIFIER type_qualifier                                                     // syntax error
     665                { IdentifierBeforeType( *$1.str, "type qualifier" ); $$ = nullptr; }
     666        | IDENTIFIER storage_class                                                      // syntax error
     667                { IdentifierBeforeType( *$1.str, "storage class" ); $$ = nullptr; }
     668        | IDENTIFIER basic_type_name                                            // syntax error
     669                { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; }
     670        | IDENTIFIER TYPEDEFname                                                        // syntax error
     671                { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; }
     672        | IDENTIFIER TYPEGENname                                                        // syntax error
     673                { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; }
    666674        ;
    667675
     
    690698        primary_expression
    691699        | postfix_expression '[' assignment_expression ',' tuple_expression_list ']'
    692                         // Historic, transitional: Disallow commas in subscripts.
    693                         // Switching to this behaviour may help check if a C compatibilty case uses comma-exprs in subscripts.
    694                         // Current: Commas in subscripts make tuples.
     700                // Historic, transitional: Disallow commas in subscripts.
     701                // Switching to this behaviour may help check if a C compatibilty case uses comma-exprs in subscripts.
     702                // Current: Commas in subscripts make tuples.
    695703                { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $5 ) ) )) ) ); }
    696704        | postfix_expression '[' assignment_expression ']'
     
    712720        | postfix_expression '(' argument_expression_list_opt ')'
    713721                { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
     722        | VA_ARG '(' primary_expression ',' declaration_specifier_nobody abstract_parameter_declarator_opt ')'
     723                // { SemanticError( yylloc, "va_arg is currently unimplemented." ); $$ = nullptr; }
     724                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( new string( "__builtin_va_arg") ) ),
     725                                                                                           (ExpressionNode *)($3->set_last( (ExpressionNode *)($6 ? $6->addType( $5 ) : $5) )) ) ); }
    714726        | postfix_expression '`' identifier                                     // CFA, postfix call
    715727                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), $1 ) ); }
     
    21482160        | LONG
    21492161                { $$ = DeclarationNode::newLength( DeclarationNode::Long ); }
    2150         | VALIST                                                                                        // GCC, __builtin_va_list
     2162        | VA_LIST                                                                                       // GCC, __builtin_va_list
    21512163                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
    21522164        | AUTO_TYPE
     
    25932605                { $$ = DeclarationNode::newEnumValueGeneric( $1, $2 ); }
    25942606        | INLINE type_name
    2595                 { $$ = DeclarationNode::newEnumValueGeneric( new string("inline"), nullptr ); }
     2607                { $$ = DeclarationNode::newEnumInLine( *$2->type->symbolic.name ); }
    25962608        | enumerator_list ',' identifier_or_type_name enumerator_value_opt
    25972609                { $$ = $1->appendList( DeclarationNode::newEnumValueGeneric( $3, $4 ) ); }
     
    29933005                { $$ = DeclarationNode::newDirectiveStmt( new StatementNode( build_directive( $1 ) ) ); }
    29943006        | declaration
     3007        | IDENTIFIER IDENTIFIER
     3008                { IdentifierBeforeIdentifier( *$1.str, *$2.str, " declaration" ); $$ = nullptr; }
     3009        | IDENTIFIER type_qualifier                                                     // syntax error
     3010                { IdentifierBeforeType( *$1.str, "type qualifier" ); $$ = nullptr; }
     3011        | IDENTIFIER storage_class                                                      // syntax error
     3012                { IdentifierBeforeType( *$1.str, "storage class" ); $$ = nullptr; }
     3013        | IDENTIFIER basic_type_name                                            // syntax error
     3014                { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; }
     3015        | IDENTIFIER TYPEDEFname                                                        // syntax error
     3016                { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; }
     3017        | IDENTIFIER TYPEGENname                                                        // syntax error
     3018                { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; }
    29953019        | external_function_definition
    29963020        | EXTENSION external_definition                                         // GCC, multiple __extension__ allowed, meaning unknown
     
    30233047                        $$ = $6;
    30243048                }
     3049        // global distribution
    30253050        | type_qualifier_list
    30263051                {
     
    30473072        | declaration_qualifier_list type_qualifier_list
    30483073                {
    3049                         if ( ($1->type && $1->type->qualifiers.val) || $2->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
    3050                         if ( ($1->type && $1->type->forall) || $2->type->forall ) forall = true; // remember generic type
     3074                        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." ); }
     3075                        if ( ($1->type && $1->type->forall) || ($2->type && $2->type->forall) ) forall = true; // remember generic type
    30513076                }
    30523077          '{' up external_definition_list_opt down '}'          // CFA, namespace
     
    36553680// functions.
    36563681
     3682abstract_parameter_declarator_opt:
     3683        // empty
     3684                { $$ = nullptr; }
     3685        | abstract_parameter_declarator
     3686        ;
     3687
    36573688abstract_parameter_declarator:
    36583689        abstract_parameter_ptr
Note: See TracChangeset for help on using the changeset viewer.