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

Yihe Li via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 16 04:21:44 PDT 2024


================
@@ -115,20 +115,20 @@ void usage() {
   S('A'); // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute: Don't let that S-Char go!}}
   S(1);
   S(2.2);
-  Y(); // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute: Don't throw me away either!}}
+  Y(); // expected-warning {{ignoring temporary of type 'Y' declared with 'nodiscard' attribute: Don't throw me away either!}}
   S s;
-  ConvertTo{}; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute: Don't throw me away!}}
+  ConvertTo{}; // expected-warning {{ignoring return value of type 'ConvertTo' declared with 'nodiscard' attribute: Don't throw me away!}}
----------------
Mick235711 wrote:

BTW, isn't this supposed to be a constructor call? Why is `ConvertTo{}` different compared to `Y()` above?

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


More information about the cfe-commits mailing list