[PATCH] D37565: [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.
Roman Lebedev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 7 12:11:19 PDT 2017
lebedev.ri planned changes to this revision.
lebedev.ri added inline comments.
================
Comment at: test/Sema/outof-range-constant-compare.c:41
+ if (a < 0x0000000000000000UL)
+ return 0;
+ if (a <= 0x0000000000000000UL)
----------------
rjmccall wrote:
> Hmm. I think this should probably still warn under -Wtautological-compare, shouldn't it? The fact that it also warns under -Wsign-compare is something we should try to suppress, but it's definitely still a tautological comparison because of the promotion to an unsigned type.
Hmm, actually, i guess so?
```
int value(void);
int main()
{
int a = value();
if (a <= 0x0000000000000000UL)
return 0;
}
```
```
|-BinaryOperator <line:5:9, col:14> '_Bool' '<='
| |-ImplicitCastExpr <col:9> 'unsigned long' <IntegralCast>
| | `-ImplicitCastExpr <col:9> 'int' <LValueToRValue>
| | `-DeclRefExpr <col:9> 'int' lvalue Var 0x7028450 'a' 'int'
| `-IntegerLiteral <col:14> 'unsigned long' 0
```
Here, clang and gcc both only warn about different sign comparison.
Repository:
rL LLVM
https://reviews.llvm.org/D37565
More information about the cfe-commits
mailing list