diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2011-12-15 02:41:52 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2011-12-15 02:41:52 +0000 |
| commit | 8349dc1fd64b910bf56b7b4ca568754a173748f4 (patch) | |
| tree | 2be8319d76ab9d18258420f6115766fb65e1858a | |
| parent | a2510070eeea0a59c13af6f878a8b206aff7dbbd (diff) | |
| download | bcm5719-llvm-8349dc1fd64b910bf56b7b4ca568754a173748f4.tar.gz bcm5719-llvm-8349dc1fd64b910bf56b7b4ca568754a173748f4.zip | |
Enhance the -Wsign-compare handling to suppress the -Wsign-compare warning in the case of a shifted bitfield. PR11572.
llvm-svn: 146634
| -rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 2 | ||||
| -rw-r--r-- | clang/test/Sema/compare.c | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 5de124de4de..ebdc8321f70 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/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/clang/test/Sema/compare.c b/clang/test/Sema/compare.c index cd973d4885c..03aebb3a046 100644 --- a/clang/test/Sema/compare.c +++ b/clang/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 +} |

