diff options
author | Daniel Marjamaki <daniel.marjamaki@evidente.se> | 2017-10-11 14:49:35 +0000 |
---|---|---|
committer | Daniel Marjamaki <daniel.marjamaki@evidente.se> | 2017-10-11 14:49:35 +0000 |
commit | d3d83681bc96a86f646fdec1e195b76c5b569168 (patch) | |
tree | 36df778745f0b353edcf06b7bdc55f25971ecebf /clang/test/Analysis/bitwise-ops.c | |
parent | 8d565a233d08ec5388553b1bceb24c98e3d25049 (diff) | |
download | bcm5719-llvm-d3d83681bc96a86f646fdec1e195b76c5b569168.tar.gz bcm5719-llvm-d3d83681bc96a86f646fdec1e195b76c5b569168.zip |
[Analyzer] Clarify error messages for undefined result
Differential Revision: https://reviews.llvm.org/D30295
llvm-svn: 315462
Diffstat (limited to 'clang/test/Analysis/bitwise-ops.c')
-rw-r--r-- | clang/test/Analysis/bitwise-ops.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/clang/test/Analysis/bitwise-ops.c b/clang/test/Analysis/bitwise-ops.c index 407aa19289c..acef6681d89 100644 --- a/clang/test/Analysis/bitwise-ops.c +++ b/clang/test/Analysis/bitwise-ops.c @@ -22,11 +22,25 @@ int testConstantShifts_PR18073(int which) { case 1: return 0ULL << 63; // no-warning case 2: - return 0ULL << 64; // expected-warning{{The result of the '<<' expression is undefined}} + return 0ULL << 64; // expected-warning{{The result of the left shift is undefined due to shifting by '64', which is greater or equal to the width of type 'unsigned long long'}} case 3: - return 0ULL << 65; // expected-warning{{The result of the '<<' expression is undefined}} + return 0ULL << 65; // expected-warning{{The result of the left shift is undefined due to shifting by '65', which is greater or equal to the width of type 'unsigned long long'}} default: return 0; } -}
\ No newline at end of file +} + +int testOverflowShift(int a) { + if (a == 323) { + return 1 << a; // expected-warning{{The result of the left shift is undefined due to shifting by '323', which is greater or equal to the width of type 'int'}} + } + return 0; +} + +int testNegativeShift(int a) { + if (a == -5) { + return 1 << a; // expected-warning{{The result of the left shift is undefined because the right operand is negative}} + } + return 0; +} |