re PR c++/84767 (ICE with pointer to VLA)
authorJakub Jelinek <jakub@redhat.com>
Fri, 9 Mar 2018 19:12:29 +0000 (20:12 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 9 Mar 2018 19:12:29 +0000 (20:12 +0100)
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: r258395

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

index 346262eec23f8de9a7a9b19d9b0f7fb3c5e2591a..7d7ece875a4ccee6651a5ecb0ae78fa9ed119032 100644 (file)
@@ -1,3 +1,9 @@
+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-09  Martin Sebor  <msebor@redhat.com>
 
        PR tree-optimization/84526
index ecd0fb83f371f28b04055c85fdd75dea471d89b8..3b3f44f6605ef64a5925df06b990a029c452befc 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/84767
+       * g++.dg/ext/vla18.C: New test.
+
 2018-03-09  Martin Sebor  <msebor@redhat.com>
 
        PR tree-optimization/84526
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 811829e8529948896d2350e6aa24c160636bd5ca..5a0a2525c0cab6ab2ae8acdc11818a0023fcbd5e 100644 (file)
@@ -1192,6 +1192,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