Changeset 59cde21 for src/SymTab
- Timestamp:
- Oct 7, 2015, 12:23:53 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- b0be06ac, f28a53a
- Parents:
- 4aa0858
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/IdTable.cc
r4aa0858 r59cde21 10 10 // Created On : Sun May 17 17:04:02 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Aug 19 15:47:58201513 // Update Count : 3812 // Last Modified On : Wed Oct 07 12:21:13 2015 13 // Update Count : 73 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? 39 40 if ( ! entry.empty() && entry.top().second == scopeLevel ) { 40 41 entry.pop(); … … 65 66 66 67 if ( it == declTable.end() ) { 68 // first time this name mangling has been defined 67 69 declTable[ manglename ].push( DeclEntry( decl, scopeLevel ) ); 68 70 } else { 69 71 std::stack< DeclEntry >& entry = it->second; 70 72 if ( ! entry.empty() && entry.top().second == scopeLevel ) { 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? 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 ) ) ); 73 78 74 if ( decl->get_linkage() != LinkageSpec::C || ResolvExpr::typesCompatible( decl->get_type(), entry.top().first->get_type(), Indexer() ) ) { 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? 75 85 FunctionDecl *newentry = dynamic_cast< FunctionDecl* >( decl ); 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 ); 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 82 91 } else { 83 92 // two objects with the same mangled name defined in the same scope. 84 // both objects must be marked extern for this to be okay 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? 85 96 ObjectDecl *newobj = dynamic_cast< ObjectDecl* >( 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 );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 ); 89 100 } // if 90 101 } // if 91 102 } else { 92 // C definitions with the same name but incompatible types 93 throw SemanticError( "duplicate definition for 2 ", decl ); 103 throw SemanticError( "duplicate definition for ", decl ); 94 104 } // if 95 105 } else { 106 // new scope level - shadow existing definition 96 107 declTable[ manglename ].push( DeclEntry( decl, scopeLevel ) ); 97 108 } // if 98 109 } // if 99 // ensure the set of routines with C linkage cannot be overloaded100 110 // this ensures that no two declarations with the same unmangled name both have C linkage 101 111 for ( InnerTableType::iterator i = declTable.begin(); i != declTable.end(); ++i ) {
Note: See TracChangeset
for help on using the changeset viewer.