[PATCH] D63082: [Diagnostics] Added support for -Wint-in-bool-context
Dávid Bolvanský via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 30 12:39:32 PDT 2019
xbolva00 marked 3 inline comments as done.
xbolva00 added inline comments.
================
Comment at: test/Sema/warn-int-in-bool-context.c:26
+ r = a << 7; // expected-warning {{'<<' in boolean context; did you mean '<'?}}
+ r = ONE << b; // expected-warning {{'<<' in boolean context; did you mean '<'?}}
+
----------------
jfb wrote:
> I'm not sure the "did you mean" part is helpful. Do we have data showing that this is what people actually mean?
No, no data, just what GCC suggests.
================
Comment at: test/Sema/warn-int-in-bool-context.c:33
+ r = a ? 3 : -2;
+ r = a ? 0 : TWO; // expected-warning {{'?:' with integer constants in boolean context}}
+ r = a ? 3 : ONE; // expected-warning {{'?:' with integer constants in boolean context, the expression will always evaluate to 'true'}}
----------------
jfb wrote:
> Why does this one warn? It doesn't always yield the same result.
GCC warns here..
================
Comment at: test/Sema/warn-unreachable.c:147
+ // expected-warning at +1 {{'*' in boolean context, the expression will always evaluate to 'false'}}
if (0 * x) calledFun(); // expected-warning {{will never be executed}}
}
----------------
jfb wrote:
> It seems like here the "will never be executed" warning is more useful. Do we want to emit both?
Useful but -Wunreachable-code is disabled by default (not part of -Wall).
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63082/new/
https://reviews.llvm.org/D63082
More information about the cfe-commits
mailing list