[clang] [Clang] Fix crash for _Countof(void) by correcting extension handling (PR #181169)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 12 08:55:01 PST 2026
================
@@ -35,6 +35,8 @@ void test_semantic_failures() {
int non_array;
(void)_Countof non_array; // expected-error {{'_Countof' requires an argument of array type; 'int' invalid}}
(void)_Countof(int); // expected-error {{'_Countof' requires an argument of array type; 'int' invalid}}
+ (void)_Countof(void); // expected-error {{invalid application of '_Countof' to an incomplete type 'void'}}
+ int arr2[_Countof(void)]; // expected-error {{invalid application of '_Countof' to an incomplete type 'void'}}
----------------
AaronBallman wrote:
One more test we should consider is with an expression operand rather than a type operand:
```
void *vp = &non_array;
(void)_Countof(*vp); // error, applied to incomplete type void
```
https://github.com/llvm/llvm-project/pull/181169
More information about the cfe-commits
mailing list