- Timestamp:
- Mar 24, 2023, 4:51:11 PM (3 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 512d937c
- Parents:
- 0e16a2d (diff), 1633e04 (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. - Location:
- src
- Files:
-
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Print.cpp
r0e16a2d r75d874a 369 369 --indent; 370 370 } 371 } 372 373 if ( ! node->withExprs.empty() ) { 374 // Not with a clause, but the 'with clause'. 375 ++indent; 376 os << " with clause" << endl << indent; 377 printAll( node->withExprs ); 378 --indent; 371 379 } 372 380 -
src/Common/module.mk
r0e16a2d r75d874a 20 20 Common/CodeLocationTools.hpp \ 21 21 Common/CodeLocationTools.cpp \ 22 Common/Debug.h \23 22 Common/DeclStats.hpp \ 24 23 Common/DeclStats.cpp \ -
src/Common/utility.h
r0e16a2d r75d874a 190 190 } 191 191 192 template< typename... Params >193 void warn( const Params & ... params ) {194 std::cerr << "Warning: ";195 toString_single( std::cerr, params... );196 std::cerr << std::endl;197 }198 199 192 // determines if pref is a prefix of str 200 193 static inline bool isPrefix( const std::string & str, const std::string & pref, unsigned int start = 0 ) { -
src/InitTweak/FixInit.cc
r0e16a2d r75d874a 1233 1233 } 1234 1234 1235 template< typename Visitor, typename... Params >1236 void error( Visitor & v, CodeLocation loc, const Params &... params ) {1237 SemanticErrorException err( loc, toString( params... ) );1238 v.errors.append( err );1239 }1240 1241 1235 template< typename... Params > 1242 1236 void GenStructMemberCalls::emit( CodeLocation loc, const Params &... params ) { 1243 // toggle warnings vs. errors here. 1244 // warn( params... ); 1245 error( *this, loc, params... ); 1237 SemanticErrorException err( loc, toString( params... ) ); 1238 errors.append( err ); 1246 1239 } 1247 1240 -
src/InitTweak/FixInitNew.cpp
r0e16a2d r75d874a 1303 1303 } 1304 1304 1305 template< typename Visitor, typename... Params >1306 void error( Visitor & v, CodeLocation loc, const Params &... params ) {1307 SemanticErrorException err( loc, toString( params... ) );1308 v.errors.append( err );1309 }1310 1311 1305 template< typename... Params > 1312 1306 void GenStructMemberCalls::emit( CodeLocation loc, const Params &... params ) { 1313 // toggle warnings vs. errors here. 1314 // warn( params... ); 1315 error( *this, loc, params... ); 1307 SemanticErrorException err( loc, toString( params... ) ); 1308 errors.append( err ); 1316 1309 } 1317 1310 -
src/Parser/parser.yy
r0e16a2d r75d874a 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 14 09:37:58202313 // Update Count : 599012 // Last Modified On : Wed Mar 22 21:26:01 2023 13 // Update Count : 6002 14 14 // 15 15 … … 270 270 SemanticError( yylloc, ::toString( "Identifier \"", identifier, "\" cannot appear before a ", kind, ".\n" 271 271 "Possible cause is misspelled storage/CV qualifier, misspelled typename, or missing generic parameter." ) ); 272 } // IdentifierBeforeType 273 274 static bool TypedefForall( DeclarationNode * decl ) { 275 if ( decl->type->forall || (decl->type->kind == TypeData::Aggregate && decl->type->aggregate.params) ) { 276 SemanticError( yylloc, "forall qualifier in typedef is currently unimplemented." ); 277 return true; 278 } // if 279 return false; 272 280 } // IdentifierBeforeType 273 281 … … 496 504 %type<decl> typedef_name typedef_declaration typedef_expression 497 505 498 %type<decl> variable_type_redeclarator type_ptr type_array type_function 506 %type<decl> variable_type_redeclarator variable_type_ptr variable_type_array variable_type_function 507 %type<decl> general_function_declarator function_type_redeclarator function_type_array function_type_no_ptr function_type_ptr 499 508 500 509 %type<decl> type_parameter_redeclarator type_parameter_ptr type_parameter_array type_parameter_function … … 1957 1966 TYPEDEF type_specifier declarator 1958 1967 { 1959 // if type_specifier is an anon aggregate => name1960 1968 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "4" ); 1961 $$ = $3->addType( $2 )->addTypedef(); // watchout frees $2 and $3 1969 if ( TypedefForall( $2 ) ) $$ = nullptr; 1970 else $$ = $3->addType( $2 )->addTypedef(); // watchout frees $2 and $3 1962 1971 } 1963 1972 | typedef_declaration pop ',' push declarator … … 1969 1978 { 1970 1979 typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname, "6" ); 1971 $$ = $4->addQualifiers( $1 )->addType( $3 )->addTypedef(); 1980 if ( TypedefForall( $1 ) ) $$ = nullptr; 1981 else $$ = $4->addQualifiers( $1 )->addType( $3 )->addTypedef(); 1972 1982 } 1973 1983 | type_specifier TYPEDEF declarator 1974 1984 { 1975 1985 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "7" ); 1976 $$ = $3->addType( $1 )->addTypedef(); 1986 if ( TypedefForall( $1 ) ) $$ = nullptr; 1987 else $$ = $3->addType( $1 )->addTypedef(); 1977 1988 } 1978 1989 | type_specifier TYPEDEF type_qualifier_list declarator 1979 1990 { 1980 1991 typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname, "8" ); 1981 $$ = $4->addQualifiers( $1 )->addType( $1 )->addTypedef(); 1992 if ( TypedefForall( $3 ) ) $$ = nullptr; 1993 else $$ = $4->addQualifiers( $1 )->addType( $1 )->addTypedef(); 1982 1994 } 1983 1995 ; … … 2016 2028 // A semantic check is required to ensure asm_name only appears on declarations with implicit or explicit static 2017 2029 // storage-class 2018 declarator asm_name_opt initializer_opt2030 variable_declarator asm_name_opt initializer_opt 2019 2031 { $$ = $1->addAsmName( $2 )->addInitializer( $3 ); } 2032 | variable_type_redeclarator asm_name_opt initializer_opt 2033 { $$ = $1->addAsmName( $2 )->addInitializer( $3 ); } 2034 2035 | general_function_declarator asm_name_opt 2036 { $$ = $1->addAsmName( $2 )->addInitializer( nullptr ); } 2037 | general_function_declarator asm_name_opt '=' VOID 2038 { $$ = $1->addAsmName( $2 )->addInitializer( new InitializerNode( true ) ); } 2039 2020 2040 | declaring_list ',' attribute_list_opt declarator asm_name_opt initializer_opt 2021 2041 { $$ = $1->appendList( $4->addQualifiers( $3 )->addAsmName( $5 )->addInitializer( $6 ) ); } 2042 ; 2043 2044 general_function_declarator: 2045 function_type_redeclarator 2046 | function_declarator 2022 2047 ; 2023 2048 … … 2543 2568 // A semantic check is required to ensure bit_subrange only appears on integral types. 2544 2569 { $$ = $1->addBitfield( $2 ); } 2570 | function_type_redeclarator bit_subrange_size_opt 2571 // A semantic check is required to ensure bit_subrange only appears on integral types. 2572 { $$ = $1->addBitfield( $2 ); } 2545 2573 ; 2546 2574 … … 3195 3223 $$ = $2->addFunctionBody( $4, $3 )->addType( $1 ); 3196 3224 } 3197 | declaration_specifier variable_type_redeclarator with_clause_opt compound_statement3225 | declaration_specifier function_type_redeclarator with_clause_opt compound_statement 3198 3226 { 3199 3227 rebindForall( $1, $2 ); … … 3231 3259 | variable_type_redeclarator 3232 3260 | function_declarator 3261 | function_type_redeclarator 3233 3262 ; 3234 3263 … … 3481 3510 ; 3482 3511 3483 // This pattern parses a declaration for a variable or function prototypethat redefines a type name, e.g.:3512 // This pattern parses a declaration for a variable that redefines a type name, e.g.: 3484 3513 // 3485 3514 // typedef int foo; … … 3487 3516 // int foo; // redefine typedef name in new scope 3488 3517 // } 3489 //3490 // The pattern precludes declaring an array of functions versus a pointer to an array of functions, and returning arrays3491 // and functions versus pointers to arrays and functions.3492 3518 3493 3519 paren_type: … … 3504 3530 paren_type attribute_list_opt 3505 3531 { $$ = $1->addQualifiers( $2 ); } 3506 | type_ptr3507 | type_array attribute_list_opt3532 | variable_type_ptr 3533 | variable_type_array attribute_list_opt 3508 3534 { $$ = $1->addQualifiers( $2 ); } 3509 | type_function attribute_list_opt3535 | variable_type_function attribute_list_opt 3510 3536 { $$ = $1->addQualifiers( $2 ); } 3511 3537 ; 3512 3538 3513 type_ptr:3539 variable_type_ptr: 3514 3540 ptrref_operator variable_type_redeclarator 3515 3541 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3516 3542 | ptrref_operator type_qualifier_list variable_type_redeclarator 3517 3543 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 3518 | '(' type_ptr ')' attribute_list_opt// redundant parenthesis3544 | '(' variable_type_ptr ')' attribute_list_opt // redundant parenthesis 3519 3545 { $$ = $2->addQualifiers( $4 ); } 3520 | '(' attribute_list type_ptr ')' attribute_list_opt // redundant parenthesis3546 | '(' attribute_list variable_type_ptr ')' attribute_list_opt // redundant parenthesis 3521 3547 { $$ = $3->addQualifiers( $2 )->addQualifiers( $5 ); } 3522 3548 ; 3523 3549 3524 type_array:3550 variable_type_array: 3525 3551 paren_type array_dimension 3526 3552 { $$ = $1->addArray( $2 ); } 3527 | '(' type_ptr ')' array_dimension3553 | '(' variable_type_ptr ')' array_dimension 3528 3554 { $$ = $2->addArray( $4 ); } 3529 | '(' attribute_list type_ptr ')' array_dimension3555 | '(' attribute_list variable_type_ptr ')' array_dimension 3530 3556 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); } 3531 | '(' type_array ')' multi_array_dimension// redundant parenthesis3557 | '(' variable_type_array ')' multi_array_dimension // redundant parenthesis 3532 3558 { $$ = $2->addArray( $4 ); } 3533 | '(' attribute_list type_array ')' multi_array_dimension // redundant parenthesis3559 | '(' attribute_list variable_type_array ')' multi_array_dimension // redundant parenthesis 3534 3560 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); } 3535 | '(' type_array ')'// redundant parenthesis3561 | '(' variable_type_array ')' // redundant parenthesis 3536 3562 { $$ = $2; } 3537 | '(' attribute_list type_array ')'// redundant parenthesis3563 | '(' attribute_list variable_type_array ')' // redundant parenthesis 3538 3564 { $$ = $3->addQualifiers( $2 ); } 3539 3565 ; 3540 3566 3541 type_function: 3567 variable_type_function: 3568 '(' variable_type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3569 { $$ = $2->addParamList( $6 ); } 3570 | '(' attribute_list variable_type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3571 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); } 3572 | '(' variable_type_function ')' // redundant parenthesis 3573 { $$ = $2; } 3574 | '(' attribute_list variable_type_function ')' // redundant parenthesis 3575 { $$ = $3->addQualifiers( $2 ); } 3576 ; 3577 3578 // This pattern parses a declaration for a function prototype that redefines a type name. It precludes declaring an 3579 // array of functions versus a pointer to an array of functions, and returning arrays and functions versus pointers to 3580 // arrays and functions. 3581 3582 function_type_redeclarator: 3583 function_type_no_ptr attribute_list_opt 3584 { $$ = $1->addQualifiers( $2 ); } 3585 | function_type_ptr 3586 | function_type_array attribute_list_opt 3587 { $$ = $1->addQualifiers( $2 ); } 3588 ; 3589 3590 function_type_no_ptr: 3542 3591 paren_type '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3543 3592 { $$ = $1->addParamList( $4 ); } 3544 | '(' type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)3593 | '(' function_type_ptr ')' '(' push parameter_type_list_opt pop ')' 3545 3594 { $$ = $2->addParamList( $6 ); } 3546 | '(' attribute_list type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)3595 | '(' attribute_list function_type_ptr ')' '(' push parameter_type_list_opt pop ')' 3547 3596 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); } 3548 | '(' type_function ')'// redundant parenthesis3597 | '(' function_type_no_ptr ')' // redundant parenthesis 3549 3598 { $$ = $2; } 3550 | '(' attribute_list type_function ')' // redundant parenthesis 3599 | '(' attribute_list function_type_no_ptr ')' // redundant parenthesis 3600 { $$ = $3->addQualifiers( $2 ); } 3601 ; 3602 3603 function_type_ptr: 3604 ptrref_operator function_type_redeclarator 3605 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3606 | ptrref_operator type_qualifier_list function_type_redeclarator 3607 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 3608 | '(' function_type_ptr ')' attribute_list_opt 3609 { $$ = $2->addQualifiers( $4 ); } 3610 | '(' attribute_list function_type_ptr ')' attribute_list_opt 3611 { $$ = $3->addQualifiers( $2 )->addQualifiers( $5 ); } 3612 ; 3613 3614 function_type_array: 3615 '(' function_type_ptr ')' array_dimension 3616 { $$ = $2->addArray( $4 ); } 3617 | '(' attribute_list function_type_ptr ')' array_dimension 3618 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); } 3619 | '(' function_type_array ')' multi_array_dimension // redundant parenthesis 3620 { $$ = $2->addArray( $4 ); } 3621 | '(' attribute_list function_type_array ')' multi_array_dimension // redundant parenthesis 3622 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); } 3623 | '(' function_type_array ')' // redundant parenthesis 3624 { $$ = $2; } 3625 | '(' attribute_list function_type_array ')' // redundant parenthesis 3551 3626 { $$ = $3->addQualifiers( $2 ); } 3552 3627 ; -
src/SynTree/FunctionDecl.cc
r0e16a2d r75d874a 87 87 } // if 88 88 89 if ( !withExprs.empty() ) { 90 os << indent << "... with clause" << std::endl; 91 os << indent + 1; 92 printAll( withExprs, os, indent + 1 ); 93 } 94 89 95 if ( statements ) { 90 96 os << indent << "... with body" << endl << indent+1;
Note:
See TracChangeset
for help on using the changeset viewer.