forked from OSchip/llvm-project
Enhance the -Wsign-compare handling to suppress the -Wsign-compare warning in the case of a shifted bitfield. PR11572.
llvm-svn: 146634
This commit is contained in:
parent
a2510070ee
commit
8349dc1fd6
|
@ -3257,7 +3257,7 @@ IntRange GetExprRange(ASTContext &C, Expr *E, unsigned MaxWidth) {
|
|||
// user has an explicit widening cast, we should treat the value as
|
||||
// being of the new, wider type.
|
||||
if (ImplicitCastExpr *CE = dyn_cast<ImplicitCastExpr>(E)) {
|
||||
if (CE->getCastKind() == CK_NoOp)
|
||||
if (CE->getCastKind() == CK_NoOp || CE->getCastKind() == CK_LValueToRValue)
|
||||
return GetExprRange(C, CE->getSubExpr(), MaxWidth);
|
||||
|
||||
IntRange OutputTypeRange = IntRange::forValueOfType(C, CE->getType());
|
||||
|
|
|
@ -327,3 +327,9 @@ void test10(void) {
|
|||
b = (si == (ui = sl)); // expected-warning {{comparison of integers of different signs: 'int' and 'unsigned int'}}
|
||||
b = (si == (ui = sl&15));
|
||||
}
|
||||
|
||||
// PR11572
|
||||
struct test11S { unsigned x : 30; };
|
||||
int test11(unsigned y, struct test11S *p) {
|
||||
return y > (p->x >> 24); // no-warning
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue