[PATCH] D148505: Allow `__attribute__((warn_unused))` on individual constructors

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 17 08:07:42 PDT 2023


aaron.ballman added inline comments.


================
Comment at: clang/docs/ReleaseNotes.rst:189-190
   preprocessor operators now return 1 also for attributes defined by plugins.
+- In C++, the ``__attribute__((warn_unused))`` can now also be used on individual
+  constructors,
 
----------------



================
Comment at: clang/include/clang/Basic/Attr.td:2996
   let Spellings = [GCC<"warn_unused">];
-  let Subjects = SubjectList<[Record]>;
+  let Subjects = SubjectList<[Record, CXXConstructor]>;
   let Documentation = [Undocumented];
----------------
I'm confused -- if you want this to behave like `nodiscard`, why aren't these changes for `warn_unused_result` (which is what implements `nodiscard`)? I don't think this should go on `warn_unused` because that's for the declaration of the type as a unit and not written on functions.

I think you don't need any changes to Attr.td for this functionality.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148505



More information about the cfe-commits mailing list