Changeset a16764a6 for src/SymTab/Validate.cc
- Timestamp:
- Feb 28, 2018, 4:48:22 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, resolv-new, with_gc
- Children:
- 446ffa3
- Parents:
- 6a8df56
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
r6a8df56 ra16764a6 360 360 // the only case in which "void" is valid is where it is the only one in the list 361 361 if ( containsVoid && ( nvals > 1 || isVarArgs ) ) { 362 throwSemanticError( func, "invalid type void in function type " );362 SemanticError( func, "invalid type void in function type " ); 363 363 } 364 364 … … 401 401 for ( Expression * param : inst->parameters ) { 402 402 if ( ! dynamic_cast< TypeExpr * >( param ) ) { 403 throwSemanticError( inst, "Expression parameters for generic types are currently unsupported: " );403 SemanticError( inst, "Expression parameters for generic types are currently unsupported: " ); 404 404 } 405 405 } … … 501 501 TraitDecl *traitDecl = local_indexer->lookupTrait( traitInst->name ); 502 502 if ( ! traitDecl ) { 503 throwSemanticError( traitInst->location, "use of undeclared trait " + traitInst->name );503 SemanticError( traitInst->location, "use of undeclared trait " + traitInst->name ); 504 504 } // if 505 505 if ( traitDecl->get_parameters().size() != traitInst->get_parameters().size() ) { 506 throwSemanticError( traitInst, "incorrect number of trait parameters: " );506 SemanticError( traitInst, "incorrect number of trait parameters: " ); 507 507 } // if 508 508 traitInst->baseTrait = traitDecl; … … 512 512 TypeExpr * expr = dynamic_cast< TypeExpr * >( std::get<1>(p) ); 513 513 if ( ! expr ) { 514 throwSemanticError( std::get<1>(p), "Expression parameters for trait instances are currently unsupported: " );514 SemanticError( std::get<1>(p), "Expression parameters for trait instances are currently unsupported: " ); 515 515 } 516 516 if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( expr->get_type() ) ) { … … 618 618 bool isVoid = fixFunction( assertion ); 619 619 if ( isVoid ) { 620 throwSemanticError( node, "invalid type void in assertion of function " );620 SemanticError( node, "invalid type void in assertion of function " ); 621 621 } // if 622 622 } // for … … 662 662 // were cast to void. 663 663 if ( ! returnStmt->get_expr() && returnVals.size() != 0 ) { 664 throwSemanticError( returnStmt, "Non-void function returns no values: " );664 SemanticError( returnStmt, "Non-void function returns no values: " ); 665 665 } 666 666 } … … 703 703 ReferenceToType *rtt = dynamic_cast<ReferenceToType*>(ret); 704 704 if ( ! rtt ) { 705 throwSemanticError( typeInst->location, "Cannot apply type parameters to base type of " + typeInst->name );705 SemanticError( typeInst->location, "Cannot apply type parameters to base type of " + typeInst->name ); 706 706 } 707 707 rtt->get_parameters().clear(); … … 741 741 Type * t2 = typedefNames[ tyDecl->get_name() ].first->get_base(); 742 742 if ( ! ResolvExpr::typesCompatible( t1, t2, Indexer() ) ) { 743 throwSemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name );743 SemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name ); 744 744 } 745 745 // Cannot redefine VLA typedefs. Note: this is slightly incorrect, because our notion of VLAs … … 748 748 // to fix this corner case likely outweighs the utility of allowing it. 749 749 if ( isVariableLength( t1 ) || isVariableLength( t2 ) ) { 750 throwSemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name );750 SemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name ); 751 751 } 752 752 } else { … … 897 897 if ( CodeGen::isCtorDtorAssign( funcDecl->get_name() ) ) { // TODO: also check /=, etc. 898 898 if ( params.size() == 0 ) { 899 throwSemanticError( funcDecl, "Constructors, destructors, and assignment functions require at least one parameter " );899 SemanticError( funcDecl, "Constructors, destructors, and assignment functions require at least one parameter " ); 900 900 } 901 901 ReferenceType * refType = dynamic_cast< ReferenceType * >( params.front()->get_type() ); 902 902 if ( ! refType ) { 903 throwSemanticError( funcDecl, "First parameter of a constructor, destructor, or assignment function must be a reference " );903 SemanticError( funcDecl, "First parameter of a constructor, destructor, or assignment function must be a reference " ); 904 904 } 905 905 if ( CodeGen::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) { 906 throwSemanticError( funcDecl, "Constructors and destructors cannot have explicit return values " );906 SemanticError( funcDecl, "Constructors and destructors cannot have explicit return values " ); 907 907 } 908 908 } … … 939 939 940 940 sub.apply( inst ); 941 if ( args.size() < params->size() ) throwSemanticError( inst, "Too few type arguments in generic type " );942 if ( args.size() > params->size() ) throwSemanticError( inst, "Too many type arguments in generic type " );941 if ( args.size() < params->size() ) SemanticError( inst, "Too few type arguments in generic type " ); 942 if ( args.size() > params->size() ) SemanticError( inst, "Too many type arguments in generic type " ); 943 943 } 944 944 }
Note: See TracChangeset
for help on using the changeset viewer.