[clang] [Clang] Diagnose invalid object size kinds during constant evaluation (PR #230979)

via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 12 05:03:11 PDT 2026


================
@@ -30,6 +30,13 @@ int f3(void) {
   return OBJECT_SIZE_BUILTIN(&a, 4); // expected-error {{argument value 4 is outside the valid range [0, 3]}}
 }
 
+// expected-error at +2 {{static assertion expression is not an integral constant expression}}
+// expected-note at +1 {{argument value -1 is outside the valid range [0, 3]}}
+_Static_assert(OBJECT_SIZE_BUILTIN((void *)0, -1), "");
+
+// expected-error at +2 {{static assertion expression is not an integral constant expression}}
+// expected-note at +1 {{argument value 4 is outside the valid range [0, 3]}}
+_Static_assert(OBJECT_SIZE_BUILTIN((void *)0, 4), "");
----------------
keepyixiao wrote:

Done, I moved the expected diagnostics onto the same line as the
_Static_assert to match the surrounding tests.

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


More information about the cfe-commits mailing list