]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/84767 (ICE with pointer to VLA)
authorJakub Jelinek <jakub@redhat.com>
Mon, 25 Jun 2018 17:29:17 +0000 (19:29 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 25 Jun 2018 17:29:17 +0000 (19:29 +0200)
Backported from mainline
2018-03-09  Jakub Jelinek  <jakub@redhat.com>

PR c++/84767
* tree-inline.c (copy_tree_body_r): For INDIRECT_REF of a remapped
decl, use remap_type if we want to use the type.

* g++.dg/ext/vla18.C: New test.

From-SVN: r262072

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/vla18.C [new file with mode: 0644]
gcc/tree-inline.c

index 8903a771e3f33959d9fd7dc3fcdbd3f5fc412675..2873eb9a01cccece23cff696f87b5691909859b5 100644 (file)
@@ -1,6 +1,12 @@
 2018-06-25  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-03-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/84767
+       * tree-inline.c (copy_tree_body_r): For INDIRECT_REF of a remapped
+       decl, use remap_type if we want to use the type.
+
        2018-03-08  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/84739
index 48022ed15b6ac7b47992c029fd8e69db32d54923..1c42c350d87926ad00e09966d8dd774d7b05f69b 100644 (file)
@@ -1,6 +1,11 @@
 2018-06-25  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-03-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/84767
+       * g++.dg/ext/vla18.C: New test.
+
        2018-03-08  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/84739
diff --git a/gcc/testsuite/g++.dg/ext/vla18.C b/gcc/testsuite/g++.dg/ext/vla18.C
new file mode 100644 (file)
index 0000000..31a1bb3
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/84767
+// { dg-do compile }
+// { dg-options "" }
+
+int v[1][10];
+
+struct A
+{
+  A (int);
+};
+
+A::A (int i)
+{
+  typedef int T[1][i];
+  T *x = (T *) v;
+  (*x)[0][0] = 0;
+}
+
+A a = 10;
index 93bdf3e2bb5faf2262ea08e77a0d87d347774b1f..607e70c382ff29da357db6c043c4f69c7e99be3f 100644 (file)
@@ -1165,6 +1165,7 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data)
              *tp = gimple_fold_indirect_ref (ptr);
              if (! *tp)
                {
+                 type = remap_type (type, id);
                  if (TREE_CODE (ptr) == ADDR_EXPR)
                    {
                      *tp