[cfe-commits] r90859 - in /cfe/trunk: lib/Sema/SemaLookup.cpp test/SemaCXX/linkage-spec.cpp test/SemaCXX/using-directive.cpp
Douglas Gregor
dgregor at apple.com
Tue Dec 8 07:38:36 PST 2009
Author: dgregor
Date: Tue Dec 8 09:38:36 2009
New Revision: 90859
URL: http://llvm.org/viewvc/llvm-project?rev=90859&view=rev
Log:
When performing unqualified name lookup in C++, don't look directly
into transparent contexts; instead, we'll look into their nearest
enclosing non-transparent contexts further up the stack. Fixes PR5479.
Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/SemaCXX/linkage-spec.cpp
cfe/trunk/test/SemaCXX/using-directive.cpp
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=90859&r1=90858&r2=90859&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue Dec 8 09:38:36 2009
@@ -480,7 +480,12 @@
DeclContext *OuterCtx = findOuterContext(S);
for (; Ctx && Ctx->getPrimaryContext() != OuterCtx;
Ctx = Ctx->getLookupParent()) {
- if (Ctx->isFunctionOrMethod())
+ // We do not directly look into function or method contexts
+ // (since all local variables are found via the identifier
+ // changes) or in transparent contexts (since those entities
+ // will be found in the nearest enclosing non-transparent
+ // context).
+ if (Ctx->isFunctionOrMethod() || Ctx->isTransparentContext())
continue;
// Perform qualified name lookup into this context.
Modified: cfe/trunk/test/SemaCXX/linkage-spec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/linkage-spec.cpp?rev=90859&r1=90858&r2=90859&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/linkage-spec.cpp (original)
+++ cfe/trunk/test/SemaCXX/linkage-spec.cpp Tue Dec 8 09:38:36 2009
@@ -40,3 +40,17 @@
}
using namespace pr5430;
extern "C" void pr5430::func(void) { }
+
+// PR5404
+int f2(char *)
+{
+ return 0;
+}
+
+extern "C"
+{
+ int f2(int)
+ {
+ return f2((char *)0);
+ }
+}
Modified: cfe/trunk/test/SemaCXX/using-directive.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/using-directive.cpp?rev=90859&r1=90858&r2=90859&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/using-directive.cpp (original)
+++ cfe/trunk/test/SemaCXX/using-directive.cpp Tue Dec 8 09:38:36 2009
@@ -112,3 +112,12 @@
void testAlias() {
inAliased();
}
+
+namespace N { void f2(int); }
+
+extern "C++" {
+ using namespace N;
+ void f3() { f2(1); }
+}
+
+void f4() { f2(1); }
More information about the cfe-commits
mailing list