Changes in src/SymTab/Validate.cc [4b97770:d55d7a6]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
r4b97770 rd55d7a6 366 366 dwts.erase( j ); 367 367 if ( i != end ) { 368 throw SemanticError( "invalid type void in function type ", func);368 throw SemanticError( func, "invalid type void in function type " ); 369 369 } // if 370 370 } else { … … 374 374 *i = (*i)->acceptMutator( fixer ); 375 375 if ( fixer.pass.isVoid ) { 376 throw SemanticError( "invalid type void in function type ", func);376 throw SemanticError( func, "invalid type void in function type " ); 377 377 } // if 378 378 } // for … … 411 411 for ( Expression * param : inst->parameters ) { 412 412 if ( ! dynamic_cast< TypeExpr * >( param ) ) { 413 throw SemanticError( "Expression parameters for generic types are currently unsupported: ", inst);413 throw SemanticError( inst, "Expression parameters for generic types are currently unsupported: " ); 414 414 } 415 415 } … … 511 511 TraitDecl *traitDecl = local_indexer->lookupTrait( traitInst->name ); 512 512 if ( ! traitDecl ) { 513 throw SemanticError( "use of undeclared trait " + traitInst->name );513 throw SemanticError( traitInst->location, "use of undeclared trait " + traitInst->name ); 514 514 } // if 515 515 if ( traitDecl->get_parameters().size() != traitInst->get_parameters().size() ) { 516 throw SemanticError( "incorrect number of trait parameters: ", traitInst);516 throw SemanticError( traitInst, "incorrect number of trait parameters: " ); 517 517 } // if 518 518 traitInst->baseTrait = traitDecl; … … 522 522 TypeExpr * expr = dynamic_cast< TypeExpr * >( std::get<1>(p) ); 523 523 if ( ! expr ) { 524 throw SemanticError( "Expression parameters for trait instances are currently unsupported: ", std::get<1>(p));524 throw SemanticError( std::get<1>(p), "Expression parameters for trait instances are currently unsupported: " ); 525 525 } 526 526 if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( expr->get_type() ) ) { … … 629 629 assertion = assertion->acceptMutator( fixer ); 630 630 if ( fixer.pass.isVoid ) { 631 throw SemanticError( "invalid type void in assertion of function ", node);631 throw SemanticError( node, "invalid type void in assertion of function " ); 632 632 } // if 633 633 } // for … … 673 673 // were cast to void. 674 674 if ( ! returnStmt->get_expr() && returnVals.size() != 0 ) { 675 throw SemanticError( "Non-void function returns no values: " , returnStmt);675 throw SemanticError( returnStmt, "Non-void function returns no values: " ); 676 676 } 677 677 } … … 714 714 ReferenceToType *rtt = dynamic_cast<ReferenceToType*>(ret); 715 715 if ( ! rtt ) { 716 throw SemanticError( "Cannot apply type parameters to base type of " + typeInst->name);716 throw SemanticError( typeInst->location, "Cannot apply type parameters to base type of " + typeInst->name ); 717 717 } 718 718 rtt->get_parameters().clear(); … … 752 752 Type * t2 = typedefNames[ tyDecl->get_name() ].first->get_base(); 753 753 if ( ! ResolvExpr::typesCompatible( t1, t2, Indexer() ) ) { 754 throw SemanticError( "Cannot redefine typedef: " + tyDecl->name );754 throw SemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name ); 755 755 } 756 756 // Cannot redefine VLA typedefs. Note: this is slightly incorrect, because our notion of VLAs … … 759 759 // to fix this corner case likely outweighs the utility of allowing it. 760 760 if ( isVariableLength( t1 ) || isVariableLength( t2 ) ) { 761 throw SemanticError( "Cannot redefine typedef: " + tyDecl->name );761 throw SemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name ); 762 762 } 763 763 } else { … … 908 908 if ( CodeGen::isCtorDtorAssign( funcDecl->get_name() ) ) { // TODO: also check /=, etc. 909 909 if ( params.size() == 0 ) { 910 throw SemanticError( "Constructors, destructors, and assignment functions require at least one parameter ", funcDecl);910 throw SemanticError( funcDecl, "Constructors, destructors, and assignment functions require at least one parameter " ); 911 911 } 912 912 ReferenceType * refType = dynamic_cast< ReferenceType * >( params.front()->get_type() ); 913 913 if ( ! refType ) { 914 throw SemanticError( "First parameter of a constructor, destructor, or assignment function must be a reference ", funcDecl);914 throw SemanticError( funcDecl, "First parameter of a constructor, destructor, or assignment function must be a reference " ); 915 915 } 916 916 if ( CodeGen::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) { 917 throw SemanticError( "Constructors and destructors cannot have explicit return values ", funcDecl);917 throw SemanticError( funcDecl, "Constructors and destructors cannot have explicit return values " ); 918 918 } 919 919 } … … 950 950 951 951 sub.apply( inst ); 952 if ( args.size() < params->size() ) throw SemanticError( "Too few type arguments in generic type ", inst);953 if ( args.size() > params->size() ) throw SemanticError( "Too many type arguments in generic type ", inst);952 if ( args.size() < params->size() ) throw SemanticError( inst, "Too few type arguments in generic type " ); 953 if ( args.size() > params->size() ) throw SemanticError( inst, "Too many type arguments in generic type " ); 954 954 } 955 955 }
Note:
See TracChangeset
for help on using the changeset viewer.