https://github.com/w007878 updated 
https://github.com/llvm/llvm-project/pull/203736

>From c5bf40cb6076c5a20bad7eb7997844236b360545 Mon Sep 17 00:00:00 2001
From: Fan Mo <[email protected]>
Date: Sat, 13 Jun 2026 20:33:20 -0500
Subject: [PATCH 1/4] fix: use getDeclName in static assert failed boolean
 condition printer

---
 clang/lib/Sema/SemaTemplate.cpp      |  2 +-
 clang/test/SemaCXX/static-assert.cpp | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 8c94a1ad39208..41664f36dd6a3 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -3647,7 +3647,7 @@ class FailedBooleanConditionPrinterHelper : public 
PrinterHelper {
       DR->getQualifier().print(OS, Policy, true);
       // Then print the decl itself.
       const ValueDecl *VD = DR->getDecl();
-      OS << VD->getName();
+      OS << VD->getDeclName();
       if (const auto *IV = dyn_cast<VarTemplateSpecializationDecl>(VD)) {
         // This is a template variable, print the expanded template arguments.
         printTemplateArgumentList(
diff --git a/clang/test/SemaCXX/static-assert.cpp 
b/clang/test/SemaCXX/static-assert.cpp
index 354016db36432..f9c6378ecc396 100644
--- a/clang/test/SemaCXX/static-assert.cpp
+++ b/clang/test/SemaCXX/static-assert.cpp
@@ -364,3 +364,17 @@ namespace Diagnostics {
   static_assert(1 << 3 != 8, ""); // expected-error {{failed}} \
                                  // expected-note {{evaluates to '8 != 8'}}
 }
+
+namespace GH203701 {
+  struct S {
+    constexpr S(auto) {}
+    constexpr operator int() const { return 0; }
+    constexpr static f() const { return 0; }
+  };
+
+  constexpr auto a = [](this S) { return 1; };
+
+  static_assert((&decltype(a)::operator())(1) == 42); // expected-error 
{{static assertion failed}}
+  static_assert((&S::operator int) == nullptr, ""); // expected-error {{static 
assertion failed}}
+  static_assert((S::f() == 1)); // expected-error {{static assertion failed}}
+}

>From 66e68710b4a2e4e220d45a54f18a891a52abe595 Mon Sep 17 00:00:00 2001
From: Fan Mo <[email protected]>
Date: Sat, 13 Jun 2026 21:42:16 -0500
Subject: [PATCH 2/4] fix test

---
 clang/test/SemaCXX/static-assert.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/clang/test/SemaCXX/static-assert.cpp 
b/clang/test/SemaCXX/static-assert.cpp
index f9c6378ecc396..21a11ee7a5c45 100644
--- a/clang/test/SemaCXX/static-assert.cpp
+++ b/clang/test/SemaCXX/static-assert.cpp
@@ -369,12 +369,10 @@ namespace GH203701 {
   struct S {
     constexpr S(auto) {}
     constexpr operator int() const { return 0; }
-    constexpr static f() const { return 0; }
   };
 
   constexpr auto a = [](this S) { return 1; };
 
-  static_assert((&decltype(a)::operator())(1) == 42); // expected-error 
{{static assertion failed}}
-  static_assert((&S::operator int) == nullptr, ""); // expected-error {{static 
assertion failed}}
-  static_assert((S::f() == 1)); // expected-error {{static assertion failed}}
+  static_assert((&decltype(a)::operator())(1) == 42, ""); // expected-error-re 
{{static assertion failed due to requirement '(&const GH203701::(lambda at 
{.*})::operator())(1) == 42'}}
+  static_assert((&S::operator int) == nullptr, ""); // expected-error {{static 
assertion failed due to requirement '(&GH203701::S::operator int) == nullptr'}}
 }

>From 3088167d0348e6d13496edbac829eda93138beba Mon Sep 17 00:00:00 2001
From: Fan Mo <[email protected]>
Date: Sat, 13 Jun 2026 23:13:42 -0500
Subject: [PATCH 3/4] move test to c++17

---
 clang/test/SemaCXX/static-assert-cxx17.cpp | 12 ++++++++++++
 clang/test/SemaCXX/static-assert.cpp       | 12 ------------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/clang/test/SemaCXX/static-assert-cxx17.cpp 
b/clang/test/SemaCXX/static-assert-cxx17.cpp
index 41a7b025d0eb7..e3038f8cec130 100644
--- a/clang/test/SemaCXX/static-assert-cxx17.cpp
+++ b/clang/test/SemaCXX/static-assert-cxx17.cpp
@@ -104,3 +104,15 @@ void foo6() {
 }
 template void foo6<ExampleTypes>();
 // expected-note@-1{{in instantiation of function template specialization 
'foo6<ExampleTypes>' requested here}}
+
+namespace GH203701 {
+  struct S {
+    constexpr S(auto) {}
+    constexpr operator int() const { return 0; }
+  };
+
+  constexpr auto a = [](this S) { return 1; };
+
+  static_assert((&decltype(a)::operator())(1) == 42, ""); // 
expected-error-re@-1 {{static assertion failed due to requirement '\(&const 
GH203701::\(lambda at {{.*}}\)::operator\(\)\)\(1\) == 42'}}
+  static_assert((&S::operator int) == nullptr, ""); // expected-error {{static 
assertion failed due to requirement '(&GH203701::S::operator int) == nullptr'}}
+}
diff --git a/clang/test/SemaCXX/static-assert.cpp 
b/clang/test/SemaCXX/static-assert.cpp
index 21a11ee7a5c45..354016db36432 100644
--- a/clang/test/SemaCXX/static-assert.cpp
+++ b/clang/test/SemaCXX/static-assert.cpp
@@ -364,15 +364,3 @@ namespace Diagnostics {
   static_assert(1 << 3 != 8, ""); // expected-error {{failed}} \
                                  // expected-note {{evaluates to '8 != 8'}}
 }
-
-namespace GH203701 {
-  struct S {
-    constexpr S(auto) {}
-    constexpr operator int() const { return 0; }
-  };
-
-  constexpr auto a = [](this S) { return 1; };
-
-  static_assert((&decltype(a)::operator())(1) == 42, ""); // expected-error-re 
{{static assertion failed due to requirement '(&const GH203701::(lambda at 
{.*})::operator())(1) == 42'}}
-  static_assert((&S::operator int) == nullptr, ""); // expected-error {{static 
assertion failed due to requirement '(&GH203701::S::operator int) == nullptr'}}
-}

>From a192beb4169f620b13e587a42fb1843a4ae0f64d Mon Sep 17 00:00:00 2001
From: Fan Mo <[email protected]>
Date: Sun, 14 Jun 2026 00:13:11 -0500
Subject: [PATCH 4/4] use independent test file

---
 clang/test/SemaCXX/GH203701.cpp            | 14 ++++++++++++++
 clang/test/SemaCXX/static-assert-cxx17.cpp | 12 ------------
 2 files changed, 14 insertions(+), 12 deletions(-)
 create mode 100644 clang/test/SemaCXX/GH203701.cpp

diff --git a/clang/test/SemaCXX/GH203701.cpp b/clang/test/SemaCXX/GH203701.cpp
new file mode 100644
index 0000000000000..f583865de9ac4
--- /dev/null
+++ b/clang/test/SemaCXX/GH203701.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify %s
+
+namespace GH203701 {
+  struct S {
+    constexpr S(auto) {}
+    constexpr operator int() const { return 0; }
+  };
+
+  constexpr auto a = [](this S) { return 1; };
+
+  static_assert((&decltype(a)::operator())(1) == 42, ""); // expected-error-re 
{{static assertion failed due to requirement '(&const GH203701::(lambda at 
{{.*}})::operator())(1) == 42'{{.*}}}} \
+                                                           // expected-note 
{{expression evaluates to '1 == 42'}}
+  static_assert((&S::operator int) == nullptr, ""); // expected-error {{static 
assertion failed due to requirement '(&GH203701::S::operator int) == nullptr'}}
+}
diff --git a/clang/test/SemaCXX/static-assert-cxx17.cpp 
b/clang/test/SemaCXX/static-assert-cxx17.cpp
index e3038f8cec130..41a7b025d0eb7 100644
--- a/clang/test/SemaCXX/static-assert-cxx17.cpp
+++ b/clang/test/SemaCXX/static-assert-cxx17.cpp
@@ -104,15 +104,3 @@ void foo6() {
 }
 template void foo6<ExampleTypes>();
 // expected-note@-1{{in instantiation of function template specialization 
'foo6<ExampleTypes>' requested here}}
-
-namespace GH203701 {
-  struct S {
-    constexpr S(auto) {}
-    constexpr operator int() const { return 0; }
-  };
-
-  constexpr auto a = [](this S) { return 1; };
-
-  static_assert((&decltype(a)::operator())(1) == 42, ""); // 
expected-error-re@-1 {{static assertion failed due to requirement '\(&const 
GH203701::\(lambda at {{.*}}\)::operator\(\)\)\(1\) == 42'}}
-  static_assert((&S::operator int) == nullptr, ""); // expected-error {{static 
assertion failed due to requirement '(&GH203701::S::operator int) == nullptr'}}
-}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to