From 21823bfe318a02a73f96e05c368211b640f6bc53 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 20 Dec 2011 18:11:52 +0000 Subject: When performing name lookup for a redeclaration, ignore module visibility restrictions. This ensures that all declarations of the same entity end up in the same redeclaration chain, even if some of those declarations aren't visible. While this may seem unfortunate to some---why can't two C modules have different functions named 'f'?---it's an acknowedgment that a module does not introduce a new "namespace" of names. As part of this, stop merging the 'module-private' bit from previous declarations to later declarations, because we want each declaration in a module to stand on its own because this can effect, for example, submodule visibility. Note that this notion of names that are invisible to normal name lookup but are available for redeclaration lookups is how we should implement friend declarations and extern declarations within local function scopes. I'm not tackling that problem now. llvm-svn: 146980 --- clang/lib/Sema/SemaLookup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'clang/lib/Sema/SemaLookup.cpp') diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index bc1cb3fca63..a5fc682d18c 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -1169,7 +1169,7 @@ bool Sema::LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation) { // If this declaration is module-private and it came from an AST // file, we can't see it. - NamedDecl *D = getVisibleDecl(*I); + NamedDecl *D = R.isForRedeclaration()? *I : getVisibleDecl(*I); if (!D) continue; -- cgit v1.2.3