diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 49719ab4f524..351694c74d1a 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -343,11 +343,11 @@ Decl *Sema::LookupDecl(DeclarationName Name, unsigned NSI, Scope *S, } } + if (!LookInParent && !Ctx->isTransparentContext()) + return 0; + Ctx = Ctx->getParent(); } - - if (!LookInParent && !Ctx->isTransparentContext()) - return 0; } } diff --git a/clang/test/SemaCXX/qualified-id-lookup.cpp b/clang/test/SemaCXX/qualified-id-lookup.cpp index 0ef8e69107bf..c0d1ca370d13 100644 --- a/clang/test/SemaCXX/qualified-id-lookup.cpp +++ b/clang/test/SemaCXX/qualified-id-lookup.cpp @@ -1,5 +1,4 @@ // RUN: clang -fsyntax-only -verify %s - namespace Ns { int f(); // expected-note{{previous declaration is here}} @@ -71,5 +70,18 @@ namespace a { } } +// PR clang/3291 +namespace a { + namespace a { // A1 + namespace a { // A2 + int i; + } + } +} +void test_a() { + a::a::i = 3; // expected-error{{no member named 'i'}} + a::a::a::i = 4; +} +