[PATCH] D103938: Diagnose -Wunused-value in constant evaluation context

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 23 10:42:14 PDT 2021


rsmith added a comment.

I've given this some more thought, and I think it's only the "constant evaluated" check that we want to bypass in this case. It's common to use `sizeof` or `decltype` with a comma operator in order to put an expression in a SFINAE context, and I don't think we should warn on those cases. So I think we should still do the context check for `DiagIfReachable`, but only bail out for unevaluated contexts, not for constant-evaluated contexts. Does that seem reasonable?



================
Comment at: clang/test/SemaCXX/warn-unused-value.cpp:147
+  new double[false ? (1, 2) : 3]
+            [false ? (1, 2) : 3]; // expected-warning {{expression result unused}}
+}
----------------
Please add a FIXME saying that we shouldn't diagnose the unreachable constant expression here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103938



More information about the cfe-commits mailing list