ChuanqiXu updated this revision to Diff 520047.
ChuanqiXu added a comment.

Code cleanup and gentle ping~. Given this is small and innocent, I'd like to 
land this in 2 weeks if no comments come in.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148506/new/

https://reviews.llvm.org/D148506

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Modules/pr62158.cppm
  clang/test/SemaCXX/pr62174.cpp

Index: clang/test/SemaCXX/pr62174.cpp
===================================================================
--- /dev/null
+++ clang/test/SemaCXX/pr62174.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++20 %s -fsyntax-only -verify
+// expected-no-diagnostics
+namespace lib {
+    namespace impl {
+        template <class>
+        inline constexpr bool test = false;
+    }
+    using impl::test;
+}
+
+struct foo {};
+
+template <>
+inline constexpr bool lib::test<foo> = true;
+
+static_assert(lib::test<foo>);
Index: clang/test/Modules/pr62158.cppm
===================================================================
--- /dev/null
+++ clang/test/Modules/pr62158.cppm
@@ -0,0 +1,46 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/lib.cppm -o %t/lib.pcm
+// RUN: %clang_cc1 -std=c++20 %t/main.cpp -fmodule-file=lib=%t/lib.pcm \
+// RUN:     -verify -fsyntax-only
+
+//--- header.h
+namespace lib::inline __1 {
+template <class>
+inline constexpr bool test = false;
+template <class>
+constexpr bool func() {
+    return false;
+}
+inline constexpr bool non_templ = true;
+} // namespace lib
+
+//--- lib.cppm
+module;
+#include "header.h"
+export module lib;
+
+export namespace lib {
+    using lib::test;
+    using lib::func;
+    using lib::non_templ;
+} // namespace lib
+
+//--- main.cpp
+// expected-no-diagnostics
+import lib;
+
+struct foo {};
+
+template <>
+inline constexpr bool lib::test<foo> = true;
+
+template <>
+constexpr bool lib::func<foo>() {
+    return true;
+}
+
+static_assert(lib::test<foo>);
+static_assert(lib::func<foo>());
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1821,17 +1821,20 @@
   return OldM == NewM;
 }
 
-static bool isUsingDecl(NamedDecl *D) {
+static bool isUsingDeclAtClassScope(NamedDecl *D) {
+  if (D->getDeclContext()->isFileContext())
+    return false;
+
   return isa<UsingShadowDecl>(D) ||
          isa<UnresolvedUsingTypenameDecl>(D) ||
          isa<UnresolvedUsingValueDecl>(D);
 }
 
-/// Removes using shadow declarations from the lookup results.
+/// Removes using shadow declarations at class scope from the lookup results.
 static void RemoveUsingDecls(LookupResult &R) {
   LookupResult::Filter F = R.makeFilter();
   while (F.hasNext())
-    if (isUsingDecl(F.next()))
+    if (isUsingDeclAtClassScope(F.next()))
       F.erase();
 
   F.done();
@@ -6378,10 +6381,6 @@
     // containing the two f's declared in X, but neither of them
     // matches.
 
-    // C++ [dcl.meaning]p1:
-    //   [...] the member shall not merely have been introduced by a
-    //   using-declaration in the scope of the class or namespace nominated by
-    //   the nested-name-specifier of the declarator-id.
     RemoveUsingDecls(Previous);
   }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to