Changes in src/Parser/parser.yy [46da46b:c86b08d]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (144 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r46da46b rc86b08d 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Nov 21 22:34:30 202213 // Update Count : 584811 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Apr 4 14:02:00 2023 13 // Update Count : 6329 14 14 // 15 15 … … 44 44 45 45 #include <cstdio> 46 #include <sstream> 46 47 #include <stack> 47 48 using namespace std; … … 55 56 #include "Common/utility.h" // for maybeMoveBuild, maybeBuild, CodeLo... 56 57 57 #include "SynTree/Attribute.h" // for Attribute58 #include "SynTree/Attribute.h" // for Attribute 58 59 59 60 // lex uses __null in a boolean context, it's fine. … … 63 64 64 65 extern DeclarationNode * parseTree; 65 extern LinkageSpec::Spec linkage;66 extern ast::Linkage::Spec linkage; 66 67 extern TypedefTable typedefTable; 67 68 68 stack< LinkageSpec::Spec> linkageStack;69 stack<ast::Linkage::Spec> linkageStack; 69 70 70 71 bool appendStr( string & to, string & from ) { … … 199 200 } // fieldDecl 200 201 201 #define NEW_ZERO new ExpressionNode( build_constantInteger( *new string( "0" ) ) )202 #define NEW_ONE new ExpressionNode( build_constantInteger( *new string( "1" ) ) )202 #define NEW_ZERO new ExpressionNode( build_constantInteger( yylloc, *new string( "0" ) ) ) 203 #define NEW_ONE new ExpressionNode( build_constantInteger( yylloc, *new string( "1" ) ) ) 203 204 #define UPDOWN( compop, left, right ) (compop == OperKinds::LThan || compop == OperKinds::LEThan ? left : right) 204 205 #define MISSING_ANON_FIELD "Missing loop fields with an anonymous loop index is meaningless as loop index is unavailable in loop body." … … 206 207 #define MISSING_HIGH "Missing high value for down-to range so index is uninitialized." 207 208 208 ForCtrl * forCtrl( DeclarationNode * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) { 209 static ForCtrl * makeForCtrl( 210 const CodeLocation & location, 211 DeclarationNode * init, 212 enum OperKinds compop, 213 ExpressionNode * comp, 214 ExpressionNode * inc ) { 215 // Wrap both comp/inc if they are non-null. 216 if ( comp ) comp = new ExpressionNode( build_binary_val( location, 217 compop, 218 new ExpressionNode( build_varref( location, new string( *init->name ) ) ), 219 comp ) ); 220 if ( inc ) inc = new ExpressionNode( build_binary_val( location, 221 // choose += or -= for upto/downto 222 compop == OperKinds::LThan || compop == OperKinds::LEThan ? OperKinds::PlusAssn : OperKinds::MinusAssn, 223 new ExpressionNode( build_varref( location, new string( *init->name ) ) ), 224 inc ) ); 225 // The StatementNode call frees init->name, it must happen later. 226 return new ForCtrl( new StatementNode( init ), comp, inc ); 227 } 228 229 ForCtrl * forCtrl( const CodeLocation & location, DeclarationNode * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) { 209 230 if ( index->initializer ) { 210 231 SemanticError( yylloc, "Direct initialization disallowed. Use instead: type var; initialization ~ comparison ~ increment." ); … … 213 234 SemanticError( yylloc, "Multiple loop indexes disallowed in for-loop declaration." ); 214 235 } // if 215 return new ForCtrl( index->addInitializer( new InitializerNode( start ) ), 216 // NULL comp/inc => leave blank 217 comp ? new ExpressionNode( build_binary_val( compop, new ExpressionNode( build_varref( new string( *index->name ) ) ), comp ) ) : nullptr, 218 inc ? new ExpressionNode( build_binary_val( compop == OperKinds::LThan || compop == OperKinds::LEThan ? // choose += or -= for upto/downto 219 OperKinds::PlusAssn : OperKinds::MinusAssn, new ExpressionNode( build_varref( new string( *index->name ) ) ), inc ) ) : nullptr ); 236 DeclarationNode * initDecl = index->addInitializer( new InitializerNode( start ) ); 237 return makeForCtrl( location, initDecl, compop, comp, inc ); 220 238 } // forCtrl 221 239 222 ForCtrl * forCtrl( ExpressionNode * type, string * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) {223 ConstantExpr * constant = dynamic_cast<ConstantExpr *>(type->expr.get());224 if ( constant && (constant-> get_constant()->get_value() == "0" || constant->get_constant()->get_value()== "1") ) {225 type = new ExpressionNode( new CastExpr( maybeMoveBuild<Expression>(type), new BasicType( Type::Qualifiers(),BasicType::SignedInt ) ) );240 ForCtrl * forCtrl( const CodeLocation & location, ExpressionNode * type, string * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) { 241 ast::ConstantExpr * constant = dynamic_cast<ast::ConstantExpr *>(type->expr.get()); 242 if ( constant && (constant->rep == "0" || constant->rep == "1") ) { 243 type = new ExpressionNode( new ast::CastExpr( location, maybeMoveBuild(type), new ast::BasicType( ast::BasicType::SignedInt ) ) ); 226 244 } // if 227 // type = new ExpressionNode( build_func( new ExpressionNode( build_varref( new string( "__for_control_index_constraints__" ) ) ), type ) ); 228 return new ForCtrl( 229 distAttr( DeclarationNode::newTypeof( type, true ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ), 230 // NULL comp/inc => leave blank 231 comp ? new ExpressionNode( build_binary_val( compop, new ExpressionNode( build_varref( new string( *index ) ) ), comp ) ) : nullptr, 232 inc ? new ExpressionNode( build_binary_val( compop == OperKinds::LThan || compop == OperKinds::LEThan ? // choose += or -= for upto/downto 233 OperKinds::PlusAssn : OperKinds::MinusAssn, new ExpressionNode( build_varref( new string( *index ) ) ), inc ) ) : nullptr ); 245 DeclarationNode * initDecl = distAttr( 246 DeclarationNode::newTypeof( type, true ), 247 DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) 248 ); 249 return makeForCtrl( location, initDecl, compop, comp, inc ); 234 250 } // forCtrl 235 251 236 ForCtrl * forCtrl( ExpressionNode * type, ExpressionNode * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) {237 if ( NameExpr * identifier = dynamic_cast<NameExpr *>(index->expr.get()) ) {238 return forCtrl( type, new string( identifier->name ), start, compop, comp, inc );239 } else if ( CommaExpr * commaExpr = dynamic_cast<CommaExpr *>(index->expr.get()) ) {240 if ( NameExpr * identifier = dynamic_cast<NameExpr *>(commaExpr->arg1) ) {241 return forCtrl( type, new string( identifier->name ), start, compop, comp, inc );252 ForCtrl * forCtrl( const CodeLocation & location, ExpressionNode * type, ExpressionNode * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) { 253 if ( auto identifier = dynamic_cast<ast::NameExpr *>(index->expr.get()) ) { 254 return forCtrl( location, type, new string( identifier->name ), start, compop, comp, inc ); 255 } else if ( auto commaExpr = dynamic_cast<ast::CommaExpr *>( index->expr.get() ) ) { 256 if ( auto identifier = commaExpr->arg1.as<ast::NameExpr>() ) { 257 return forCtrl( location, type, new string( identifier->name ), start, compop, comp, inc ); 242 258 } else { 243 259 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed." ); return nullptr; … … 284 300 ExpressionNode * en; 285 301 DeclarationNode * decl; 286 AggregateDecl::Aggregate aggKey;287 TypeDecl::Kind tclass;302 ast::AggregateDecl::Aggregate aggKey; 303 ast::TypeDecl::Kind tclass; 288 304 StatementNode * sn; 289 WaitForStmt * wfs; 290 Expression * constant; 305 ast::WaitForStmt * wfs; 306 ast::WaitUntilStmt::ClauseNode * wuscn; 307 ast::Expr * constant; 291 308 CondCtl * ifctl; 292 309 ForCtrl * fctl; … … 298 315 bool flag; 299 316 EnumHiding hide; 300 CatchStmt::Kind catch_kind;301 GenericExpr * genexpr;317 ast::ExceptionKind catch_kind; 318 ast::GenericExpr * genexpr; 302 319 } 303 320 304 // ************************* TERMINAL TOKENS ********************************321 // ************************ TERMINAL TOKENS ******************************** 305 322 306 323 // keywords … … 331 348 %token ATTRIBUTE EXTENSION // GCC 332 349 %token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN 333 %token CHOOSE FALLTHRU FALLTHROUGH WITH WHEN WAITFOR // CFA350 %token CHOOSE FALLTHRU FALLTHROUGH WITH WHEN WAITFOR WAITUNTIL // CFA 334 351 %token DISABLE ENABLE TRY THROW THROWRESUME AT // CFA 335 352 %token ASM // C99, extension ISO/IEC 9899:1999 Section J.5.10(1) … … 337 354 338 355 // names and constants: lexer differentiates between identifier and typedef names 339 %token<tok> IDENTIFIER QUOTED_IDENTIFIERTYPEDIMname TYPEDEFname TYPEGENname340 %token<tok> TIMEOUT W ORCATCH RECOVER CATCHRESUME FIXUP FINALLY // CFA356 %token<tok> IDENTIFIER TYPEDIMname TYPEDEFname TYPEGENname 357 %token<tok> TIMEOUT WAND WOR CATCH RECOVER CATCHRESUME FIXUP FINALLY // CFA 341 358 %token<tok> INTEGERconstant CHARACTERconstant STRINGliteral 342 359 %token<tok> DIRECTIVE … … 407 424 %type<catch_kind> handler_key 408 425 %type<sn> mutex_statement 409 %type<en> when_clause when_clause_opt waitfor timeout 410 %type<sn> waitfor_statement 411 %type<wfs> waitfor_clause 426 %type<en> when_clause when_clause_opt waitfor waituntil timeout 427 %type<sn> waitfor_statement waituntil_statement 428 %type<wfs> wor_waitfor_clause 429 %type<wuscn> waituntil_clause wand_waituntil_clause wor_waituntil_clause 412 430 413 431 // declarations … … 482 500 %type<decl> typedef_name typedef_declaration typedef_expression 483 501 484 %type<decl> variable_type_redeclarator type_ptr type_array type_function 502 %type<decl> variable_type_redeclarator variable_type_ptr variable_type_array variable_type_function 503 %type<decl> general_function_declarator function_type_redeclarator function_type_array function_type_no_ptr function_type_ptr 485 504 486 505 %type<decl> type_parameter_redeclarator type_parameter_ptr type_parameter_array type_parameter_function … … 512 531 // Similar issues exit with the waitfor statement. 513 532 514 // Order of these lines matters (low-to-high precedence). THEN is left associative over W OR/TIMEOUT/ELSE, WOR is left515 // associative over TIMEOUT/ELSE, and TIMEOUT is left associative over ELSE.533 // Order of these lines matters (low-to-high precedence). THEN is left associative over WAND/WOR/TIMEOUT/ELSE, WAND/WOR 534 // is left associative over TIMEOUT/ELSE, and TIMEOUT is left associative over ELSE. 516 535 %precedence THEN // rule precedence for IF/WAITFOR statement 536 %precedence ANDAND // token precedence for start of WAND in WAITFOR statement 537 %precedence WAND // token precedence for start of WAND in WAITFOR statement 538 %precedence OROR // token precedence for start of WOR in WAITFOR statement 517 539 %precedence WOR // token precedence for start of WOR in WAITFOR statement 518 540 %precedence TIMEOUT // token precedence for start of TIMEOUT in WAITFOR statement … … 592 614 constant: 593 615 // ENUMERATIONconstant is not included here; it is treated as a variable with type "enumeration constant". 594 INTEGERconstant { $$ = new ExpressionNode( build_constantInteger( *$1 ) ); }595 | FLOATING_DECIMALconstant { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); }596 | FLOATING_FRACTIONconstant { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); }597 | FLOATINGconstant { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); }598 | CHARACTERconstant { $$ = new ExpressionNode( build_constantChar( *$1 ) ); }616 INTEGERconstant { $$ = new ExpressionNode( build_constantInteger( yylloc, *$1 ) ); } 617 | FLOATING_DECIMALconstant { $$ = new ExpressionNode( build_constantFloat( yylloc, *$1 ) ); } 618 | FLOATING_FRACTIONconstant { $$ = new ExpressionNode( build_constantFloat( yylloc, *$1 ) ); } 619 | FLOATINGconstant { $$ = new ExpressionNode( build_constantFloat( yylloc, *$1 ) ); } 620 | CHARACTERconstant { $$ = new ExpressionNode( build_constantChar( yylloc, *$1 ) ); } 599 621 ; 600 622 601 623 quasi_keyword: // CFA 602 624 TIMEOUT 625 | WAND 603 626 | WOR 604 627 | CATCH … … 621 644 622 645 string_literal: 623 string_literal_list { $$ = build_constantStr( *$1 ); }646 string_literal_list { $$ = build_constantStr( yylloc, *$1 ); } 624 647 ; 625 648 … … 638 661 primary_expression: 639 662 IDENTIFIER // typedef name cannot be used as a variable name 640 { $$ = new ExpressionNode( build_varref( $1 ) ); }663 { $$ = new ExpressionNode( build_varref( yylloc, $1 ) ); } 641 664 | quasi_keyword 642 { $$ = new ExpressionNode( build_varref( $1 ) ); }665 { $$ = new ExpressionNode( build_varref( yylloc, $1 ) ); } 643 666 | TYPEDIMname // CFA, generic length argument 644 667 // { $$ = new ExpressionNode( new TypeExpr( maybeMoveBuildType( DeclarationNode::newFromTypedef( $1 ) ) ) ); } 645 668 // { $$ = new ExpressionNode( build_varref( $1 ) ); } 646 { $$ = new ExpressionNode( build_dimensionref( $1 ) ); }669 { $$ = new ExpressionNode( build_dimensionref( yylloc, $1 ) ); } 647 670 | tuple 648 671 | '(' comma_expression ')' 649 672 { $$ = $2; } 650 673 | '(' compound_statement ')' // GCC, lambda expression 651 { $$ = new ExpressionNode( new StmtExpr( dynamic_cast<CompoundStmt *>(maybeMoveBuild<Statement>($2) ) ) ); }674 { $$ = new ExpressionNode( new ast::StmtExpr( yylloc, dynamic_cast<ast::CompoundStmt *>( maybeMoveBuild( $2 ) ) ) ); } 652 675 | type_name '.' identifier // CFA, nested type 653 { $$ = new ExpressionNode( build_qualified_expr( $1, build_varref($3 ) ) ); }676 { $$ = new ExpressionNode( build_qualified_expr( yylloc, $1, build_varref( yylloc, $3 ) ) ); } 654 677 | type_name '.' '[' field_name_list ']' // CFA, nested type / tuple field selector 655 678 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } … … 657 680 { 658 681 // add the missing control expression to the GenericExpr and return it 659 $5->control = maybeMoveBuild <Expression>( $3 );682 $5->control = maybeMoveBuild( $3 ); 660 683 $$ = new ExpressionNode( $5 ); 661 684 } … … 683 706 { 684 707 // steal the association node from the singleton and delete the wrapper 685 $1->associations.splice($1->associations.end(), $3->associations); 708 assert( 1 == $3->associations.size() ); 709 $1->associations.push_back( $3->associations.front() ); 686 710 delete $3; 687 711 $$ = $1; … … 693 717 { 694 718 // create a GenericExpr wrapper with one association pair 695 $$ = new GenericExpr( nullptr, { { maybeMoveBuildType($1), maybeMoveBuild<Expression>( $3 ) } } );719 $$ = new ast::GenericExpr( yylloc, nullptr, { { maybeMoveBuildType( $1 ), maybeMoveBuild( $3 ) } } ); 696 720 } 697 721 | DEFAULT ':' assignment_expression 698 { $$ = new GenericExpr( nullptr, { { maybeMoveBuild<Expression>( $3 ) } } ); }722 { $$ = new ast::GenericExpr( yylloc, nullptr, { { maybeMoveBuild( $3 ) } } ); } 699 723 ; 700 724 … … 705 729 // Switching to this behaviour may help check if a C compatibilty case uses comma-exprs in subscripts. 706 730 // Current: Commas in subscripts make tuples. 707 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, new ExpressionNode( build_tuple((ExpressionNode *)($3->set_last( $5 ) ) )) ) ); }731 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, $1, new ExpressionNode( build_tuple( yylloc, (ExpressionNode *)($3->set_last( $5 ) ) )) ) ); } 708 732 | postfix_expression '[' assignment_expression ']' 709 733 // CFA, comma_expression disallowed in this context because it results in a common user error: subscripting a … … 711 735 // little advantage to this feature and many disadvantages. It is possible to write x[(i,j)] in CFA, which is 712 736 // equivalent to the old x[i,j]. 713 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $3 ) ); }737 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, $1, $3 ) ); } 714 738 | constant '[' assignment_expression ']' // 3[a], 'a'[a], 3.5[a] 715 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $3 ) ); }739 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, $1, $3 ) ); } 716 740 | string_literal '[' assignment_expression ']' // "abc"[3], 3["abc"] 717 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, new ExpressionNode( $1 ), $3 ) ); }741 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, new ExpressionNode( $1 ), $3 ) ); } 718 742 | postfix_expression '{' argument_expression_list_opt '}' // CFA, constructor call 719 743 { 720 744 Token fn; 721 745 fn.str = new std::string( "?{}" ); // location undefined - use location of '{'? 722 $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref(fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) );746 $$ = new ExpressionNode( new ast::ConstructorExpr( yylloc, build_func( yylloc, new ExpressionNode( build_varref( yylloc, fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) ); 723 747 } 724 748 | postfix_expression '(' argument_expression_list_opt ')' 725 { $$ = new ExpressionNode( build_func( $1, $3 ) ); }749 { $$ = new ExpressionNode( build_func( yylloc, $1, $3 ) ); } 726 750 | VA_ARG '(' primary_expression ',' declaration_specifier_nobody abstract_parameter_declarator_opt ')' 727 751 // { SemanticError( yylloc, "va_arg is currently unimplemented." ); $$ = nullptr; } 728 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref(new string( "__builtin_va_arg") ) ),752 { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, new string( "__builtin_va_arg") ) ), 729 753 (ExpressionNode *)($3->set_last( (ExpressionNode *)($6 ? $6->addType( $5 ) : $5) )) ) ); } 730 754 | postfix_expression '`' identifier // CFA, postfix call 731 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref(build_postfix_name( $3 ) ) ), $1 ) ); }755 { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, build_postfix_name( $3 ) ) ), $1 ) ); } 732 756 | constant '`' identifier // CFA, postfix call 733 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref(build_postfix_name( $3 ) ) ), $1 ) ); }757 { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, build_postfix_name( $3 ) ) ), $1 ) ); } 734 758 | string_literal '`' identifier // CFA, postfix call 735 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref(build_postfix_name( $3 ) ) ), new ExpressionNode( $1 ) ) ); }759 { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, build_postfix_name( $3 ) ) ), new ExpressionNode( $1 ) ) ); } 736 760 | postfix_expression '.' identifier 737 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref($3 ) ) ); }761 { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, build_varref( yylloc, $3 ) ) ); } 738 762 | postfix_expression '.' INTEGERconstant // CFA, tuple index 739 { $$ = new ExpressionNode( build_fieldSel( $1, build_constantInteger(*$3 ) ) ); }763 { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, build_constantInteger( yylloc, *$3 ) ) ); } 740 764 | postfix_expression FLOATING_FRACTIONconstant // CFA, tuple index 741 { $$ = new ExpressionNode( build_fieldSel( $1, build_field_name_FLOATING_FRACTIONconstant(*$2 ) ) ); }765 { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, build_field_name_FLOATING_FRACTIONconstant( yylloc, *$2 ) ) ); } 742 766 | postfix_expression '.' '[' field_name_list ']' // CFA, tuple field selector 743 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple($4 ) ) ); }767 { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, build_tuple( yylloc, $4 ) ) ); } 744 768 | postfix_expression '.' aggregate_control 745 { $$ = new ExpressionNode( build_keyword_cast( $3, $1 ) ); }769 { $$ = new ExpressionNode( build_keyword_cast( yylloc, $3, $1 ) ); } 746 770 | postfix_expression ARROW identifier 747 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref($3 ) ) ); }771 { $$ = new ExpressionNode( build_pfieldSel( yylloc, $1, build_varref( yylloc, $3 ) ) ); } 748 772 | postfix_expression ARROW INTEGERconstant // CFA, tuple index 749 { $$ = new ExpressionNode( build_pfieldSel( $1, build_constantInteger(*$3 ) ) ); }773 { $$ = new ExpressionNode( build_pfieldSel( yylloc, $1, build_constantInteger( yylloc, *$3 ) ) ); } 750 774 | postfix_expression ARROW '[' field_name_list ']' // CFA, tuple field selector 751 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple($4 ) ) ); }775 { $$ = new ExpressionNode( build_pfieldSel( yylloc, $1, build_tuple( yylloc, $4 ) ) ); } 752 776 | postfix_expression ICR 753 { $$ = new ExpressionNode( build_unary_ptr(OperKinds::IncrPost, $1 ) ); }777 { $$ = new ExpressionNode( build_unary_val( yylloc, OperKinds::IncrPost, $1 ) ); } 754 778 | postfix_expression DECR 755 { $$ = new ExpressionNode( build_unary_ptr(OperKinds::DecrPost, $1 ) ); }779 { $$ = new ExpressionNode( build_unary_val( yylloc, OperKinds::DecrPost, $1 ) ); } 756 780 | '(' type_no_function ')' '{' initializer_list_opt comma_opt '}' // C99, compound-literal 757 { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); }781 { $$ = new ExpressionNode( build_compoundLiteral( yylloc, $2, new InitializerNode( $5, true ) ) ); } 758 782 | '(' type_no_function ')' '@' '{' initializer_list_opt comma_opt '}' // CFA, explicit C compound-literal 759 { $$ = new ExpressionNode( build_compoundLiteral( $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); }783 { $$ = new ExpressionNode( build_compoundLiteral( yylloc, $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); } 760 784 | '^' primary_expression '{' argument_expression_list_opt '}' // CFA, destructor call 761 785 { 762 786 Token fn; 763 787 fn.str = new string( "^?{}" ); // location undefined 764 $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref(fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) );788 $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) ); 765 789 } 766 790 ; … … 781 805 '@' // CFA, default parameter 782 806 { SemanticError( yylloc, "Default parameter for argument is currently unimplemented." ); $$ = nullptr; } 783 // { $$ = new ExpressionNode( build_constantInteger( *new string( "2" ) ) ); }807 // { $$ = new ExpressionNode( build_constantInteger( *new string( "2" ) ) ); } 784 808 | assignment_expression 785 809 ; … … 793 817 field_name 794 818 | FLOATING_DECIMALconstant field 795 { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( *$1 ) ), maybeMoveBuild<Expression>( $2 ) ) ); }819 { $$ = new ExpressionNode( build_fieldSel( yylloc, new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( yylloc, *$1 ) ), maybeMoveBuild( $2 ) ) ); } 796 820 | FLOATING_DECIMALconstant '[' field_name_list ']' 797 { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( *$1 ) ), build_tuple($3 ) ) ); }821 { $$ = new ExpressionNode( build_fieldSel( yylloc, new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( yylloc, *$1 ) ), build_tuple( yylloc, $3 ) ) ); } 798 822 | field_name '.' field 799 { $$ = new ExpressionNode( build_fieldSel( $1, maybeMoveBuild<Expression>( $3 ) ) ); }823 { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, maybeMoveBuild( $3 ) ) ); } 800 824 | field_name '.' '[' field_name_list ']' 801 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple($4 ) ) ); }825 { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, build_tuple( yylloc, $4 ) ) ); } 802 826 | field_name ARROW field 803 { $$ = new ExpressionNode( build_pfieldSel( $1, maybeMoveBuild<Expression>( $3 ) ) ); }827 { $$ = new ExpressionNode( build_pfieldSel( yylloc, $1, maybeMoveBuild( $3 ) ) ); } 804 828 | field_name ARROW '[' field_name_list ']' 805 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple($4 ) ) ); }829 { $$ = new ExpressionNode( build_pfieldSel( yylloc, $1, build_tuple( yylloc, $4 ) ) ); } 806 830 ; 807 831 808 832 field_name: 809 833 INTEGERconstant fraction_constants_opt 810 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantInteger(*$1 ), $2 ) ); }834 { $$ = new ExpressionNode( build_field_name_fraction_constants( yylloc, build_constantInteger( yylloc, *$1 ), $2 ) ); } 811 835 | FLOATINGconstant fraction_constants_opt 812 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant(*$1 ), $2 ) ); }836 { $$ = new ExpressionNode( build_field_name_fraction_constants( yylloc, build_field_name_FLOATINGconstant( yylloc, *$1 ), $2 ) ); } 813 837 | identifier_at fraction_constants_opt // CFA, allow anonymous fields 814 838 { 815 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref($1 ), $2 ) );839 $$ = new ExpressionNode( build_field_name_fraction_constants( yylloc, build_varref( yylloc, $1 ), $2 ) ); 816 840 } 817 841 ; … … 822 846 | fraction_constants_opt FLOATING_FRACTIONconstant 823 847 { 824 Expression * constant = build_field_name_FLOATING_FRACTIONconstant(*$2 );825 $$ = $1 != nullptr ? new ExpressionNode( build_fieldSel( $1,constant ) ) : new ExpressionNode( constant );848 ast::Expr * constant = build_field_name_FLOATING_FRACTIONconstant( yylloc, *$2 ); 849 $$ = $1 != nullptr ? new ExpressionNode( build_fieldSel( yylloc, $1, constant ) ) : new ExpressionNode( constant ); 826 850 } 827 851 ; … … 842 866 { 843 867 switch ( $1 ) { 844 case OperKinds::AddressOf:845 $$ = new ExpressionNode( new AddressExpr( maybeMoveBuild<Expression>( $2 ) ) );868 case OperKinds::AddressOf: 869 $$ = new ExpressionNode( new ast::AddressExpr( maybeMoveBuild( $2 ) ) ); 846 870 break; 847 case OperKinds::PointTo:848 $$ = new ExpressionNode( build_unary_val( $1, $2 ) );871 case OperKinds::PointTo: 872 $$ = new ExpressionNode( build_unary_val( yylloc, $1, $2 ) ); 849 873 break; 850 case OperKinds::And:851 $$ = new ExpressionNode( new AddressExpr( new AddressExpr( maybeMoveBuild<Expression>( $2 ) ) ) );874 case OperKinds::And: 875 $$ = new ExpressionNode( new ast::AddressExpr( new ast::AddressExpr( maybeMoveBuild( $2 ) ) ) ); 852 876 break; 853 default:877 default: 854 878 assert( false ); 855 879 } 856 880 } 857 881 | unary_operator cast_expression 858 { $$ = new ExpressionNode( build_unary_val($1, $2 ) ); }882 { $$ = new ExpressionNode( build_unary_val( yylloc, $1, $2 ) ); } 859 883 | ICR unary_expression 860 { $$ = new ExpressionNode( build_unary_ptr(OperKinds::Incr, $2 ) ); }884 { $$ = new ExpressionNode( build_unary_val( yylloc, OperKinds::Incr, $2 ) ); } 861 885 | DECR unary_expression 862 { $$ = new ExpressionNode( build_unary_ptr(OperKinds::Decr, $2 ) ); }886 { $$ = new ExpressionNode( build_unary_val( yylloc, OperKinds::Decr, $2 ) ); } 863 887 | SIZEOF unary_expression 864 { $$ = new ExpressionNode( new SizeofExpr( maybeMoveBuild<Expression>( $2 ) ) ); }888 { $$ = new ExpressionNode( new ast::SizeofExpr( yylloc, maybeMoveBuild( $2 ) ) ); } 865 889 | SIZEOF '(' type_no_function ')' 866 { $$ = new ExpressionNode( new SizeofExpr(maybeMoveBuildType( $3 ) ) ); }890 { $$ = new ExpressionNode( new ast::SizeofExpr( yylloc, maybeMoveBuildType( $3 ) ) ); } 867 891 | ALIGNOF unary_expression // GCC, variable alignment 868 { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuild<Expression>( $2 ) ) ); }892 { $$ = new ExpressionNode( new ast::AlignofExpr( yylloc, maybeMoveBuild( $2 ) ) ); } 869 893 | ALIGNOF '(' type_no_function ')' // GCC, type alignment 870 { $$ = new ExpressionNode( new AlignofExpr(maybeMoveBuildType( $3 ) ) ); }894 { $$ = new ExpressionNode( new ast::AlignofExpr( yylloc, maybeMoveBuildType( $3 ) ) ); } 871 895 | OFFSETOF '(' type_no_function ',' identifier ')' 872 { $$ = new ExpressionNode( build_offsetOf( $3, build_varref($5 ) ) ); }896 { $$ = new ExpressionNode( build_offsetOf( yylloc, $3, build_varref( yylloc, $5 ) ) ); } 873 897 | TYPEID '(' type_no_function ')' 874 898 { … … 895 919 unary_expression 896 920 | '(' type_no_function ')' cast_expression 897 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }921 { $$ = new ExpressionNode( build_cast( yylloc, $2, $4 ) ); } 898 922 | '(' aggregate_control '&' ')' cast_expression // CFA 899 { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); }923 { $$ = new ExpressionNode( build_keyword_cast( yylloc, $2, $5 ) ); } 900 924 | '(' aggregate_control '*' ')' cast_expression // CFA 901 { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); }925 { $$ = new ExpressionNode( build_keyword_cast( yylloc, $2, $5 ) ); } 902 926 | '(' VIRTUAL ')' cast_expression // CFA 903 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild<Expression>( $4 ), maybeMoveBuildType( nullptr ) ) ); }927 { $$ = new ExpressionNode( new ast::VirtualCastExpr( yylloc, maybeMoveBuild( $4 ), maybeMoveBuildType( nullptr ) ) ); } 904 928 | '(' VIRTUAL type_no_function ')' cast_expression // CFA 905 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild<Expression>( $5 ), maybeMoveBuildType( $3 ) ) ); }929 { $$ = new ExpressionNode( new ast::VirtualCastExpr( yylloc, maybeMoveBuild( $5 ), maybeMoveBuildType( $3 ) ) ); } 906 930 | '(' RETURN type_no_function ')' cast_expression // CFA 907 { $$ = new ExpressionNode( build_cast( $3, $5, CastExpr::Return ) ); }931 { SemanticError( yylloc, "Return cast is currently unimplemented." ); $$ = nullptr; } 908 932 | '(' COERCE type_no_function ')' cast_expression // CFA 909 933 { SemanticError( yylloc, "Coerce cast is currently unimplemented." ); $$ = nullptr; } … … 911 935 { SemanticError( yylloc, "Qualifier cast is currently unimplemented." ); $$ = nullptr; } 912 936 // | '(' type_no_function ')' tuple 913 // { $$ = new ExpressionNode( build_cast($2, $4 ) ); }937 // { $$ = new ast::ExpressionNode( build_cast( yylloc, $2, $4 ) ); } 914 938 ; 915 939 … … 929 953 cast_expression 930 954 | exponential_expression '\\' cast_expression 931 { $$ = new ExpressionNode( build_binary_val( OperKinds::Exp, $1, $3 ) ); }955 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Exp, $1, $3 ) ); } 932 956 ; 933 957 … … 935 959 exponential_expression 936 960 | multiplicative_expression '*' exponential_expression 937 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); }961 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Mul, $1, $3 ) ); } 938 962 | multiplicative_expression '/' exponential_expression 939 { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); }963 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Div, $1, $3 ) ); } 940 964 | multiplicative_expression '%' exponential_expression 941 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); }965 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Mod, $1, $3 ) ); } 942 966 ; 943 967 … … 945 969 multiplicative_expression 946 970 | additive_expression '+' multiplicative_expression 947 { $$ = new ExpressionNode( build_binary_val( OperKinds::Plus, $1, $3 ) ); }971 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Plus, $1, $3 ) ); } 948 972 | additive_expression '-' multiplicative_expression 949 { $$ = new ExpressionNode( build_binary_val( OperKinds::Minus, $1, $3 ) ); }973 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Minus, $1, $3 ) ); } 950 974 ; 951 975 … … 953 977 additive_expression 954 978 | shift_expression LS additive_expression 955 { $$ = new ExpressionNode( build_binary_val( OperKinds::LShift, $1, $3 ) ); }979 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::LShift, $1, $3 ) ); } 956 980 | shift_expression RS additive_expression 957 { $$ = new ExpressionNode( build_binary_val( OperKinds::RShift, $1, $3 ) ); }981 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::RShift, $1, $3 ) ); } 958 982 ; 959 983 … … 961 985 shift_expression 962 986 | relational_expression '<' shift_expression 963 { $$ = new ExpressionNode( build_binary_val( OperKinds::LThan, $1, $3 ) ); }987 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::LThan, $1, $3 ) ); } 964 988 | relational_expression '>' shift_expression 965 { $$ = new ExpressionNode( build_binary_val( OperKinds::GThan, $1, $3 ) ); }989 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::GThan, $1, $3 ) ); } 966 990 | relational_expression LE shift_expression 967 { $$ = new ExpressionNode( build_binary_val( OperKinds::LEThan, $1, $3 ) ); }991 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::LEThan, $1, $3 ) ); } 968 992 | relational_expression GE shift_expression 969 { $$ = new ExpressionNode( build_binary_val( OperKinds::GEThan, $1, $3 ) ); }993 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::GEThan, $1, $3 ) ); } 970 994 ; 971 995 … … 973 997 relational_expression 974 998 | equality_expression EQ relational_expression 975 { $$ = new ExpressionNode( build_binary_val( OperKinds::Eq, $1, $3 ) ); }999 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Eq, $1, $3 ) ); } 976 1000 | equality_expression NE relational_expression 977 { $$ = new ExpressionNode( build_binary_val( OperKinds::Neq, $1, $3 ) ); }1001 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Neq, $1, $3 ) ); } 978 1002 ; 979 1003 … … 981 1005 equality_expression 982 1006 | AND_expression '&' equality_expression 983 { $$ = new ExpressionNode( build_binary_val( OperKinds::BitAnd, $1, $3 ) ); }1007 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::BitAnd, $1, $3 ) ); } 984 1008 ; 985 1009 … … 987 1011 AND_expression 988 1012 | exclusive_OR_expression '^' AND_expression 989 { $$ = new ExpressionNode( build_binary_val( OperKinds::Xor, $1, $3 ) ); }1013 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Xor, $1, $3 ) ); } 990 1014 ; 991 1015 … … 993 1017 exclusive_OR_expression 994 1018 | inclusive_OR_expression '|' exclusive_OR_expression 995 { $$ = new ExpressionNode( build_binary_val( OperKinds::BitOr, $1, $3 ) ); }1019 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::BitOr, $1, $3 ) ); } 996 1020 ; 997 1021 … … 999 1023 inclusive_OR_expression 1000 1024 | logical_AND_expression ANDAND inclusive_OR_expression 1001 { $$ = new ExpressionNode( build_and_or( $1, $3, true) ); }1025 { $$ = new ExpressionNode( build_and_or( yylloc, $1, $3, ast::AndExpr ) ); } 1002 1026 ; 1003 1027 … … 1005 1029 logical_AND_expression 1006 1030 | logical_OR_expression OROR logical_AND_expression 1007 { $$ = new ExpressionNode( build_and_or( $1, $3, false) ); }1031 { $$ = new ExpressionNode( build_and_or( yylloc, $1, $3, ast::OrExpr ) ); } 1008 1032 ; 1009 1033 … … 1011 1035 logical_OR_expression 1012 1036 | logical_OR_expression '?' comma_expression ':' conditional_expression 1013 { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }1037 { $$ = new ExpressionNode( build_cond( yylloc, $1, $3, $5 ) ); } 1014 1038 // FIX ME: computes $1 twice 1015 1039 | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand 1016 { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); }1040 { $$ = new ExpressionNode( build_cond( yylloc, $1, $1, $4 ) ); } 1017 1041 ; 1018 1042 … … 1029 1053 // SemanticError( yylloc, "C @= assignment is currently unimplemented." ); $$ = nullptr; 1030 1054 // } else { 1031 $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) );1055 $$ = new ExpressionNode( build_binary_val( yylloc, $2, $1, $3 ) ); 1032 1056 // } // if 1033 1057 } … … 1074 1098 // { $$ = new ExpressionNode( build_tuple( $3 ) ); } 1075 1099 '[' ',' tuple_expression_list ']' 1076 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); }1100 { $$ = new ExpressionNode( build_tuple( yylloc, (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); } 1077 1101 | '[' push assignment_expression pop ',' tuple_expression_list ']' 1078 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $6 ) ) )); }1102 { $$ = new ExpressionNode( build_tuple( yylloc, (ExpressionNode *)($3->set_last( $6 ) ) )); } 1079 1103 ; 1080 1104 … … 1092 1116 assignment_expression 1093 1117 | comma_expression ',' assignment_expression 1094 { $$ = new ExpressionNode( new CommaExpr( maybeMoveBuild<Expression>( $1 ), maybeMoveBuild<Expression>( $3 ) ) ); }1118 { $$ = new ExpressionNode( new ast::CommaExpr( yylloc, maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); } 1095 1119 ; 1096 1120 … … 1113 1137 | mutex_statement 1114 1138 | waitfor_statement 1139 | waituntil_statement 1115 1140 | exception_statement 1116 1141 | enable_disable_statement … … 1118 1143 | asm_statement 1119 1144 | DIRECTIVE 1120 { $$ = new StatementNode( build_directive( $1 ) ); }1145 { $$ = new StatementNode( build_directive( yylloc, $1 ) ); } 1121 1146 ; 1122 1147 … … 1124 1149 // labels cannot be identifiers 0 or 1 1125 1150 identifier_or_type_name ':' attribute_list_opt statement 1126 { $$ = $4->add_label( $1, $3 ); }1151 { $$ = $4->add_label( yylloc, $1, $3 ); } 1127 1152 | identifier_or_type_name ':' attribute_list_opt error // syntax error 1128 1153 { … … 1136 1161 compound_statement: 1137 1162 '{' '}' 1138 { $$ = new StatementNode( build_compound( (StatementNode *)0 ) ); }1163 { $$ = new StatementNode( build_compound( yylloc, (StatementNode *)0 ) ); } 1139 1164 | '{' push 1140 1165 local_label_declaration_opt // GCC, local labels appear at start of block 1141 1166 statement_decl_list // C99, intermix declarations and statements 1142 1167 pop '}' 1143 { $$ = new StatementNode( build_compound( $4 ) ); }1168 { $$ = new StatementNode( build_compound( yylloc, $4 ) ); } 1144 1169 ; 1145 1170 … … 1172 1197 expression_statement: 1173 1198 comma_expression_opt ';' 1174 { $$ = new StatementNode( build_expr( $1 ) ); } 1175 | MUTEX '(' ')' comma_expression ';' 1176 { $$ = new StatementNode( build_mutex( nullptr, new StatementNode( build_expr( $4 ) ) ) ); } 1199 { $$ = new StatementNode( build_expr( yylloc, $1 ) ); } 1177 1200 ; 1178 1201 … … 1183 1206 { $$ = $2; } 1184 1207 | SWITCH '(' comma_expression ')' case_clause 1185 { $$ = new StatementNode( build_switch( true, $3, $5 ) ); }1208 { $$ = new StatementNode( build_switch( yylloc, true, $3, $5 ) ); } 1186 1209 | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt pop '}' // CFA 1187 1210 { 1188 StatementNode *sw = new StatementNode( build_switch( true, $3, $8 ) );1211 StatementNode *sw = new StatementNode( build_switch( yylloc, true, $3, $8 ) ); 1189 1212 // The semantics of the declaration list is changed to include associated initialization, which is performed 1190 1213 // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound … … 1192 1215 // therefore, are removed from the grammar even though C allows it. The change also applies to choose 1193 1216 // statement. 1194 $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;1217 $$ = $7 ? new StatementNode( build_compound( yylloc, (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw; 1195 1218 } 1196 1219 | SWITCH '(' comma_expression ')' '{' error '}' // CFA, syntax error 1197 1220 { SemanticError( yylloc, "Only declarations can appear before the list of case clauses." ); $$ = nullptr; } 1198 1221 | CHOOSE '(' comma_expression ')' case_clause // CFA 1199 { $$ = new StatementNode( build_switch( false, $3, $5 ) ); }1222 { $$ = new StatementNode( build_switch( yylloc, false, $3, $5 ) ); } 1200 1223 | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt pop '}' // CFA 1201 1224 { 1202 StatementNode *sw = new StatementNode( build_switch( false, $3, $8 ) );1203 $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;1225 StatementNode *sw = new StatementNode( build_switch( yylloc, false, $3, $8 ) ); 1226 $$ = $7 ? new StatementNode( build_compound( yylloc, (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw; 1204 1227 } 1205 1228 | CHOOSE '(' comma_expression ')' '{' error '}' // CFA, syntax error … … 1210 1233 IF '(' conditional_declaration ')' statement %prec THEN 1211 1234 // explicitly deal with the shift/reduce conflict on if/else 1212 { $$ = new StatementNode( build_if( $3, maybe_build_compound($5 ), nullptr ) ); }1235 { $$ = new StatementNode( build_if( yylloc, $3, maybe_build_compound( yylloc, $5 ), nullptr ) ); } 1213 1236 | IF '(' conditional_declaration ')' statement ELSE statement 1214 { $$ = new StatementNode( build_if( $3, maybe_build_compound( $5 ), maybe_build_compound($7 ) ) ); }1237 { $$ = new StatementNode( build_if( yylloc, $3, maybe_build_compound( yylloc, $5 ), maybe_build_compound( yylloc, $7 ) ) ); } 1215 1238 ; 1216 1239 … … 1224 1247 | declaration comma_expression // semi-colon separated 1225 1248 { $$ = new CondCtl( $1, $2 ); } 1226 ;1249 ; 1227 1250 1228 1251 // CASE and DEFAULT clauses are only allowed in the SWITCH statement, precluding Duff's device. In addition, a case … … 1232 1255 constant_expression { $$ = $1; } 1233 1256 | constant_expression ELLIPSIS constant_expression // GCC, subrange 1234 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild<Expression>( $1 ), maybeMoveBuild<Expression>( $3 ) ) ); }1257 { $$ = new ExpressionNode( new ast::RangeExpr( yylloc, maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); } 1235 1258 | subrange // CFA, subrange 1236 1259 ; … … 1248 1271 | CASE case_value_list error // syntax error 1249 1272 { SemanticError( yylloc, "Missing colon after case list." ); $$ = nullptr; } 1250 | DEFAULT ':' { $$ = new StatementNode( build_default( ) ); }1273 | DEFAULT ':' { $$ = new StatementNode( build_default( yylloc ) ); } 1251 1274 // A semantic check is required to ensure only one default clause per switch/choose statement. 1252 1275 | DEFAULT error // syntax error … … 1260 1283 1261 1284 case_clause: // CFA 1262 case_label_list statement { $$ = $1->append_last_case( maybe_build_compound( $2 ) ); }1285 case_label_list statement { $$ = $1->append_last_case( maybe_build_compound( yylloc, $2 ) ); } 1263 1286 ; 1264 1287 … … 1271 1294 switch_clause_list: // CFA 1272 1295 case_label_list statement_list_nodecl 1273 { $$ = $1->append_last_case( new StatementNode( build_compound( $2 ) ) ); }1296 { $$ = $1->append_last_case( new StatementNode( build_compound( yylloc, $2 ) ) ); } 1274 1297 | switch_clause_list case_label_list statement_list_nodecl 1275 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); }1298 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( yylloc, $3 ) ) ) ) ); } 1276 1299 ; 1277 1300 1278 1301 iteration_statement: 1279 1302 WHILE '(' ')' statement %prec THEN // CFA => while ( 1 ) 1280 { $$ = new StatementNode( build_while( new CondCtl( nullptr, NEW_ONE ), maybe_build_compound($4 ) ) ); }1303 { $$ = new StatementNode( build_while( yylloc, new CondCtl( nullptr, NEW_ONE ), maybe_build_compound( yylloc, $4 ) ) ); } 1281 1304 | WHILE '(' ')' statement ELSE statement // CFA 1282 1305 { 1283 $$ = new StatementNode( build_while( new CondCtl( nullptr, NEW_ONE ), maybe_build_compound($4 ) ) );1284 SemanticWarning( yylloc, Warning::SuperfluousElse , "");1306 $$ = new StatementNode( build_while( yylloc, new CondCtl( nullptr, NEW_ONE ), maybe_build_compound( yylloc, $4 ) ) ); 1307 SemanticWarning( yylloc, Warning::SuperfluousElse ); 1285 1308 } 1286 1309 | WHILE '(' conditional_declaration ')' statement %prec THEN 1287 { $$ = new StatementNode( build_while( $3, maybe_build_compound($5 ) ) ); }1310 { $$ = new StatementNode( build_while( yylloc, $3, maybe_build_compound( yylloc, $5 ) ) ); } 1288 1311 | WHILE '(' conditional_declaration ')' statement ELSE statement // CFA 1289 { $$ = new StatementNode( build_while( $3, maybe_build_compound($5 ), $7 ) ); }1312 { $$ = new StatementNode( build_while( yylloc, $3, maybe_build_compound( yylloc, $5 ), $7 ) ); } 1290 1313 | DO statement WHILE '(' ')' ';' // CFA => do while( 1 ) 1291 { $$ = new StatementNode( build_do_while( NEW_ONE, maybe_build_compound($2 ) ) ); }1314 { $$ = new StatementNode( build_do_while( yylloc, NEW_ONE, maybe_build_compound( yylloc, $2 ) ) ); } 1292 1315 | DO statement WHILE '(' ')' ELSE statement // CFA 1293 1316 { 1294 $$ = new StatementNode( build_do_while( NEW_ONE, maybe_build_compound($2 ) ) );1295 SemanticWarning( yylloc, Warning::SuperfluousElse , "");1317 $$ = new StatementNode( build_do_while( yylloc, NEW_ONE, maybe_build_compound( yylloc, $2 ) ) ); 1318 SemanticWarning( yylloc, Warning::SuperfluousElse ); 1296 1319 } 1297 1320 | DO statement WHILE '(' comma_expression ')' ';' 1298 { $$ = new StatementNode( build_do_while( $5, maybe_build_compound($2 ) ) ); }1321 { $$ = new StatementNode( build_do_while( yylloc, $5, maybe_build_compound( yylloc, $2 ) ) ); } 1299 1322 | DO statement WHILE '(' comma_expression ')' ELSE statement // CFA 1300 { $$ = new StatementNode( build_do_while( $5, maybe_build_compound($2 ), $8 ) ); }1323 { $$ = new StatementNode( build_do_while( yylloc, $5, maybe_build_compound( yylloc, $2 ), $8 ) ); } 1301 1324 | FOR '(' ')' statement %prec THEN // CFA => for ( ;; ) 1302 { $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), maybe_build_compound($4 ) ) ); }1325 { $$ = new StatementNode( build_for( yylloc, new ForCtrl( nullptr, nullptr, nullptr ), maybe_build_compound( yylloc, $4 ) ) ); } 1303 1326 | FOR '(' ')' statement ELSE statement // CFA 1304 1327 { 1305 $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), maybe_build_compound($4 ) ) );1306 SemanticWarning( yylloc, Warning::SuperfluousElse , "");1328 $$ = new StatementNode( build_for( yylloc, new ForCtrl( nullptr, nullptr, nullptr ), maybe_build_compound( yylloc, $4 ) ) ); 1329 SemanticWarning( yylloc, Warning::SuperfluousElse ); 1307 1330 } 1308 1331 | FOR '(' for_control_expression_list ')' statement %prec THEN 1309 { $$ = new StatementNode( build_for( $3, maybe_build_compound($5 ) ) ); }1332 { $$ = new StatementNode( build_for( yylloc, $3, maybe_build_compound( yylloc, $5 ) ) ); } 1310 1333 | FOR '(' for_control_expression_list ')' statement ELSE statement // CFA 1311 { $$ = new StatementNode( build_for( $3, maybe_build_compound($5 ), $7 ) ); }1334 { $$ = new StatementNode( build_for( yylloc, $3, maybe_build_compound( yylloc, $5 ), $7 ) ); } 1312 1335 ; 1313 1336 … … 1323 1346 if ( $1->condition ) { 1324 1347 if ( $3->condition ) { 1325 $1->condition->expr.reset( new LogicalExpr( $1->condition->expr.release(), $3->condition->expr.release(), true) );1348 $1->condition->expr.reset( new ast::LogicalExpr( yylloc, $1->condition->expr.release(), $3->condition->expr.release(), ast::AndExpr ) ); 1326 1349 } // if 1327 1350 } else $1->condition = $3->condition; 1328 1351 if ( $1->change ) { 1329 1352 if ( $3->change ) { 1330 $1->change->expr.reset( new CommaExpr($1->change->expr.release(), $3->change->expr.release() ) );1353 $1->change->expr.reset( new ast::CommaExpr( yylloc, $1->change->expr.release(), $3->change->expr.release() ) ); 1331 1354 } // if 1332 1355 } else $1->change = $3->change; … … 1337 1360 for_control_expression: 1338 1361 ';' comma_expression_opt ';' comma_expression_opt 1339 { $$ = new ForCtrl( (ExpressionNode * )nullptr, $2, $4 ); }1362 { $$ = new ForCtrl( nullptr, $2, $4 ); } 1340 1363 | comma_expression ';' comma_expression_opt ';' comma_expression_opt 1341 { $$ = new ForCtrl( $1, $3, $5 ); } 1364 { 1365 StatementNode * init = $1 ? new StatementNode( new ast::ExprStmt( yylloc, maybeMoveBuild( $1 ) ) ) : nullptr; 1366 $$ = new ForCtrl( init, $3, $5 ); 1367 } 1342 1368 | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';' 1343 { $$ = new ForCtrl( $1, $2, $4 ); }1369 { $$ = new ForCtrl( new StatementNode( $1 ), $2, $4 ); } 1344 1370 1345 1371 | '@' ';' comma_expression // CFA, empty loop-index 1346 { $$ = new ForCtrl( (ExpressionNode *)nullptr, $3, nullptr ); }1372 { $$ = new ForCtrl( nullptr, $3, nullptr ); } 1347 1373 | '@' ';' comma_expression ';' comma_expression // CFA, empty loop-index 1348 { $$ = new ForCtrl( (ExpressionNode *)nullptr, $3, $5 ); }1374 { $$ = new ForCtrl( nullptr, $3, $5 ); } 1349 1375 1350 1376 | comma_expression // CFA, anonymous loop-index 1351 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), NEW_ZERO, OperKinds::LThan, $1->clone(), NEW_ONE ); }1377 { $$ = forCtrl( yylloc, $1, new string( DeclarationNode::anonymous.newName() ), NEW_ZERO, OperKinds::LThan, $1->clone(), NEW_ONE ); } 1352 1378 | downupdowneq comma_expression // CFA, anonymous loop-index 1353 { $$ = forCtrl( $2, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $1, NEW_ZERO, $2->clone() ), $1, UPDOWN( $1, $2->clone(), NEW_ZERO ), NEW_ONE ); }1379 { $$ = forCtrl( yylloc, $2, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $1, NEW_ZERO, $2->clone() ), $1, UPDOWN( $1, $2->clone(), NEW_ZERO ), NEW_ONE ); } 1354 1380 1355 1381 | comma_expression updowneq comma_expression // CFA, anonymous loop-index 1356 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $2, $1->clone(), $3 ), $2, UPDOWN( $2, $3->clone(), $1->clone() ), NEW_ONE ); }1382 { $$ = forCtrl( yylloc, $1, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $2, $1->clone(), $3 ), $2, UPDOWN( $2, $3->clone(), $1->clone() ), NEW_ONE ); } 1357 1383 | '@' updowneq comma_expression // CFA, anonymous loop-index 1358 1384 { 1359 1385 if ( $2 == OperKinds::LThan || $2 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; } 1360 else $$ = forCtrl( $3, new string( DeclarationNode::anonymous.newName() ), $3->clone(), $2, nullptr, NEW_ONE );1386 else $$ = forCtrl( yylloc, $3, new string( DeclarationNode::anonymous.newName() ), $3->clone(), $2, nullptr, NEW_ONE ); 1361 1387 } 1362 1388 | comma_expression updowneq '@' // CFA, anonymous loop-index … … 1366 1392 } 1367 1393 | comma_expression updowneq comma_expression '~' comma_expression // CFA, anonymous loop-index 1368 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $2, $1->clone(), $3 ), $2, UPDOWN( $2, $3->clone(), $1->clone() ), $5 ); }1394 { $$ = forCtrl( yylloc, $1, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $2, $1->clone(), $3 ), $2, UPDOWN( $2, $3->clone(), $1->clone() ), $5 ); } 1369 1395 | '@' updowneq comma_expression '~' comma_expression // CFA, anonymous loop-index 1370 1396 { 1371 1397 if ( $2 == OperKinds::LThan || $2 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; } 1372 else $$ = forCtrl( $3, new string( DeclarationNode::anonymous.newName() ), $3->clone(), $2, nullptr, $5 );1398 else $$ = forCtrl( yylloc, $3, new string( DeclarationNode::anonymous.newName() ), $3->clone(), $2, nullptr, $5 ); 1373 1399 } 1374 1400 | comma_expression updowneq '@' '~' comma_expression // CFA, anonymous loop-index … … 1389 1415 1390 1416 | comma_expression ';' comma_expression // CFA 1391 { $$ = forCtrl( $3, $1, NEW_ZERO, OperKinds::LThan, $3->clone(), NEW_ONE ); }1417 { $$ = forCtrl( yylloc, $3, $1, NEW_ZERO, OperKinds::LThan, $3->clone(), NEW_ONE ); } 1392 1418 | comma_expression ';' downupdowneq comma_expression // CFA 1393 { $$ = forCtrl( $4, $1, UPDOWN( $3, NEW_ZERO, $4->clone() ), $3, UPDOWN( $3, $4->clone(), NEW_ZERO ), NEW_ONE ); }1419 { $$ = forCtrl( yylloc, $4, $1, UPDOWN( $3, NEW_ZERO, $4->clone() ), $3, UPDOWN( $3, $4->clone(), NEW_ZERO ), NEW_ONE ); } 1394 1420 1395 1421 | comma_expression ';' comma_expression updowneq comma_expression // CFA 1396 { $$ = forCtrl( $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), NEW_ONE ); }1422 { $$ = forCtrl( yylloc, $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), NEW_ONE ); } 1397 1423 | comma_expression ';' '@' updowneq comma_expression // CFA 1398 1424 { 1399 1425 if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; } 1400 else $$ = forCtrl( $5, $1, $5->clone(), $4, nullptr, NEW_ONE );1426 else $$ = forCtrl( yylloc, $5, $1, $5->clone(), $4, nullptr, NEW_ONE ); 1401 1427 } 1402 1428 | comma_expression ';' comma_expression updowneq '@' // CFA … … 1404 1430 if ( $4 == OperKinds::GThan || $4 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; } 1405 1431 else if ( $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; } 1406 else $$ = forCtrl( $3, $1, $3->clone(), $4, nullptr, NEW_ONE );1432 else $$ = forCtrl( yylloc, $3, $1, $3->clone(), $4, nullptr, NEW_ONE ); 1407 1433 } 1408 1434 | comma_expression ';' '@' updowneq '@' // CFA, error … … 1410 1436 1411 1437 | comma_expression ';' comma_expression updowneq comma_expression '~' comma_expression // CFA 1412 { $$ = forCtrl( $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), $7 ); }1438 { $$ = forCtrl( yylloc, $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), $7 ); } 1413 1439 | comma_expression ';' '@' updowneq comma_expression '~' comma_expression // CFA, error 1414 1440 { 1415 1441 if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; } 1416 else $$ = forCtrl( $5, $1, $5->clone(), $4, nullptr, $7 );1442 else $$ = forCtrl( yylloc, $5, $1, $5->clone(), $4, nullptr, $7 ); 1417 1443 } 1418 1444 | comma_expression ';' comma_expression updowneq '@' '~' comma_expression // CFA … … 1420 1446 if ( $4 == OperKinds::GThan || $4 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; } 1421 1447 else if ( $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; } 1422 else $$ = forCtrl( $3, $1, $3->clone(), $4, nullptr, $7 );1448 else $$ = forCtrl( yylloc, $3, $1, $3->clone(), $4, nullptr, $7 ); 1423 1449 } 1424 1450 | comma_expression ';' comma_expression updowneq comma_expression '~' '@' // CFA 1425 { $$ = forCtrl( $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), nullptr ); }1451 { $$ = forCtrl( yylloc, $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), nullptr ); } 1426 1452 | comma_expression ';' '@' updowneq comma_expression '~' '@' // CFA, error 1427 1453 { 1428 1454 if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; } 1429 else $$ = forCtrl( $5, $1, $5->clone(), $4, nullptr, nullptr );1455 else $$ = forCtrl( yylloc, $5, $1, $5->clone(), $4, nullptr, nullptr ); 1430 1456 } 1431 1457 | comma_expression ';' comma_expression updowneq '@' '~' '@' // CFA … … 1433 1459 if ( $4 == OperKinds::GThan || $4 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; } 1434 1460 else if ( $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; } 1435 else $$ = forCtrl( $3, $1, $3->clone(), $4, nullptr, nullptr );1461 else $$ = forCtrl( yylloc, $3, $1, $3->clone(), $4, nullptr, nullptr ); 1436 1462 } 1437 1463 | comma_expression ';' '@' updowneq '@' '~' '@' // CFA … … 1439 1465 1440 1466 | declaration comma_expression // CFA 1441 { $$ = forCtrl( $1, NEW_ZERO, OperKinds::LThan, $2, NEW_ONE ); }1467 { $$ = forCtrl( yylloc, $1, NEW_ZERO, OperKinds::LThan, $2, NEW_ONE ); } 1442 1468 | declaration downupdowneq comma_expression // CFA 1443 { $$ = forCtrl( $1, UPDOWN( $2, NEW_ZERO, $3 ), $2, UPDOWN( $2, $3->clone(), NEW_ZERO ), NEW_ONE ); }1469 { $$ = forCtrl( yylloc, $1, UPDOWN( $2, NEW_ZERO, $3 ), $2, UPDOWN( $2, $3->clone(), NEW_ZERO ), NEW_ONE ); } 1444 1470 1445 1471 | declaration comma_expression updowneq comma_expression // CFA 1446 { $$ = forCtrl( $1, UPDOWN( $3, $2->clone(), $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), NEW_ONE ); }1472 { $$ = forCtrl( yylloc, $1, UPDOWN( $3, $2->clone(), $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), NEW_ONE ); } 1447 1473 | declaration '@' updowneq comma_expression // CFA 1448 1474 { 1449 1475 if ( $3 == OperKinds::LThan || $3 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; } 1450 else $$ = forCtrl( $1, $4, $3, nullptr, NEW_ONE );1476 else $$ = forCtrl( yylloc, $1, $4, $3, nullptr, NEW_ONE ); 1451 1477 } 1452 1478 | declaration comma_expression updowneq '@' // CFA … … 1454 1480 if ( $3 == OperKinds::GThan || $3 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; } 1455 1481 else if ( $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; } 1456 else $$ = forCtrl( $1, $2, $3, nullptr, NEW_ONE );1482 else $$ = forCtrl( yylloc, $1, $2, $3, nullptr, NEW_ONE ); 1457 1483 } 1458 1484 1459 1485 | declaration comma_expression updowneq comma_expression '~' comma_expression // CFA 1460 { $$ = forCtrl( $1, UPDOWN( $3, $2, $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), $6 ); }1486 { $$ = forCtrl( yylloc, $1, UPDOWN( $3, $2, $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), $6 ); } 1461 1487 | declaration '@' updowneq comma_expression '~' comma_expression // CFA 1462 1488 { 1463 1489 if ( $3 == OperKinds::LThan || $3 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; } 1464 else $$ = forCtrl( $1, $4, $3, nullptr, $6 );1490 else $$ = forCtrl( yylloc, $1, $4, $3, nullptr, $6 ); 1465 1491 } 1466 1492 | declaration comma_expression updowneq '@' '~' comma_expression // CFA … … 1468 1494 if ( $3 == OperKinds::GThan || $3 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; } 1469 1495 else if ( $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; } 1470 else $$ = forCtrl( $1, $2, $3, nullptr, $6 );1496 else $$ = forCtrl( yylloc, $1, $2, $3, nullptr, $6 ); 1471 1497 } 1472 1498 | declaration comma_expression updowneq comma_expression '~' '@' // CFA 1473 { $$ = forCtrl( $1, UPDOWN( $3, $2, $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), nullptr ); }1499 { $$ = forCtrl( yylloc, $1, UPDOWN( $3, $2, $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), nullptr ); } 1474 1500 | declaration '@' updowneq comma_expression '~' '@' // CFA 1475 1501 { 1476 1502 if ( $3 == OperKinds::LThan || $3 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; } 1477 else $$ = forCtrl( $1, $4, $3, nullptr, nullptr );1503 else $$ = forCtrl( yylloc, $1, $4, $3, nullptr, nullptr ); 1478 1504 } 1479 1505 | declaration comma_expression updowneq '@' '~' '@' // CFA … … 1481 1507 if ( $3 == OperKinds::GThan || $3 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; } 1482 1508 else if ( $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; } 1483 else $$ = forCtrl( $1, $2, $3, nullptr, nullptr );1509 else $$ = forCtrl( yylloc, $1, $2, $3, nullptr, nullptr ); 1484 1510 } 1485 1511 | declaration '@' updowneq '@' '~' '@' // CFA, error … … 1496 1522 SemanticError( yylloc, "Type iterator is currently unimplemented." ); $$ = nullptr; 1497 1523 } 1498 ;1524 ; 1499 1525 1500 1526 downupdowneq: … … 1505 1531 | ErangeDownEq 1506 1532 { $$ = OperKinds::GEThan; } 1507 ;1533 ; 1508 1534 1509 1535 updown: … … 1512 1538 | ErangeDown 1513 1539 { $$ = OperKinds::GThan; } 1514 ;1540 ; 1515 1541 1516 1542 updowneq: … … 1520 1546 | ErangeDownEq 1521 1547 { $$ = OperKinds::GEThan; } 1522 ;1548 ; 1523 1549 1524 1550 jump_statement: 1525 1551 GOTO identifier_or_type_name ';' 1526 { $$ = new StatementNode( build_branch( $2,BranchStmt::Goto ) ); }1552 { $$ = new StatementNode( build_branch( yylloc, $2, ast::BranchStmt::Goto ) ); } 1527 1553 | GOTO '*' comma_expression ';' // GCC, computed goto 1528 1554 // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; => goto *(i+3); … … 1531 1557 // A semantic check is required to ensure fallthru appears only in the body of a choose statement. 1532 1558 | fall_through_name ';' // CFA 1533 { $$ = new StatementNode( build_branch( BranchStmt::FallThrough ) ); }1559 { $$ = new StatementNode( build_branch( yylloc, ast::BranchStmt::FallThrough ) ); } 1534 1560 | fall_through_name identifier_or_type_name ';' // CFA 1535 { $$ = new StatementNode( build_branch( $2,BranchStmt::FallThrough ) ); }1561 { $$ = new StatementNode( build_branch( yylloc, $2, ast::BranchStmt::FallThrough ) ); } 1536 1562 | fall_through_name DEFAULT ';' // CFA 1537 { $$ = new StatementNode( build_branch( BranchStmt::FallThroughDefault ) ); }1563 { $$ = new StatementNode( build_branch( yylloc, ast::BranchStmt::FallThroughDefault ) ); } 1538 1564 | CONTINUE ';' 1539 1565 // A semantic check is required to ensure this statement appears only in the body of an iteration statement. 1540 { $$ = new StatementNode( build_branch( BranchStmt::Continue ) ); }1566 { $$ = new StatementNode( build_branch( yylloc, ast::BranchStmt::Continue ) ); } 1541 1567 | CONTINUE identifier_or_type_name ';' // CFA, multi-level continue 1542 1568 // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and 1543 1569 // the target of the transfer appears only at the start of an iteration statement. 1544 { $$ = new StatementNode( build_branch( $2,BranchStmt::Continue ) ); }1570 { $$ = new StatementNode( build_branch( yylloc, $2, ast::BranchStmt::Continue ) ); } 1545 1571 | BREAK ';' 1546 1572 // A semantic check is required to ensure this statement appears only in the body of an iteration statement. 1547 { $$ = new StatementNode( build_branch( BranchStmt::Break ) ); }1573 { $$ = new StatementNode( build_branch( yylloc, ast::BranchStmt::Break ) ); } 1548 1574 | BREAK identifier_or_type_name ';' // CFA, multi-level exit 1549 1575 // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and 1550 1576 // the target of the transfer appears only at the start of an iteration statement. 1551 { $$ = new StatementNode( build_branch( $2,BranchStmt::Break ) ); }1577 { $$ = new StatementNode( build_branch( yylloc, $2, ast::BranchStmt::Break ) ); } 1552 1578 | RETURN comma_expression_opt ';' 1553 { $$ = new StatementNode( build_return( $2 ) ); }1579 { $$ = new StatementNode( build_return( yylloc, $2 ) ); } 1554 1580 | RETURN '{' initializer_list_opt comma_opt '}' ';' 1555 1581 { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } 1556 1582 | SUSPEND ';' 1557 { $$ = new StatementNode( build_suspend( nullptr) ); }1583 { $$ = new StatementNode( build_suspend( yylloc, nullptr, ast::SuspendStmt::None ) ); } 1558 1584 | SUSPEND compound_statement 1559 { $$ = new StatementNode( build_suspend( $2) ); }1585 { $$ = new StatementNode( build_suspend( yylloc, $2, ast::SuspendStmt::None ) ); } 1560 1586 | SUSPEND COROUTINE ';' 1561 { $$ = new StatementNode( build_suspend( nullptr,SuspendStmt::Coroutine ) ); }1587 { $$ = new StatementNode( build_suspend( yylloc, nullptr, ast::SuspendStmt::Coroutine ) ); } 1562 1588 | SUSPEND COROUTINE compound_statement 1563 { $$ = new StatementNode( build_suspend( $3,SuspendStmt::Coroutine ) ); }1589 { $$ = new StatementNode( build_suspend( yylloc, $3, ast::SuspendStmt::Coroutine ) ); } 1564 1590 | SUSPEND GENERATOR ';' 1565 { $$ = new StatementNode( build_suspend( nullptr,SuspendStmt::Generator ) ); }1591 { $$ = new StatementNode( build_suspend( yylloc, nullptr, ast::SuspendStmt::Generator ) ); } 1566 1592 | SUSPEND GENERATOR compound_statement 1567 { $$ = new StatementNode( build_suspend( $3,SuspendStmt::Generator ) ); }1593 { $$ = new StatementNode( build_suspend( yylloc, $3, ast::SuspendStmt::Generator ) ); } 1568 1594 | THROW assignment_expression_opt ';' // handles rethrow 1569 { $$ = new StatementNode( build_throw( $2 ) ); }1595 { $$ = new StatementNode( build_throw( yylloc, $2 ) ); } 1570 1596 | THROWRESUME assignment_expression_opt ';' // handles reresume 1571 { $$ = new StatementNode( build_resume( $2 ) ); }1597 { $$ = new StatementNode( build_resume( yylloc, $2 ) ); } 1572 1598 | THROWRESUME assignment_expression_opt AT assignment_expression ';' // handles reresume 1573 1599 { $$ = new StatementNode( build_resume_at( $2, $4 ) ); } … … 1581 1607 with_statement: 1582 1608 WITH '(' tuple_expression_list ')' statement 1583 { $$ = new StatementNode( build_with( $3, $5 ) ); }1584 ; 1585 1586 // If MUTEX becomes a general qualifier, there are shift/reduce conflicts, so change syntax to "with mutex".1609 { $$ = new StatementNode( build_with( yylloc, $3, $5 ) ); } 1610 ; 1611 1612 // If MUTEX becomes a general qualifier, there are shift/reduce conflicts, so possibly change syntax to "with mutex". 1587 1613 mutex_statement: 1588 MUTEX '(' argument_expression_list ')' statement 1589 { $$ = new StatementNode( build_mutex( $3, $5 ) ); } 1614 MUTEX '(' argument_expression_list_opt ')' statement 1615 { 1616 if ( ! $3 ) { SemanticError( yylloc, "mutex argument list cannot be empty." ); $$ = nullptr; } 1617 $$ = new StatementNode( build_mutex( yylloc, $3, $5 ) ); 1618 } 1590 1619 ; 1591 1620 … … 1598 1627 { $$ = nullptr; } 1599 1628 | when_clause 1600 ;1601 1602 waitfor:1603 WAITFOR '(' cast_expression ')'1604 { $$ = $3; }1605 // | WAITFOR '(' cast_expression ',' argument_expression_list_opt ')'1606 // { $$ = (ExpressionNode *)$3->set_last( $5 ); }1607 | WAITFOR '(' cast_expression_list ':' argument_expression_list_opt ')'1608 { $$ = (ExpressionNode *)($3->set_last( $5 )); }1609 1629 ; 1610 1630 … … 1617 1637 1618 1638 timeout: 1619 TIMEOUT '(' comma_expression ')' { $$ = $3; } 1620 ; 1621 1622 waitfor_clause: 1639 TIMEOUT '(' comma_expression ')' { $$ = $3; } 1640 ; 1641 1642 wor: 1643 OROR 1644 | WOR 1645 1646 waitfor: 1647 WAITFOR '(' cast_expression ')' 1648 { $$ = $3; } 1649 | WAITFOR '(' cast_expression_list ':' argument_expression_list_opt ')' 1650 { $$ = (ExpressionNode *)($3->set_last( $5 )); } 1651 ; 1652 1653 wor_waitfor_clause: 1623 1654 when_clause_opt waitfor statement %prec THEN 1624 { $$ = build_waitfor( $2, maybe_build_compound( $3 ), $1 ); } 1625 | when_clause_opt waitfor statement WOR waitfor_clause 1626 { $$ = build_waitfor( $2, maybe_build_compound( $3 ), $1, $5 ); } 1627 | when_clause_opt timeout statement %prec THEN 1628 { $$ = build_waitfor_timeout( $2, maybe_build_compound( $3 ), $1 ); } 1629 | when_clause_opt ELSE statement 1630 { $$ = build_waitfor_timeout( nullptr, maybe_build_compound( $3 ), $1 ); } 1655 // Called first: create header for WaitForStmt. 1656 { $$ = build_waitfor( yylloc, new ast::WaitForStmt( yylloc ), $1, $2, maybe_build_compound( yylloc, $3 ) ); } 1657 | wor_waitfor_clause wor when_clause_opt waitfor statement 1658 { $$ = build_waitfor( yylloc, $1, $3, $4, maybe_build_compound( yylloc, $5 ) ); } 1659 | wor_waitfor_clause wor when_clause_opt ELSE statement 1660 { $$ = build_waitfor_else( yylloc, $1, $3, maybe_build_compound( yylloc, $5 ) ); } 1661 | wor_waitfor_clause wor when_clause_opt timeout statement %prec THEN 1662 { $$ = build_waitfor_timeout( yylloc, $1, $3, $4, maybe_build_compound( yylloc, $5 ) ); } 1631 1663 // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless) 1632 | w hen_clause_opt timeout statement WORELSE statement // syntax error1664 | wor_waitfor_clause wor when_clause_opt timeout statement wor ELSE statement // syntax error 1633 1665 { SemanticError( yylloc, "else clause must be conditional after timeout or timeout never triggered." ); $$ = nullptr; } 1634 | w hen_clause_opt timeout statement WORwhen_clause ELSE statement1635 { $$ = build_waitfor_ timeout( $2, maybe_build_compound( $3 ), $1, maybe_build_compound( $7 ), $5); }1666 | wor_waitfor_clause wor when_clause_opt timeout statement wor when_clause ELSE statement 1667 { $$ = build_waitfor_else( yylloc, build_waitfor_timeout( yylloc, $1, $3, $4, maybe_build_compound( yylloc, $5 ) ), $7, maybe_build_compound( yylloc, $9 ) ); } 1636 1668 ; 1637 1669 1638 1670 waitfor_statement: 1639 when_clause_opt waitfor statement %prec THEN 1640 { $$ = new StatementNode( build_waitfor( $2, $3, $1 ) ); } 1641 | when_clause_opt waitfor statement WOR waitfor_clause 1642 { $$ = new StatementNode( build_waitfor( $2, $3, $1, $5 ) ); } 1671 wor_waitfor_clause %prec THEN 1672 { $$ = new StatementNode( $1 ); } 1673 ; 1674 1675 wand: 1676 ANDAND 1677 | WAND 1678 ; 1679 1680 waituntil: 1681 WAITUNTIL '(' cast_expression ')' 1682 { $$ = $3; } 1683 ; 1684 1685 waituntil_clause: 1686 when_clause_opt waituntil statement 1687 { $$ = build_waituntil_clause( yylloc, $1, $2, maybe_build_compound( yylloc, $3 ) ); } 1688 | '(' wor_waituntil_clause ')' 1689 { $$ = $2; } 1690 ; 1691 1692 wand_waituntil_clause: 1693 waituntil_clause %prec THEN 1694 { $$ = $1; } 1695 | waituntil_clause wand wand_waituntil_clause 1696 { $$ = new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::AND, $1, $3 ); } 1697 ; 1698 1699 wor_waituntil_clause: 1700 wand_waituntil_clause 1701 { $$ = $1; } 1702 | wor_waituntil_clause wor wand_waituntil_clause 1703 { $$ = new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::OR, $1, $3 ); } 1704 | wor_waituntil_clause wor when_clause_opt ELSE statement 1705 { $$ = new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::LEFT_OR, $1, build_waituntil_else( yylloc, $3, maybe_build_compound( yylloc, $5 ) ) ); } 1706 | wor_waituntil_clause wor when_clause_opt timeout statement %prec THEN 1707 { $$ = new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::LEFT_OR, $1, build_waituntil_timeout( yylloc, $3, $4, maybe_build_compound( yylloc, $5 ) ) ); } 1708 // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless) 1709 | wor_waituntil_clause wor when_clause_opt timeout statement wor ELSE statement // syntax error 1710 { SemanticError( yylloc, "else clause must be conditional after timeout or timeout never triggered." ); $$ = nullptr; } 1711 | wor_waituntil_clause wor when_clause_opt timeout statement wor when_clause ELSE statement 1712 { $$ = new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::LEFT_OR, $1, 1713 new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::OR, 1714 build_waituntil_timeout( yylloc, $3, $4, maybe_build_compound( yylloc, $5 ) ), 1715 build_waituntil_else( yylloc, $7, maybe_build_compound( yylloc, $9 ) ) ) ); } 1716 ; 1717 1718 waituntil_statement: 1719 wor_waituntil_clause %prec THEN 1720 // SKULLDUGGERY: create an empty compound statement to test parsing of waituntil statement. 1721 { 1722 $$ = new StatementNode( build_waituntil_stmt( yylloc, $1 ) ); 1723 // $$ = new StatementNode( build_compound( yylloc, nullptr ) ); 1724 } 1643 1725 ; 1644 1726 1645 1727 exception_statement: 1646 TRY compound_statement handler_clause %prec THEN1647 { $$ = new StatementNode( build_try( $2, $3, 0) ); }1728 TRY compound_statement handler_clause %prec THEN 1729 { $$ = new StatementNode( build_try( yylloc, $2, $3, nullptr ) ); } 1648 1730 | TRY compound_statement finally_clause 1649 { $$ = new StatementNode( build_try( $2, 0, $3 ) ); }1731 { $$ = new StatementNode( build_try( yylloc, $2, nullptr, $3 ) ); } 1650 1732 | TRY compound_statement handler_clause finally_clause 1651 { $$ = new StatementNode( build_try( $2, $3, $4 ) ); }1733 { $$ = new StatementNode( build_try( yylloc, $2, $3, $4 ) ); } 1652 1734 ; 1653 1735 1654 1736 handler_clause: 1655 1737 handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement 1656 { $$ = new StatementNode( build_catch( $1, $4, $6, $8 ) ); }1738 { $$ = new StatementNode( build_catch( yylloc, $1, $4, $6, $8 ) ); } 1657 1739 | handler_clause handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement 1658 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $5, $7, $9 ) ) ); }1740 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( yylloc, $2, $5, $7, $9 ) ) ); } 1659 1741 ; 1660 1742 … … 1666 1748 1667 1749 handler_key: 1668 CATCH { $$ = CatchStmt::Terminate; }1669 | RECOVER { $$ = CatchStmt::Terminate; }1670 | CATCHRESUME { $$ = CatchStmt::Resume; }1671 | FIXUP { $$ = CatchStmt::Resume; }1750 CATCH { $$ = ast::Terminate; } 1751 | RECOVER { $$ = ast::Terminate; } 1752 | CATCHRESUME { $$ = ast::Resume; } 1753 | FIXUP { $$ = ast::Resume; } 1672 1754 ; 1673 1755 1674 1756 finally_clause: 1675 FINALLY compound_statement { $$ = new StatementNode( build_finally( $2 ) ); }1757 FINALLY compound_statement { $$ = new StatementNode( build_finally( yylloc, $2 ) ); } 1676 1758 ; 1677 1759 … … 1699 1781 asm_statement: 1700 1782 ASM asm_volatile_opt '(' string_literal ')' ';' 1701 { $$ = new StatementNode( build_asm( $2, $4, 0) ); }1783 { $$ = new StatementNode( build_asm( yylloc, $2, $4, nullptr ) ); } 1702 1784 | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ')' ';' // remaining GCC 1703 { $$ = new StatementNode( build_asm( $2, $4, $6 ) ); }1785 { $$ = new StatementNode( build_asm( yylloc, $2, $4, $6 ) ); } 1704 1786 | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ':' asm_operands_opt ')' ';' 1705 { $$ = new StatementNode( build_asm( $2, $4, $6, $8 ) ); }1787 { $$ = new StatementNode( build_asm( yylloc, $2, $4, $6, $8 ) ); } 1706 1788 | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list_opt ')' ';' 1707 { $$ = new StatementNode( build_asm( $2, $4, $6, $8, $10 ) ); }1789 { $$ = new StatementNode( build_asm( yylloc, $2, $4, $6, $8, $10 ) ); } 1708 1790 | ASM asm_volatile_opt GOTO '(' string_literal ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' label_list ')' ';' 1709 { $$ = new StatementNode( build_asm( $2, $5, 0, $8, $10, $12 ) ); }1791 { $$ = new StatementNode( build_asm( yylloc, $2, $5, nullptr, $8, $10, $12 ) ); } 1710 1792 ; 1711 1793 … … 1731 1813 asm_operand: // GCC 1732 1814 string_literal '(' constant_expression ')' 1733 { $$ = new ExpressionNode( new AsmExpr( nullptr, $1, maybeMoveBuild<Expression>( $3 ) ) ); }1815 { $$ = new ExpressionNode( new ast::AsmExpr( yylloc, "", $1, maybeMoveBuild( $3 ) ) ); } 1734 1816 | '[' IDENTIFIER ']' string_literal '(' constant_expression ')' 1735 { $$ = new ExpressionNode( new AsmExpr( $2, $4, maybeMoveBuild<Expression>( $6 ) ) ); } 1817 { 1818 $$ = new ExpressionNode( new ast::AsmExpr( yylloc, *$2.str, $4, maybeMoveBuild( $6 ) ) ); 1819 delete $2.str; 1820 } 1736 1821 ; 1737 1822 … … 1748 1833 identifier 1749 1834 { 1750 $$ = new LabelNode(); $$->labels. push_back(*$1 );1835 $$ = new LabelNode(); $$->labels.emplace_back( yylloc, *$1 ); 1751 1836 delete $1; // allocated by lexer 1752 1837 } 1753 1838 | label_list ',' identifier 1754 1839 { 1755 $$ = $1; $1->labels. push_back(*$3 );1840 $$ = $1; $1->labels.emplace_back( yylloc, *$3 ); 1756 1841 delete $3; // allocated by lexer 1757 1842 } … … 1804 1889 { 1805 1890 // printf( "C_DECLARATION1 %p %s\n", $$, $$->name ? $$->name->c_str() : "(nil)" ); 1806 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {1891 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) { 1807 1892 // printf( "\tattr %s\n", attr->name.c_str() ); 1808 1893 // } // for … … 1816 1901 { $$ = DeclarationNode::newStaticAssert( $3, $5 ); } 1817 1902 | STATICASSERT '(' constant_expression ')' ';' // CFA 1818 { $$ = DeclarationNode::newStaticAssert( $3, build_constantStr( *new string( "\"\"" ) ) ); }1903 { $$ = DeclarationNode::newStaticAssert( $3, build_constantStr( yylloc, *new string( "\"\"" ) ) ); } 1819 1904 1820 1905 // C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function … … 1880 1965 // '[' ']' identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' // S/R conflict 1881 1966 // { 1882 // $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true );1967 // $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, nullptr, true ); 1883 1968 // } 1884 1969 // '[' ']' identifier '(' push cfa_parameter_ellipsis_list_opt pop ')' 1885 1970 // { 1886 1971 // typedefTable.setNextIdentifier( *$5 ); 1887 // $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );1972 // $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, nullptr, true ); 1888 1973 // } 1889 1974 // | '[' ']' TYPEDEFname '(' push cfa_parameter_ellipsis_list_opt pop ')' 1890 1975 // { 1891 1976 // typedefTable.setNextIdentifier( *$5 ); 1892 // $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );1977 // $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, nullptr, true ); 1893 1978 // } 1894 1979 // | '[' ']' typegen_name … … 1902 1987 cfa_abstract_tuple identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' attribute_list_opt 1903 1988 // To obtain LR(1 ), this rule must be factored out from function return type (see cfa_abstract_declarator). 1904 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0)->addQualifiers( $8 ); }1989 { $$ = DeclarationNode::newFunction( $2, $1, $5, nullptr )->addQualifiers( $8 ); } 1905 1990 | cfa_function_return identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' attribute_list_opt 1906 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0)->addQualifiers( $8 ); }1991 { $$ = DeclarationNode::newFunction( $2, $1, $5, nullptr )->addQualifiers( $8 ); } 1907 1992 ; 1908 1993 … … 1940 2025 { 1941 2026 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "4" ); 1942 $$ = $3->addType( $2 )->addTypedef(); 2027 if ( $2->type->forall || ($2->type->kind == TypeData::Aggregate && $2->type->aggregate.params) ) { 2028 SemanticError( yylloc, "forall qualifier in typedef is currently unimplemented." ); $$ = nullptr; 2029 } else $$ = $3->addType( $2 )->addTypedef(); // watchout frees $2 and $3 1943 2030 } 1944 2031 | typedef_declaration pop ',' push declarator … … 1948 2035 } 1949 2036 | type_qualifier_list TYPEDEF type_specifier declarator // remaining OBSOLESCENT (see 2 ) 1950 { 1951 typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname, "6" ); 1952 $$ = $4->addType( $3 )->addQualifiers( $1 )->addTypedef(); 1953 } 2037 { SemanticError( yylloc, "Type qualifiers/specifiers before TYPEDEF is deprecated, move after TYPEDEF." ); $$ = nullptr; } 1954 2038 | type_specifier TYPEDEF declarator 1955 { 1956 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "7" ); 1957 $$ = $3->addType( $1 )->addTypedef(); 1958 } 2039 { SemanticError( yylloc, "Type qualifiers/specifiers before TYPEDEF is deprecated, move after TYPEDEF." ); $$ = nullptr; } 1959 2040 | type_specifier TYPEDEF type_qualifier_list declarator 1960 { 1961 typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname, "8" ); 1962 $$ = $4->addQualifiers( $1 )->addTypedef()->addType( $1 ); 1963 } 2041 { SemanticError( yylloc, "Type qualifiers/specifiers before TYPEDEF is deprecated, move after TYPEDEF." ); $$ = nullptr; } 1964 2042 ; 1965 2043 … … 1968 2046 TYPEDEF identifier '=' assignment_expression 1969 2047 { 1970 SemanticError( yylloc, "T ypedefexpression is deprecated, use typeof(...) instead." ); $$ = nullptr;2048 SemanticError( yylloc, "TYPEDEF expression is deprecated, use typeof(...) instead." ); $$ = nullptr; 1971 2049 } 1972 2050 | typedef_expression pop ',' push identifier '=' assignment_expression 1973 2051 { 1974 SemanticError( yylloc, "T ypedefexpression is deprecated, use typeof(...) instead." ); $$ = nullptr;2052 SemanticError( yylloc, "TYPEDEF expression is deprecated, use typeof(...) instead." ); $$ = nullptr; 1975 2053 } 1976 2054 ; … … 1982 2060 | typedef_expression // deprecated GCC, naming expression type 1983 2061 | sue_declaration_specifier 2062 { 2063 assert( $1->type ); 2064 if ( $1->type->qualifiers.any() ) { // CV qualifiers ? 2065 SemanticError( yylloc, "Useless type qualifier(s) in empty declaration." ); $$ = nullptr; 2066 } 2067 // enums are never empty declarations because there must have at least one enumeration. 2068 if ( $1->type->kind == TypeData::AggregateInst && $1->storageClasses.any() ) { // storage class ? 2069 SemanticError( yylloc, "Useless storage qualifier(s) in empty aggregate declaration." ); $$ = nullptr; 2070 } 2071 } 1984 2072 ; 1985 2073 … … 1987 2075 // A semantic check is required to ensure asm_name only appears on declarations with implicit or explicit static 1988 2076 // storage-class 1989 declarator asm_name_opt initializer_opt2077 variable_declarator asm_name_opt initializer_opt 1990 2078 { $$ = $1->addAsmName( $2 )->addInitializer( $3 ); } 2079 | variable_type_redeclarator asm_name_opt initializer_opt 2080 { $$ = $1->addAsmName( $2 )->addInitializer( $3 ); } 2081 2082 | general_function_declarator asm_name_opt 2083 { $$ = $1->addAsmName( $2 )->addInitializer( nullptr ); } 2084 | general_function_declarator asm_name_opt '=' VOID 2085 { $$ = $1->addAsmName( $2 )->addInitializer( new InitializerNode( true ) ); } 2086 1991 2087 | declaring_list ',' attribute_list_opt declarator asm_name_opt initializer_opt 1992 2088 { $$ = $1->appendList( $4->addQualifiers( $3 )->addAsmName( $5 )->addInitializer( $6 ) ); } 1993 2089 ; 1994 2090 2091 general_function_declarator: 2092 function_type_redeclarator 2093 | function_declarator 2094 ; 2095 1995 2096 declaration_specifier: // type specifier + storage class 1996 2097 basic_declaration_specifier 2098 | type_declaration_specifier 1997 2099 | sue_declaration_specifier 1998 | type_declaration_specifier 2100 | sue_declaration_specifier invalid_types 2101 { 2102 SemanticError( yylloc, ::toString( "Missing ';' after end of ", 2103 $1->type->enumeration.name ? "enum" : ast::AggregateDecl::aggrString( $1->type->aggregate.kind ), 2104 " declaration" ) ); 2105 $$ = nullptr; 2106 } 2107 ; 2108 2109 invalid_types: 2110 aggregate_key 2111 | basic_type_name 2112 | indirect_type 1999 2113 ; 2000 2114 … … 2013 2127 basic_type_specifier 2014 2128 | sue_type_specifier 2015 {2016 // printf( "sue_type_specifier2 %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" );2017 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {2018 // printf( "\tattr %s\n", attr->name.c_str() );2019 // } // for2020 }2021 2129 | type_type_specifier 2022 2130 ; … … 2065 2173 { $$ = DeclarationNode::newTypeQualifier( Type::Atomic ); } 2066 2174 | forall 2175 { $$ = DeclarationNode::newForall( $1 ); } 2067 2176 ; 2068 2177 2069 2178 forall: 2070 2179 FORALL '(' type_parameter_list ')' // CFA 2071 { $$ = DeclarationNode::newForall( $3 ); }2180 { $$ = $3; } 2072 2181 ; 2073 2182 … … 2226 2335 { $$ = DeclarationNode::newTypeof( $3 ); } 2227 2336 | BASETYPEOF '(' type ')' // CFA: basetypeof( x ) y; 2228 { $$ = DeclarationNode::newTypeof( new ExpressionNode( new TypeExpr(maybeMoveBuildType( $3 ) ) ), true ); }2337 { $$ = DeclarationNode::newTypeof( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ), true ); } 2229 2338 | BASETYPEOF '(' comma_expression ')' // CFA: basetypeof( a+b ) y; 2230 2339 { $$ = DeclarationNode::newTypeof( $3, true ); } … … 2239 2348 { 2240 2349 // printf( "sue_declaration_specifier %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" ); 2241 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {2350 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) { 2242 2351 // printf( "\tattr %s\n", attr->name.c_str() ); 2243 2352 // } // for … … 2255 2364 { 2256 2365 // printf( "sue_type_specifier %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" ); 2257 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {2366 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) { 2258 2367 // printf( "\tattr %s\n", attr->name.c_str() ); 2259 2368 // } // for … … 2333 2442 { 2334 2443 // printf( "elaborated_type %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" ); 2335 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {2444 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) { 2336 2445 // printf( "\tattr %s\n", attr->name.c_str() ); 2337 2446 // } // for … … 2357 2466 '{' field_declaration_list_opt '}' type_parameters_opt 2358 2467 { 2359 // printf( "aggregate_type1 %s\n", $3.str->c_str() );2360 // if ( $2 )2361 // for ( Attribute * attr: reverseIterate( $2->attributes ) ) {2362 // printf( "copySpecifiers12 %s\n", attr->name.c_str() );2363 // } // for2364 2468 $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 ); 2365 // printf( "aggregate_type2 %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" );2366 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {2367 // printf( "aggregate_type3 %s\n", attr->name.c_str() );2368 // } // for2369 2469 } 2370 2470 | aggregate_key attribute_list_opt TYPEDEFname // unqualified type name … … 2375 2475 '{' field_declaration_list_opt '}' type_parameters_opt 2376 2476 { 2377 // printf( "AGG3\n" );2378 2477 DeclarationNode::newFromTypedef( $3 ); 2379 2478 $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 ); … … 2386 2485 '{' field_declaration_list_opt '}' type_parameters_opt 2387 2486 { 2388 // printf( "AGG4\n" );2389 2487 DeclarationNode::newFromTypeGen( $3, nullptr ); 2390 2488 $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 ); … … 2413 2511 // switched to a TYPEGENname. Link any generic arguments from typegen_name to new generic declaration and 2414 2512 // delete newFromTypeGen. 2415 $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, $3->type->symbolic.actuals, nullptr, false )->addQualifiers( $2 ); 2416 $3->type->symbolic.name = nullptr; 2417 $3->type->symbolic.actuals = nullptr; 2418 delete $3; 2513 if ( $3->type->kind == TypeData::SymbolicInst && ! $3->type->symbolic.isTypedef ) { 2514 $$ = $3->addQualifiers( $2 ); 2515 } else { 2516 $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, $3->type->symbolic.actuals, nullptr, false )->addQualifiers( $2 ); 2517 $3->type->symbolic.name = nullptr; // copied to $$ 2518 $3->type->symbolic.actuals = nullptr; 2519 delete $3; 2520 } 2419 2521 } 2420 2522 ; … … 2427 2529 aggregate_data: 2428 2530 STRUCT vtable_opt 2429 { $$ = AggregateDecl::Struct; }2531 { $$ = ast::AggregateDecl::Struct; } 2430 2532 | UNION 2431 { $$ = AggregateDecl::Union; }2533 { $$ = ast::AggregateDecl::Union; } 2432 2534 | EXCEPTION // CFA 2433 { $$ = AggregateDecl::Exception; }2434 // { SemanticError( yylloc, "exception aggregate is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }2535 { $$ = ast::AggregateDecl::Exception; } 2536 // { SemanticError( yylloc, "exception aggregate is currently unimplemented." ); $$ = ast::AggregateDecl::NoAggregate; } 2435 2537 ; 2436 2538 2437 2539 aggregate_control: // CFA 2438 2540 MONITOR 2439 { $$ = AggregateDecl::Monitor; }2541 { $$ = ast::AggregateDecl::Monitor; } 2440 2542 | MUTEX STRUCT 2441 { $$ = AggregateDecl::Monitor; }2543 { $$ = ast::AggregateDecl::Monitor; } 2442 2544 | GENERATOR 2443 { $$ = AggregateDecl::Generator; }2545 { $$ = ast::AggregateDecl::Generator; } 2444 2546 | MUTEX GENERATOR 2445 { SemanticError( yylloc, "monitor generator is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; } 2547 { 2548 SemanticError( yylloc, "monitor generator is currently unimplemented." ); 2549 $$ = ast::AggregateDecl::NoAggregate; 2550 } 2446 2551 | COROUTINE 2447 { $$ = AggregateDecl::Coroutine; }2552 { $$ = ast::AggregateDecl::Coroutine; } 2448 2553 | MUTEX COROUTINE 2449 { SemanticError( yylloc, "monitor coroutine is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; } 2554 { 2555 SemanticError( yylloc, "monitor coroutine is currently unimplemented." ); 2556 $$ = ast::AggregateDecl::NoAggregate; 2557 } 2450 2558 | THREAD 2451 { $$ = AggregateDecl::Thread; }2559 { $$ = ast::AggregateDecl::Thread; } 2452 2560 | MUTEX THREAD 2453 { SemanticError( yylloc, "monitor thread is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; } 2561 { 2562 SemanticError( yylloc, "monitor thread is currently unimplemented." ); 2563 $$ = ast::AggregateDecl::NoAggregate; 2564 } 2454 2565 ; 2455 2566 … … 2467 2578 $$ = fieldDecl( $1, $2 ); 2468 2579 // printf( "type_specifier2 %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" ); 2469 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {2580 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) { 2470 2581 // printf( "\tattr %s\n", attr->name.c_str() ); 2471 2582 // } // for … … 2473 2584 | EXTENSION type_specifier field_declaring_list_opt ';' // GCC 2474 2585 { $$ = fieldDecl( $2, $3 ); distExt( $$ ); } 2586 | STATIC type_specifier field_declaring_list_opt ';' // CFA 2587 { SemanticError( yylloc, "STATIC aggregate field qualifier currently unimplemented." ); $$ = nullptr; } 2475 2588 | INLINE type_specifier field_abstract_list_opt ';' // CFA 2476 2589 { … … 2483 2596 } 2484 2597 | INLINE aggregate_control ';' // CFA 2485 { SemanticError( yylloc, "INLINE aggregate control currently unimplemented." ); $$ = nullptr; }2598 { SemanticError( yylloc, "INLINE aggregate control currently unimplemented." ); $$ = nullptr; } 2486 2599 | typedef_declaration ';' // CFA 2487 2600 | cfa_field_declaring_list ';' // CFA, new style field declaration … … 2509 2622 { $$ = $1->addBitfield( $2 ); } 2510 2623 | variable_type_redeclarator bit_subrange_size_opt 2624 // A semantic check is required to ensure bit_subrange only appears on integral types. 2625 { $$ = $1->addBitfield( $2 ); } 2626 | function_type_redeclarator bit_subrange_size_opt 2511 2627 // A semantic check is required to ensure bit_subrange only appears on integral types. 2512 2628 { $$ = $1->addBitfield( $2 ); } … … 2563 2679 { $$ = DeclarationNode::newEnum( $3->name, $6, true, false, nullptr, $4 )->addQualifiers( $2 ); } 2564 2680 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}' 2565 {2566 if ( $3->storageClasses.val != 0 || $3->type->qualifiers. val != 0)2681 { 2682 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.any() ) 2567 2683 { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } 2568 2684 … … 2575 2691 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt 2576 2692 { 2577 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." ); }2693 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." ); } 2578 2694 typedefTable.makeTypedef( *$6 ); 2579 2695 } … … 2609 2725 enum_type_nobody: // enum - {...} 2610 2726 ENUM attribute_list_opt identifier 2611 { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, 0, false, false )->addQualifiers( $2 ); }2727 { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, nullptr, false, false )->addQualifiers( $2 ); } 2612 2728 | ENUM attribute_list_opt type_name 2613 { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, 0, false, false )->addQualifiers( $2 ); }2729 { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, nullptr, false, false )->addQualifiers( $2 ); } 2614 2730 ; 2615 2731 … … 2751 2867 type_no_function: // sizeof, alignof, cast (constructor) 2752 2868 cfa_abstract_declarator_tuple // CFA 2753 | type_specifier 2869 | type_specifier // cannot be type_specifier_nobody, e.g., (struct S {}){} is a thing 2754 2870 | type_specifier abstract_declarator 2755 2871 { $$ = $2->addType( $1 ); } … … 2796 2912 designator_list ':' // C99, CFA uses ":" instead of "=" 2797 2913 | identifier_at ':' // GCC, field name 2798 { $$ = new ExpressionNode( build_varref( $1 ) ); }2914 { $$ = new ExpressionNode( build_varref( yylloc, $1 ) ); } 2799 2915 ; 2800 2916 … … 2808 2924 designator: 2809 2925 '.' identifier_at // C99, field name 2810 { $$ = new ExpressionNode( build_varref( $2 ) ); }2926 { $$ = new ExpressionNode( build_varref( yylloc, $2 ) ); } 2811 2927 | '[' push assignment_expression pop ']' // C99, single array element 2812 2928 // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple. … … 2815 2931 { $$ = $3; } 2816 2932 | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements 2817 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild<Expression>( $3 ), maybeMoveBuild<Expression>( $5 ) ) ); }2933 { $$ = new ExpressionNode( new ast::RangeExpr( yylloc, maybeMoveBuild( $3 ), maybeMoveBuild( $5 ) ) ); } 2818 2934 | '.' '[' push field_name_list pop ']' // CFA, tuple field selector 2819 2935 { $$ = $4; } … … 2855 2971 { 2856 2972 typedefTable.addToScope( *$2, TYPEDEFname, "9" ); 2857 if ( $1 == TypeDecl::Otype ) { SemanticError( yylloc, "otype keyword is deprecated, use T " ); }2858 if ( $1 == TypeDecl::Dtype ) { SemanticError( yylloc, "dtype keyword is deprecated, use T &" ); }2859 if ( $1 == TypeDecl::Ttype ) { SemanticError( yylloc, "ttype keyword is deprecated, use T ..." ); }2973 if ( $1 == ast::TypeDecl::Otype ) { SemanticError( yylloc, "otype keyword is deprecated, use T " ); } 2974 if ( $1 == ast::TypeDecl::Dtype ) { SemanticError( yylloc, "dtype keyword is deprecated, use T &" ); } 2975 if ( $1 == ast::TypeDecl::Ttype ) { SemanticError( yylloc, "ttype keyword is deprecated, use T ..." ); } 2860 2976 } 2861 2977 type_initializer_opt assertion_list_opt … … 2868 2984 { 2869 2985 typedefTable.addToScope( *$2, TYPEDIMname, "9" ); 2870 $$ = DeclarationNode::newTypeParam( TypeDecl::Dimension, $2 );2986 $$ = DeclarationNode::newTypeParam( ast::TypeDecl::Dimension, $2 ); 2871 2987 } 2872 2988 // | type_specifier identifier_parameter_declarator 2873 2989 | assertion_list 2874 { $$ = DeclarationNode::newTypeParam( TypeDecl::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }2990 { $$ = DeclarationNode::newTypeParam( ast::TypeDecl::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); } 2875 2991 ; 2876 2992 2877 2993 new_type_class: // CFA 2878 2994 // empty 2879 { $$ = TypeDecl::Otype; }2995 { $$ = ast::TypeDecl::Otype; } 2880 2996 | '&' 2881 { $$ = TypeDecl::Dtype; }2997 { $$ = ast::TypeDecl::Dtype; } 2882 2998 | '*' 2883 { $$ = TypeDecl::DStype; } // dtype + sized2999 { $$ = ast::TypeDecl::DStype; } // dtype + sized 2884 3000 // | '(' '*' ')' 2885 // { $$ = TypeDecl::Ftype; }3001 // { $$ = ast::TypeDecl::Ftype; } 2886 3002 | ELLIPSIS 2887 { $$ = TypeDecl::Ttype; }3003 { $$ = ast::TypeDecl::Ttype; } 2888 3004 ; 2889 3005 2890 3006 type_class: // CFA 2891 3007 OTYPE 2892 { $$ = TypeDecl::Otype; }3008 { $$ = ast::TypeDecl::Otype; } 2893 3009 | DTYPE 2894 { $$ = TypeDecl::Dtype; }3010 { $$ = ast::TypeDecl::Dtype; } 2895 3011 | FTYPE 2896 { $$ = TypeDecl::Ftype; }3012 { $$ = ast::TypeDecl::Ftype; } 2897 3013 | TTYPE 2898 { $$ = TypeDecl::Ttype; }3014 { $$ = ast::TypeDecl::Ttype; } 2899 3015 ; 2900 3016 … … 2922 3038 type_list: // CFA 2923 3039 type 2924 { $$ = new ExpressionNode( new TypeExpr(maybeMoveBuildType( $1 ) ) ); }3040 { $$ = new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $1 ) ) ); } 2925 3041 | assignment_expression 2926 3042 | type_list ',' type 2927 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new TypeExpr(maybeMoveBuildType( $3 ) ) ) )); }3043 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ) )); } 2928 3044 | type_list ',' assignment_expression 2929 3045 { $$ = (ExpressionNode *)( $1->set_last( $3 )); } … … 2950 3066 { 2951 3067 typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" ); 2952 $$ = DeclarationNode::newTypeDecl( $1, 0);3068 $$ = DeclarationNode::newTypeDecl( $1, nullptr ); 2953 3069 } 2954 3070 | identifier_or_type_name '(' type_parameter_list ')' … … 2961 3077 trait_specifier: // CFA 2962 3078 TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' '}' 2963 { $$ = DeclarationNode::newTrait( $2, $4, 0 ); } 3079 { 3080 SemanticWarning( yylloc, Warning::DeprecTraitSyntax ); 3081 $$ = DeclarationNode::newTrait( $2, $4, nullptr ); 3082 } 3083 | forall TRAIT identifier_or_type_name '{' '}' // alternate 3084 { $$ = DeclarationNode::newTrait( $3, $1, nullptr ); } 2964 3085 | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}' 2965 { $$ = DeclarationNode::newTrait( $2, $4, $8 ); } 3086 { 3087 SemanticWarning( yylloc, Warning::DeprecTraitSyntax ); 3088 $$ = DeclarationNode::newTrait( $2, $4, $8 ); 3089 } 3090 | forall TRAIT identifier_or_type_name '{' push trait_declaration_list pop '}' // alternate 3091 { $$ = DeclarationNode::newTrait( $3, $1, $6 ); } 2966 3092 ; 2967 3093 … … 3022 3148 external_definition: 3023 3149 DIRECTIVE 3024 { $$ = DeclarationNode::newDirectiveStmt( new StatementNode( build_directive( $1 ) ) ); }3150 { $$ = DeclarationNode::newDirectiveStmt( new StatementNode( build_directive( yylloc, $1 ) ) ); } 3025 3151 | declaration 3152 { 3153 // Variable declarations of anonymous types requires creating a unique type-name across multiple translation 3154 // unit, which is a dubious task, especially because C uses name rather than structural typing; hence it is 3155 // disallowed at the moment. 3156 if ( $1->linkage == ast::Linkage::Cforall && ! $1->storageClasses.is_static && $1->type && $1->type->kind == TypeData::AggregateInst ) { 3157 if ( $1->type->aggInst.aggregate->kind == TypeData::Enum && $1->type->aggInst.aggregate->enumeration.anon ) { 3158 SemanticError( yylloc, "extern anonymous enumeration is currently unimplemented." ); $$ = nullptr; 3159 } else if ( $1->type->aggInst.aggregate->aggregate.anon ) { // handles struct or union 3160 SemanticError( yylloc, "extern anonymous struct/union is currently unimplemented." ); $$ = nullptr; 3161 } 3162 } 3163 } 3026 3164 | IDENTIFIER IDENTIFIER 3027 3165 { IdentifierBeforeIdentifier( *$1.str, *$2.str, " declaration" ); $$ = nullptr; } … … 3043 3181 } 3044 3182 | ASM '(' string_literal ')' ';' // GCC, global assembler statement 3045 { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0) ) ); }3183 { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( yylloc, false, $3, nullptr ) ) ); } 3046 3184 | EXTERN STRINGliteral 3047 3185 { 3048 3186 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall" 3049 linkage = LinkageSpec::update( yylloc, linkage, $2 );3187 linkage = ast::Linkage::update( yylloc, linkage, $2 ); 3050 3188 } 3051 3189 up external_definition down … … 3058 3196 { 3059 3197 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall" 3060 linkage = LinkageSpec::update( yylloc, linkage, $2 );3198 linkage = ast::Linkage::update( yylloc, linkage, $2 ); 3061 3199 } 3062 3200 '{' up external_definition_list_opt down '}' … … 3069 3207 | type_qualifier_list 3070 3208 { 3071 if ( $1->type->qualifiers. val) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }3209 if ( $1->type->qualifiers.any() ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); } 3072 3210 if ( $1->type->forall ) forall = true; // remember generic type 3073 3211 } … … 3075 3213 { 3076 3214 distQual( $5, $1 ); 3077 forall = false;3215 forall = false; 3078 3216 $$ = $5; 3079 3217 } 3080 3218 | declaration_qualifier_list 3081 3219 { 3082 if ( $1->type && $1->type->qualifiers. val) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }3220 if ( $1->type && $1->type->qualifiers.any() ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); } 3083 3221 if ( $1->type && $1->type->forall ) forall = true; // remember generic type 3084 3222 } … … 3086 3224 { 3087 3225 distQual( $5, $1 ); 3088 forall = false;3226 forall = false; 3089 3227 $$ = $5; 3090 3228 } 3091 3229 | declaration_qualifier_list type_qualifier_list 3092 3230 { 3093 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." ); }3231 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." ); } 3094 3232 if ( ($1->type && $1->type->forall) || ($2->type && $2->type->forall) ) forall = true; // remember generic type 3095 3233 } … … 3097 3235 { 3098 3236 distQual( $6, $1->addQualifiers( $2 ) ); 3099 forall = false;3237 forall = false; 3100 3238 $$ = $6; 3101 3239 } … … 3141 3279 $$ = $2->addFunctionBody( $4, $3 )->addType( $1 ); 3142 3280 } 3143 | declaration_specifier variable_type_redeclarator with_clause_opt compound_statement3281 | declaration_specifier function_type_redeclarator with_clause_opt compound_statement 3144 3282 { 3145 3283 rebindForall( $1, $2 ); … … 3177 3315 | variable_type_redeclarator 3178 3316 | function_declarator 3317 | function_type_redeclarator 3179 3318 ; 3180 3319 3181 3320 subrange: 3182 3321 constant_expression '~' constant_expression // CFA, integer subrange 3183 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild<Expression>( $1 ), maybeMoveBuild<Expression>( $3 ) ) ); }3322 { $$ = new ExpressionNode( new ast::RangeExpr( yylloc, maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); } 3184 3323 ; 3185 3324 … … 3287 3426 variable_ptr: 3288 3427 ptrref_operator variable_declarator 3289 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3428 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3290 3429 | ptrref_operator type_qualifier_list variable_declarator 3291 3430 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3303 3442 | '(' attribute_list variable_ptr ')' array_dimension 3304 3443 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); } 3305 | '(' variable_array ')' multi_array_dimension // redundant parenthesis3444 | '(' variable_array ')' multi_array_dimension // redundant parenthesis 3306 3445 { $$ = $2->addArray( $4 ); } 3307 3446 | '(' attribute_list variable_array ')' multi_array_dimension // redundant parenthesis … … 3351 3490 function_ptr: 3352 3491 ptrref_operator function_declarator 3353 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3492 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3354 3493 | ptrref_operator type_qualifier_list function_declarator 3355 3494 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3403 3542 KR_function_ptr: 3404 3543 ptrref_operator KR_function_declarator 3405 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3544 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3406 3545 | ptrref_operator type_qualifier_list KR_function_declarator 3407 3546 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3427 3566 ; 3428 3567 3429 // This pattern parses a declaration for a variable or function prototypethat redefines a type name, e.g.:3568 // This pattern parses a declaration for a variable that redefines a type name, e.g.: 3430 3569 // 3431 3570 // typedef int foo; … … 3433 3572 // int foo; // redefine typedef name in new scope 3434 3573 // } 3435 //3436 // The pattern precludes declaring an array of functions versus a pointer to an array of functions, and returning arrays3437 // and functions versus pointers to arrays and functions.3438 3574 3439 3575 paren_type: … … 3450 3586 paren_type attribute_list_opt 3451 3587 { $$ = $1->addQualifiers( $2 ); } 3452 | type_ptr3453 | type_array attribute_list_opt3588 | variable_type_ptr 3589 | variable_type_array attribute_list_opt 3454 3590 { $$ = $1->addQualifiers( $2 ); } 3455 | type_function attribute_list_opt3591 | variable_type_function attribute_list_opt 3456 3592 { $$ = $1->addQualifiers( $2 ); } 3457 3593 ; 3458 3594 3459 type_ptr:3595 variable_type_ptr: 3460 3596 ptrref_operator variable_type_redeclarator 3461 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3597 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3462 3598 | ptrref_operator type_qualifier_list variable_type_redeclarator 3463 3599 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 3464 | '(' type_ptr ')' attribute_list_opt// redundant parenthesis3600 | '(' variable_type_ptr ')' attribute_list_opt // redundant parenthesis 3465 3601 { $$ = $2->addQualifiers( $4 ); } 3466 | '(' attribute_list type_ptr ')' attribute_list_opt // redundant parenthesis3602 | '(' attribute_list variable_type_ptr ')' attribute_list_opt // redundant parenthesis 3467 3603 { $$ = $3->addQualifiers( $2 )->addQualifiers( $5 ); } 3468 3604 ; 3469 3605 3470 type_array:3606 variable_type_array: 3471 3607 paren_type array_dimension 3472 3608 { $$ = $1->addArray( $2 ); } 3473 | '(' type_ptr ')' array_dimension3609 | '(' variable_type_ptr ')' array_dimension 3474 3610 { $$ = $2->addArray( $4 ); } 3475 | '(' attribute_list type_ptr ')' array_dimension3611 | '(' attribute_list variable_type_ptr ')' array_dimension 3476 3612 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); } 3477 | '(' type_array ')' multi_array_dimension// redundant parenthesis3613 | '(' variable_type_array ')' multi_array_dimension // redundant parenthesis 3478 3614 { $$ = $2->addArray( $4 ); } 3479 | '(' attribute_list type_array ')' multi_array_dimension // redundant parenthesis3615 | '(' attribute_list variable_type_array ')' multi_array_dimension // redundant parenthesis 3480 3616 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); } 3481 | '(' type_array ')'// redundant parenthesis3617 | '(' variable_type_array ')' // redundant parenthesis 3482 3618 { $$ = $2; } 3483 | '(' attribute_list type_array ')'// redundant parenthesis3619 | '(' attribute_list variable_type_array ')' // redundant parenthesis 3484 3620 { $$ = $3->addQualifiers( $2 ); } 3485 3621 ; 3486 3622 3487 type_function: 3623 variable_type_function: 3624 '(' variable_type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3625 { $$ = $2->addParamList( $6 ); } 3626 | '(' attribute_list variable_type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3627 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); } 3628 | '(' variable_type_function ')' // redundant parenthesis 3629 { $$ = $2; } 3630 | '(' attribute_list variable_type_function ')' // redundant parenthesis 3631 { $$ = $3->addQualifiers( $2 ); } 3632 ; 3633 3634 // This pattern parses a declaration for a function prototype that redefines a type name. It precludes declaring an 3635 // array of functions versus a pointer to an array of functions, and returning arrays and functions versus pointers to 3636 // arrays and functions. 3637 3638 function_type_redeclarator: 3639 function_type_no_ptr attribute_list_opt 3640 { $$ = $1->addQualifiers( $2 ); } 3641 | function_type_ptr 3642 | function_type_array attribute_list_opt 3643 { $$ = $1->addQualifiers( $2 ); } 3644 ; 3645 3646 function_type_no_ptr: 3488 3647 paren_type '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3489 3648 { $$ = $1->addParamList( $4 ); } 3490 | '(' type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)3649 | '(' function_type_ptr ')' '(' push parameter_type_list_opt pop ')' 3491 3650 { $$ = $2->addParamList( $6 ); } 3492 | '(' attribute_list type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)3651 | '(' attribute_list function_type_ptr ')' '(' push parameter_type_list_opt pop ')' 3493 3652 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); } 3494 | '(' type_function ')'// redundant parenthesis3653 | '(' function_type_no_ptr ')' // redundant parenthesis 3495 3654 { $$ = $2; } 3496 | '(' attribute_list type_function ')' // redundant parenthesis 3655 | '(' attribute_list function_type_no_ptr ')' // redundant parenthesis 3656 { $$ = $3->addQualifiers( $2 ); } 3657 ; 3658 3659 function_type_ptr: 3660 ptrref_operator function_type_redeclarator 3661 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3662 | ptrref_operator type_qualifier_list function_type_redeclarator 3663 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 3664 | '(' function_type_ptr ')' attribute_list_opt 3665 { $$ = $2->addQualifiers( $4 ); } 3666 | '(' attribute_list function_type_ptr ')' attribute_list_opt 3667 { $$ = $3->addQualifiers( $2 )->addQualifiers( $5 ); } 3668 ; 3669 3670 function_type_array: 3671 '(' function_type_ptr ')' array_dimension 3672 { $$ = $2->addArray( $4 ); } 3673 | '(' attribute_list function_type_ptr ')' array_dimension 3674 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); } 3675 | '(' function_type_array ')' multi_array_dimension // redundant parenthesis 3676 { $$ = $2->addArray( $4 ); } 3677 | '(' attribute_list function_type_array ')' multi_array_dimension // redundant parenthesis 3678 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); } 3679 | '(' function_type_array ')' // redundant parenthesis 3680 { $$ = $2; } 3681 | '(' attribute_list function_type_array ')' // redundant parenthesis 3497 3682 { $$ = $3->addQualifiers( $2 ); } 3498 3683 ; … … 3517 3702 identifier_parameter_ptr: 3518 3703 ptrref_operator identifier_parameter_declarator 3519 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3704 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3520 3705 | ptrref_operator type_qualifier_list identifier_parameter_declarator 3521 3706 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3574 3759 type_parameter_ptr: 3575 3760 ptrref_operator type_parameter_redeclarator 3576 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3761 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3577 3762 | ptrref_operator type_qualifier_list type_parameter_redeclarator 3578 3763 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3617 3802 abstract_ptr: 3618 3803 ptrref_operator 3619 { $$ = DeclarationNode::newPointer( 0, $1 ); }3804 { $$ = DeclarationNode::newPointer( nullptr, $1 ); } 3620 3805 | ptrref_operator type_qualifier_list 3621 3806 { $$ = DeclarationNode::newPointer( $2, $1 ); } 3622 3807 | ptrref_operator abstract_declarator 3623 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3808 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3624 3809 | ptrref_operator type_qualifier_list abstract_declarator 3625 3810 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3650 3835 // Only the first dimension can be empty. 3651 3836 '[' ']' 3652 { $$ = DeclarationNode::newArray( 0, 0, false ); }3837 { $$ = DeclarationNode::newArray( nullptr, nullptr, false ); } 3653 3838 | '[' ']' multi_array_dimension 3654 { $$ = DeclarationNode::newArray( 0, 0, false )->addArray( $3 ); }3839 { $$ = DeclarationNode::newArray( nullptr, nullptr, false )->addArray( $3 ); } 3655 3840 // Cannot use constant_expression because of tuples => semantic check 3656 3841 | '[' push assignment_expression pop ',' comma_expression ']' // CFA 3657 { $$ = DeclarationNode::newArray( $3, 0, false )->addArray( DeclarationNode::newArray( $6, 0, false ) ); }3842 { $$ = DeclarationNode::newArray( $3, nullptr, false )->addArray( DeclarationNode::newArray( $6, nullptr, false ) ); } 3658 3843 // { SemanticError( yylloc, "New array dimension is currently unimplemented." ); $$ = nullptr; } 3659 3844 | '[' push array_type_list pop ']' // CFA … … 3664 3849 array_type_list: 3665 3850 basic_type_name 3666 { $$ = new ExpressionNode( new TypeExpr(maybeMoveBuildType( $1 ) ) ); }3851 { $$ = new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $1 ) ) ); } 3667 3852 | type_name 3668 { $$ = new ExpressionNode( new TypeExpr(maybeMoveBuildType( $1 ) ) ); }3853 { $$ = new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $1 ) ) ); } 3669 3854 | assignment_expression upupeq assignment_expression 3670 3855 | array_type_list ',' basic_type_name 3671 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new TypeExpr(maybeMoveBuildType( $3 ) ) ) )); }3672 | array_type_list ',' type_name 3673 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new TypeExpr(maybeMoveBuildType( $3 ) ) ) )); }3856 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ) )); } 3857 | array_type_list ',' type_name 3858 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ) )); } 3674 3859 | array_type_list ',' assignment_expression upupeq assignment_expression 3675 3860 ; … … 3680 3865 | ErangeUpEq 3681 3866 { $$ = OperKinds::LEThan; } 3682 ;3867 ; 3683 3868 3684 3869 multi_array_dimension: 3685 3870 '[' push assignment_expression pop ']' 3686 { $$ = DeclarationNode::newArray( $3, 0, false ); }3871 { $$ = DeclarationNode::newArray( $3, nullptr, false ); } 3687 3872 | '[' push '*' pop ']' // C99 3688 3873 { $$ = DeclarationNode::newVarArray( 0 ); } 3689 3874 | multi_array_dimension '[' push assignment_expression pop ']' 3690 { $$ = $1->addArray( DeclarationNode::newArray( $4, 0, false ) ); }3875 { $$ = $1->addArray( DeclarationNode::newArray( $4, nullptr, false ) ); } 3691 3876 | multi_array_dimension '[' push '*' pop ']' // C99 3692 3877 { $$ = $1->addArray( DeclarationNode::newVarArray( 0 ) ); } … … 3785 3970 array_parameter_1st_dimension: 3786 3971 '[' ']' 3787 { $$ = DeclarationNode::newArray( 0, 0, false ); }3972 { $$ = DeclarationNode::newArray( nullptr, nullptr, false ); } 3788 3973 // multi_array_dimension handles the '[' '*' ']' case 3789 3974 | '[' push type_qualifier_list '*' pop ']' // remaining C99 3790 3975 { $$ = DeclarationNode::newVarArray( $3 ); } 3791 3976 | '[' push type_qualifier_list pop ']' 3792 { $$ = DeclarationNode::newArray( 0, $3, false ); }3977 { $$ = DeclarationNode::newArray( nullptr, $3, false ); } 3793 3978 // multi_array_dimension handles the '[' assignment_expression ']' case 3794 3979 | '[' push type_qualifier_list assignment_expression pop ']' … … 3819 4004 variable_abstract_ptr: 3820 4005 ptrref_operator 3821 { $$ = DeclarationNode::newPointer( 0, $1 ); }4006 { $$ = DeclarationNode::newPointer( nullptr, $1 ); } 3822 4007 | ptrref_operator type_qualifier_list 3823 4008 { $$ = DeclarationNode::newPointer( $2, $1 ); } 3824 4009 | ptrref_operator variable_abstract_declarator 3825 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }4010 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3826 4011 | ptrref_operator type_qualifier_list variable_abstract_declarator 3827 4012 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3865 4050 // No SUE declaration in parameter list. 3866 4051 ptrref_operator type_specifier_nobody 3867 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }4052 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3868 4053 | type_qualifier_list ptrref_operator type_specifier_nobody 3869 4054 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3870 4055 | ptrref_operator cfa_abstract_function 3871 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }4056 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3872 4057 | type_qualifier_list ptrref_operator cfa_abstract_function 3873 4058 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3874 4059 | ptrref_operator cfa_identifier_parameter_declarator_tuple 3875 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }4060 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3876 4061 | type_qualifier_list ptrref_operator cfa_identifier_parameter_declarator_tuple 3877 4062 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } … … 3882 4067 // shift/reduce conflict with new-style empty (void) function return type. 3883 4068 '[' ']' type_specifier_nobody 3884 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }4069 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 3885 4070 | cfa_array_parameter_1st_dimension type_specifier_nobody 3886 4071 { $$ = $2->addNewArray( $1 ); } 3887 4072 | '[' ']' multi_array_dimension type_specifier_nobody 3888 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }4073 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 3889 4074 | cfa_array_parameter_1st_dimension multi_array_dimension type_specifier_nobody 3890 4075 { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); } … … 3893 4078 3894 4079 | '[' ']' cfa_identifier_parameter_ptr 3895 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }4080 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 3896 4081 | cfa_array_parameter_1st_dimension cfa_identifier_parameter_ptr 3897 4082 { $$ = $2->addNewArray( $1 ); } 3898 4083 | '[' ']' multi_array_dimension cfa_identifier_parameter_ptr 3899 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }4084 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 3900 4085 | cfa_array_parameter_1st_dimension multi_array_dimension cfa_identifier_parameter_ptr 3901 4086 { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); } … … 3953 4138 cfa_abstract_ptr: // CFA 3954 4139 ptrref_operator type_specifier 3955 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }4140 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3956 4141 | type_qualifier_list ptrref_operator type_specifier 3957 4142 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3958 4143 | ptrref_operator cfa_abstract_function 3959 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }4144 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3960 4145 | type_qualifier_list ptrref_operator cfa_abstract_function 3961 4146 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3962 4147 | ptrref_operator cfa_abstract_declarator_tuple 3963 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }4148 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3964 4149 | type_qualifier_list ptrref_operator cfa_abstract_declarator_tuple 3965 4150 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
Note:
See TracChangeset
for help on using the changeset viewer.