[PATCH] D90871: [Sema] Fold VLAs to constant arrays in a few more contexts

Erik Pilkington via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 5 11:54:14 PST 2020


erik.pilkington created this revision.
erik.pilkington added reviewers: rsmith, rjmccall, arphaman.
Herald added subscribers: ributzka, jkorous.
erik.pilkington requested review of this revision.

D89523 <https://reviews.llvm.org/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:

1. When the VLA appears in an ivar -- this seems like a corollary to the field thing
2. When the VLA has an initializer -- VLAs can't have an initializer

Thanks for taking a look!


https://reviews.llvm.org/D90871

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/decl-in-prototype.c
  clang/test/Sema/vla.c
  clang/test/SemaObjC/variable-size-ivar.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90871.303204.patch
Type: text/x-patch
Size: 10148 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201105/7302fb69/attachment.bin>


More information about the cfe-commits mailing list