[clang] Add more tests for _Countof (PR #133333)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 7 04:24:48 PDT 2025
================
@@ -121,10 +150,14 @@ void test_typedefs() {
static_assert(_Countof(*x) == 12);
}
-void test_zero_size_arrays() {
+void test_zero_size_arrays(int n) {
int array[0]; // expected-warning {{zero size arrays are an extension}}
static_assert(_Countof(array) == 0);
static_assert(_Countof(int[0]) == 0); // expected-warning {{zero size arrays are an extension}}
+ int multi_array[0][n]; // expected-warning {{zero size arrays are an extension}}
----------------
AaronBallman wrote:
Note, currently we don't issue a zero-sized array extension warning for this case: https://godbolt.org/z/78W8cr9o5 (seems like a preexisting bug)
https://github.com/llvm/llvm-project/pull/133333
More information about the cfe-commits
mailing list