This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Ada] Fix ICE on aggregate of multidimensional array type
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 23 Jul 2010 21:53:44 +0200
- Subject: Re: [Ada] Fix ICE on aggregate of multidimensional array type
- References: <201007222113.10089.ebotcazou@adacore.com>
> 2010-07-22 Eric Botcazou <ebotcazou@adacore.com>
>
> * gcc-interface/utils.c (gnat_types_compatible_p): Don't require strict
> equality for the component type of array types.
Unfortunately this is now too lax and leads to other problems. Hence this new
fix, tested on x86-64-suse-linux, applied on the mainline.
2010-07-23 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/utils.c (gnat_types_compatible_p): Revert latest change
and recurse only for multidimensional array types instead.
2010-07-23 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/aggr16.ad[sb]: New test.
* gnat.dg/aggr16_pkg.ads: New helper.
--
Eric Botcazou
Index: gcc-interface/utils.c
===================================================================
--- gcc-interface/utils.c (revision 162425)
+++ gcc-interface/utils.c (working copy)
@@ -2081,7 +2081,7 @@ gnat_types_compatible_p (tree t1, tree t
return 1;
/* Array types are also compatible if they are constrained and have the same
- domain and compatible component types. */
+ domain(s) and the same component type. */
if (code == ARRAY_TYPE
&& (TYPE_DOMAIN (t1) == TYPE_DOMAIN (t2)
|| (TYPE_DOMAIN (t1)
@@ -2090,7 +2090,9 @@ gnat_types_compatible_p (tree t1, tree t
TYPE_MIN_VALUE (TYPE_DOMAIN (t2)))
&& tree_int_cst_equal (TYPE_MAX_VALUE (TYPE_DOMAIN (t1)),
TYPE_MAX_VALUE (TYPE_DOMAIN (t2)))))
- && gnat_types_compatible_p (TREE_TYPE (t1), TREE_TYPE (t2)))
+ && (TREE_TYPE (t1) == TREE_TYPE (t2)
+ || (TREE_CODE (TREE_TYPE (t1)) == ARRAY_TYPE
+ && gnat_types_compatible_p (TREE_TYPE (t1), TREE_TYPE (t2)))))
return 1;
/* Padding record types are also compatible if they pad the same
-- { dg-do compile }
with Aggr16_Pkg; use Aggr16_Pkg;
package body Aggr16 is
type Arr is array (1 .. 4) of Time;
type Change_Type is (One, Two, Three);
type Change (D : Change_Type) is record
case D is
when Three =>
A : Arr;
when Others =>
B : Boolean;
end case;
end record;
procedure Proc is
C : Change (Three);
begin
C.A := (others => Null_Time);
end;
end Aggr16;
package Aggr16_Pkg is
type Time_Type is (A, B);
type Time (D : Time_Type := A) is private;
Null_Time : constant Time;
private
type Hour is record
I1 : Integer;
I2 : Integer;
end record;
type Time (D : Time_Type := A) is record
case D is
when A =>
A_Time : Integer;
when B =>
B_Time : Hour;
end case;
end record;
Null_Time : constant Time := (A, 0);
end Aggr16_Pkg;
package Aggr16 is
procedure Proc;
end Aggr16;