re PR ada/53592 (ICE on assignment to component of vector_type)
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 15 Jun 2012 10:41:13 +0000 (10:41 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 15 Jun 2012 10:41:13 +0000 (10:41 +0000)
PR ada/53592
* gcc-interface/gigi.h (maybe_vector_array): Make static inline.
* gcc-interface/utils.c (maybe_vector_array): Delete.
* gcc-interface/trans.c (gnat_to_gnu) <N_Indexed_Component>: Mark the
array object as addressable if it has vector type and is on the LHS.

From-SVN: r188653

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

index d9be5f8e1cbe71a5bda4513a8b2847897440620a..8cca048644c9553ad86c7940859432ef9713f712 100644 (file)
@@ -1,3 +1,11 @@
+2012-06-15  Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR ada/53592
+       * gcc-interface/gigi.h (maybe_vector_array): Make static inline.
+       * gcc-interface/utils.c (maybe_vector_array): Delete.
+       * gcc-interface/trans.c (gnat_to_gnu) <N_Indexed_Component>: Mark the
+       array object as addressable if it has vector type and is on the LHS.
+
 2012-06-15  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR middle-end/53590
index e2aac80b66534e1354ae2d6b40c610c6fee1317f..cfa52b069db0d42fe8519ef74f3cfaa362d9061a 100644 (file)
@@ -783,10 +783,6 @@ extern tree remove_conversions (tree exp, bool true_address);
    likewise return an expression pointing to the underlying array.  */
 extern tree maybe_unconstrained_array (tree exp);
 
-/* If EXP's type is a VECTOR_TYPE, return EXP converted to the associated
-   TYPE_REPRESENTATIVE_ARRAY.  */
-extern tree maybe_vector_array (tree exp);
-
 /* Return an expression that does an unchecked conversion of EXPR to TYPE.
    If NOTRUNC_P is true, truncation operations should be suppressed.  */
 extern tree unchecked_convert (tree type, tree expr, bool notrunc_p);
@@ -1033,6 +1029,20 @@ extern void enumerate_modes (void (*f) (const char *, int, int, int, int, int,
 /* Convenient shortcuts.  */
 #define VECTOR_TYPE_P(TYPE) (TREE_CODE (TYPE) == VECTOR_TYPE)
 
+/* If EXP's type is a VECTOR_TYPE, return EXP converted to the associated
+   TYPE_REPRESENTATIVE_ARRAY.  */
+
+static inline tree
+maybe_vector_array (tree exp)
+{
+  tree etype = TREE_TYPE (exp);
+
+  if (VECTOR_TYPE_P (etype))
+    exp = convert (TYPE_REPRESENTATIVE_ARRAY (etype), exp);
+
+  return exp;
+}
+
 static inline unsigned HOST_WIDE_INT
 ceil_pow2 (unsigned HOST_WIDE_INT x)
 {
index 6e651f4312352185161a2fbe69b902cfd1621386..65231bde84872d589dd0c6d16b129212b60fa579 100644 (file)
@@ -5372,7 +5372,12 @@ gnat_to_gnu (Node_Id gnat_node)
 
        /* Convert vector inputs to their representative array type, to fit
           what the code below expects.  */
-       gnu_array_object = maybe_vector_array (gnu_array_object);
+       if (VECTOR_TYPE_P (TREE_TYPE (gnu_array_object)))
+         {
+           if (present_in_lhs_or_actual_p (gnat_node))
+             gnat_mark_addressable (gnu_array_object);
+           gnu_array_object = maybe_vector_array (gnu_array_object);
+         }
 
        gnu_array_object = maybe_unconstrained_array (gnu_array_object);
 
index 62a4b319dfbe7ced2aafcb59e3bfb83f82ad4c03..d2183bbe160648d09497ed3d764a568d9990a0d2 100644 (file)
@@ -5149,20 +5149,6 @@ maybe_unconstrained_array (tree exp)
 
   return exp;
 }
-
-/* If EXP's type is a VECTOR_TYPE, return EXP converted to the associated
-   TYPE_REPRESENTATIVE_ARRAY.  */
-
-tree
-maybe_vector_array (tree exp)
-{
-  tree etype = TREE_TYPE (exp);
-
-  if (VECTOR_TYPE_P (etype))
-    exp = convert (TYPE_REPRESENTATIVE_ARRAY (etype), exp);
-
-  return exp;
-}
 \f
 /* Return true if EXPR is an expression that can be folded as an operand
    of a VIEW_CONVERT_EXPR.  See ada-tree.h for a complete rationale.  */
index 2360767d0e1ae1e8f442281c504f3b9f2e6b6e0b..5efced7c34e81537dad94e57285aa3971e69dbbd 100644 (file)
@@ -1,3 +1,7 @@
+2012-06-15  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/vect8.ad[sb]: New test.
+
 2012-06-14  Richard Guenther  <rguenther@suse.de>
 
        * gcc.dg/tree-ssa/vrp.h: New testcase.
diff --git a/gcc/testsuite/gnat.dg/vect8.adb b/gcc/testsuite/gnat.dg/vect8.adb
new file mode 100644 (file)
index 0000000..b13555a
--- /dev/null
@@ -0,0 +1,11 @@
+package body Vect8 is
+
+   function Foo (V : Vec) return Vec is
+      Ret : Vec;
+   begin
+      Ret (1) := V (1) + V (2);
+      Ret (2) := V (1) - V (2);
+      return Ret;
+   end;
+
+end Vect8;
diff --git a/gcc/testsuite/gnat.dg/vect8.ads b/gcc/testsuite/gnat.dg/vect8.ads
new file mode 100644 (file)
index 0000000..5406c70
--- /dev/null
@@ -0,0 +1,10 @@
+-- { dg-do compile }
+
+package Vect8 is
+
+   type Vec is array (1 .. 2) of Long_Float;
+   pragma Machine_Attribute (Vec, "vector_type");
+
+   function Foo (V : Vec) return Vec;
+
+end Vect8;