[clang] [clang] Added warn-assignment-bool-context (PR #115234)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 21 08:39:54 PST 2025


================
@@ -20287,7 +20287,11 @@ void Sema::DiagnoseEqualityWithExtraParens(ParenExpr *ParenE) {
 
 ExprResult Sema::CheckBooleanCondition(SourceLocation Loc, Expr *E,
                                        bool IsConstexpr) {
-  DiagnoseAssignmentAsCondition(E);
+  // This warning is already covered by `warn_assignment_bool_context` in C++.
+  // NOTE: Ideally both warnings would be combined
+  if (!getLangOpts().CPlusPlus || getLangOpts().ObjC)
----------------
erichkeane wrote:

There isn't unfortunately.  We'd have to find some way to intuit whether this is a condition or not, and I don't have a good feel for how to do that.  Perhaps @cor3ntin has an idea?

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


More information about the cfe-commits mailing list