[clang] Add more tests for _Countof (PR #133333)

Alejandro Colomar via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 28 06:54:13 PDT 2025


================
@@ -102,6 +126,11 @@ void test_unspecified_array_length() {
   static_assert(_Countof(**x) == 3);
 }
 
+void test_completed_array() {
+  int a[] = {1, 2, global_num};
+  static_assert(_Countof(a) == 3);
----------------
alejandro-colomar wrote:

@AaronBallman This test seems to have caught a bug in the implementation.

I see the following report in the CI:

```
File /var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/clang/test/C/C2y/n3369.c Line 131: invalid application of '_Countof' to an incomplete type 'int[]'
```

But this shouldn't happen.  The type should be completed.  In my GCC implementation, this test passes, AFAIR.

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


More information about the cfe-commits mailing list