Changeset e07caa2 for src/Parser
- Timestamp:
- Jul 19, 2018, 6:16:41 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:
- 68bceeb
- Parents:
- 679a260
- Location:
- src/Parser
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r679a260 re07caa2 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 18 22:50:27201813 // Update Count : 1 09612 // Last Modified On : Thu Jul 19 17:40:03 2018 13 // Update Count : 1106 14 14 // 15 15 … … 54 54 55 55 DeclarationNode::DeclarationNode() : 56 builtin( NoBuiltinType ), 57 type( nullptr ), 58 inLine( false ), 59 bitfieldWidth( nullptr ), 60 hasEllipsis( false ), 61 linkage( ::linkage ), 62 asmName( nullptr ), 63 initializer( nullptr ), 64 extension( false ), 65 asmStmt( nullptr ) { 56 linkage( ::linkage ) { 66 57 67 58 // variable.name = nullptr; … … 1004 995 // struct T; // anonymous member 1005 996 // }; 1006 if ( ! (extracted && decl->name == "" && ! anon ) ) {1007 if ( decl->name == "") {997 if ( ! (extracted && decl->name == "" && ! anon && ! cur->get_inLine()) ) { 998 if ( decl->name == "" ) { 1008 999 if ( DeclarationWithType * dwt = dynamic_cast<DeclarationWithType *>( decl ) ) { 1009 1000 if ( ReferenceToType * aggr = dynamic_cast<ReferenceToType *>( dwt->get_type() ) ) { 1010 1001 if ( aggr->name.find("anonymous") == std::string::npos ) { 1011 if ( ! cur->inLine ) { 1012 // 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 1013 1005 SemanticWarning( cur->location, Warning::AggrForwardDecl, aggr->name.c_str() ); 1014 } 1015 } 1016 } 1017 } 1018 } 1006 } // if 1007 } // if 1008 } // if 1009 } // if 1010 } // if 1019 1011 decl->location = cur->location; 1020 * 1021 } 1012 *out++ = decl; 1013 } // if 1022 1014 } // if 1023 1015 } catch( SemanticErrorException &e ) { 1024 1016 errors.append( e ); 1025 1017 } // try 1026 } // while1018 } // for 1027 1019 1028 1020 if ( ! errors.isEmpty() ) { -
src/Parser/ParseNode.h
r679a260 re07caa2 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 18 17:35:55201813 // Update Count : 84 412 // Last Modified On : Thu Jul 19 15:55:26 2018 13 // Update Count : 848 14 14 // 15 15 … … 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 333 bool inLine ;332 BuiltinType builtin = NoBuiltinType; 333 334 TypeData * type = nullptr; 335 336 bool inLine = false; 334 337 Type::FuncSpecifiers funcSpecs; 335 338 Type::StorageClasses storageClasses; 336 339 337 ExpressionNode * bitfieldWidth ;340 ExpressionNode * bitfieldWidth = nullptr; 338 341 std::unique_ptr<ExpressionNode> enumeratorValue; 339 bool hasEllipsis ;342 bool hasEllipsis = false; 340 343 LinkageSpec::Spec linkage; 341 Expression * asmName ;344 Expression * asmName = nullptr; 342 345 std::list< Attribute * > attributes; 343 InitializerNode * initializer ;346 InitializerNode * initializer = nullptr; 344 347 bool extension = false; 345 348 std::string error; 346 StatementNode * asmStmt ;349 StatementNode * asmStmt = nullptr; 347 350 348 351 static UniqueName anonymous; -
src/Parser/parser.yy
r679a260 re07caa2 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 1 0:21:43201813 // Update Count : 38 0812 // Last Modified On : Thu Jul 19 16:42:16 2018 13 // Update Count : 3820 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 ) { … … 338 345 %type<decl> exception_declaration 339 346 340 %type<decl> field_declaration_list_opt field_declaration field_declaring_list_opt field_declarator field_abstract_list field_abstract_opt347 %type<decl> field_declaration_list_opt field_declaration field_declaring_list_opt field_declarator field_abstract_list_opt field_abstract 341 348 %type<en> field field_name_list field_name fraction_constants_opt 342 349 … … 1938 1945 if ( $2 ) { // field declarator ? 1939 1946 $$ = distAttr( $1, $2 ); 1940 } else if ( $1->type && $1->type->kind == TypeData::Aggregate && $1->type->aggregate.anon) {1947 } else if ( $1->type && $1->type->kind == TypeData::Aggregate ) { 1941 1948 $$ = DeclarationNode::newName( nullptr ); 1942 1949 $$ = distAttr( $1, $$ ); // mark all fields in list … … 1960 1967 } // if 1961 1968 } 1962 | INLINE type_specifier field_abstract_list ';'// CFA1969 | INLINE type_specifier field_abstract_list_opt ';' // CFA 1963 1970 { 1964 1971 $3->inLine = true; 1965 1972 $$ = distAttr( $2, $3 ); // mark all fields in list 1973 distInl( $3 ); 1966 1974 } 1967 1975 | typedef_declaration ';' // CFA … … 1984 1992 1985 1993 field_declarator: 1986 bit_subrange_size // no field name1994 bit_subrange_size // C special case, no field name 1987 1995 { $$ = DeclarationNode::newBitfield( $1 ); } 1988 1996 | variable_declarator bit_subrange_size_opt … … 1994 2002 ; 1995 2003 1996 field_abstract_list: 1997 field_abstract_opt 1998 | field_abstract_list ',' attribute_list_opt field_abstract_opt 1999 { $$ = $1->appendList( $4->addQualifiers( $3 ) ); } 2000 ; 2001 2002 field_abstract_opt: 2004 field_abstract_list_opt: 2003 2005 // empty 2004 2006 { $$ = DeclarationNode::newName( nullptr ); } 2005 | bit_subrange_size // no field name 2006 // A semantic check is required to ensure bit_subrange only appears on integral types. 2007 { $$ = DeclarationNode::newBitfield( $1 ); } 2008 | variable_abstract_declarator 2007 | field_abstract 2008 | field_abstract_list_opt ',' attribute_list_opt field_abstract 2009 { $$ = $1->appendList( $4->addQualifiers( $3 ) ); } 2010 ; 2011 2012 field_abstract: 2013 // no bit fields 2014 variable_abstract_declarator 2009 2015 ; 2010 2016
Note: See TracChangeset
for help on using the changeset viewer.