[PATCH] D157879: [clang] Report missing designated initializers in C++

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 15 07:23:07 PDT 2023


aaron.ballman added a comment.

Thank you for working on this! The changes should come with a release note.

I think the diagnostic is triggered a bit to aggressively in the case where there is an invalid initializer for a field -- we'll claim there is no initializer in that case, but that effectively duplicates the diagnostics without adding anything actionable for the user to do (once they fix the initialization, both diagnostics go away). Can we silence the diagnostic in these cases?



================
Comment at: clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp:64
+                       // wmissing-warning at -1 {{missing field 'y' initializer}}
+                       // wmissing-warning at -2 {{missing field 'a' initializer}}
 struct C { int :0, x, :0, y, :0; };
----------------
This second warning seems wrong, there is an initializer for `a`, it's just not a valid one.


================
Comment at: clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp:73
   .x = 1, // override-error {{overrides prior initialization}}
-};
+}; //wmissing-warning {{missing field 'x' initializer}}
+
----------------
This warning is quite wrong, there's a whole pile of initializers for `x`. :-)


================
Comment at: clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp:229
     .a = 1, // reorder-error {{field 'b' will be initialized after field 'a'}}
-};
+}; // wmissing-warning {{missing field 'a' initializer}}
 }
----------------
I also think this one is wrong.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157879



More information about the cfe-commits mailing list