diff options
author | Gabor Horvath <xazax.hun@gmail.com> | 2017-10-30 17:06:42 +0000 |
---|---|---|
committer | Gabor Horvath <xazax.hun@gmail.com> | 2017-10-30 17:06:42 +0000 |
commit | 4581f7497b41a90595a5a850c6a031b9cf60f50e (patch) | |
tree | 22bf7ce3e62fa4426b20eb4db3832f925001f0fd /clang/test/Analysis/bitwise-ops.c | |
parent | 0f4c5712b40e83b30e8ce248dcd06a73921cfbbf (diff) | |
download | bcm5719-llvm-4581f7497b41a90595a5a850c6a031b9cf60f50e.tar.gz bcm5719-llvm-4581f7497b41a90595a5a850c6a031b9cf60f50e.zip |
[analyzer] Left shifting a negative value is undefined
The analyzer did not return an UndefVal in case a negative value was left
shifted. I also altered the UndefResultChecker to emit a clear warning in this
case.
Differential Revision: https://reviews.llvm.org/D39423
llvm-svn: 316924
Diffstat (limited to 'clang/test/Analysis/bitwise-ops.c')
-rw-r--r-- | clang/test/Analysis/bitwise-ops.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/test/Analysis/bitwise-ops.c b/clang/test/Analysis/bitwise-ops.c index acef6681d89..fe546580be3 100644 --- a/clang/test/Analysis/bitwise-ops.c +++ b/clang/test/Analysis/bitwise-ops.c @@ -44,3 +44,10 @@ int testNegativeShift(int a) { } return 0; } + +int testNegativeLeftShift(int a) { + if (a == -3) { + return a << 1; // expected-warning{{The result of the left shift is undefined because the left operand is negative}} + } + return 0; +} |