OSDN Git Service

PR middle-end/42874
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 Jan 2010 15:09:23 +0000 (15:09 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 Jan 2010 15:09:23 +0000 (15:09 +0000)
* tree-inline.c (cannot_copy_type_1): Removed.
(copy_forbidden): Don't forbid copying of functions containing
records/unions with variable length fields.

* gcc.dg/vla-22.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156287 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vla-22.c [new file with mode: 0644]
gcc/tree-inline.c

index 0edb3c8..10a9bc9 100644 (file)
@@ -1,3 +1,10 @@
+2010-01-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/42874
+       * tree-inline.c (cannot_copy_type_1): Removed.
+       (copy_forbidden): Don't forbid copying of functions containing
+       records/unions with variable length fields.
+
 2010-01-27  Christian Bruel  <christian.bruel@st.com>
 
        Revert:
index 492cba8..fd63e1b 100644 (file)
@@ -1,3 +1,8 @@
+2010-01-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/42874
+       * gcc.dg/vla-22.c: New test.
+
 2010-01-26  Jakub Jelinek  <jakub@redhat.com>
 
        * ada/acats/run_all.sh: Make sure norun.lst is sorted using the
diff --git a/gcc/testsuite/gcc.dg/vla-22.c b/gcc/testsuite/gcc.dg/vla-22.c
new file mode 100644 (file)
index 0000000..f924650
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+extern void bar (int *);
+
+static inline __attribute__((always_inline))
+int
+foo (int i)
+{
+  struct S {
+    int ar[1][i];
+  } s;
+
+  s.ar[0][0] = 0;
+  bar (&s.ar[0][0]);
+}
+
+void
+baz (int i)
+{
+  foo (i + 2);
+}
index e08842c..815d88a 100644 (file)
@@ -2730,39 +2730,6 @@ has_label_address_in_static_1 (tree *nodep, int *walk_subtrees, void *fnp)
   return NULL_TREE;
 }
 
-/* Callback through walk_tree.  Determine if we've got an aggregate
-   type that we can't support; return non-null if so.  */
-
-static tree
-cannot_copy_type_1 (tree *nodep, int *walk_subtrees ATTRIBUTE_UNUSED,
-                    void *data ATTRIBUTE_UNUSED)
-{
-  tree t, node = *nodep;
-
-  if (TREE_CODE (node) == RECORD_TYPE || TREE_CODE (node) == UNION_TYPE)
-    {
-      /* We cannot inline a function of the form
-
-          void F (int i) { struct S { int ar[i]; } s; }
-
-        Attempting to do so produces a catch-22.
-        If walk_tree examines the TYPE_FIELDS chain of RECORD_TYPE/
-        UNION_TYPE nodes, then it goes into infinite recursion on a
-        structure containing a pointer to its own type.  If it doesn't,
-        then the type node for S doesn't get adjusted properly when
-        F is inlined.
-
-        ??? This is likely no longer true, but it's too late in the 4.0
-        cycle to try to find out.  This should be checked for 4.1.  */
-      for (t = TYPE_FIELDS (node); t; t = TREE_CHAIN (t))
-       if (variably_modified_type_p (TREE_TYPE (t), NULL))
-         return node;
-    }
-
-  return NULL_TREE;
-}
-
-
 /* Determine if the function can be copied.  If so return NULL.  If
    not return a string describng the reason for failure.  */
 
@@ -2805,16 +2772,6 @@ copy_forbidden (struct function *fun, tree fndecl)
                      "address of local label in a static variable");
          goto fail;
        }
-
-      if (!TREE_STATIC (decl) && !DECL_EXTERNAL (decl)
-         && variably_modified_type_p (TREE_TYPE (decl), NULL)
-         && walk_tree_without_duplicates (&TREE_TYPE (decl),
-                                          cannot_copy_type_1, NULL))
-       {
-         reason = G_("function %q+F can never be copied "
-                     "because it uses variable sized variables");
-         goto fail;
-       }
     }
 
  fail: