[PATCH] D59754: [Sema] Add c++2a designated initializer warnings

Don Hinton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 25 14:44:48 PDT 2019


hintonda marked 2 inline comments as done.
hintonda added a comment.

Thanks for the review.



================
Comment at: clang/lib/Sema/SemaInit.cpp:2017
 
+      auto LastIdx = Field != FieldEnd
+                         ? Field->getFieldIndex()
----------------
Rakete1111 wrote:
> Can `Field` ever be `FieldEnd` at this point?
Yes.  If the last trip through the loop was a designated initializer, and it happened to be the last field in the RecordDecl, Field will be equal FieldEnd.  At this point, the loop will exit below unless there's another designated initializer that's out of order.


================
Comment at: clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp:30
+// out of order designators
+A a1 = {.y = 1, .x = 2}; // expected-warning {{designated initializers are a C99 feature}}
+
----------------
Rakete1111 wrote:
> Those warnings are misleading, since C++20 does have designated initializers; they just don't support some stuff that C99 does. It would be better  IMO if you could separate them. As in, the above should give you: `out-of-order designated initializers are a C99 feature` or something like that.
I think that would be a good idea as well, but wanted to get advise first.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59754/new/

https://reviews.llvm.org/D59754





More information about the cfe-commits mailing list