[C++ PATCH] Fix PR c++/6073

Jakub Jelinek jakub@redhat.com
Thu Mar 28 07:08:00 GMT 2002


Hi!

The following testcase is failing since
2002-03-18  Jason Merrill  <jason@redhat.com>
        PR c++/3948 -- C++ ABI change, followup to 2001-12-18 patch.
        * class.c (finish_struct_bits): Also set TREE_ADDRESSABLE for a
        type with a nontrivial destructor.
patch. The problem is that finish_struct_1 adjusts static field modes
only if it has exact same type, while finish_struct_bits changed all
variants too, so we end up with record_type A, record_type const A all being
BLKmode, but var_decl A::a QImode.
Ok to commit, provided testing succeeds?

2002-03-28  Jakub Jelinek  <jakub@redhat.com>

	PR c++/6073
	* class.c (finish_struct_1): Update static field's DECL_MODE even
	if its type is a variant of t.

	* g++.dg/opt/static1.C: New test.

--- gcc/cp/class.c.jj	Wed Mar 20 23:26:44 2002
+++ gcc/cp/class.c	Thu Mar 28 15:54:13 2002
@@ -5162,7 +5162,7 @@ finish_struct_1 (t)
      working on.  */
   for (x = TYPE_FIELDS (t); x; x = TREE_CHAIN (x))
     if (TREE_CODE (x) == VAR_DECL && TREE_STATIC (x)
-	&& TREE_TYPE (x) == t)
+	&& TYPE_MAIN_VARIANT (TREE_TYPE (x)) == t)
       DECL_MODE (x) = TYPE_MODE (t);
 
   /* Done with FIELDS...now decide whether to sort these for
--- gcc/testsuite/g++.dg/opt/static1.C.jj	Thu Mar 28 16:03:19 2002
+++ gcc/testsuite/g++.dg/opt/static1.C	Thu Mar 28 16:02:29 2002
@@ -0,0 +1,20 @@
+// PR c++/6073
+// This testcase ICEd because finish_struct_bits changed
+// A's and const A's TYPE_MODE from QI to BLK, but did
+// not change a's DECL_MODE because its mode was not
+// TYPE_MAIN_VARIANT.
+
+struct A
+{
+  static const A a;
+  ~A ();
+};
+
+void bar (A x);
+void foo ();
+
+void
+foo ()
+{
+  bar (A::a);
+}

	Jakub



More information about the Gcc-patches mailing list