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]

[Ada] Fix ICE on instantiated packed array type


This fixes an assertion failure in relate_alias_sets on an instantiated packed 
array type, because of a missing test before invoking the function.

Tested on x86_64-suse-linux, applied on mainline.


2014-10-27  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/decl.c (gnat_to_gnu_entity): Apply special treatment
	of derived packed array types to constrained subtypes only.


2014-10-27  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/specs/pack10.ads: New test.
	* gnat.dg/specs/pack10_pkg.ad[sb]: New helper.


-- 
Eric Botcazou
-- { dg-do compile }

with Pack10_Pkg; use Pack10_Pkg;

package Pack10 is

   type Boolean_Vector is array (Positive range <>) of Boolean;

   type Packed_Boolean_Vector is new Boolean_Vector;
   pragma Pack (Packed_Boolean_Vector);

   procedure My_Proc is new Proc (Packed_Boolean_Vector);

end Pack10;
package body Pack10_Pkg is

   procedure Proc is begin null; end;

end Pack10_Pkg;
-- { dg-excess-errors "cannot generate code" }

package Pack10_Pkg is

   generic
      type Vector_Type (<>) is private;
   procedure Proc;

end Pack10_Pkg;
Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c	(revision 216725)
+++ gcc-interface/decl.c	(working copy)
@@ -5083,8 +5083,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
       if (Is_Derived_Type (gnat_entity) && !type_annotate_only)
 	{
 	  Entity_Id gnat_parent_type = Underlying_Type (Etype (gnat_entity));
-	  /* For packed array subtypes, the implementation type is used.  */
+	  /* For constrained packed array subtypes, the implementation type is
+	     used instead of the nominal type.  */
 	  if (kind == E_Array_Subtype
+	      && Is_Constrained (gnat_entity)
 	      && Present (Packed_Array_Impl_Type (gnat_parent_type)))
 	    gnat_parent_type = Packed_Array_Impl_Type (gnat_parent_type);
 	  relate_alias_sets (gnu_type, gnat_to_gnu_type (gnat_parent_type),

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