[PATCH] D58878: [Diagnostics] Warn for assignments in bool contexts

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 4 22:19:43 PST 2019


rjmccall added a comment.

This seems eminently reasonable to warn about.  I think people might legitimately complain about extending an existing warning to a new set of contexts without putting it under a new warning flag, though.  How annoying would it be to clone the warnings and put them in a subgroup?  You could also change the diagnostics to say "converting the result of an assignment to bool" instead of "using the result of an assignment as a condition".



================
Comment at: clang/test/Sema/assigment_in_bool_context.cpp:1
+// RUN: %clang_cc1 -Wparentheses -fsyntax-only -verify %s
+
----------------
This test should go in `test/SemaCXX`.  You should add a similar test in `test/Sema` that's C-only and which uses `_Bool`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58878





More information about the cfe-commits mailing list