This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] Fix layout_decl


Hi!

This patch fixes ICE in g++.old-deja/g++.other/crash34.C I've posted today
(in the second load of C++ patches).
The issue is that X is a static member with the same type as the containing
class, so when it gets DECL_RTL generated, it has still DECL_MODE VOIDmode,
thus DECL_RTL is (mem/s/u (symbol_ref:SI ("_1w.X")) 0).
Later on, when the whole w class is finalized and layout_decl updates its
DECL_MODE to the correct mode and DECL_SIZE as well, DECL_RTL is not updated
and the compiler crashes later on when it tries to copy the static field
into function argument.
Ok to commit?

class v
{
    double x, y;
public:
    v();
};

class w : public v {
public :
    static const w X;
    w();
};


2000-11-03  Jakub Jelinek  <jakub@redhat.com>

	* stor-layout.c (layout_decl): If setting previously VOIDmode
	DECL_MODE for decl which has DECL_RTL already set, call
	make_decl_rtl.

--- gcc/stor-layout.c.jj	Wed Oct 25 17:25:45 2000
+++ gcc/stor-layout.c	Fri Nov  3 17:51:29 2000
@@ -311,7 +311,14 @@ layout_decl (decl, known_align)
 
   TREE_UNSIGNED (decl) = TREE_UNSIGNED (type);
   if (DECL_MODE (decl) == VOIDmode)
-    DECL_MODE (decl) = TYPE_MODE (type);
+    {
+      DECL_MODE (decl) = TYPE_MODE (type);
+
+      /* If this DECL has already RTL assigned, make sure its mode is updated
+	 as well.  */
+      if (DECL_RTL (decl))
+	make_decl_rtl (decl, NULL, 0);
+    }
 
   if (DECL_SIZE (decl) == 0)
     {

	Jakub

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]