Changeset 09d1ad0


Ignore:
Timestamp:
Apr 19, 2016, 3:57:26 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, string, with_gc
Children:
6b6597c
Parents:
b644d6f
Message:

Fix incompatible Cdecl check to only fire on decls in the same scope

Location:
src/SymTab
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Indexer.cc

    rb644d6f r09d1ad0  
    511511        }
    512512
    513         bool Indexer::hasIncompatibleCDecl( const std::string &id, const std::string &mangleName ) const {
     513        bool Indexer::hasIncompatibleCDecl( const std::string &id, const std::string &mangleName, unsigned long scope ) const {
    514514                if ( ! tables ) return false;
     515                if ( tables->scope < scope ) return false;
    515516
    516517                IdTable::const_iterator decls = tables->idTable.find( id );
     
    524525                }
    525526
    526                 return tables->base.hasIncompatibleCDecl( id, mangleName );
     527                return tables->base.hasIncompatibleCDecl( id, mangleName, scope );
    527528        }
    528529       
     
    617618                DeclarationWithType *existing = lookupIdAtScope( name, mangleName, scope );
    618619                if ( ! existing || ! addedIdConflicts( existing, decl ) ) {
    619                         // this ensures that no two declarations with the same unmangled name both have C linkage
    620                         if ( decl->get_linkage() == LinkageSpec::C && hasIncompatibleCDecl( name, mangleName ) ) {
     620                        // this ensures that no two declarations with the same unmangled name at the same scope both have C linkage
     621                        if ( decl->get_linkage() == LinkageSpec::C && hasIncompatibleCDecl( name, mangleName, scope ) ) {
    621622                                throw SemanticError( "invalid overload of C function ", decl );
    622623                        } // NOTE this is broken in Richard's original code in such a way that it never triggers (it
  • src/SymTab/Indexer.h

    rb644d6f r09d1ad0  
    9999                DeclarationWithType *lookupIdAtScope( const std::string &id, const std::string &mangleName, unsigned long scope ) const;
    100100                /// returns true if there exists a declaration with C linkage and the given name with a different mangled name
    101                 bool hasIncompatibleCDecl( const std::string &id, const std::string &mangleName ) const;
     101                bool hasIncompatibleCDecl( const std::string &id, const std::string &mangleName, unsigned long scope ) const;
    102102                // equivalents to lookup functions that only look at tables at scope `scope` (which should be >= tables->scope)
    103103                NamedTypeDecl *lookupTypeAtScope( const std::string &id, unsigned long scope ) const;
Note: See TracChangeset for help on using the changeset viewer.