[PATCH] D64380: Add 'require_designated_init' and 'required' attribute to clang
Emmett Neyman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 10 16:51:32 PDT 2019
emmettneyman added inline comments.
================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3533-3541
+def err_require_designated_init_failed : Error<
+ "variable declaration does not use designated initializer syntax">;
+def note_declared_required_designated_init_here : Note<
+ "required by 'require_designated_init' attribute here">;
+
+def err_required_failed : Error<
+ "initializer for variable %0 must explicitly initialize field %1">;
----------------
aaron.ballman wrote:
> I'm a little uncomfortable with these being errors rather than warnings. I think of these attributes as being preferences rather than requirements; the code isn't *wrong* if it fails to use the designated initializer (it's conforming to C or C++, does not have UB, etc) and other implementations are free to ignore those attributes and the end result will be identical to what's produced by Clang.
>
> What do you think about turning these into warnings? Users can always use `-Werror` to strengthen their own requirements.
That makes sense, I'll make the change.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64380/new/
https://reviews.llvm.org/D64380
More information about the cfe-commits
mailing list