Changeset d55d7a6 for src/SymTab
- Timestamp:
- Feb 15, 2018, 3:58:56 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:
- 75e3cb2
- Parents:
- d27e340
- Location:
- src/SymTab
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Indexer.cc
rd27e340 rd55d7a6 388 388 if ( newentry && oldentry ) { 389 389 if ( newentry->get_statements() && oldentry->get_statements() ) { 390 throw SemanticError( "duplicate function definition for ", added);390 throw SemanticError( added, "duplicate function definition for " ); 391 391 } // if 392 392 } else { … … 398 398 ObjectDecl *oldobj = dynamic_cast< ObjectDecl* >( existing ); 399 399 if ( ! newobj->get_storageClasses().is_extern && ! oldobj->get_storageClasses().is_extern ) { 400 throw SemanticError( "duplicate object definition for ", added);400 throw SemanticError( added, "duplicate object definition for " ); 401 401 } // if 402 402 } // if 403 403 } else { 404 throw SemanticError( "duplicate definition for ", added);404 throw SemanticError( added, "duplicate definition for " ); 405 405 } // if 406 406 … … 431 431 // isomorphic to C type-compatibility, which it may not be. 432 432 if ( hasIncompatibleCDecl( name, mangleName, scope ) ) { 433 throw SemanticError( "conflicting overload of C function ", decl);433 throw SemanticError( decl, "conflicting overload of C function " ); 434 434 } 435 435 } else { 436 436 // Check that a Cforall declaration doesn't overload any C declaration 437 437 if ( hasCompatibleCDecl( name, mangleName, scope ) ) { 438 throw SemanticError( "Cforall declaration hides C function ", decl);438 throw SemanticError( decl, "Cforall declaration hides C function " ); 439 439 } 440 440 } … … 455 455 return true; 456 456 } else { 457 throw SemanticError( "redeclaration of ", added);457 throw SemanticError( added, "redeclaration of " ); 458 458 } 459 459 } … … 482 482 return false; 483 483 } else if ( ! added->get_members().empty() ) { 484 throw SemanticError( "redeclaration of ", added);484 throw SemanticError( added, "redeclaration of " ); 485 485 } // if 486 486 return true; -
src/SymTab/Validate.cc
rd27e340 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.