Changeset 2514607d for src/Parser
- Timestamp:
- Jul 23, 2018, 6:00:57 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- e68b3a8
- Parents:
- cbdf565 (diff), c29c342 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- src/Parser
- Files:
-
- 5 edited
-
DeclarationNode.cc (modified) (13 diffs)
-
ParseNode.h (modified) (11 diffs)
-
TypeData.cc (modified) (10 diffs)
-
TypeData.h (modified) (5 diffs)
-
parser.yy (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
rcbdf565 r2514607d 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 6 06:56:08201813 // Update Count : 1 08812 // Last Modified On : Fri Jul 20 14:56:54 2018 13 // Update Count : 1107 14 14 // 15 15 … … 54 54 55 55 DeclarationNode::DeclarationNode() : 56 builtin( NoBuiltinType ), 57 type( nullptr ), 58 bitfieldWidth( nullptr ), 59 hasEllipsis( false ), 60 linkage( ::linkage ), 61 asmName( nullptr ), 62 initializer( nullptr ), 63 extension( false ), 64 asmStmt( nullptr ) { 56 linkage( ::linkage ) { 65 57 66 58 // variable.name = nullptr; … … 104 96 newnode->builtin = NoBuiltinType; 105 97 newnode->type = maybeClone( type ); 98 newnode->inLine = inLine; 106 99 newnode->storageClasses = storageClasses; 107 100 newnode->funcSpecs = funcSpecs; … … 131 124 } // DeclarationNode::clone 132 125 133 void DeclarationNode::print( std::ostream & os, int indent ) const {126 void DeclarationNode::print( std::ostream & os, int indent ) const { 134 127 os << string( indent, ' ' ); 135 128 if ( name ) { … … 167 160 } 168 161 169 void DeclarationNode::printList( std::ostream & os, int indent ) const {162 void DeclarationNode::printList( std::ostream & os, int indent ) const { 170 163 ParseNode::printList( os, indent ); 171 164 if ( hasEllipsis ) { … … 521 514 } // DeclarationNode::copySpecifiers 522 515 523 static void addQualifiersToType( TypeData *& src, TypeData * dst ) {516 static void addQualifiersToType( TypeData *& src, TypeData * dst ) { 524 517 if ( dst->base ) { 525 518 addQualifiersToType( src, dst->base ); … … 574 567 } // addQualifiers 575 568 576 static void addTypeToType( TypeData *& src, TypeData *&dst ) {569 static void addTypeToType( TypeData *& src, TypeData *& dst ) { 577 570 if ( src->forall && dst->kind == TypeData::Function ) { 578 571 if ( dst->forall ) { … … 965 958 } 966 959 967 void buildList( const DeclarationNode * firstNode, std::list< Declaration * > & outputList ) {960 void buildList( const DeclarationNode * firstNode, std::list< Declaration * > & outputList ) { 968 961 SemanticErrorException errors; 969 962 std::back_insert_iterator< std::list< Declaration * > > out( outputList ); … … 1002 995 // struct T; // anonymous member 1003 996 // }; 1004 if ( ! (extracted && decl->name == "" && ! anon ) ) {1005 if ( decl->name == "") {997 if ( ! (extracted && decl->name == "" && ! anon && ! cur->get_inLine()) ) { 998 if ( decl->name == "" ) { 1006 999 if ( DeclarationWithType * dwt = dynamic_cast<DeclarationWithType *>( decl ) ) { 1007 1000 if ( ReferenceToType * aggr = dynamic_cast<ReferenceToType *>( dwt->get_type() ) ) { 1008 1001 if ( aggr->name.find("anonymous") == std::string::npos ) { 1009 bool isInline = false; 1010 if (cur->type->kind == TypeData::Aggregate || cur->type->kind == TypeData::AggregateInst) { 1011 if (cur->type->kind == TypeData::Aggregate) { 1012 isInline = cur->type->aggregate.inLine; 1013 } else { 1014 isInline = cur->type->aggInst.inLine; 1015 if ( TypeData * aggr = cur->type->aggInst.aggregate ) { 1016 if ( aggr->kind == TypeData::Aggregate ) { 1017 isInline = isInline || aggr->aggregate.inLine; 1018 } 1019 } 1020 } 1021 } 1022 if (! isInline) { 1023 // temporary: warn about anonymous member declarations of named types, since this conflicts with the syntax for the forward declaration of an anonymous type 1002 if ( ! cur->get_inLine() ) { 1003 // temporary: warn about anonymous member declarations of named types, since 1004 // this conflicts with the syntax for the forward declaration of an anonymous type 1024 1005 SemanticWarning( cur->location, Warning::AggrForwardDecl, aggr->name.c_str() ); 1025 } 1026 } 1027 } 1028 } 1029 } 1006 } // if 1007 } // if 1008 } // if 1009 } // if 1010 } // if 1030 1011 decl->location = cur->location; 1031 * out++ = decl;1032 } 1012 *out++ = decl; 1013 } // if 1033 1014 } // if 1034 } catch( SemanticErrorException & e ) {1015 } catch( SemanticErrorException & e ) { 1035 1016 errors.append( e ); 1036 1017 } // try 1037 } // while1018 } // for 1038 1019 1039 1020 if ( ! errors.isEmpty() ) { … … 1043 1024 1044 1025 // currently only builds assertions, function parameters, and return values 1045 void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > & outputList ) {1026 void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > & outputList ) { 1046 1027 SemanticErrorException errors; 1047 1028 std::back_insert_iterator< std::list< DeclarationWithType * > > out( outputList ); … … 1074 1055 * out++ = obj; 1075 1056 } // if 1076 } catch( SemanticErrorException & e ) {1057 } catch( SemanticErrorException & e ) { 1077 1058 errors.append( e ); 1078 1059 } // try … … 1084 1065 } // buildList 1085 1066 1086 void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > & outputList ) {1067 void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > & outputList ) { 1087 1068 SemanticErrorException errors; 1088 1069 std::back_insert_iterator< std::list< Type * > > out( outputList ); … … 1092 1073 try { 1093 1074 * out++ = cur->buildType(); 1094 } catch( SemanticErrorException & e ) {1075 } catch( SemanticErrorException & e ) { 1095 1076 errors.append( e ); 1096 1077 } // try -
src/Parser/ParseNode.h
rcbdf565 r2514607d 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 6 16:17:18201813 // Update Count : 8 4312 // Last Modified On : Fri Jul 20 14:56:30 2018 13 // Update Count : 850 14 14 // 15 15 … … 68 68 } 69 69 70 virtual void print( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const {}71 virtual void printList( std::ostream & os, int indent = 0 ) const {70 virtual void print( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const {} 71 virtual void printList( std::ostream & os, int indent = 0 ) const { 72 72 print( os, indent ); 73 73 if ( next ) next->print( os, indent ); … … 103 103 InitializerNode * next_init() const { return kids; } 104 104 105 void print( std::ostream & os, int indent = 0 ) const;105 void print( std::ostream & os, int indent = 0 ) const; 106 106 void printOneLine( std::ostream & ) const; 107 107 … … 127 127 ExpressionNode * set_extension( bool exten ) { extension = exten; return this; } 128 128 129 virtual void print( std::ostream & os, __attribute__((unused)) int indent = 0 ) const override {130 os << expr.get() << std::endl;131 } 132 void printOneLine( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const {}129 virtual void print( std::ostream & os, __attribute__((unused)) int indent = 0 ) const override { 130 os << expr.get(); 131 } 132 void printOneLine( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const {} 133 133 134 134 template<typename T> … … 290 290 } 291 291 292 virtual void print( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const override;293 virtual void printList( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const override;292 virtual void print( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const override; 293 virtual void printList( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const override; 294 294 295 295 Declaration * build() const; … … 303 303 bool get_extension() const { return extension; } 304 304 DeclarationNode * set_extension( bool exten ) { extension = exten; return this; } 305 306 bool get_inLine() const { return inLine; } 307 DeclarationNode * set_inLine( bool inL ) { inLine = inL; return this; } 305 308 public: 306 309 DeclarationNode * get_last() { return (DeclarationNode *)ParseNode::get_last(); } … … 327 330 StaticAssert_t assert; 328 331 329 BuiltinType builtin; 330 331 TypeData * type; 332 332 BuiltinType builtin = NoBuiltinType; 333 334 TypeData * type = nullptr; 335 336 bool inLine = false; 333 337 Type::FuncSpecifiers funcSpecs; 334 338 Type::StorageClasses storageClasses; 335 339 336 ExpressionNode * bitfieldWidth ;340 ExpressionNode * bitfieldWidth = nullptr; 337 341 std::unique_ptr<ExpressionNode> enumeratorValue; 338 bool hasEllipsis ;342 bool hasEllipsis = false; 339 343 LinkageSpec::Spec linkage; 340 Expression * asmName ;344 Expression * asmName = nullptr; 341 345 std::list< Attribute * > attributes; 342 InitializerNode * initializer ;346 InitializerNode * initializer = nullptr; 343 347 bool extension = false; 344 348 std::string error; 345 StatementNode * asmStmt ;349 StatementNode * asmStmt = nullptr; 346 350 347 351 static UniqueName anonymous; … … 377 381 virtual StatementNode * append_last_case( StatementNode * ); 378 382 379 virtual void print( std::ostream & os, __attribute__((unused)) int indent = 0 ) const override {383 virtual void print( std::ostream & os, __attribute__((unused)) int indent = 0 ) const override { 380 384 os << stmt.get() << std::endl; 381 385 } … … 435 439 436 440 template< typename SynTreeType, typename NodeType, template< typename, typename...> class Container, typename... Args > 437 void buildList( const NodeType * firstNode, Container< SynTreeType *, Args... > & outputList ) {441 void buildList( const NodeType * firstNode, Container< SynTreeType *, Args... > & outputList ) { 438 442 SemanticErrorException errors; 439 443 std::back_insert_iterator< Container< SynTreeType *, Args... > > out( outputList ); … … 449 453 assertf(false, "buildList unknown type"); 450 454 } // if 451 } catch( SemanticErrorException & e ) {455 } catch( SemanticErrorException & e ) { 452 456 errors.append( e ); 453 457 } // try … … 460 464 461 465 // in DeclarationNode.cc 462 void buildList( const DeclarationNode * firstNode, std::list< Declaration * > & outputList );463 void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > & outputList );464 void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > & outputList );466 void buildList( const DeclarationNode * firstNode, std::list< Declaration * > & outputList ); 467 void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > & outputList ); 468 void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > & outputList ); 465 469 466 470 template< typename SynTreeType, typename NodeType > 467 void buildMoveList( const NodeType * firstNode, std::list< SynTreeType * > & outputList ) {471 void buildMoveList( const NodeType * firstNode, std::list< SynTreeType * > & outputList ) { 468 472 buildList( firstNode, outputList ); 469 473 delete firstNode; -
src/Parser/TypeData.cc
rcbdf565 r2514607d 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 12 13:52:09201813 // Update Count : 6 0612 // Last Modified On : Fri Jul 20 14:39:31 2018 13 // Update Count : 622 14 14 // 15 15 … … 76 76 aggregate.parent = nullptr; 77 77 aggregate.anon = false; 78 aggregate.inLine = false;79 78 break; 80 79 case AggregateInst: … … 83 82 aggInst.params = nullptr; 84 83 aggInst.hoistType = false; 85 aggInst.inLine = false;86 84 break; 87 85 case Symbolic: … … 221 219 newtype->aggregate.body = aggregate.body; 222 220 newtype->aggregate.anon = aggregate.anon; 223 newtype->aggregate.inLine = aggregate.inLine;224 221 newtype->aggregate.tagged = aggregate.tagged; 225 222 newtype->aggregate.parent = aggregate.parent ? new string( *aggregate.parent ) : nullptr; … … 229 226 newtype->aggInst.params = maybeClone( aggInst.params ); 230 227 newtype->aggInst.hoistType = aggInst.hoistType; 231 newtype->aggInst.inLine = aggInst.inLine;232 228 break; 233 229 case Enum: … … 275 271 276 272 switch ( kind ) { 277 case Unknown: 278 os << "entity of unknown type "; 273 case Basic: 274 if ( signedness != DeclarationNode::NoSignedness ) os << DeclarationNode::signednessNames[ signedness ] << " "; 275 if ( length != DeclarationNode::NoLength ) os << DeclarationNode::lengthNames[ length ] << " "; 276 if ( complextype == DeclarationNode::NoComplexType ) { // basic type 277 assert( basictype != DeclarationNode::NoBasicType ); 278 os << DeclarationNode::basicTypeNames[ basictype ] << " "; 279 } else { // complex type 280 // handle double _Complex 281 if ( basictype != DeclarationNode::NoBasicType ) os << DeclarationNode::basicTypeNames[ basictype ] << " "; 282 os << DeclarationNode::complexTypeNames[ complextype ] << " "; 283 } // if 279 284 break; 280 285 case Pointer: … … 285 290 } // if 286 291 break; 287 case EnumConstant: 288 os << "enumeration constant "; 289 break; 290 case Basic: 291 if ( signedness != DeclarationNode::NoSignedness ) os << DeclarationNode::signednessNames[ signedness ] << " "; 292 if ( length != DeclarationNode::NoLength ) os << DeclarationNode::lengthNames[ length ] << " "; 293 assert( basictype != DeclarationNode::NoBasicType ); 294 os << DeclarationNode::basicTypeNames[ basictype ] << " "; 295 if ( complextype != DeclarationNode::NoComplexType ) os << DeclarationNode::complexTypeNames[ complextype ] << " "; 292 case Reference: 293 os << "reference "; 294 if ( base ) { 295 os << "to "; 296 base->print( os, indent ); 297 } // if 296 298 break; 297 299 case Array: … … 379 381 } // if 380 382 break; 381 case SymbolicInst: 382 os << "instance of type " << *symbolic.name; 383 if ( symbolic.actuals ) { 384 os << " with parameters" << endl; 385 symbolic.actuals->printList( os, indent + 2 ); 386 } // if 383 case EnumConstant: 384 os << "enumeration constant "; 387 385 break; 388 386 case Symbolic: … … 406 404 } // if 407 405 break; 406 case SymbolicInst: 407 os << *symbolic.name; 408 if ( symbolic.actuals ) { 409 os << "("; 410 symbolic.actuals->printList( os, indent + 2 ); 411 os << ")"; 412 } // if 413 break; 408 414 case Tuple: 409 415 os << "tuple "; … … 421 427 case Builtin: 422 428 os << DeclarationNode::builtinTypeNames[builtintype]; 429 break; 430 case GlobalScope: 431 break; 432 case Qualified: 433 qualified.parent->print( os ); 434 os << "."; 435 qualified.child->print( os ); 436 break; 437 case Unknown: 438 os << "entity of unknown type "; 423 439 break; 424 440 default: -
src/Parser/TypeData.h
rcbdf565 r2514607d 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 12 14:00:09201813 // Update Count : 19 312 // Last Modified On : Fri Jul 20 13:56:40 2018 13 // Update Count : 195 14 14 // 15 15 … … 26 26 27 27 struct TypeData { 28 enum Kind { Basic, Pointer, Array, Reference, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic,28 enum Kind { Basic, Pointer, Reference, Array, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic, 29 29 SymbolicInst, Tuple, Typeof, Builtin, GlobalScope, Qualified, Unknown }; 30 30 … … 37 37 bool body; 38 38 bool anon; 39 bool inLine;40 39 41 40 bool tagged; … … 47 46 ExpressionNode * params; 48 47 bool hoistType; 49 bool inLine;50 48 }; 51 49 … … 79 77 }; 80 78 81 struct Qualified_t { // qualified type S.T79 struct Qualified_t { // qualified type S.T 82 80 TypeData * parent; 83 81 TypeData * child; -
src/Parser/parser.yy
rcbdf565 r2514607d 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 12 16:16:25201813 // Update Count : 3 75612 // Last Modified On : Fri Jul 20 11:46:46 2018 13 // Update Count : 3837 14 14 // 15 15 … … 114 114 } // for 115 115 } // distExt 116 117 void distInl( DeclarationNode * declaration ) { 118 // distribute EXTENSION across all declarations 119 for ( DeclarationNode *iter = declaration; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 120 iter->set_inLine( true ); 121 } // for 122 } // distInl 116 123 117 124 void distQual( DeclarationNode * declaration, DeclarationNode * qualifiers ) { … … 166 173 } // build_postfix_name 167 174 175 DeclarationNode * fieldDecl( DeclarationNode * typeSpec, DeclarationNode * fieldList ) { 176 if ( ! fieldList ) { // field declarator ? 177 if ( ! ( typeSpec->type && typeSpec->type->kind == TypeData::Aggregate ) ) { 178 stringstream ss; 179 typeSpec->type->print( ss ); 180 SemanticWarning( yylloc, Warning::SuperfluousDecl, ss.str().c_str() ); 181 return nullptr; 182 } // if 183 fieldList = DeclarationNode::newName( nullptr ); 184 } // if 185 return distAttr( typeSpec, fieldList ); // mark all fields in list 186 } // fieldDecl 187 168 188 bool forall = false, yyy = false; // aggregate have one or more forall qualifiers ? 169 189 … … 338 358 %type<decl> exception_declaration 339 359 340 %type<decl> field_declaration field_declaration_list_opt field_declarator_opt field_declaring_list341 %type<en> field field_ list field_name fraction_constants_opt360 %type<decl> field_declaration_list_opt field_declaration field_declaring_list_opt field_declarator field_abstract_list_opt field_abstract 361 %type<en> field field_name_list field_name fraction_constants_opt 342 362 343 363 %type<decl> external_function_definition function_definition function_array function_declarator function_no_ptr function_ptr … … 352 372 %type<decl> cfa_array_parameter_1st_dimension 353 373 354 %type<decl> cfa_trait_declaring_list cfa_declaration cfa_field_declaring_list 374 %type<decl> cfa_trait_declaring_list cfa_declaration cfa_field_declaring_list cfa_field_abstract_list 355 375 %type<decl> cfa_function_declaration cfa_function_return cfa_function_specifier 356 376 … … 492 512 ; 493 513 494 identifier:495 IDENTIFIER496 | ATTR_IDENTIFIER // CFA497 | quasi_keyword498 ;499 500 514 no_attr_identifier: 501 515 IDENTIFIER 502 516 | quasi_keyword 517 | '@' // CFA 518 { Token tok = { new string( DeclarationNode::anonymous.newName() ), yylval.tok.loc }; $$ = tok; } 519 ; 520 521 identifier: 522 no_attr_identifier 523 | ATTR_IDENTIFIER // CFA 503 524 ; 504 525 … … 541 562 | type_name '.' no_attr_identifier // CFA, nested type 542 563 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 543 | type_name '.' '[' field_ list ']'// CFA, nested type / tuple field selector564 | type_name '.' '[' field_name_list ']' // CFA, nested type / tuple field selector 544 565 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 545 566 | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11 … … 594 615 | postfix_expression FLOATING_FRACTIONconstant // CFA, tuple index 595 616 { $$ = new ExpressionNode( build_fieldSel( $1, build_field_name_FLOATING_FRACTIONconstant( *$2 ) ) ); } 596 | postfix_expression '.' '[' field_ list ']'// CFA, tuple field selector617 | postfix_expression '.' '[' field_name_list ']' // CFA, tuple field selector 597 618 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); } 598 619 | postfix_expression ARROW no_attr_identifier … … 602 623 | postfix_expression ARROW INTEGERconstant // CFA, tuple index 603 624 { $$ = new ExpressionNode( build_pfieldSel( $1, build_constantInteger( *$3 ) ) ); } 604 | postfix_expression ARROW '[' field_ list ']'// CFA, tuple field selector625 | postfix_expression ARROW '[' field_name_list ']' // CFA, tuple field selector 605 626 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $4 ) ) ); } 606 627 | postfix_expression ICR … … 629 650 // empty 630 651 { $$ = nullptr; } 631 // | '@' // use default argument 632 // { $$ = new ExpressionNode( build_constantInteger( *new string( "2" ) ) ); } 652 | '?' // CFA, default parameter 653 { SemanticError( yylloc, "Default parameter for argument is currently unimplemented." ); $$ = nullptr; } 654 // { $$ = new ExpressionNode( build_constantInteger( *new string( "2" ) ) ); } 633 655 | assignment_expression 634 656 ; 635 657 636 field_ list:// CFA, tuple field selector658 field_name_list: // CFA, tuple field selector 637 659 field 638 | field_ list ',' field{ $$ = (ExpressionNode *)$1->set_last( $3 ); }660 | field_name_list ',' field { $$ = (ExpressionNode *)$1->set_last( $3 ); } 639 661 ; 640 662 … … 643 665 | FLOATING_DECIMALconstant field 644 666 { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( *$1 ) ), maybeMoveBuild<Expression>( $2 ) ) ); } 645 | FLOATING_DECIMALconstant '[' field_ list ']'667 | FLOATING_DECIMALconstant '[' field_name_list ']' 646 668 { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( *$1 ) ), build_tuple( $3 ) ) ); } 647 669 | field_name '.' field 648 670 { $$ = new ExpressionNode( build_fieldSel( $1, maybeMoveBuild<Expression>( $3 ) ) ); } 649 | field_name '.' '[' field_ list ']'671 | field_name '.' '[' field_name_list ']' 650 672 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); } 651 673 | field_name ARROW field 652 674 { $$ = new ExpressionNode( build_pfieldSel( $1, maybeMoveBuild<Expression>( $3 ) ) ); } 653 | field_name ARROW '[' field_ list ']'675 | field_name ARROW '[' field_name_list ']' 654 676 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $4 ) ) ); } 655 677 ; … … 1932 1954 1933 1955 field_declaration: 1934 type_specifier field_declaring_list ';' 1935 { $$ = distAttr( $1, $2 ); } 1936 | EXTENSION type_specifier field_declaring_list ';' // GCC 1937 { distExt( $3 ); $$ = distAttr( $2, $3 ); } // mark all fields in list 1938 | INLINE type_specifier field_declaring_list ';' // CFA 1939 { 1940 if ( $2->type && ( $2->type->kind == TypeData::Aggregate || $2->type->kind == TypeData::AggregateInst ) ) { 1941 if ( $2->type->kind == TypeData::Aggregate ) { 1942 $2->type->aggregate.inLine = true; 1943 } else { 1944 $2->type->aggInst.inLine = true; 1945 } // if 1946 $$ = distAttr( $2, $3 ); 1947 } else { 1948 SemanticError( yylloc, "inline qualifier only allowed for aggregate field declarations." ); $$ = nullptr; 1949 } // if 1956 type_specifier field_declaring_list_opt ';' 1957 { $$ = fieldDecl( $1, $2 ); } 1958 | EXTENSION type_specifier field_declaring_list_opt ';' // GCC 1959 { $$ = fieldDecl( $2, $3 ); distExt( $$ ); } 1960 | INLINE type_specifier field_abstract_list_opt ';' // CFA 1961 { 1962 if ( ! $3 ) { // field declarator ? 1963 $3 = DeclarationNode::newName( nullptr ); 1964 } // if 1965 $3->inLine = true; 1966 $$ = distAttr( $2, $3 ); // mark all fields in list 1967 distInl( $3 ); 1950 1968 } 1951 1969 | typedef_declaration ';' // CFA … … 1953 1971 | EXTENSION cfa_field_declaring_list ';' // GCC 1954 1972 { distExt( $2 ); $$ = $2; } // mark all fields in list 1973 | INLINE cfa_field_abstract_list ';' // CFA, new style field declaration 1974 { $$ = $2; } // mark all fields in list 1955 1975 | cfa_typedef_declaration ';' // CFA 1956 1976 | static_assert // C11 1957 1977 ; 1958 1978 1979 field_declaring_list_opt: 1980 // empty 1981 { $$ = nullptr; } 1982 | field_declarator 1983 | field_declaring_list_opt ',' attribute_list_opt field_declarator 1984 { $$ = $1->appendList( $4->addQualifiers( $3 ) ); } 1985 ; 1986 1987 field_declarator: 1988 bit_subrange_size // C special case, no field name 1989 { $$ = DeclarationNode::newBitfield( $1 ); } 1990 | variable_declarator bit_subrange_size_opt 1991 // A semantic check is required to ensure bit_subrange only appears on integral types. 1992 { $$ = $1->addBitfield( $2 ); } 1993 | variable_type_redeclarator bit_subrange_size_opt 1994 // A semantic check is required to ensure bit_subrange only appears on integral types. 1995 { $$ = $1->addBitfield( $2 ); } 1996 ; 1997 1998 field_abstract_list_opt: 1999 // empty 2000 { $$ = nullptr; } 2001 | field_abstract 2002 | field_abstract_list_opt ',' attribute_list_opt field_abstract 2003 { $$ = $1->appendList( $4->addQualifiers( $3 ) ); } 2004 ; 2005 2006 field_abstract: 2007 // no bit fields 2008 variable_abstract_declarator 2009 ; 2010 1959 2011 cfa_field_declaring_list: // CFA, new style field declaration 1960 cfa_abstract_declarator_tuple // CFA, no field name1961 |cfa_abstract_declarator_tuple no_attr_identifier_or_type_name2012 // bit-fields are handled by C declarations 2013 cfa_abstract_declarator_tuple no_attr_identifier_or_type_name 1962 2014 { $$ = $1->addName( $2 ); } 1963 2015 | cfa_field_declaring_list ',' no_attr_identifier_or_type_name 1964 2016 { $$ = $1->appendList( $1->cloneType( $3 ) ); } 1965 | cfa_field_declaring_list ',' // CFA, no field name 2017 ; 2018 2019 cfa_field_abstract_list: // CFA, new style field declaration 2020 // bit-fields are handled by C declarations 2021 cfa_abstract_declarator_tuple 2022 | cfa_field_abstract_list ',' 1966 2023 { $$ = $1->appendList( $1->cloneType( 0 ) ); } 1967 ;1968 1969 field_declaring_list:1970 field_declarator_opt1971 | field_declaring_list ',' attribute_list_opt field_declarator_opt1972 { $$ = $1->appendList( $4->addQualifiers( $3 ) ); }1973 ;1974 1975 field_declarator_opt:1976 // empty1977 { $$ = DeclarationNode::newName( 0 ); /* XXX */ } // CFA, no field name1978 // '@'1979 // { $$ = DeclarationNode::newName( new string( DeclarationNode::anonymous.newName() ) ); } // CFA, no field name1980 | bit_subrange_size // no field name1981 { $$ = DeclarationNode::newBitfield( $1 ); }1982 | variable_declarator bit_subrange_size_opt1983 // A semantic check is required to ensure bit_subrange only appears on base type int.1984 { $$ = $1->addBitfield( $2 ); }1985 | variable_type_redeclarator bit_subrange_size_opt1986 // A semantic check is required to ensure bit_subrange only appears on base type int.1987 { $$ = $1->addBitfield( $2 ); }1988 | variable_abstract_declarator // CFA, no field name1989 2024 ; 1990 2025 … … 2226 2261 | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements 2227 2262 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild< Expression >( $3 ), maybeMoveBuild< Expression >( $5 ) ) ); } 2228 | '.' '[' push field_ list pop ']'// CFA, tuple field selector2263 | '.' '[' push field_name_list pop ']' // CFA, tuple field selector 2229 2264 { $$ = $4; } 2230 2265 ;
Note:
See TracChangeset
for help on using the changeset viewer.