[Sema] Fold VLAs to constant arrays in a few more contexts
authorErik Pilkington <erik.pilkington@gmail.com>
Thu, 3 Dec 2020 15:01:53 +0000 (10:01 -0500)
committerErik Pilkington <erik.pilkington@gmail.com>
Fri, 4 Dec 2020 15:03:23 +0000 (10:03 -0500)
commit090dd647d98dc50a56a42fbba0f3f11b10a3a187
tree039abc03675d9ee0c23b7915500ecf829557b74b
parentc8ec685ca555459051125f9c0194ceee19e959d7
[Sema] Fold VLAs to constant arrays in a few more contexts

552c6c2 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, so this commit carves 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

Differential revision: https://reviews.llvm.org/D90871
clang/include/clang/Sema/DeclSpec.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Sema/SemaDecl.cpp
clang/test/CXX/basic/basic.types/p10.cpp
clang/test/Sema/decl-in-prototype.c
clang/test/Sema/vla.c
clang/test/SemaCXX/vla.cpp
clang/test/SemaObjC/variable-size-ivar.m [new file with mode: 0644]