diff options
| author | Davide Italiano <davide@freebsd.org> | 2015-07-06 18:02:09 +0000 |
|---|---|---|
| committer | Davide Italiano <davide@freebsd.org> | 2015-07-06 18:02:09 +0000 |
| commit | bf0f7757e24264bb6e211e30f60a75f272b0a90d (patch) | |
| tree | 7e32d8cc052765a1eea8d89cb7bb42ce4abc0227 /clang/test/CXX/expr | |
| parent | 183f53fd2213006589847fe40567720296e68717 (diff) | |
| download | bcm5719-llvm-bf0f7757e24264bb6e211e30f60a75f272b0a90d.tar.gz bcm5719-llvm-bf0f7757e24264bb6e211e30f60a75f272b0a90d.zip | |
[Sema] Warn when shifting a negative value.
Example:
% ./clang -Wshift-negative-value emit.c
emit.c:3:14: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
int a = -1 << 3;
~~ ^
1 warning generated.
PR: 24026
Differential Revision: http://reviews.llvm.org/D10938
Reviewed by: rsmith
llvm-svn: 241478
Diffstat (limited to 'clang/test/CXX/expr')
| -rw-r--r-- | clang/test/CXX/expr/expr.const/p2-0x.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/test/CXX/expr/expr.const/p2-0x.cpp b/clang/test/CXX/expr/expr.const/p2-0x.cpp index d027c7a388b..2adefd928af 100644 --- a/clang/test/CXX/expr/expr.const/p2-0x.cpp +++ b/clang/test/CXX/expr/expr.const/p2-0x.cpp @@ -157,7 +157,7 @@ namespace UndefinedBehavior { constexpr int shl_unsigned_negative = unsigned(-3) << 1; // ok constexpr int shl_unsigned_into_sign = 1u << 31; // ok constexpr int shl_unsigned_overflow = 1024u << 31; // ok - constexpr int shl_signed_negative = (-3) << 1; // expected-error {{constant expression}} expected-note {{left shift of negative value -3}} + constexpr int shl_signed_negative = (-3) << 1; // expected-warning {{shifting a negative signed value is undefined}} // expected-error {{constant expression}} expected-note {{left shift of negative value -3}} constexpr int shl_signed_ok = 1 << 30; // ok constexpr int shl_signed_into_sign = 1 << 31; // ok (DR1457) constexpr int shl_signed_into_sign_2 = 0x7fffffff << 1; // ok (DR1457) |

