[PATCH] D103938: Diagnose -Wunused-value based on CFG reachability

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 28 04:14:23 PDT 2021


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM with some minor corrections in comments, thank you for the fix!



================
Comment at: clang/lib/Sema/SemaStmt.cpp:381-382
 
-  DiagRuntimeBehavior(Loc, nullptr, PDiag(DiagID) << R1 << R2);
+  // Skip diagnose for comma operator in SFINAE context since the type of left
+  // operand could trigger substitution error so technically it is *used*.
+  if (DiagID != diag::warn_unused_comma_left_operand || !isSFINAEContext())
----------------



================
Comment at: clang/test/SemaCXX/warn-unused-value.cpp:154
+
+// comma operator diagnoses should be suppressed in SFINAE context.
+template <typename T, int = (T{},0)> int c(int) { return 0; }
----------------



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