diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -1212,7 +1212,8 @@ return getPrimaryContext()->Encloses(DC); for (; DC; DC = DC->getParent()) - if (!isa(DC) && DC->getPrimaryContext() == this) + if (!isa(DC) && !isa(DC) && + DC->getPrimaryContext() == this) return true; return false; } diff --git a/clang/test/SemaCXX/lookup-through-export.cpp b/clang/test/SemaCXX/lookup-through-export.cpp new file mode 100644 --- /dev/null +++ b/clang/test/SemaCXX/lookup-through-export.cpp @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -std=c++20 %s -verify + +// expected-no-diagnostics +export module X; +export { + namespace A { + namespace B { + int bar; + } + } // namespace A + namespace C { + void foo() { + using namespace A; + (void)B::bar; + } + } // namespace C +} + +export { + namespace D { + namespace E { + int bar; + } + } // namespace D + namespace F { + void foo() { + using namespace D; + (void)E::bar; + } + } // namespace F +}