aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2009-12-03 08:33:03 +0000
committerDodji Seketeli <dodji@gcc.gnu.org>2009-12-03 09:33:03 +0100
commit84894f850fd94064c2673de1d26a1390a65508dd (patch)
tree801fa0d123db0311962b9a816fed19689206532c /gcc
parent249ccaff220334750acbaf9351dd06b0fdcbde06 (diff)
downloadgcc-84894f850fd94064c2673de1d26a1390a65508dd.zip
gcc-84894f850fd94064c2673de1d26a1390a65508dd.tar.gz
gcc-84894f850fd94064c2673de1d26a1390a65508dd.tar.bz2
re PR c++/42217 (ICE with zero-length bit-field)
Fix PR c++/42217 gcc/cp/ChangeLog PR c++/42217 * class.c (remove_zero_width_bit_fields): The width of the bit field is in DECL_SIZE, not in DECL_INITIAL. gcc/testsuite/ChangeLog PR c++/42217 * g++.dg/other/bitfield4.C: New test. From-SVN: r154938
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/class.c7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/other/bitfield4.C10
4 files changed, 27 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6753829..f11ee70 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2009-12-03 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/42217
+ * class.c (remove_zero_width_bit_fields): The width of the bit field is
+ in DECL_SIZE, not in DECL_INITIAL.
+
2009-12-03 Jakub Jelinek <jakub@redhat.com>
PR c++/42256
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 1dcc238..ca75bc1 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -4254,7 +4254,12 @@ remove_zero_width_bit_fields (tree t)
{
if (TREE_CODE (*fieldsp) == FIELD_DECL
&& DECL_C_BIT_FIELD (*fieldsp)
- && DECL_INITIAL (*fieldsp))
+ /* We should not be confused by the fact that grokbitfield
+ temporarily sets the width of the bit field into
+ DECL_INITIAL (*fieldsp).
+ check_bitfield_decl eventually sets DECL_SIZE (*fieldsp)
+ to that width. */
+ && integer_zerop (DECL_SIZE (*fieldsp)))
*fieldsp = TREE_CHAIN (*fieldsp);
else
fieldsp = &TREE_CHAIN (*fieldsp);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index aeb92ac..550c136 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2009-12-03 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/42217
+ * g++.dg/other/bitfield4.C: New test.
+
2009-12-03 Jakub Jelinek <jakub@redhat.com>
PR c++/42256
diff --git a/gcc/testsuite/g++.dg/other/bitfield4.C b/gcc/testsuite/g++.dg/other/bitfield4.C
new file mode 100644
index 0000000..d140f82
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/bitfield4.C
@@ -0,0 +1,10 @@
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// Origin PR c++/42217
+// { dg-do compile }
+
+struct A
+{
+ int : 0;
+};
+A a = A();
+