public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Fix ICE on instantiated packed array type
@ 2014-10-27 11:28 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2014-10-27 11:28 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 544 bytes --]

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

[-- Attachment #2: pack10.ads --]
[-- Type: text/x-adasrc, Size: 305 bytes --]

-- { 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;

[-- Attachment #3: pack10_pkg.adb --]
[-- Type: text/x-adasrc, Size: 83 bytes --]

package body Pack10_Pkg is

   procedure Proc is begin null; end;

end Pack10_Pkg;

[-- Attachment #4: pack10_pkg.ads --]
[-- Type: text/x-adasrc, Size: 158 bytes --]

-- { dg-excess-errors "cannot generate code" }

package Pack10_Pkg is

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

end Pack10_Pkg;

[-- Attachment #5: p.diff --]
[-- Type: text/x-patch, Size: 847 bytes --]

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),

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-10-27 11:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-27 11:28 [Ada] Fix ICE on instantiated packed array type Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).