re PR c/8081 (ICE with variably sized types returned from nested functions)
authorRichard Guenther <rguenther@suse.de>
Fri, 13 Jan 2012 12:05:27 +0000 (12:05 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 13 Jan 2012 12:05:27 +0000 (12:05 +0000)
2012-01-13  Richard Guenther  <rguenther@suse.de>

PR middle-end/8081
* gimplify.c (gimplify_modify_expr_rhs): For calls with a
variable-sized result always use RSO.

* gcc.dg/torture/pr8081.c: New testcase.

From-SVN: r183153

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr8081.c [new file with mode: 0644]

index 60830ae9436a0d9368616d2e61f51c4db56b3023..6bd16d3fc2ceaaef6ffa4685529f903f47b92265 100644 (file)
@@ -1,3 +1,9 @@
+2012-01-13  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/8081
+       * gimplify.c (gimplify_modify_expr_rhs): For calls with a
+       variable-sized result always use RSO.
+
 2012-01-12  DJ Delorie  <dj@redhat.com>
 
        * cfgexpand.c (convert_debug_memory_address): Allow any valid
index 94b99a1182324a7c538ca1670b101cb75cfe0b16..99ae5ee4bc5e066a8b4c74d38835969b2f730a96 100644 (file)
@@ -4417,6 +4417,11 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p,
                /* It's OK to use the target directly if it's being
                   initialized. */
                use_target = true;
+             else if (variably_modified_type_p (TREE_TYPE (*to_p), NULL_TREE))
+               /* Always use the target and thus RSO for variable-sized types.
+                  GIMPLE cannot deal with a variable-sized assignment
+                  embedded in a call statement.  */
+               use_target = true;
              else if (TREE_CODE (*to_p) != SSA_NAME
                      && (!is_gimple_variable (*to_p)
                          || needs_to_live_in_memory (*to_p)))
index b26ac263360cc0db2f1a77438453fd4a3eeee295..cbee6be3d5da4520874f6fb23370f430d83fa62d 100644 (file)
@@ -1,3 +1,8 @@
+2012-01-13  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/8081
+       * gcc.dg/torture/pr8081.c: New testcase.
+
 2012-01-13  Georg-Johann Lay  <avr@gjlay.de>
 
        * gcc.dg/pr46309.c: Set branch cost to greater 1 for avr.
diff --git a/gcc/testsuite/gcc.dg/torture/pr8081.c b/gcc/testsuite/gcc.dg/torture/pr8081.c
new file mode 100644 (file)
index 0000000..6899f6a
--- /dev/null
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+
+extern void abort (void);
+int
+main (int argc, char **argv)
+{
+  int size = 10;
+  typedef struct
+    {
+      char val[size];
+    }
+  block;
+  block a, b;
+  block __attribute__((noinline))
+  retframe_block ()
+    {
+      return *(block *) &b;
+    }
+  b.val[0] = -1;
+  b.val[9] = -2;
+  a=retframe_block ();
+  if (a.val[0] != -1
+      || a.val[9] != -2)
+    abort ();
+  return 0;
+}