aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaLookup.cpp7
-rw-r--r--test/SemaCXX/linkage-spec.cpp14
-rw-r--r--test/SemaCXX/using-directive.cpp9
3 files changed, 29 insertions, 1 deletions
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp
index 1ddfef839f..48d7320d2e 100644
--- a/lib/Sema/SemaLookup.cpp
+++ b/lib/Sema/SemaLookup.cpp
@@ -480,7 +480,12 @@ bool Sema::CppLookupName(LookupResult &R, Scope *S) {
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.
diff --git a/test/SemaCXX/linkage-spec.cpp b/test/SemaCXX/linkage-spec.cpp
index fc9b3ab51e..d19727ac07 100644
--- a/test/SemaCXX/linkage-spec.cpp
+++ b/test/SemaCXX/linkage-spec.cpp
@@ -40,3 +40,17 @@ namespace pr5430 {
}
using namespace pr5430;
extern "C" void pr5430::func(void) { }
+
+// PR5404
+int f2(char *)
+{
+ return 0;
+}
+
+extern "C"
+{
+ int f2(int)
+ {
+ return f2((char *)0);
+ }
+}
diff --git a/test/SemaCXX/using-directive.cpp b/test/SemaCXX/using-directive.cpp
index 51f347dc7a..b7583f27cb 100644
--- a/test/SemaCXX/using-directive.cpp
+++ b/test/SemaCXX/using-directive.cpp
@@ -112,3 +112,12 @@ using namespace Alias;
void testAlias() {
inAliased();
}
+
+namespace N { void f2(int); }
+
+extern "C++" {
+ using namespace N;
+ void f3() { f2(1); }
+}
+
+void f4() { f2(1); }