Changes in src/AST/SymbolTable.cpp [b9fe89b:251ce80]
- File:
-
- 1 edited
-
src/AST/SymbolTable.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/SymbolTable.cpp
rb9fe89b r251ce80 88 88 } 89 89 90 SymbolTable::SymbolTable( ErrorDetection errorMode)90 SymbolTable::SymbolTable() 91 91 : idTable(), typeTable(), structTable(), enumTable(), unionTable(), traitTable(), 92 prevScope(), scope( 0 ), repScope( 0 ) , errorMode(errorMode){ ++*stats().count; }92 prevScope(), scope( 0 ), repScope( 0 ) { ++*stats().count; } 93 93 94 94 SymbolTable::~SymbolTable() { stats().size->push( idTable ? idTable->size() : 0 ); } 95 96 void SymbolTable::OnFindError( CodeLocation location, std::string error ) const {97 assertf( errorMode != AssertClean, "Name collision/redefinition, found during a compilation phase where none should be possible. Detail: %s", error.c_str() );98 if (errorMode == ValidateOnAdd) {99 SemanticError(location, error);100 }101 assertf( errorMode == IgnoreErrors, "Unrecognized symbol-table error mode %d", errorMode );102 }103 95 104 96 void SymbolTable::enterScope() { … … 277 269 } 278 270 279 bool SymbolTable::addedTypeConflicts( 280 const NamedTypeDecl * existing, const NamedTypeDecl * added ) const { 281 if ( existing->base == nullptr ) { 282 return false; 283 } else if ( added->base == nullptr ) { 271 namespace { 272 /// true if redeclaration conflict between two types 273 bool addedTypeConflicts( const NamedTypeDecl * existing, const NamedTypeDecl * added ) { 274 if ( existing->base == nullptr ) { 275 return false; 276 } else if ( added->base == nullptr ) { 277 return true; 278 } else { 279 // typedef redeclarations are errors only if types are different 280 if ( ! ResolvExpr::typesCompatible( existing->base, added->base ) ) { 281 SemanticError( added->location, "redeclaration of " + added->name ); 282 } 283 } 284 // does not need to be added to the table if both existing and added have a base that are 285 // the same 284 286 return true; 285 } else { 286 // typedef redeclarations are errors only if types are different 287 if ( ! ResolvExpr::typesCompatible( existing->base, added->base ) ) { 288 OnFindError( added->location, "redeclaration of " + added->name ); 289 } 290 } 291 // does not need to be added to the table if both existing and added have a base that are 292 // the same 293 return true; 294 } 295 296 bool SymbolTable::addedDeclConflicts( 297 const AggregateDecl * existing, const AggregateDecl * added ) const { 298 if ( ! existing->body ) { 299 return false; 300 } else if ( added->body ) { 301 OnFindError( added, "redeclaration of " ); 302 } 303 return true; 287 } 288 289 /// true if redeclaration conflict between two aggregate declarations 290 bool addedDeclConflicts( const AggregateDecl * existing, const AggregateDecl * added ) { 291 if ( ! existing->body ) { 292 return false; 293 } else if ( added->body ) { 294 SemanticError( added, "redeclaration of " ); 295 } 296 return true; 297 } 304 298 } 305 299 … … 654 648 if ( deleter && ! existing.deleter ) { 655 649 if ( handleConflicts.mode == OnConflict::Error ) { 656 OnFindError( added, "deletion of defined identifier " );650 SemanticError( added, "deletion of defined identifier " ); 657 651 } 658 652 return true; 659 653 } else if ( ! deleter && existing.deleter ) { 660 654 if ( handleConflicts.mode == OnConflict::Error ) { 661 OnFindError( added, "definition of deleted identifier " );655 SemanticError( added, "definition of deleted identifier " ); 662 656 } 663 657 return true; … … 667 661 if ( isDefinition( added ) && isDefinition( existing.id ) ) { 668 662 if ( handleConflicts.mode == OnConflict::Error ) { 669 OnFindError( added,663 SemanticError( added, 670 664 isFunction( added ) ? 671 665 "duplicate function definition for " : … … 676 670 } else { 677 671 if ( handleConflicts.mode == OnConflict::Error ) { 678 OnFindError( added, "duplicate definition for " );672 SemanticError( added, "duplicate definition for " ); 679 673 } 680 674 return true; … … 728 722 // Check that a Cforall declaration doesn't override any C declaration 729 723 if ( hasCompatibleCDecl( name, mangleName ) ) { 730 OnFindError( decl, "Cforall declaration hides C function " );724 SemanticError( decl, "Cforall declaration hides C function " ); 731 725 } 732 726 } else { … … 734 728 // type-compatibility, which it may not be. 735 729 if ( hasIncompatibleCDecl( name, mangleName ) ) { 736 OnFindError( decl, "conflicting overload of C function " );730 SemanticError( decl, "conflicting overload of C function " ); 737 731 } 738 732 }
Note:
See TracChangeset
for help on using the changeset viewer.