This revision was automatically updated to reflect the committed changes. Closed by commit rG86c5b870b2e5: [AST] Don't consider 'ExportDecl' when calculating DeclContext 'Encloses' (authored by ChuanqiXu).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116911/new/ https://reviews.llvm.org/D116911 Files: clang/lib/AST/DeclBase.cpp clang/test/SemaCXX/lookup-through-export.cpp Index: clang/test/SemaCXX/lookup-through-export.cpp =================================================================== --- /dev/null +++ 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 +} Index: clang/lib/AST/DeclBase.cpp =================================================================== --- clang/lib/AST/DeclBase.cpp +++ clang/lib/AST/DeclBase.cpp @@ -1212,7 +1212,8 @@ return getPrimaryContext()->Encloses(DC); for (; DC; DC = DC->getParent()) - if (!isa<LinkageSpecDecl>(DC) && DC->getPrimaryContext() == this) + if (!isa<LinkageSpecDecl>(DC) && !isa<ExportDecl>(DC) && + DC->getPrimaryContext() == this) return true; return false; }
Index: clang/test/SemaCXX/lookup-through-export.cpp =================================================================== --- /dev/null +++ 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 +} Index: clang/lib/AST/DeclBase.cpp =================================================================== --- clang/lib/AST/DeclBase.cpp +++ clang/lib/AST/DeclBase.cpp @@ -1212,7 +1212,8 @@ return getPrimaryContext()->Encloses(DC); for (; DC; DC = DC->getParent()) - if (!isa<LinkageSpecDecl>(DC) && DC->getPrimaryContext() == this) + if (!isa<LinkageSpecDecl>(DC) && !isa<ExportDecl>(DC) && + DC->getPrimaryContext() == this) return true; return false; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits