Changeset 7c782af for src/Parser
- Timestamp:
- Feb 16, 2018, 4:22:25 PM (8 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, resolv-new, stuck-waitfor-destruct, with_gc
- Children:
- 5964127
- Parents:
- c71b256 (diff), 62cd621 (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:
-
- 8 edited
-
DeclarationNode.cc (modified) (8 diffs)
-
ExpressionNode.cc (modified) (2 diffs)
-
LinkageSpec.cc (modified) (3 diffs)
-
LinkageSpec.h (modified) (2 diffs)
-
ParseNode.h (modified) (1 diff)
-
TypeData.cc (modified) (5 diffs)
-
TypeData.h (modified) (1 diff)
-
parser.yy (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
rc71b256 r7c782af 581 581 dst->basictype = src->basictype; 582 582 } else if ( src->basictype != DeclarationNode::NoBasicType ) 583 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::basicTypeNames[ src->basictype ] + " in type: ", src);583 throw SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::basicTypeNames[ src->basictype ] + " in type: " ); 584 584 585 585 if ( dst->complextype == DeclarationNode::NoComplexType ) { 586 586 dst->complextype = src->complextype; 587 587 } else if ( src->complextype != DeclarationNode::NoComplexType ) 588 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::complexTypeNames[ src->complextype ] + " in type: ", src);588 throw SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::complexTypeNames[ src->complextype ] + " in type: " ); 589 589 590 590 if ( dst->signedness == DeclarationNode::NoSignedness ) { 591 591 dst->signedness = src->signedness; 592 592 } else if ( src->signedness != DeclarationNode::NoSignedness ) 593 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::signednessNames[ src->signedness ] + " in type: ", src);593 throw SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::signednessNames[ src->signedness ] + " in type: " ); 594 594 595 595 if ( dst->length == DeclarationNode::NoLength ) { … … 598 598 dst->length = DeclarationNode::LongLong; 599 599 } else if ( src->length != DeclarationNode::NoLength ) 600 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::lengthNames[ src->length ] + " in type: ", src);600 throw SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::lengthNames[ src->length ] + " in type: " ); 601 601 } // if 602 602 break; … … 966 966 } // if 967 967 } catch( SemanticError &e ) { 968 e.set_location( cur->location );969 968 errors.append( e ); 970 969 } // try … … 1001 1000 } // if 1002 1001 } catch( SemanticError &e ) { 1003 e.set_location( cur->location );1004 1002 errors.append( e ); 1005 1003 } // try … … 1020 1018 * out++ = cur->buildType(); 1021 1019 } catch( SemanticError &e ) { 1022 e.set_location( cur->location );1023 1020 errors.append( e ); 1024 1021 } // try … … 1032 1029 1033 1030 Declaration * DeclarationNode::build() const { 1034 if ( ! error.empty() ) throw SemanticError( error + " in declaration of ", this);1031 if ( ! error.empty() ) throw SemanticError( this, error + " in declaration of " ); 1035 1032 1036 1033 if ( asmStmt ) { … … 1055 1052 // inline _Noreturn int i; // disallowed 1056 1053 if ( type->kind != TypeData::Function && funcSpecs.any() ) { 1057 throw SemanticError( "invalid function specifier for ", this);1054 throw SemanticError( this, "invalid function specifier for " ); 1058 1055 } // if 1059 1056 return buildDecl( type, name ? *name : string( "" ), storageClasses, maybeBuild< Expression >( bitfieldWidth ), funcSpecs, linkage, asmName, maybeBuild< Initializer >(initializer), attributes )->set_extension( extension ); … … 1065 1062 // inlne _Noreturn enum E { ... }; // disallowed 1066 1063 if ( funcSpecs.any() ) { 1067 throw SemanticError( "invalid function specifier for ", this);1064 throw SemanticError( this, "invalid function specifier for " ); 1068 1065 } // if 1069 1066 assertf( name, "ObjectDecl must a have name\n" ); -
src/Parser/ExpressionNode.cc
rc71b256 r7c782af 356 356 357 357 Expression * build_field_name_FLOATING_FRACTIONconstant( const string & str ) { 358 if ( str.find_first_not_of( "0123456789", 1 ) != string::npos ) throw SemanticError( "invalid tuple index " + str );358 if ( str.find_first_not_of( "0123456789", 1 ) != string::npos ) throw SemanticError( yylloc, "invalid tuple index " + str ); 359 359 Expression * ret = build_constantInteger( *new string( str.substr(1) ) ); 360 360 delete &str; … … 363 363 364 364 Expression * build_field_name_FLOATING_DECIMALconstant( const string & str ) { 365 if ( str[str.size()-1] != '.' ) throw SemanticError( "invalid tuple index " + str );365 if ( str[str.size()-1] != '.' ) throw SemanticError( yylloc, "invalid tuple index " + str ); 366 366 Expression * ret = build_constantInteger( *new string( str.substr( 0, str.size()-1 ) ) ); 367 367 delete &str; -
src/Parser/LinkageSpec.cc
rc71b256 r7c782af 24 24 namespace LinkageSpec { 25 25 26 Spec linkageCheck( const string * spec ) {26 Spec linkageCheck( CodeLocation location, const string * spec ) { 27 27 assert( spec ); 28 28 unique_ptr<const string> guard( spec ); // allocated by lexer … … 34 34 return BuiltinC; 35 35 } else { 36 throw SemanticError( "Invalid linkage specifier " + *spec );36 throw SemanticError( location, "Invalid linkage specifier " + *spec ); 37 37 } // if 38 38 } 39 39 40 Spec linkageUpdate( Spec old_spec, const string * cmd ) {40 Spec linkageUpdate( CodeLocation location, Spec old_spec, const string * cmd ) { 41 41 assert( cmd ); 42 42 unique_ptr<const string> guard( cmd ); // allocated by lexer … … 48 48 return old_spec; 49 49 } else { 50 throw SemanticError( "Invalid linkage specifier " + *cmd );50 throw SemanticError( location, "Invalid linkage specifier " + *cmd ); 51 51 } // if 52 52 } -
src/Parser/LinkageSpec.h
rc71b256 r7c782af 17 17 18 18 #include <string> 19 20 #include "Common/CodeLocation.h" 19 21 20 22 namespace LinkageSpec { … … 45 47 46 48 47 Spec linkageCheck( const std::string * );49 Spec linkageCheck( CodeLocation location, const std::string * ); 48 50 // Returns the Spec with the given name (limited to C, Cforall & BuiltinC) 49 Spec linkageUpdate( Spec old_spec, const std::string * cmd );51 Spec linkageUpdate( CodeLocation location, Spec old_spec, const std::string * cmd ); 50 52 /* If cmd = "C" returns a Spec that is old_spec with is_mangled = false 51 53 * If cmd = "Cforall" returns old_spec Spec with is_mangled = true -
src/Parser/ParseNode.h
rc71b256 r7c782af 434 434 } // if 435 435 } catch( SemanticError &e ) { 436 e.set_location( cur->location );437 436 errors.append( e ); 438 437 } // try -
src/Parser/TypeData.cc
rc71b256 r7c782af 31 31 using namespace std; 32 32 33 TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) /*, PTR1( (void*)(0xdeadbeefdeadbeef)), PTR2( (void*)(0xdeadbeefdeadbeef) ) */ {33 TypeData::TypeData( Kind k ) : location( yylloc ), kind( k ), base( nullptr ), forall( nullptr ) /*, PTR1( (void*)(0xdeadbeefdeadbeef)), PTR2( (void*)(0xdeadbeefdeadbeef) ) */ { 34 34 switch ( kind ) { 35 35 case Unknown: … … 521 521 522 522 static string genTSError( string msg, DeclarationNode::BasicType basictype ) { 523 throw SemanticError( string( "invalid type specifier \"" ) + msg + "\" for type \"" + DeclarationNode::basicTypeNames[basictype] + "\"." );523 throw SemanticError( yylloc, string( "invalid type specifier \"" ) + msg + "\" for type \"" + DeclarationNode::basicTypeNames[basictype] + "\"." ); 524 524 } // genTSError 525 525 … … 800 800 assert( td->base ); 801 801 if ( td->symbolic.isTypedef ) { 802 ret = new TypedefDecl( name, scs, typebuild( td->base ), linkage );802 ret = new TypedefDecl( name, td->location, scs, typebuild( td->base ), linkage ); 803 803 } else { 804 804 ret = new TypeDecl( name, scs, typebuild( td->base ), TypeDecl::Dtype, true ); … … 923 923 // type set => parameter name already transformed by a declaration names so there is a duplicate 924 924 // declaration name attempting a second transformation 925 if ( param->type ) throw SemanticError( string( "duplicate declaration name " ) + *param->name );925 if ( param->type ) throw SemanticError( param->location, string( "duplicate declaration name " ) + *param->name ); 926 926 // declaration type reset => declaration already transformed by a parameter name so there is a duplicate 927 927 // parameter name attempting a second transformation 928 if ( ! decl->type ) throw SemanticError( string( "duplicate parameter name " ) + *param->name );928 if ( ! decl->type ) throw SemanticError( param->location, string( "duplicate parameter name " ) + *param->name ); 929 929 param->type = decl->type; // set copy declaration type to parameter type 930 930 decl->type = nullptr; // reset declaration type … … 933 933 } // for 934 934 // declaration type still set => type not moved to a matching parameter so there is a missing parameter name 935 if ( decl->type ) throw SemanticError( string( "missing name in parameter list " ) + *decl->name );935 if ( decl->type ) throw SemanticError( decl->location, string( "missing name in parameter list " ) + *decl->name ); 936 936 } // for 937 937 -
src/Parser/TypeData.h
rc71b256 r7c782af 76 76 }; 77 77 78 CodeLocation location; 79 78 80 Kind kind; 79 81 TypeData * base; -
src/Parser/parser.yy
rc71b256 r7c782af 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Dec 21 11:32:56 201713 // Update Count : 299612 // Last Modified On : Thu Feb 15 17:12:31 2018 13 // Update Count : 3006 14 14 // 15 15 … … 482 482 { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); } 483 483 | type_name '.' no_attr_identifier // CFA, nested type 484 { throw SemanticError( "Qualified names are currently unimplemented."); $$ = nullptr; }// FIX ME484 { throw SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME 485 485 | type_name '.' '[' push field_list pop ']' // CFA, nested type / tuple field selector 486 { throw SemanticError("Qualified names are currently unimplemented."); $$ = nullptr; } // FIX ME 486 { throw SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME 487 | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11 488 { throw SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } // FIX ME 489 ; 490 491 generic_assoc_list: // C11 492 | generic_association 493 | generic_assoc_list ',' generic_association 494 ; 495 496 generic_association: // C11 497 type_no_function ':' assignment_expression 498 | DEFAULT ':' assignment_expression 487 499 ; 488 500 … … 767 779 | unary_expression assignment_operator assignment_expression 768 780 { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); } 781 | unary_expression '=' '{' initializer_list comma_opt '}' // FIX ME 782 { $$ = nullptr; } 769 783 ; 770 784 … … 1050 1064 | RETURN comma_expression_opt ';' 1051 1065 { $$ = new StatementNode( build_return( $2 ) ); } 1066 | RETURN '{' initializer_list comma_opt '}' // FIX ME 1067 { $$ = nullptr; } 1052 1068 | THROW assignment_expression_opt ';' // handles rethrow 1053 1069 { $$ = new StatementNode( build_throw( $2 ) ); } … … 1068 1084 mutex_statement: 1069 1085 MUTEX '(' argument_expression_list ')' statement 1070 { throw SemanticError( "Mutex statement is currently unimplemented."); $$ = nullptr; } // FIX ME1086 { throw SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; } // FIX ME 1071 1087 ; 1072 1088 … … 1289 1305 static_assert: 1290 1306 STATICASSERT '(' constant_expression ',' string_literal ')' ';' // C11 1291 { throw SemanticError( "Static assert is currently unimplemented."); $$ = nullptr; } // FIX ME1307 { throw SemanticError( yylloc, "Static assert is currently unimplemented." ); $$ = nullptr; } // FIX ME 1292 1308 1293 1309 // C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function … … 2377 2393 { 2378 2394 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall" 2379 linkage = LinkageSpec::linkageUpdate( linkage, $2 );2395 linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 ); 2380 2396 } 2381 2397 '{' external_definition_list_opt '}'
Note:
See TracChangeset
for help on using the changeset viewer.