Changeset d55d7a6 for src/Parser
- Timestamp:
- Feb 15, 2018, 3:58:56 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, with_gc
- Children:
- 75e3cb2
- Parents:
- d27e340
- Location:
- src/Parser
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
rd27e340 rd55d7a6 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
rd27e340 rd55d7a6 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
rd27e340 rd55d7a6 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
rd27e340 rd55d7a6 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
rd27e340 rd55d7a6 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
rd27e340 rd55d7a6 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 … … 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/parser.yy
rd27e340 rd55d7a6 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 ME486 { throw SemanticError(yylloc, "Qualified names are currently unimplemented."); $$ = nullptr; } // FIX ME 487 487 ; 488 488 … … 1072 1072 mutex_statement: 1073 1073 MUTEX '(' argument_expression_list ')' statement 1074 { throw SemanticError( "Mutex statement is currently unimplemented."); $$ = nullptr; } // FIX ME1074 { throw SemanticError(yylloc, "Mutex statement is currently unimplemented."); $$ = nullptr; } // FIX ME 1075 1075 ; 1076 1076 … … 1293 1293 static_assert: 1294 1294 STATICASSERT '(' constant_expression ',' string_literal ')' ';' // C11 1295 { throw SemanticError( "Static assert is currently unimplemented."); $$ = nullptr; } // FIX ME1295 { throw SemanticError(yylloc, "Static assert is currently unimplemented."); $$ = nullptr; } // FIX ME 1296 1296 1297 1297 // C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function … … 2381 2381 { 2382 2382 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall" 2383 linkage = LinkageSpec::linkageUpdate( linkage, $2 );2383 linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 ); 2384 2384 } 2385 2385 '{' external_definition_list_opt '}'
Note:
See TracChangeset
for help on using the changeset viewer.