diff options
Diffstat (limited to 'test/Sema/integer-overflow.c')
-rw-r--r-- | test/Sema/integer-overflow.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/test/Sema/integer-overflow.c b/test/Sema/integer-overflow.c index db5c1f4c7118..e74bc119798b 100644 --- a/test/Sema/integer-overflow.c +++ b/test/Sema/integer-overflow.c @@ -1,6 +1,11 @@ -// RUN: %clang_cc1 %s -verify -fsyntax-only +// RUN: %clang_cc1 %s -verify -fsyntax-only -triple x86_64-pc-linux-gnu typedef unsigned long long uint64_t; -typedef unsigned long long uint32_t; +typedef unsigned int uint32_t; + +// Check integer sizes. +int array64[sizeof(uint64_t) == 8 ? 1 : -1]; +int array32[sizeof(uint32_t) == 4 ? 1 : -1]; +int arrayint[sizeof(int) < sizeof(uint64_t) ? 1 : -1]; uint64_t f0(uint64_t); uint64_t f1(uint64_t, uint32_t); @@ -153,3 +158,23 @@ struct s { .y = 5, .x = 4 * 1024 * 1024 * 1024 // expected-warning {{overflow in expression; result is 0 with type 'int'}} }; + +struct s2 { + unsigned a0; + + struct s3 { + unsigned a2; + + struct s4 { + unsigned a4; + } a3; + } a1; +} s2 = { + .a0 = 4 * 1024 * 1024 * 1024, // expected-warning {{overflow in expression; result is 0 with type 'int'}} + { + .a2 = 4 * 1024 * 1024 * 1024, // expected-warning {{overflow in expression; result is 0 with type 'int'}} + { + .a4 = 4 * 1024 * 1024 * 1024 // expected-warning {{overflow in expression; result is 0 with type 'int'}} + } + } +}; |