[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 26 12:59:05 PDT 2025


AaronBallman wrote:

Good catch on the VLA test cases @jyknight! It turns out we model VLAs very oddly in the type system. Given:
```
extern int n;
int array[7][n];
```
We make a VariableArrayType whose element type is a VariableArrayType rather than a ConstantArrayType of size 7 whose element type is a VariableArrayType. This made `_Countof` a little bit more complicated because we need to look through that design choice. I've implement that (in both ExprConstant.cpp and CGExprScalar.cpp), but we may someday want to do a deeper repair. Instead, I added a FIXME and a note in Type.h so others aren't surprised by this as well.

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


More information about the cfe-commits mailing list