[PATCH] D147349: [C2x] Implement support for empty brace initialization (WG14 N2900 and WG14 N3011)

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 31 12:11:52 PDT 2023


aaron.ballman created this revision.
aaron.ballman added reviewers: jyknight, efriedma, erichkeane, cor3ntin, clang-language-wg.
Herald added a project: All.
aaron.ballman requested review of this revision.
Herald added a project: clang.

This implements support for allowing `{}` to consistently zero initialize objects. We already supported most of this work as a GNU extension, but the C2x feature goes beyond what the GNU extension allowed.

The changes in this patch are:

- Removed the `-Wgnu-empty-initializer` warning group. The extension is now a C2x extension warning instead. Note that use of `-Wno-gnu-empty-initializer` seems to be quite low in the wild (https://sourcegraph.com/search?q=context%3Aglobal+-file%3A.*test.*+%22-Wno-gnu-empty-initializer%22&patternType=standard&sm=1&groupBy=repo which currently only gives 8 hits total), so this is not expected to be an overly disruptive change. But I'm adding the clang vendors review group just in case this expectation is wrong.
- Reworded the diagnostic wording to be about a C2x extension, added a pre-C2x compat warning
- Allow `{}` to zero initialize a VLA

This functionality is exposed as an extension in all older C modes (same as the GNU extension was), but does *not* allow the extension for VLA initialization in C++ due to concern about handling non-trivially constructible types.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147349

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/Parse/ParseInit.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/test/C/C2x/n2900_n3011.c
  clang/test/C/C2x/n2900_n3011_2.c
  clang/test/Sema/complex-init-list.c
  clang/test/Sema/flexible-array-init.c
  clang/test/Sema/gnu-flags.c
  clang/test/Sema/sizeless-1.c
  clang/test/Sema/vla.c
  clang/test/SemaObjC/property.m
  clang/test/SemaOpenCL/intel-subgroup-avc-ext-types.cl
  clang/www/c_status.html

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147349.510098.patch
Type: text/x-patch
Size: 33767 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230331/8814a70a/attachment-0001.bin>


More information about the cfe-commits mailing list