diff options
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 2 | ||||
-rw-r--r-- | test/Sema/compare.c | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 5de124de4d..ebdc8321f7 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -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()); diff --git a/test/Sema/compare.c b/test/Sema/compare.c index cd973d4885..03aebb3a04 100644 --- a/test/Sema/compare.c +++ b/test/Sema/compare.c @@ -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 +} |