D89523 removed support for promoting VLAs to constant arrays when the bounds isn't an ICE, since this can result in miscompiling a conforming program that assumes that the array is a VLA. Promoting VLAs for fields is still supported, since clang doesn't support VLAs in fields, so no conforming program could have a field VLA.
This change is really disruptive for us (hundreds of projects are failing to compile with this change), so I think we should carve out two more cases where we promote VLAs which can't miscompile a conforming program:
- When the VLA appears in an ivar -- this seems like a corollary to the field thing
- When the VLA has an initializer -- VLAs can't have an initializer
Thanks for taking a look!
Can we set a HasInitializer flag on Declarator instead (much like we provide a FunctionDefinitionKind)? This flag seems a bit ad-hoc (and also doesn't cover C++ braced initializers as named).