diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2016-01-11 17:22:01 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2016-01-11 17:22:01 +0000 |
commit | f5c136186f4f6b1c3b2bb4b2e7a57496592a0117 (patch) | |
tree | f557cfce16e5751dc29dc8c6f9ab6675efd4b7d4 /clang/test/Sema/integer-overflow.c | |
parent | 7af056280840836a661b1ab000ed41d5ab121d8f (diff) | |
download | bcm5719-llvm-f5c136186f4f6b1c3b2bb4b2e7a57496592a0117.tar.gz bcm5719-llvm-f5c136186f4f6b1c3b2bb4b2e7a57496592a0117.zip |
[Sema] Issue a warning for integer overflow in struct initializer
Clang wasn't issuing a warning when compiling the following code:
struct s {
unsigned x;
} s = {
.x = 4 * 1024 * 1024 * 1024
};
rdar://problem/23399683
Differential Revision: http://reviews.llvm.org/D15097
llvm-svn: 257357
Diffstat (limited to 'clang/test/Sema/integer-overflow.c')
-rw-r--r-- | clang/test/Sema/integer-overflow.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/test/Sema/integer-overflow.c b/clang/test/Sema/integer-overflow.c index 44fbcd4c818..db5c1f4c711 100644 --- a/clang/test/Sema/integer-overflow.c +++ b/clang/test/Sema/integer-overflow.c @@ -145,3 +145,11 @@ uint64_t check_integer_overflows(int i) { // expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}} return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024))); } + +struct s { + unsigned x; + unsigned y; +} s = { + .y = 5, + .x = 4 * 1024 * 1024 * 1024 // expected-warning {{overflow in expression; result is 0 with type 'int'}} +}; |