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 | 1416d5328a4350d5514ac8ec793acd461e6a38c5 (patch) | |
tree | 2f0f731dbe5d913075eabd4fd97bdaa1e4a695be /test/Analysis | |
parent | f822d3299b46ebefc293d06360e47a6bd731b4bd (diff) |
[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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316924 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis')
-rw-r--r-- | test/Analysis/bitwise-ops.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/Analysis/bitwise-ops.c b/test/Analysis/bitwise-ops.c index acef6681d8..fe546580be 100644 --- a/test/Analysis/bitwise-ops.c +++ b/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; +} |