diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/CodeGen/bitfield-promote.c | 19 | ||||
-rw-r--r-- | test/Sema/bitfield.c | 4 |
2 files changed, 23 insertions, 0 deletions
diff --git a/test/CodeGen/bitfield-promote.c b/test/CodeGen/bitfield-promote.c new file mode 100644 index 0000000000..5894e51626 --- /dev/null +++ b/test/CodeGen/bitfield-promote.c @@ -0,0 +1,19 @@ +// RUN: clang -O3 -emit-llvm -S -o %t %s && +// RUN: grep 'ret i64 4294967292' %t | count 2 && +// RUN: grep 'ret i64 -4' %t | count 1 && +// RUN: true + +long long f0(void) { + struct { unsigned f0 : 32; } x = { 18 }; + return (long long) (x.f0 - (int) 22); +} + +long long f1(void) { + struct { unsigned f0 : 31; } x = { 18 }; + return (long long) (x.f0 - (int) 22); +} + +long long f2(void) { + struct { unsigned f0 ; } x = { 18 }; + return (long long) (x.f0 - (int) 22); +} diff --git a/test/Sema/bitfield.c b/test/Sema/bitfield.c index 7a7f96c752..e81b802789 100644 --- a/test/Sema/bitfield.c +++ b/test/Sema/bitfield.c @@ -25,3 +25,7 @@ struct a { unsigned : -2; // expected-error {{anonymous bit-field has negative width (-2)}} float : 12; // expected-error {{anonymous bit-field has non-integral type 'float'}} }; + +struct b {unsigned x : 2;} x; +__typeof__(x.x+1) y; +int y; |