[PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values
Roman Lebedev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 13 11:32:56 PDT 2017
lebedev.ri added inline comments.
================
Comment at: cfe/trunk/test/Sema/tautological-constant-compare.c:23
+
+ if (c > macro(255))
+ return;
----------------
I'm having second thoughts about macro handling.
Right now we completely ignore the comparisons when the constant is anyhow involved with macros.
I.e.
```
unsigned char c;
if (c > 255) // expected-warning {{comparison 'unsigned char' > 255 is always false}}
return; // would be diagnosed correctly
// but
assert (c <= 255); // would be completely ignored.
```
Perhaps we should be a bit more strict, and should not bailout in such cases?
But i *guess* this case we still should ignore
```
#define macro(val) (val > 255)
if (macro(c))
return;
```
(Even though gcc warns in the last variant too)
Repository:
rL LLVM
https://reviews.llvm.org/D38101
More information about the cfe-commits
mailing list