[clang] [clang] Improve diagnostic on [[nodiscard]] attribute (PR #112521)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 15 06:19:11 PST 2024


================
@@ -9300,6 +9300,12 @@ def warn_unused_container_subscript_expr : Warning<
 def warn_unused_call : Warning<
   "ignoring return value of function declared with %0 attribute">,
   InGroup<UnusedValue>;
+def warn_unused_return_type : Warning<
+  "ignoring %select{return value|temporary}0 of type %2 declared with %1 attribute">,
+  InGroup<UnusedValue>;
+def warn_unused_return_type_msg : Warning<
----------------
erichkeane wrote:

Rather than separate diagnostics, can we do this with a `%select` for the last argument?  So:

`ignoring %select{return value|temporary}0 of type %2 declared with %1 attribute%select{: %4}3`.

https://github.com/llvm/llvm-project/pull/112521


More information about the cfe-commits mailing list