Changeset 679e644
- Timestamp:
- Jul 19, 2018, 10:30:56 AM (6 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:
- 679a260
- Parents:
- 2f84692
- Location:
- src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/SemanticError.h
r2f84692 r679e644 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 16 15:01:23201813 // Update Count : 3 012 // Last Modified On : Thu Jul 19 10:09:17 2018 13 // Update Count : 31 14 14 // 15 15 … … 57 57 {"qualifiers-zero_t-one_t", "questionable use of type qualifier %s with %s", Severity::Warn}, 58 58 {"aggregate-forward-decl" , "forward declaration of nested aggregate: %s" , Severity::Warn}, 59 {"superfluous-decl" , "declaration does not allocate storage: %s" , Severity::Warn}, 59 60 }; 60 61 … … 64 65 BadQualifiersZeroOne, 65 66 AggrForwardDecl, 66 NUMBER_OF_WARNINGS, //This MUST be the last warning 67 SuperfluousDecl, 68 NUMBER_OF_WARNINGS, // This MUST be the last warning 67 69 }; 68 70 -
src/Parser/DeclarationNode.cc
r2f84692 r679e644 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 : 10 8812 // Last Modified On : Wed Jul 18 22:50:27 2018 13 // Update Count : 1096 14 14 // 15 15 … … 56 56 builtin( NoBuiltinType ), 57 57 type( nullptr ), 58 inLine( false ), 58 59 bitfieldWidth( nullptr ), 59 60 hasEllipsis( false ), … … 104 105 newnode->builtin = NoBuiltinType; 105 106 newnode->type = maybeClone( type ); 107 newnode->inLine = inLine; 106 108 newnode->storageClasses = storageClasses; 107 109 newnode->funcSpecs = funcSpecs; … … 1007 1009 if ( ReferenceToType * aggr = dynamic_cast<ReferenceToType *>( dwt->get_type() ) ) { 1008 1010 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) { 1011 // bool isInline = false; 1012 // if (cur->type->kind == TypeData::Aggregate || cur->type->kind == TypeData::AggregateInst) { 1013 // if (cur->type->kind == TypeData::Aggregate) { 1014 // isInline = cur->type->aggregate.inLine; 1015 // } else { 1016 // isInline = cur->type->aggInst.inLine; 1017 // if ( TypeData * aggr = cur->type->aggInst.aggregate ) { 1018 // if ( aggr->kind == TypeData::Aggregate ) { 1019 // isInline = isInline || aggr->aggregate.inLine; 1020 // } 1021 // } 1022 // } 1023 // } 1024 // if (! isInline) { 1025 if ( ! cur->inLine ) { 1023 1026 // temporary: warn about anonymous member declarations of named types, since this conflicts with the syntax for the forward declaration of an anonymous type 1024 1027 SemanticWarning( cur->location, Warning::AggrForwardDecl, aggr->name.c_str() ); -
src/Parser/ParseNode.h
r2f84692 r679e644 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Ju n 6 16:17:18201813 // Update Count : 84 312 // Last Modified On : Wed Jul 18 17:35:55 2018 13 // Update Count : 844 14 14 // 15 15 … … 331 331 TypeData * type; 332 332 333 bool inLine; 333 334 Type::FuncSpecifiers funcSpecs; 334 335 Type::StorageClasses storageClasses; -
src/Parser/TypeData.cc
r2f84692 r679e644 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 : 60 612 // Last Modified On : Wed Jul 18 17:51:18 2018 13 // Update Count : 607 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: -
src/Parser/TypeData.h
r2f84692 r679e644 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 : Wed Jul 18 17:31:15 2018 13 // Update Count : 194 14 14 // 15 15 … … 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 -
src/Parser/parser.yy
r2f84692 r679e644 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 1 2 16:16:25201813 // Update Count : 3 75612 // Last Modified On : Thu Jul 19 10:21:43 2018 13 // Update Count : 3808 14 14 // 15 15 … … 338 338 %type<decl> exception_declaration 339 339 340 %type<decl> field_declaration field_declaration_list_opt field_declarator_opt field_declaring_list341 %type<en> field field_ list field_name fraction_constants_opt340 %type<decl> field_declaration_list_opt field_declaration field_declaring_list_opt field_declarator field_abstract_list field_abstract_opt 341 %type<en> field field_name_list field_name fraction_constants_opt 342 342 343 343 %type<decl> external_function_definition function_definition function_array function_declarator function_no_ptr function_ptr … … 352 352 %type<decl> cfa_array_parameter_1st_dimension 353 353 354 %type<decl> cfa_trait_declaring_list cfa_declaration cfa_field_declaring_list 354 %type<decl> cfa_trait_declaring_list cfa_declaration cfa_field_declaring_list cfa_field_abstract_list 355 355 %type<decl> cfa_function_declaration cfa_function_return cfa_function_specifier 356 356 … … 492 492 ; 493 493 494 identifier:495 IDENTIFIER496 | ATTR_IDENTIFIER // CFA497 | quasi_keyword498 ;499 500 494 no_attr_identifier: 501 495 IDENTIFIER 502 496 | quasi_keyword 497 | '@' // CFA 498 { Token tok = { new string( DeclarationNode::anonymous.newName() ), yylval.tok.loc }; $$ = tok; } 499 ; 500 501 identifier: 502 no_attr_identifier 503 | ATTR_IDENTIFIER // CFA 503 504 ; 504 505 … … 541 542 | type_name '.' no_attr_identifier // CFA, nested type 542 543 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 543 | type_name '.' '[' field_ list ']'// CFA, nested type / tuple field selector544 | type_name '.' '[' field_name_list ']' // CFA, nested type / tuple field selector 544 545 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 545 546 | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11 … … 594 595 | postfix_expression FLOATING_FRACTIONconstant // CFA, tuple index 595 596 { $$ = new ExpressionNode( build_fieldSel( $1, build_field_name_FLOATING_FRACTIONconstant( *$2 ) ) ); } 596 | postfix_expression '.' '[' field_ list ']'// CFA, tuple field selector597 | postfix_expression '.' '[' field_name_list ']' // CFA, tuple field selector 597 598 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); } 598 599 | postfix_expression ARROW no_attr_identifier … … 602 603 | postfix_expression ARROW INTEGERconstant // CFA, tuple index 603 604 { $$ = new ExpressionNode( build_pfieldSel( $1, build_constantInteger( *$3 ) ) ); } 604 | postfix_expression ARROW '[' field_ list ']'// CFA, tuple field selector605 | postfix_expression ARROW '[' field_name_list ']' // CFA, tuple field selector 605 606 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $4 ) ) ); } 606 607 | postfix_expression ICR … … 629 630 // empty 630 631 { $$ = nullptr; } 631 // | '@' // use default argument 632 // { $$ = new ExpressionNode( build_constantInteger( *new string( "2" ) ) ); } 632 | '?' // CFA, default parameter 633 { SemanticError( yylloc, "Default parameter for argument is currently unimplemented." ); $$ = nullptr; } 634 // { $$ = new ExpressionNode( build_constantInteger( *new string( "2" ) ) ); } 633 635 | assignment_expression 634 636 ; 635 637 636 field_ list:// CFA, tuple field selector638 field_name_list: // CFA, tuple field selector 637 639 field 638 | field_ list ',' field{ $$ = (ExpressionNode *)$1->set_last( $3 ); }640 | field_name_list ',' field { $$ = (ExpressionNode *)$1->set_last( $3 ); } 639 641 ; 640 642 … … 643 645 | FLOATING_DECIMALconstant field 644 646 { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( *$1 ) ), maybeMoveBuild<Expression>( $2 ) ) ); } 645 | FLOATING_DECIMALconstant '[' field_ list ']'647 | FLOATING_DECIMALconstant '[' field_name_list ']' 646 648 { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( *$1 ) ), build_tuple( $3 ) ) ); } 647 649 | field_name '.' field 648 650 { $$ = new ExpressionNode( build_fieldSel( $1, maybeMoveBuild<Expression>( $3 ) ) ); } 649 | field_name '.' '[' field_ list ']'651 | field_name '.' '[' field_name_list ']' 650 652 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); } 651 653 | field_name ARROW field 652 654 { $$ = new ExpressionNode( build_pfieldSel( $1, maybeMoveBuild<Expression>( $3 ) ) ); } 653 | field_name ARROW '[' field_ list ']'655 | field_name ARROW '[' field_name_list ']' 654 656 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $4 ) ) ); } 655 657 ; … … 1932 1934 1933 1935 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 ); 1936 type_specifier field_declaring_list_opt ';' 1937 { 1938 if ( $2 ) { // field declarator ? 1939 $$ = distAttr( $1, $2 ); 1940 } else if ( $1->type && $1->type->kind == TypeData::Aggregate && $1->type->aggregate.anon ) { 1941 $$ = DeclarationNode::newName( nullptr ); 1942 $$ = distAttr( $1, $$ ); // mark all fields in list 1947 1943 } else { 1948 SemanticError( yylloc, "inline qualifier only allowed for aggregate field declarations." ); $$ = nullptr; 1949 } // if 1944 //SemanticError( yylloc, "Superfluous declaration, does not allocate storage." ); $$ = nullptr; 1945 SemanticWarning( yylloc, Warning::SuperfluousDecl, "" ); 1946 } // if 1947 } 1948 | EXTENSION type_specifier field_declaring_list_opt ';' // GCC 1949 { 1950 if ( $3 ) { // field declarator ? 1951 $$ = distAttr( $2, $3 ); // mark all fields in list 1952 distExt( $3 ); 1953 } else if ( $2->type && $2->type->kind == TypeData::Aggregate && $2->type->aggregate.anon ) { 1954 $$ = DeclarationNode::newName( nullptr ); 1955 $$ = distAttr( $2, $$ ); // mark all fields in list 1956 distExt( $$ ); 1957 } else { 1958 // SemanticError( yylloc, "Superfluous declaration, does not allocate storage." ); $$ = nullptr; 1959 SemanticWarning( yylloc, Warning::SuperfluousDecl, "" ); 1960 } // if 1961 } 1962 | INLINE type_specifier field_abstract_list ';' // CFA 1963 { 1964 $2->inLine = true; 1965 $$ = distAttr( $2, $3 ); // mark all fields in list 1950 1966 } 1951 1967 | typedef_declaration ';' // CFA … … 1953 1969 | EXTENSION cfa_field_declaring_list ';' // GCC 1954 1970 { distExt( $2 ); $$ = $2; } // mark all fields in list 1971 | INLINE cfa_field_abstract_list ';' // CFA, new style field declaration 1972 { $$ = $2; } // mark all fields in list 1955 1973 | cfa_typedef_declaration ';' // CFA 1956 1974 | static_assert // C11 1957 1975 ; 1958 1976 1977 field_declaring_list_opt: 1978 // empty 1979 { $$ = nullptr; } 1980 | field_declarator 1981 | field_declaring_list_opt ',' attribute_list_opt field_declarator 1982 { $$ = $1->appendList( $4->addQualifiers( $3 ) ); } 1983 ; 1984 1985 field_declarator: 1986 bit_subrange_size // no field name 1987 { $$ = DeclarationNode::newBitfield( $1 ); } 1988 | variable_declarator bit_subrange_size_opt 1989 // A semantic check is required to ensure bit_subrange only appears on integral types. 1990 { $$ = $1->addBitfield( $2 ); } 1991 | variable_type_redeclarator bit_subrange_size_opt 1992 // A semantic check is required to ensure bit_subrange only appears on integral types. 1993 { $$ = $1->addBitfield( $2 ); } 1994 ; 1995 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: 2003 // empty 2004 { $$ = 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 2009 ; 2010 1959 2011 cfa_field_declaring_list: // CFA, new style field declaration 1960 cfa_abstract_declarator_tuple // CFA, no field name 1961 | cfa_abstract_declarator_tuple no_attr_identifier_or_type_name 2012 cfa_abstract_declarator_tuple no_attr_identifier_or_type_name 1962 2013 { $$ = $1->addName( $2 ); } 1963 2014 | cfa_field_declaring_list ',' no_attr_identifier_or_type_name 1964 2015 { $$ = $1->appendList( $1->cloneType( $3 ) ); } 1965 | cfa_field_declaring_list ',' // CFA, no field name 2016 ; 2017 2018 cfa_field_abstract_list: // CFA, new style field declaration 2019 cfa_abstract_declarator_tuple 2020 | cfa_field_abstract_list ',' 1966 2021 { $$ = $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 2022 ; 1990 2023 … … 2226 2259 | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements 2227 2260 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild< Expression >( $3 ), maybeMoveBuild< Expression >( $5 ) ) ); } 2228 | '.' '[' push field_ list pop ']'// CFA, tuple field selector2261 | '.' '[' push field_name_list pop ']' // CFA, tuple field selector 2229 2262 { $$ = $4; } 2230 2263 ;
Note: See TracChangeset
for help on using the changeset viewer.