Changes in src/SymTab/IdTable.cc [59cde21:4aa0858]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/IdTable.cc
r59cde21 r4aa0858 10 10 // Created On : Sun May 17 17:04:02 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Oct 07 12:21:13201513 // Update Count : 7312 // Last Modified On : Wed Aug 19 15:47:58 2015 13 // Update Count : 38 14 14 // 15 15 … … 37 37 for ( InnerTableType::iterator inner = outer->second.begin(); inner != outer->second.end(); ++inner ) { 38 38 std::stack< DeclEntry >& entry = inner->second; 39 // xxx - should be while?40 39 if ( ! entry.empty() && entry.top().second == scopeLevel ) { 41 40 entry.pop(); … … 66 65 67 66 if ( it == declTable.end() ) { 68 // first time this name mangling has been defined69 67 declTable[ manglename ].push( DeclEntry( decl, scopeLevel ) ); 70 68 } else { 71 69 std::stack< DeclEntry >& entry = it->second; 72 70 if ( ! entry.empty() && entry.top().second == scopeLevel ) { 73 // if we're giving the same name mangling to things of 74 // different types then there is something wrong 75 Declaration *old = entry.top().first; 76 assert( (dynamic_cast<ObjectDecl*>( decl ) && dynamic_cast<ObjectDecl*>( old ) ) 77 || (dynamic_cast<FunctionDecl*>( decl ) && dynamic_cast<FunctionDecl*>( old ) ) ); 71 // typesCompatible doesn't really do the right thing here. When checking compatibility of function types, 72 // we should ignore outermost pointer qualifiers, except _Atomic? 78 73 79 if ( LinkageSpec::isOverridable( old->get_linkage() ) ) { 80 // new definition shadows the autogenerated one, even at the same scope 81 declTable[ manglename ].push( DeclEntry( decl, scopeLevel ) ); 82 } else if ( decl->get_linkage() != LinkageSpec::C || ResolvExpr::typesCompatible( decl->get_type(), entry.top().first->get_type(), Indexer() ) ) { 83 // typesCompatible doesn't really do the right thing here. When checking compatibility of function types, 84 // we should ignore outermost pointer qualifiers, except _Atomic? 74 if ( decl->get_linkage() != LinkageSpec::C || ResolvExpr::typesCompatible( decl->get_type(), entry.top().first->get_type(), Indexer() ) ) { 85 75 FunctionDecl *newentry = dynamic_cast< FunctionDecl* >( decl ); 86 FunctionDecl *oldentry = dynamic_cast< FunctionDecl* >( old ); 87 if ( newentry && oldentry ) { 88 if ( newentry->get_statements() && oldentry->get_statements() ) { 89 throw SemanticError( "duplicate function definition for 1 ", decl ); 90 } // if 76 FunctionDecl *old = dynamic_cast< FunctionDecl* >( entry.top().first ); 77 if ( LinkageSpec::isOverridable( old->get_linkage() ) ) { 78 // new definition shadows the autogenerated one, even at the same scope 79 declTable[ manglename ].push( DeclEntry( decl, scopeLevel ) ); 80 } else if ( newentry && old && newentry->get_statements() && old->get_statements() ) { 81 throw SemanticError( "duplicate function definition for 1 ", decl ); 91 82 } else { 92 83 // two objects with the same mangled name defined in the same scope. 93 // both objects must be marked extern or both must be intrinsic for this to be okay 94 // xxx - perhaps it's actually if either is intrinsic then this is okay? 95 // might also need to be same storage class? 84 // both objects must be marked extern for this to be okay 96 85 ObjectDecl *newobj = dynamic_cast< ObjectDecl* >( decl ); 97 ObjectDecl *oldobj = dynamic_cast< ObjectDecl* >( old);98 if ( newobj->get_storageClass() != DeclarationNode::Extern && oldobj->get_storageClass() != DeclarationNode::Extern ) {99 throw SemanticError( "duplicate definition for 3", decl );86 ObjectDecl *oldobj = dynamic_cast< ObjectDecl* >( entry.top().first ); 87 if ( newobj && oldobj && newobj->get_storageClass() != DeclarationNode::Extern && oldobj->get_storageClass() != DeclarationNode::Extern ) { 88 throw SemanticError( "duplicate definition for ", decl ); 100 89 } // if 101 90 } // if 102 91 } else { 103 throw SemanticError( "duplicate definition for ", decl ); 92 // C definitions with the same name but incompatible types 93 throw SemanticError( "duplicate definition for 2 ", decl ); 104 94 } // if 105 95 } else { 106 // new scope level - shadow existing definition107 96 declTable[ manglename ].push( DeclEntry( decl, scopeLevel ) ); 108 97 } // if 109 98 } // if 99 // ensure the set of routines with C linkage cannot be overloaded 110 100 // this ensures that no two declarations with the same unmangled name both have C linkage 111 101 for ( InnerTableType::iterator i = declTable.begin(); i != declTable.end(); ++i ) {
Note: See TracChangeset
for help on using the changeset viewer.