]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
utils.c (gnat_types_compatible_p): Don't require strict equality for the component...
authorEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 22 Jul 2010 19:12:46 +0000 (19:12 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 22 Jul 2010 19:12:46 +0000 (19:12 +0000)
* gcc-interface/utils.c (gnat_types_compatible_p): Don't require strict
equality for the component type of array types.

From-SVN: r162424

gcc/ada/ChangeLog
gcc/ada/gcc-interface/utils.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/aggr15.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/aggr15.ads [new file with mode: 0644]

index d145b668a59666f44acef3e387577eed0c0e8227..c80be7241a34e580f53cdeeee0db60412e6b8f38 100644 (file)
@@ -1,3 +1,8 @@
+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.
+
 2010-07-15  Nathan Froyd  <froydnj@codesourcery.com>
 
        * gcc-interface/decl.c: Carefully replace TREE_CHAIN with DECL_CHAIN.
 
 2010-07-13  Laurent GUERBY  <laurent@guerby.net>
 
-        PR bootstrap/44458
-        * gcc-interface/targtyps.c: Include tm_p.h.
-        * gcc-interface/Make-lang.in: Update dependencies.
-       
+       PR bootstrap/44458
+       * gcc-interface/targtyps.c: Include tm_p.h.
+       * gcc-interface/Make-lang.in: Update dependencies.
+
 2010-07-09  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/trans.c (gnat_gimplify_expr) <ADDR_EXPR>: Deal with
index de0d25c4841e96ee9b4e22e04b453069fe19947a..eb65b7d2d4ddb989cd26734d38d2ccc463bc6f2d 100644 (file)
@@ -2080,17 +2080,17 @@ gnat_types_compatible_p (tree t1, tree t2)
       && TYPE_PRECISION (TREE_TYPE (t1)) == TYPE_PRECISION (TREE_TYPE (t2)))
     return 1;
 
-  /* Array types are also compatible if they are constrained and have
-     the same component type and the same domain.  */
+  /* Array types are also compatible if they are constrained and have the same
+     domain and compatible component types.  */
   if (code == ARRAY_TYPE
-      && TREE_TYPE (t1) == TREE_TYPE (t2)
       && (TYPE_DOMAIN (t1) == TYPE_DOMAIN (t2)
          || (TYPE_DOMAIN (t1)
              && TYPE_DOMAIN (t2)
              && tree_int_cst_equal (TYPE_MIN_VALUE (TYPE_DOMAIN (t1)),
                                     TYPE_MIN_VALUE (TYPE_DOMAIN (t2)))
              && tree_int_cst_equal (TYPE_MAX_VALUE (TYPE_DOMAIN (t1)),
-                                    TYPE_MAX_VALUE (TYPE_DOMAIN (t2))))))
+                                    TYPE_MAX_VALUE (TYPE_DOMAIN (t2)))))
+      && gnat_types_compatible_p (TREE_TYPE (t1), TREE_TYPE (t2)))
     return 1;
 
   /* Padding record types are also compatible if they pad the same
index 0e6e6f98b51d8bb8829adced2a22444537faa442..40ef493c162de5437e4d3273ad2d81560df04f50 100644 (file)
@@ -1,3 +1,7 @@
+2010-07-22  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/aggr15.ad[sb]: New test.
+
 2010-07-22  Dodji Seketeli  <dodji@redhat.com>
 
        PR debug/45024
diff --git a/gcc/testsuite/gnat.dg/aggr15.adb b/gcc/testsuite/gnat.dg/aggr15.adb
new file mode 100644 (file)
index 0000000..e69e9d3
--- /dev/null
@@ -0,0 +1,18 @@
+-- { dg-do compile }\r
+-- { dg-options "-gnatws" }\r
+\r
+package body Aggr15 is\r
+\r
+  function CREATE return DATA_T is\r
+    D : DATA_T;\r
+  begin\r
+    return D;\r
+  end;\r
+\r
+  function ALL_CREATE return ALL_DATA_T is\r
+    C : constant ALL_DATA_T := (others => (others => Create));\r
+  begin\r
+    return C;\r
+  end;\r
+\r
+end Aggr15;\r
diff --git a/gcc/testsuite/gnat.dg/aggr15.ads b/gcc/testsuite/gnat.dg/aggr15.ads
new file mode 100644 (file)
index 0000000..23f26a8
--- /dev/null
@@ -0,0 +1,15 @@
+package Aggr15 is\r
+\r
+  type T is tagged record\r
+    I : Integer;\r
+  end record;\r
+\r
+  type DATA_T is record\r
+    D : T;\r
+  end record;\r
+\r
+  type ALL_DATA_T is array (1..2, 1..2) of DATA_T;\r
+\r
+  function ALL_CREATE return ALL_DATA_T;\r
+\r
+end Aggr15;\r