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

Philipp Rados via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 21 08:50:45 PST 2025


================
@@ -8477,6 +8477,9 @@ def err_incomplete_object_call : Error<
 def warn_condition_is_assignment : Warning<"using the result of an "
   "assignment as a condition without parentheses">,
   InGroup<Parentheses>;
+def warn_assignment_bool_context : Warning<"suggest parentheses around assignment used as truth value">,
----------------
PhilippRados wrote:

> The text in warn_condition_is_idiomatic_assignment is pretty close to what we want, right?

Yes, but maybe just having the more generic `warn_assignment_bool_context` with a message like "using the result of an assignment as a truth value without parentheses" which can be emitted during conditions as well. Since this implicit cast can also happen outside of conditions.

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


More information about the cfe-commits mailing list