Changeset da7fe39 for src/Parser
- Timestamp:
- Apr 23, 2018, 12:57:46 PM (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, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
- Children:
- 57acae0
- Parents:
- ba89e9b7 (diff), c8ad5d9 (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:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
rba89e9b7 rda7fe39 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 22 15:37:17201813 // Update Count : 10 3312 // Last Modified On : Fri Apr 20 22:37:20 2018 13 // Update Count : 1063 14 14 // 15 15 … … 47 47 const char * DeclarationNode::aggregateNames[] = { "struct", "union", "trait", "coroutine", "monitor", "thread", "NoAggregateNames" }; 48 48 const char * DeclarationNode::typeClassNames[] = { "otype", "dtype", "ftype", "NoTypeClassNames" }; 49 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", " NoBuiltinTypeNames" };49 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "zero_t", "one_t", "NoBuiltinTypeNames" }; 50 50 51 51 UniqueName DeclarationNode::anonymous( "__anonymous" ); … … 561 561 562 562 checkQualifiers( type, q->type ); 563 if ( (builtin == Zero || builtin == One) && error.length() == 0 ) { 564 SemanticWarning( yylloc, Warning::BadQualifiersZeroOne, Type::QualifiersNames[ilog2( q->type->qualifiers.val )], builtinTypeNames[builtin] ); 565 // appendError( error, string( "questionable qualifiers" ) ); 566 } // if 563 567 addQualifiersToType( q->type, type ); 564 568 … … 924 928 delete newType->aggInst.aggregate->enumeration.constants; 925 929 newType->aggInst.aggregate->enumeration.constants = nullptr; 930 newType->aggInst.aggregate->enumeration.body = false; 926 931 } else { 927 932 assert( newType->aggInst.aggregate->kind == TypeData::Aggregate ); 928 933 delete newType->aggInst.aggregate->aggregate.fields; 929 934 newType->aggInst.aggregate->aggregate.fields = nullptr; 935 newType->aggInst.aggregate->aggregate.body = false; 930 936 } // if 931 937 // don't hoist twice -
src/Parser/ExpressionNode.cc
rba89e9b7 rda7fe39 211 211 if ( Unsigned && size < 2 ) { // hh or h, less than int ? 212 212 // int i = -1uh => 65535 not -1, so cast is necessary for unsigned, which unfortunately eliminates warnings for large values. 213 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ) );213 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ), false ); 214 214 } else if ( lnth != -1 ) { // explicit length ? 215 215 if ( lnth == 5 ) { // int128 ? 216 216 size = 5; 217 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ) );217 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ), false ); 218 218 } else { 219 ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), lnthsInt[Unsigned][lnth], false ) );219 ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), lnthsInt[Unsigned][lnth], false ), false ); 220 220 } // if 221 221 } // if … … 285 285 Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[complx][size] ), str, v ) ); 286 286 if ( lnth != -1 ) { // explicit length ? 287 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[complx][size] ) );287 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[complx][size] ), false ); 288 288 } // if 289 289 … … 408 408 if ( dynamic_cast< VoidType * >( targetType ) ) { 409 409 delete targetType; 410 return new CastExpr( maybeMoveBuild< Expression >(expr_node) );410 return new CastExpr( maybeMoveBuild< Expression >(expr_node), false ); 411 411 } else { 412 return new CastExpr( maybeMoveBuild< Expression >(expr_node), targetType );412 return new CastExpr( maybeMoveBuild< Expression >(expr_node), targetType, false ); 413 413 } // if 414 414 } // build_cast 415 416 Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node ) { 417 return new KeywordCastExpr( maybeMoveBuild< Expression >(expr_node), target ); 418 } 415 419 416 420 Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ) { -
src/Parser/ParseNode.h
rba89e9b7 rda7fe39 179 179 180 180 Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ); 181 Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node ); 181 182 Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ); 182 183 Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member ); -
src/Parser/TypeData.cc
rba89e9b7 rda7fe39 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 22 15:49:00201813 // Update Count : 59712 // Last Modified On : Tue Apr 17 23:00:52 2018 13 // Update Count : 602 14 14 // 15 15 … … 395 395 break; 396 396 case Builtin: 397 os << "gcc builtin type";397 os << DeclarationNode::builtinTypeNames[builtintype]; 398 398 break; 399 399 default: … … 490 490 switch ( td->kind ) { 491 491 case TypeData::Aggregate: 492 if ( ! toplevel && td->aggregate. fields) {492 if ( ! toplevel && td->aggregate.body ) { 493 493 ret = td->clone(); 494 494 } // if 495 495 break; 496 496 case TypeData::Enum: 497 if ( ! toplevel && td->enumeration. constants) {497 if ( ! toplevel && td->enumeration.body ) { 498 498 ret = td->clone(); 499 499 } // if -
src/Parser/lex.ll
rba89e9b7 rda7fe39 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Thu Mar 22 16:47:06201813 * Update Count : 6 6812 * Last Modified On : Fri Apr 6 15:16:15 2018 13 * Update Count : 670 14 14 */ 15 15 … … 198 198 __asm { KEYWORD_RETURN(ASM); } // GCC 199 199 __asm__ { KEYWORD_RETURN(ASM); } // GCC 200 _At { KEYWORD_RETURN(AT); } // CFA201 200 _Atomic { KEYWORD_RETURN(ATOMIC); } // C11 202 201 __attribute { KEYWORD_RETURN(ATTRIBUTE); } // GCC … … 229 228 exception { KEYWORD_RETURN(EXCEPTION); } // CFA 230 229 extern { KEYWORD_RETURN(EXTERN); } 230 fallthrough { KEYWORD_RETURN(FALLTHROUGH); } // CFA 231 231 fallthru { KEYWORD_RETURN(FALLTHRU); } // CFA 232 fallthrough { KEYWORD_RETURN(FALLTHROUGH); } // CFA233 232 finally { KEYWORD_RETURN(FINALLY); } // CFA 234 233 float { KEYWORD_RETURN(FLOAT); } … … 260 259 __builtin_offsetof { KEYWORD_RETURN(OFFSETOF); } // GCC 261 260 one_t { NUMERIC_RETURN(ONE_T); } // CFA 261 or { QKEYWORD_RETURN(WOR); } // CFA 262 262 otype { KEYWORD_RETURN(OTYPE); } // CFA 263 263 register { KEYWORD_RETURN(REGISTER); } … … 296 296 __volatile__ { KEYWORD_RETURN(VOLATILE); } // GCC 297 297 waitfor { KEYWORD_RETURN(WAITFOR); } 298 or { QKEYWORD_RETURN(WOR); } // CFA299 298 when { KEYWORD_RETURN(WHEN); } 300 299 while { KEYWORD_RETURN(WHILE); } -
src/Parser/parser.yy
rba89e9b7 rda7fe39 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Mar 22 16:56:21201813 // Update Count : 31 2512 // Last Modified On : Tue Apr 17 17:10:30 2018 13 // Update Count : 3144 14 14 // 15 15 … … 391 391 %precedence '(' 392 392 393 %locations // support location tracking for error messages393 %locations // support location tracking for error messages 394 394 395 395 %start translation_unit // parse-tree root … … 497 497 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); } 498 498 | type_name '.' no_attr_identifier // CFA, nested type 499 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME499 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } 500 500 | type_name '.' '[' push field_list pop ']' // CFA, nested type / tuple field selector 501 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME501 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } 502 502 | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11 503 { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } // FIX ME503 { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } 504 504 ; 505 505 … … 687 687 | '(' type_no_function ')' cast_expression 688 688 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 689 | '(' COROUTINE '&' ')' cast_expression // CFA 690 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); } 691 | '(' THREAD '&' ')' cast_expression // CFA 692 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Thread, $5 ) ); } 693 | '(' MONITOR '&' ')' cast_expression // CFA 694 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Monitor, $5 ) ); } 689 695 // VIRTUAL cannot be opt because of look ahead issues 690 | '(' VIRTUAL ')' cast_expression 696 | '(' VIRTUAL ')' cast_expression // CFA 691 697 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $4 ), maybeMoveBuildType( nullptr ) ) ); } 692 | '(' VIRTUAL type_no_function ')' cast_expression 698 | '(' VIRTUAL type_no_function ')' cast_expression // CFA 693 699 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $5 ), maybeMoveBuildType( $3 ) ) ); } 694 700 // | '(' type_no_function ')' tuple … … 782 788 | logical_OR_expression '?' comma_expression ':' conditional_expression 783 789 { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); } 784 // FIX ME: this hackcomputes $1 twice790 // FIX ME: computes $1 twice 785 791 | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand 786 792 { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); } … … 797 803 { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); } 798 804 | unary_expression '=' '{' initializer_list comma_opt '}' 799 { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } // FIX ME805 { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } 800 806 ; 801 807 … … 867 873 | exception_statement 868 874 | enable_disable_statement 869 { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } // FIX ME875 { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } 870 876 | asm_statement 871 877 ; … … 1062 1068 { $$ = new StatementNode( build_return( $2 ) ); } 1063 1069 | RETURN '{' initializer_list comma_opt '}' 1064 { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } // FIX ME1070 { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } 1065 1071 | THROW assignment_expression_opt ';' // handles rethrow 1066 1072 { $$ = new StatementNode( build_throw( $2 ) ); } … … 1086 1092 mutex_statement: 1087 1093 MUTEX '(' argument_expression_list ')' statement 1088 { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; } // FIX ME1094 { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; } 1089 1095 ; 1090 1096 … … 1702 1708 | LONG 1703 1709 { $$ = DeclarationNode::newLength( DeclarationNode::Long ); } 1704 | ZERO_T1705 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }1706 | ONE_T1707 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); }1708 1710 | VALIST // GCC, __builtin_va_list 1709 1711 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } … … 1725 1727 basic_type_specifier: 1726 1728 direct_type 1729 // Cannot have type modifiers, e.g., short, long, etc. 1727 1730 | type_qualifier_list_opt indirect_type type_qualifier_list_opt 1728 1731 { $$ = $2->addQualifiers( $1 )->addQualifiers( $3 ); } … … 1730 1733 1731 1734 direct_type: 1732 // A semantic check is necessary for conflicting type qualifiers.1733 1735 basic_type_name 1734 1736 | type_qualifier_list basic_type_name … … 1749 1751 | ATTR_TYPEGENname '(' comma_expression ')' // CFA: e.g., @type(a+b) y; 1750 1752 { $$ = DeclarationNode::newAttr( $1, $3 ); } 1753 | ZERO_T // CFA 1754 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); } 1755 | ONE_T // CFA 1756 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); } 1751 1757 ; 1752 1758
Note: See TracChangeset
for help on using the changeset viewer.