Changeset 7c782af for src/SymTab
- Timestamp:
- Feb 16, 2018, 4:22:25 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, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, 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/SymTab
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Indexer.cc
rc71b256 r7c782af 443 443 // isomorphic to C type-compatibility, which it may not be. 444 444 if ( hasIncompatibleCDecl( name, mangleName, scope ) ) { 445 throw SemanticError( "conflicting overload of C function ", decl);445 throw SemanticError( decl, "conflicting overload of C function " ); 446 446 } 447 447 } else { 448 448 // Check that a Cforall declaration doesn't override any C declaration 449 449 if ( hasCompatibleCDecl( name, mangleName, scope ) ) { 450 throw SemanticError( "Cforall declaration hides C function ", decl);450 throw SemanticError( decl, "Cforall declaration hides C function " ); 451 451 } 452 452 } … … 463 463 void Indexer::addId( DeclarationWithType * decl, Expression * baseExpr ) { 464 464 // default handling of conflicts is to raise an error 465 addId( decl, [decl](IdData &, const std::string & msg) { throw SemanticError( msg, decl); return true; }, baseExpr );465 addId( decl, [decl](IdData &, const std::string & msg) { throw SemanticError( decl, msg ); return true; }, baseExpr ); 466 466 } 467 467 468 468 void Indexer::addDeletedId( DeclarationWithType * decl, BaseSyntaxNode * deleteStmt ) { 469 469 // default handling of conflicts is to raise an error 470 addId( decl, [decl](IdData &, const std::string & msg) { throw SemanticError( msg, decl); return true; }, nullptr, deleteStmt );470 addId( decl, [decl](IdData &, const std::string & msg) { throw SemanticError( decl, msg ); return true; }, nullptr, deleteStmt ); 471 471 } 472 472 … … 477 477 return true; 478 478 } else { 479 throw SemanticError( "redeclaration of ", added);479 throw SemanticError( added, "redeclaration of " ); 480 480 } 481 481 } … … 504 504 return false; 505 505 } else if ( ! added->get_members().empty() ) { 506 throw SemanticError( "redeclaration of ", added);506 throw SemanticError( added, "redeclaration of " ); 507 507 } // if 508 508 return true; -
src/SymTab/Validate.cc
rc71b256 r7c782af 361 361 // the only case in which "void" is valid is where it is the only one in the list 362 362 if ( containsVoid && ( nvals > 1 || isVarArgs ) ) { 363 throw SemanticError( "invalid type void in function type ", func);363 throw SemanticError( func, "invalid type void in function type " ); 364 364 } 365 365 … … 402 402 for ( Expression * param : inst->parameters ) { 403 403 if ( ! dynamic_cast< TypeExpr * >( param ) ) { 404 throw SemanticError( "Expression parameters for generic types are currently unsupported: ", inst);404 throw SemanticError( inst, "Expression parameters for generic types are currently unsupported: " ); 405 405 } 406 406 } … … 502 502 TraitDecl *traitDecl = local_indexer->lookupTrait( traitInst->name ); 503 503 if ( ! traitDecl ) { 504 throw SemanticError( "use of undeclared trait " + traitInst->name );504 throw SemanticError( traitInst->location, "use of undeclared trait " + traitInst->name ); 505 505 } // if 506 506 if ( traitDecl->get_parameters().size() != traitInst->get_parameters().size() ) { 507 throw SemanticError( "incorrect number of trait parameters: ", traitInst);507 throw SemanticError( traitInst, "incorrect number of trait parameters: " ); 508 508 } // if 509 509 traitInst->baseTrait = traitDecl; … … 513 513 TypeExpr * expr = dynamic_cast< TypeExpr * >( std::get<1>(p) ); 514 514 if ( ! expr ) { 515 throw SemanticError( "Expression parameters for trait instances are currently unsupported: ", std::get<1>(p));515 throw SemanticError( std::get<1>(p), "Expression parameters for trait instances are currently unsupported: " ); 516 516 } 517 517 if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( expr->get_type() ) ) { … … 619 619 bool isVoid = fixFunction( assertion ); 620 620 if ( isVoid ) { 621 throw SemanticError( "invalid type void in assertion of function ", node);621 throw SemanticError( node, "invalid type void in assertion of function " ); 622 622 } // if 623 623 } // for … … 663 663 // were cast to void. 664 664 if ( ! returnStmt->get_expr() && returnVals.size() != 0 ) { 665 throw SemanticError( "Non-void function returns no values: " , returnStmt);665 throw SemanticError( returnStmt, "Non-void function returns no values: " ); 666 666 } 667 667 } … … 704 704 ReferenceToType *rtt = dynamic_cast<ReferenceToType*>(ret); 705 705 if ( ! rtt ) { 706 throw SemanticError( "Cannot apply type parameters to base type of " + typeInst->name);706 throw SemanticError( typeInst->location, "Cannot apply type parameters to base type of " + typeInst->name ); 707 707 } 708 708 rtt->get_parameters().clear(); … … 742 742 Type * t2 = typedefNames[ tyDecl->get_name() ].first->get_base(); 743 743 if ( ! ResolvExpr::typesCompatible( t1, t2, Indexer() ) ) { 744 throw SemanticError( "Cannot redefine typedef: " + tyDecl->name );744 throw SemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name ); 745 745 } 746 746 // Cannot redefine VLA typedefs. Note: this is slightly incorrect, because our notion of VLAs … … 749 749 // to fix this corner case likely outweighs the utility of allowing it. 750 750 if ( isVariableLength( t1 ) || isVariableLength( t2 ) ) { 751 throw SemanticError( "Cannot redefine typedef: " + tyDecl->name );751 throw SemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name ); 752 752 } 753 753 } else { … … 847 847 type = new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ); 848 848 } // if 849 TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), Type::StorageClasses(), type, aggDecl->get_linkage() ) );849 TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), aggDecl->location, Type::StorageClasses(), type, aggDecl->get_linkage() ) ); 850 850 typedefNames[ aggDecl->get_name() ] = std::make_pair( std::move( tyDecl ), scopeLevel ); 851 851 } // if … … 898 898 if ( CodeGen::isCtorDtorAssign( funcDecl->get_name() ) ) { // TODO: also check /=, etc. 899 899 if ( params.size() == 0 ) { 900 throw SemanticError( "Constructors, destructors, and assignment functions require at least one parameter ", funcDecl);900 throw SemanticError( funcDecl, "Constructors, destructors, and assignment functions require at least one parameter " ); 901 901 } 902 902 ReferenceType * refType = dynamic_cast< ReferenceType * >( params.front()->get_type() ); 903 903 if ( ! refType ) { 904 throw SemanticError( "First parameter of a constructor, destructor, or assignment function must be a reference ", funcDecl);904 throw SemanticError( funcDecl, "First parameter of a constructor, destructor, or assignment function must be a reference " ); 905 905 } 906 906 if ( CodeGen::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) { 907 throw SemanticError( "Constructors and destructors cannot have explicit return values ", funcDecl);907 throw SemanticError( funcDecl, "Constructors and destructors cannot have explicit return values " ); 908 908 } 909 909 } … … 940 940 941 941 sub.apply( inst ); 942 if ( args.size() < params->size() ) throw SemanticError( "Too few type arguments in generic type ", inst);943 if ( args.size() > params->size() ) throw SemanticError( "Too many type arguments in generic type ", inst);942 if ( args.size() < params->size() ) throw SemanticError( inst, "Too few type arguments in generic type " ); 943 if ( args.size() > params->size() ) throw SemanticError( inst, "Too many type arguments in generic type " ); 944 944 } 945 945 }
Note: See TracChangeset
for help on using the changeset viewer.