From 39e3a681dfe06e7b1c80df5051930ac588e9c55b Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 6 Aug 2002 17:36:40 +0200 Subject: [PATCH] i386.c (x86_field_alignment): Apply min for all MODE_INT and MODE_CLASS_INT modes. * config/i386/i386.c (x86_field_alignment): Apply min for all MODE_INT and MODE_CLASS_INT modes. * g++.dg/abi/bitfield3.C: New test. From-SVN: r56072 --- gcc/ChangeLog | 6 +++ gcc/config/i386/i386.c | 4 +- gcc/testsuite/ChangeLog | 4 ++ gcc/testsuite/g++.dg/abi/bitfield3.C | 80 ++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/abi/bitfield3.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ade9711875a..f609be35ccc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2002-08-06 Jakub Jelinek + + * config/i386/i386.c (x86_field_alignment): Don't check + TARGET_ALIGN_DOUBLE for the second time. + Apply min for all MODE_INT and MODE_CLASS_INT modes. + 2002-08-06 Jakub Jelinek * config.gcc (*-*-linux*): Default to --enable-threads=posix if no diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index f2e33c6f77b..ae2fe990db3 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -13822,7 +13822,9 @@ x86_field_alignment (field, computed) return computed; mode = TYPE_MODE (TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE ? get_inner_array_type (field) : TREE_TYPE (field)); - if (mode == DFmode || mode == DCmode || mode == DImode || mode == CDImode) + if (mode == DFmode || mode == DCmode + || GET_MODE_CLASS (mode) == MODE_INT + || GET_MODE_CLASS (mode) == MODE_COMPLEX_INT) return MIN (32, computed); return computed; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b9de8f5aaf7..016152af1d1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2002-08-06 Jakub Jelinek + + * g++.dg/abi/bitfield3.C: New test. + 2002-08-05 Nathan Sidwell * lib/gcov.exp: Tweak expected line formats. diff --git a/gcc/testsuite/g++.dg/abi/bitfield3.C b/gcc/testsuite/g++.dg/abi/bitfield3.C new file mode 100644 index 00000000000..1e599355f69 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/bitfield3.C @@ -0,0 +1,80 @@ +// Test for oversized bitfield alignment in structs on IA-32 +// { dg-do run { target i?86-*-* } } +// { dg-options "-O2" } + +struct A +{ + char a; + int b : 224; // { dg-warning "exceeds its type" "" } + char c; +} a, a4[4]; + +struct B +{ + char d; + A e; + char f; +} b; + +struct C +{ + char g; + long long h : 64; + char i; +} c, c4[4]; + +struct D +{ + char j; + C k; + char l; +} d; + +struct E +{ + char m; + long long n : 160; // { dg-warning "exceeds its type" "" } + char o; +} e, e4[4]; + +struct F +{ + char p; + E q; + char r; +} f; + +int main (void) +{ + if (&a.c - &a.a != 32) + return 1; + if (sizeof (a) != 36) + return 2; + if (sizeof (a4) != 4 * 36) + return 3; + if (sizeof (b) != 2 * 4 + 36) + return 4; + if (__alignof__ (b.e) != 4) + return 5; + if (&c.i - &c.g != 16) + return 6; + if (sizeof (c) != 24) + return 7; + if (sizeof (c4) != 4 * 24) + return 8; + if (sizeof (d) != 2 * 8 + 24) + return 9; + if (__alignof__ (d.k) != 8) + return 10; + if (&e.o - &e.m != 28) + return 11; + if (sizeof (e) != 32) + return 12; + if (sizeof (e4) != 4 * 32) + return 13; + if (sizeof (f) != 2 * 8 + 32) + return 14; + if (__alignof__ (f.q) != 8) + return 15; + return 0; +} -- 2.30.2