diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.c-torture/execute/bitfld-3.c | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.c-torture/execute/bitfld-3.c')
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/bitfld-3.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/bitfld-3.c b/gcc/testsuite/gcc.c-torture/execute/bitfld-3.c new file mode 100644 index 000000000..52a4147cc --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/bitfld-3.c @@ -0,0 +1,54 @@ +/* Test that operations on bit-fields yield results reduced to bit-field + type. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ + +extern void exit (int); +extern void abort (void); + +struct s { + unsigned long long u33: 33; + unsigned long long u40: 40; + unsigned long long u41: 41; +}; + +struct s a = { 0x100000, 0x100000, 0x100000 }; +struct s b = { 0x100000000ULL, 0x100000000ULL, 0x100000000ULL }; +struct s c = { 0x1FFFFFFFFULL, 0, 0 }; + +int +main (void) +{ + if (a.u33 * a.u33 != 0 || a.u33 * a.u40 != 0 || a.u40 * a.u33 != 0 + || a.u40 * a.u40 != 0) + abort (); + if (a.u33 * a.u41 != 0x10000000000ULL + || a.u40 * a.u41 != 0x10000000000ULL + || a.u41 * a.u33 != 0x10000000000ULL + || a.u41 * a.u40 != 0x10000000000ULL + || a.u41 * a.u41 != 0x10000000000ULL) + abort (); + if (b.u33 + b.u33 != 0) + abort (); + if (b.u33 + b.u40 != 0x200000000ULL + || b.u33 + b.u41 != 0x200000000ULL + || b.u40 + b.u33 != 0x200000000ULL + || b.u40 + b.u40 != 0x200000000ULL + || b.u40 + b.u41 != 0x200000000ULL + || b.u41 + b.u33 != 0x200000000ULL + || b.u41 + b.u40 != 0x200000000ULL + || b.u41 + b.u41 != 0x200000000ULL) + abort (); + if (a.u33 - b.u33 != 0x100100000ULL + || a.u33 - b.u40 != 0xFF00100000ULL + || a.u33 - b.u41 != 0x1FF00100000ULL + || a.u40 - b.u33 != 0xFF00100000ULL + || a.u40 - b.u40 != 0xFF00100000ULL + || a.u40 - b.u41 != 0x1FF00100000ULL + || a.u41 - b.u33 != 0x1FF00100000ULL + || a.u41 - b.u40 != 0x1FF00100000ULL + || a.u41 - b.u41 != 0x1FF00100000ULL) + abort (); + if (++c.u33 != 0 || --c.u40 != 0xFFFFFFFFFFULL || c.u41-- != 0) + abort (); + exit (0); +} |