Changes in / [69efef81:1cb35c0]
- Location:
- src
- Files:
-
- 7 edited
-
Parser/DeclarationNode.cc (modified) (11 diffs)
-
Parser/ParseNode.h (modified) (9 diffs)
-
Parser/TypeData.cc (modified) (6 diffs)
-
Parser/TypeData.h (modified) (3 diffs)
-
Parser/parser.yy (modified) (5 diffs)
-
tests/.expect/attributes.x64.txt (modified) (2 diffs)
-
tests/.expect/declarationErrors.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r69efef81 r1cb35c0 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 19 17:40:03201813 // Update Count : 110 612 // Last Modified On : Fri Jul 20 14:56:54 2018 13 // Update Count : 1107 14 14 // 15 15 … … 124 124 } // DeclarationNode::clone 125 125 126 void DeclarationNode::print( std::ostream & os, int indent ) const {126 void DeclarationNode::print( std::ostream & os, int indent ) const { 127 127 os << string( indent, ' ' ); 128 128 if ( name ) { … … 160 160 } 161 161 162 void DeclarationNode::printList( std::ostream & os, int indent ) const {162 void DeclarationNode::printList( std::ostream & os, int indent ) const { 163 163 ParseNode::printList( os, indent ); 164 164 if ( hasEllipsis ) { … … 514 514 } // DeclarationNode::copySpecifiers 515 515 516 static void addQualifiersToType( TypeData *& src, TypeData * dst ) {516 static void addQualifiersToType( TypeData *& src, TypeData * dst ) { 517 517 if ( dst->base ) { 518 518 addQualifiersToType( src, dst->base ); … … 567 567 } // addQualifiers 568 568 569 static void addTypeToType( TypeData *& src, TypeData *&dst ) {569 static void addTypeToType( TypeData *& src, TypeData *& dst ) { 570 570 if ( src->forall && dst->kind == TypeData::Function ) { 571 571 if ( dst->forall ) { … … 958 958 } 959 959 960 void buildList( const DeclarationNode * firstNode, std::list< Declaration * > & outputList ) {960 void buildList( const DeclarationNode * firstNode, std::list< Declaration * > & outputList ) { 961 961 SemanticErrorException errors; 962 962 std::back_insert_iterator< std::list< Declaration * > > out( outputList ); … … 1013 1013 } // if 1014 1014 } // if 1015 } catch( SemanticErrorException & e ) {1015 } catch( SemanticErrorException & e ) { 1016 1016 errors.append( e ); 1017 1017 } // try … … 1024 1024 1025 1025 // currently only builds assertions, function parameters, and return values 1026 void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > & outputList ) {1026 void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > & outputList ) { 1027 1027 SemanticErrorException errors; 1028 1028 std::back_insert_iterator< std::list< DeclarationWithType * > > out( outputList ); … … 1055 1055 * out++ = obj; 1056 1056 } // if 1057 } catch( SemanticErrorException & e ) {1057 } catch( SemanticErrorException & e ) { 1058 1058 errors.append( e ); 1059 1059 } // try … … 1065 1065 } // buildList 1066 1066 1067 void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > & outputList ) {1067 void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > & outputList ) { 1068 1068 SemanticErrorException errors; 1069 1069 std::back_insert_iterator< std::list< Type * > > out( outputList ); … … 1073 1073 try { 1074 1074 * out++ = cur->buildType(); 1075 } catch( SemanticErrorException & e ) {1075 } catch( SemanticErrorException & e ) { 1076 1076 errors.append( e ); 1077 1077 } // try -
src/Parser/ParseNode.h
r69efef81 r1cb35c0 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 19 15:55:26201813 // Update Count : 8 4812 // 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; … … 381 381 virtual StatementNode * append_last_case( StatementNode * ); 382 382 383 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 { 384 384 os << stmt.get() << std::endl; 385 385 } … … 439 439 440 440 template< typename SynTreeType, typename NodeType, template< typename, typename...> class Container, typename... Args > 441 void buildList( const NodeType * firstNode, Container< SynTreeType *, Args... > & outputList ) {441 void buildList( const NodeType * firstNode, Container< SynTreeType *, Args... > & outputList ) { 442 442 SemanticErrorException errors; 443 443 std::back_insert_iterator< Container< SynTreeType *, Args... > > out( outputList ); … … 453 453 assertf(false, "buildList unknown type"); 454 454 } // if 455 } catch( SemanticErrorException & e ) {455 } catch( SemanticErrorException & e ) { 456 456 errors.append( e ); 457 457 } // try … … 464 464 465 465 // in DeclarationNode.cc 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 );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 ); 469 469 470 470 template< typename SynTreeType, typename NodeType > 471 void buildMoveList( const NodeType * firstNode, std::list< SynTreeType * > & outputList ) {471 void buildMoveList( const NodeType * firstNode, std::list< SynTreeType * > & outputList ) { 472 472 buildList( firstNode, outputList ); 473 473 delete firstNode; -
src/Parser/TypeData.cc
r69efef81 r1cb35c0 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 18 17:51:18201813 // Update Count : 6 0712 // Last Modified On : Fri Jul 20 14:39:31 2018 13 // Update Count : 622 14 14 // 15 15 … … 271 271 272 272 switch ( kind ) { 273 case Unknown: 274 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 275 284 break; 276 285 case Pointer: … … 281 290 } // if 282 291 break; 283 case EnumConstant: 284 os << "enumeration constant "; 285 break; 286 case Basic: 287 if ( signedness != DeclarationNode::NoSignedness ) os << DeclarationNode::signednessNames[ signedness ] << " "; 288 if ( length != DeclarationNode::NoLength ) os << DeclarationNode::lengthNames[ length ] << " "; 289 assert( basictype != DeclarationNode::NoBasicType ); 290 os << DeclarationNode::basicTypeNames[ basictype ] << " "; 291 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 292 298 break; 293 299 case Array: … … 375 381 } // if 376 382 break; 377 case SymbolicInst: 378 os << "instance of type " << *symbolic.name; 379 if ( symbolic.actuals ) { 380 os << " with parameters" << endl; 381 symbolic.actuals->printList( os, indent + 2 ); 382 } // if 383 case EnumConstant: 384 os << "enumeration constant "; 383 385 break; 384 386 case Symbolic: … … 402 404 } // if 403 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; 404 414 case Tuple: 405 415 os << "tuple "; … … 417 427 case Builtin: 418 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 "; 419 439 break; 420 440 default: -
src/Parser/TypeData.h
r69efef81 r1cb35c0 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 18 17:31:15201813 // Update Count : 19 412 // 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 … … 77 77 }; 78 78 79 struct Qualified_t { // qualified type S.T79 struct Qualified_t { // qualified type S.T 80 80 TypeData * parent; 81 81 TypeData * child; -
src/Parser/parser.yy
r69efef81 r1cb35c0 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 19 22:21:56 201813 // Update Count : 38 2712 // Last Modified On : Fri Jul 20 11:46:46 2018 13 // Update Count : 3837 14 14 // 15 15 … … 172 172 return new_name; 173 173 } // build_postfix_name 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 174 187 175 188 bool forall = false, yyy = false; // aggregate have one or more forall qualifiers ? … … 1942 1955 field_declaration: 1943 1956 type_specifier field_declaring_list_opt ';' 1944 { 1945 if ( ! $2 ) { // field declarator ? 1946 $2 = DeclarationNode::newName( nullptr ); 1947 if ( ! ( $1->type && $1->type->kind == TypeData::Aggregate ) ) { 1948 SemanticWarning( yylloc, Warning::SuperfluousDecl, "" ); 1949 } // if 1950 } // if 1951 $$ = distAttr( $1, $2 ); // mark all fields in list 1952 } 1957 { $$ = fieldDecl( $1, $2 ); } 1953 1958 | EXTENSION type_specifier field_declaring_list_opt ';' // GCC 1954 { 1955 if ( ! $3 ) { // field declarator ? 1956 $3 = DeclarationNode::newName( nullptr ); 1957 if ( ! ( $2->type && $2->type->kind == TypeData::Aggregate ) ) { 1958 SemanticWarning( yylloc, Warning::SuperfluousDecl, "" ); 1959 } // if 1960 } // if 1961 $$ = distAttr( $2, $3 ); // mark all fields in list 1962 distExt( $$ ); 1963 } 1959 { $$ = fieldDecl( $2, $3 ); distExt( $$ ); } 1964 1960 | INLINE type_specifier field_abstract_list_opt ';' // CFA 1965 1961 { … … 2009 2005 2010 2006 field_abstract: 2011 // no bit fields2007 // no bit fields 2012 2008 variable_abstract_declarator 2013 2009 ; 2014 2010 2015 2011 cfa_field_declaring_list: // CFA, new style field declaration 2012 // bit-fields are handled by C declarations 2016 2013 cfa_abstract_declarator_tuple no_attr_identifier_or_type_name 2017 2014 { $$ = $1->addName( $2 ); } … … 2021 2018 2022 2019 cfa_field_abstract_list: // CFA, new style field declaration 2020 // bit-fields are handled by C declarations 2023 2021 cfa_abstract_declarator_tuple 2024 2022 | cfa_field_abstract_list ',' -
src/tests/.expect/attributes.x64.txt
r69efef81 r1cb35c0 367 367 signed int __apd7__Fi_Fi_i_Fi_i___1(__attribute__ ((unused,unused,unused)) signed int (*__anonymous_object23)(__attribute__ ((unused)) signed int __anonymous_object24), __attribute__ ((unused,unused,unused)) signed int (*__anonymous_object25)(__attribute__ ((unused)) signed int __anonymous_object26)); 368 368 struct Vad { 369 __attribute__ ((unused)) signed int __anonymous_object27 ;369 __attribute__ ((unused)) signed int __anonymous_object27:4; 370 370 __attribute__ ((unused)) signed int __anonymous_object28:4; 371 __attribute__ ((unused)) signed int __anonymous_object29:4; 372 __attribute__ ((unused,unused)) signed int __anonymous_object30:6; 371 __attribute__ ((unused,unused)) signed int __anonymous_object29:6; 373 372 }; 374 373 static inline void ___constructor__F_4sVad_autogen___1(struct Vad *___dst__4sVad_1); … … 376 375 static inline void ___destructor__F_4sVad_autogen___1(struct Vad *___dst__4sVad_1); 377 376 static inline struct Vad ___operator_assign__F4sVad_4sVad4sVad_autogen___1(struct Vad *___dst__4sVad_1, struct Vad ___src__4sVad_1); 378 static inline void ___constructor__F_4sVadi_autogen___1(struct Vad *___dst__4sVad_1, __attribute__ ((unused)) signed int __anonymous_object31);379 377 static inline void ___constructor__F_4sVad_autogen___1(struct Vad *___dst__4sVad_1){ 380 ((void)((*___dst__4sVad_1).__anonymous_object27) /* ?{} */);381 378 } 382 379 static inline void ___constructor__F_4sVad4sVad_autogen___1(struct Vad *___dst__4sVad_1, struct Vad ___src__4sVad_1){ 383 ((void)((*___dst__4sVad_1).__anonymous_object27=___src__4sVad_1.__anonymous_object27) /* ?{} */);384 380 } 385 381 static inline void ___destructor__F_4sVad_autogen___1(struct Vad *___dst__4sVad_1){ 386 ((void)((*___dst__4sVad_1).__anonymous_object27) /* ^?{} */);387 382 } 388 383 static inline struct Vad ___operator_assign__F4sVad_4sVad4sVad_autogen___1(struct Vad *___dst__4sVad_1, struct Vad ___src__4sVad_1){ 389 384 struct Vad ___ret__4sVad_1; 390 ((void)((*___dst__4sVad_1).__anonymous_object27=___src__4sVad_1.__anonymous_object27));391 385 ((void)___constructor__F_4sVad4sVad_autogen___1((&___ret__4sVad_1), (*___dst__4sVad_1))); 392 386 return ___ret__4sVad_1; 393 387 } 394 static inline void ___constructor__F_4sVadi_autogen___1(struct Vad *___dst__4sVad_1, __attribute__ ((unused)) signed int __anonymous_object32){395 ((void)((*___dst__4sVad_1).__anonymous_object27=__anonymous_object32) /* ?{} */);396 } -
src/tests/.expect/declarationErrors.txt
r69efef81 r1cb35c0 17 17 18 18 19 declarationErrors.c:22:1 error: duplicate static in declaration of x6: static const volatile instance of typeInt19 declarationErrors.c:22:1 error: duplicate static in declaration of x6: static const volatile Int 20 20 21 21 declarationErrors.c:24:1 error: duplicate const in declaration of f01: static inline function
Note:
See TracChangeset
for help on using the changeset viewer.