[clang] [clang] Fix potential constant expression checking with constexpr-unknown. (PR #149227)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 17 08:39:21 PDT 2025


================
@@ -357,3 +357,27 @@ namespace pointer_comparisons {
   static_assert(!f4()); // expected-error {{static assertion expression is not an integral constant expression}} \
                         // expected-note {{in call to 'f4()'}}
 }
+
+namespace enable_if_1 {
+  template <__SIZE_TYPE__ N>
+  constexpr void foo(const char (&Str)[N])
+  __attribute((enable_if(__builtin_strlen(Str), ""))) {}
+
+  void x() {
+      foo("1234");
+  }
+}
+
+namespace enable_if_2 {
+  constexpr const char (&f())[];
+  extern const char (&Str)[];
+  constexpr int foo()
+  __attribute((enable_if(__builtin_strlen(Str), "")))
+  {return __builtin_strlen(Str);}
+
+  constexpr const char (&f())[] {return "a";}
+  constexpr const char (&Str)[] = f();
+  void x() {
+      constexpr int x = foo();
+  }
+}
----------------
cor3ntin wrote:

Can you reference the issue (either a comment or in the namespace name)?

https://github.com/llvm/llvm-project/pull/149227


More information about the cfe-commits mailing list