Changeset dcbb03b for src/SymTab
- Timestamp:
- Mar 1, 2018, 9:29:03 AM (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:
- 1f37ed02
- Parents:
- b002261 (diff), 446ffa3 (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:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.cc
rb002261 rdcbb03b 24 24 #include <vector> // for vector 25 25 26 #include "AddVisit.h" // for addVisit27 26 #include "CodeGen/OperatorTable.h" // for isCtorDtor, isCtorDtorAssign 28 27 #include "Common/PassVisitor.h" // for PassVisitor … … 332 331 definitions.push_back( dcl ); 333 332 indexer.addId( dcl ); 334 } catch ( SemanticError err ) {333 } catch ( SemanticErrorException err ) { 335 334 // okay if decl does not resolve - that means the function should not be generated 336 335 delete dcl; -
src/SymTab/Indexer.cc
rb002261 rdcbb03b 443 443 // isomorphic to C type-compatibility, which it may not be. 444 444 if ( hasIncompatibleCDecl( name, mangleName, scope ) ) { 445 throwSemanticError( decl, "conflicting overload of C function " );445 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 throwSemanticError( decl, "Cforall declaration hides C function " );450 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) { throwSemanticError( decl, msg ); return true; }, baseExpr );465 addId( decl, [decl](IdData &, const std::string & msg) { 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) { throwSemanticError( decl, msg ); return true; }, nullptr, deleteStmt );470 addId( decl, [decl](IdData &, const std::string & msg) { SemanticError( decl, msg ); return true; }, nullptr, deleteStmt ); 471 471 } 472 472 … … 477 477 return true; 478 478 } else { 479 throwSemanticError( added, "redeclaration of " );479 SemanticError( added, "redeclaration of " ); 480 480 } 481 481 } … … 504 504 return false; 505 505 } else if ( ! added->get_members().empty() ) { 506 throwSemanticError( added, "redeclaration of " );506 SemanticError( added, "redeclaration of " ); 507 507 } // if 508 508 return true; … … 603 603 if ( dynamic_cast< StructInstType * >( t ) || dynamic_cast< UnionInstType * >( t ) ) { 604 604 Expression * base = expr->clone(); 605 ResolvExpr::referenceToRvalueConversion( base ); 605 ResolvExpr::Cost cost = ResolvExpr::Cost::zero; // xxx - carry this cost into the indexer as a base cost? 606 ResolvExpr::referenceToRvalueConversion( base, cost ); 606 607 addMembers( t->getAggr(), new MemberExpr( dwt, base ), handleConflicts ); 607 608 } … … 705 706 } 706 707 707 Expression * Indexer::IdData::combine( ) const {708 Expression * Indexer::IdData::combine( ResolvExpr::Cost & cost ) const { 708 709 Expression * ret = nullptr; 709 710 if ( baseExpr ) { 710 711 Expression * base = baseExpr->clone(); 711 ResolvExpr::referenceToRvalueConversion( base );712 ResolvExpr::referenceToRvalueConversion( base, cost ); 712 713 ret = new MemberExpr( id, base ); 713 714 // xxx - this introduces hidden environments, for now remove them. -
src/SymTab/Indexer.h
rb002261 rdcbb03b 23 23 #include "SynTree/Visitor.h" // for Visitor 24 24 #include "SynTree/SynTree.h" // for AST nodes 25 26 namespace ResolvExpr { 27 class Cost; 28 } 25 29 26 30 namespace SymTab { … … 51 55 IdData( DeclarationWithType * id, Expression * baseExpr, BaseSyntaxNode * deleteStmt ) : id( id ), baseExpr( baseExpr ), deleteStmt( deleteStmt ) {} 52 56 53 Expression * combine( ) const;57 Expression * combine( ResolvExpr::Cost & cost ) const; 54 58 }; 55 59 -
src/SymTab/Validate.cc
rb002261 rdcbb03b 60 60 #include "Parser/LinkageSpec.h" // for C 61 61 #include "ResolvExpr/typeops.h" // for typesCompatible 62 #include "SymTab/AddVisit.h" // for addVisit63 62 #include "SymTab/Autogen.h" // for SizeType 64 63 #include "SynTree/Attribute.h" // for noAttributes, Attribute … … 361 360 // the only case in which "void" is valid is where it is the only one in the list 362 361 if ( containsVoid && ( nvals > 1 || isVarArgs ) ) { 363 throwSemanticError( func, "invalid type void in function type " );362 SemanticError( func, "invalid type void in function type " ); 364 363 } 365 364 … … 402 401 for ( Expression * param : inst->parameters ) { 403 402 if ( ! dynamic_cast< TypeExpr * >( param ) ) { 404 throwSemanticError( inst, "Expression parameters for generic types are currently unsupported: " );403 SemanticError( inst, "Expression parameters for generic types are currently unsupported: " ); 405 404 } 406 405 } … … 502 501 TraitDecl *traitDecl = local_indexer->lookupTrait( traitInst->name ); 503 502 if ( ! traitDecl ) { 504 throwSemanticError( traitInst->location, "use of undeclared trait " + traitInst->name );503 SemanticError( traitInst->location, "use of undeclared trait " + traitInst->name ); 505 504 } // if 506 505 if ( traitDecl->get_parameters().size() != traitInst->get_parameters().size() ) { 507 throwSemanticError( traitInst, "incorrect number of trait parameters: " );506 SemanticError( traitInst, "incorrect number of trait parameters: " ); 508 507 } // if 509 508 traitInst->baseTrait = traitDecl; … … 513 512 TypeExpr * expr = dynamic_cast< TypeExpr * >( std::get<1>(p) ); 514 513 if ( ! expr ) { 515 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: " ); 516 515 } 517 516 if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( expr->get_type() ) ) { … … 619 618 bool isVoid = fixFunction( assertion ); 620 619 if ( isVoid ) { 621 throwSemanticError( node, "invalid type void in assertion of function " );620 SemanticError( node, "invalid type void in assertion of function " ); 622 621 } // if 623 622 } // for … … 663 662 // were cast to void. 664 663 if ( ! returnStmt->get_expr() && returnVals.size() != 0 ) { 665 throwSemanticError( returnStmt, "Non-void function returns no values: " );664 SemanticError( returnStmt, "Non-void function returns no values: " ); 666 665 } 667 666 } … … 704 703 ReferenceToType *rtt = dynamic_cast<ReferenceToType*>(ret); 705 704 if ( ! rtt ) { 706 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 ); 707 706 } 708 707 rtt->get_parameters().clear(); … … 742 741 Type * t2 = typedefNames[ tyDecl->get_name() ].first->get_base(); 743 742 if ( ! ResolvExpr::typesCompatible( t1, t2, Indexer() ) ) { 744 throwSemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name );743 SemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name ); 745 744 } 746 745 // Cannot redefine VLA typedefs. Note: this is slightly incorrect, because our notion of VLAs … … 749 748 // to fix this corner case likely outweighs the utility of allowing it. 750 749 if ( isVariableLength( t1 ) || isVariableLength( t2 ) ) { 751 throwSemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name );750 SemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name ); 752 751 } 753 752 } else { … … 898 897 if ( CodeGen::isCtorDtorAssign( funcDecl->get_name() ) ) { // TODO: also check /=, etc. 899 898 if ( params.size() == 0 ) { 900 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 " ); 901 900 } 902 901 ReferenceType * refType = dynamic_cast< ReferenceType * >( params.front()->get_type() ); 903 902 if ( ! refType ) { 904 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 " ); 905 904 } 906 905 if ( CodeGen::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) { 907 throwSemanticError( funcDecl, "Constructors and destructors cannot have explicit return values " );906 SemanticError( funcDecl, "Constructors and destructors cannot have explicit return values " ); 908 907 } 909 908 } … … 940 939 941 940 sub.apply( inst ); 942 if ( args.size() < params->size() ) throwSemanticError( inst, "Too few type arguments in generic type " );943 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 " ); 944 943 } 945 944 }
Note:
See TracChangeset
for help on using the changeset viewer.