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]
Other format: [Raw text]

[PATCH] Fix an ICE in Gigi


Hi,

In Gigi we heavily rely on the TYPE_NEXT_PTR_TO and TYPE_NEXT_REF_TO mechanism 
to implement support for incomplete types.  This mechanism makes it possible 
to track pointer and references types to a given type, respectively, and 
update them when the pointed to type has changed (see update_pointer_to for 
the whole story).

The attached testcase triggers an ICE with 3.4.x at -O2 -gnatn because we fail 
to do so when building a new qualified type in build_qualified_type.

Bootstrapped/regtested on x86_64-suse-linux.  OK for mainline?


2005-11-08  Eric Botcazou  <ebotcazou@adacore.com>

	* tree.c (build_qualified_type): Chain the new type to the original
	type's TYPE_NEXT_PTR_TO or TYPE_NEXT_REF_TO linked lists if it is
	a POINTER_TYPE or a REFERENCE_TYPE respectively.


-- 
Eric Botcazou
Index: tree.c
===================================================================
--- tree.c	(revision 106397)
+++ tree.c	(working copy)
@@ -3702,6 +3702,20 @@ build_qualified_type (tree type, int typ
     {
       t = build_variant_type_copy (type);
       set_type_quals (t, type_quals);
+
+      /* If it's a pointer type, the new variant points to the same type.  */
+      if (TREE_CODE (type) == POINTER_TYPE)
+	{
+	  TYPE_NEXT_PTR_TO (t) = TYPE_NEXT_PTR_TO (type);
+	  TYPE_NEXT_PTR_TO (type) = t;
+	}
+
+      /* Same for a reference type.  */
+      else if (TREE_CODE (type) == REFERENCE_TYPE)
+	{
+	  TYPE_NEXT_REF_TO (t) = TYPE_NEXT_REF_TO (type);
+	  TYPE_NEXT_REF_TO (type) = t;
+	}
     }
 
   return t;
with F;

procedure P is
   B : Boolean;
begin
   B := F.C;
end;
package body F is

   type Func_Access is access function return Boolean;
   pragma Atomic (Func_Access);

   type Func_Array is array (Integer range <>) of Func_Access;

   Funcs : Func_Array (1 .. 1);

   function C return Boolean is
   begin
      return Funcs (1).all;
   end C;

end F;
package F is

   function C return Boolean;
   pragma Inline (C);

end F;

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