Changeset 4aa0858 for src/SymTab/IdTable.cc
- Timestamp:
- Aug 19, 2015, 3:58:35 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:
- 353d168, 59cde21
- Parents:
- 4550bcf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/IdTable.cc
r4550bcf r4aa0858 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 17:04:02 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sun May 17 17:07:43201513 // Update Count : 3 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Aug 19 15:47:58 2015 13 // Update Count : 38 14 14 // 15 15 … … 52 52 if ( decl->get_linkage() == LinkageSpec::C ) { 53 53 manglename = name; 54 } else if ( LinkageSpec::isOverridable( decl->get_linkage() ) ) { 55 // mangle the name without including the appropriate suffix 56 // this will make it so that overridable routines are placed 57 // into the same "bucket" as their user defined versions. 58 manglename = Mangler::mangle( decl, false ); 54 59 } else { 55 60 manglename = Mangler::mangle( decl ); … … 64 69 std::stack< DeclEntry >& entry = it->second; 65 70 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 66 74 if ( decl->get_linkage() != LinkageSpec::C || ResolvExpr::typesCompatible( decl->get_type(), entry.top().first->get_type(), Indexer() ) ) { 67 75 FunctionDecl *newentry = dynamic_cast< FunctionDecl* >( decl ); 68 76 FunctionDecl *old = dynamic_cast< FunctionDecl* >( entry.top().first ); 69 if ( newentry && old && newentry->get_statements() && old->get_statements() ) { 70 throw SemanticError( "duplicate function definition for ", decl ); 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 ); 71 82 } else { 83 // two objects with the same mangled name defined in the same scope. 84 // both objects must be marked extern for this to be okay 72 85 ObjectDecl *newobj = dynamic_cast< ObjectDecl* >( decl ); 73 86 ObjectDecl *oldobj = dynamic_cast< ObjectDecl* >( entry.top().first ); 74 if ( newobj && oldobj && newobj->get_ init() && oldobj->get_init()) {87 if ( newobj && oldobj && newobj->get_storageClass() != DeclarationNode::Extern && oldobj->get_storageClass() != DeclarationNode::Extern ) { 75 88 throw SemanticError( "duplicate definition for ", decl ); 76 89 } // if 77 90 } // if 78 91 } else { 79 throw SemanticError( "duplicate definition for ", decl ); 92 // C definitions with the same name but incompatible types 93 throw SemanticError( "duplicate definition for 2 ", decl ); 80 94 } // if 81 95 } else { … … 84 98 } // if 85 99 // ensure the set of routines with C linkage cannot be overloaded 100 // this ensures that no two declarations with the same unmangled name both have C linkage 86 101 for ( InnerTableType::iterator i = declTable.begin(); i != declTable.end(); ++i ) { 87 102 if ( ! i->second.empty() && i->second.top().first->get_linkage() == LinkageSpec::C && declTable.size() > 1 ) {
Note: See TracChangeset
for help on using the changeset viewer.