From: Jakub Jelinek Date: Mon, 25 Jun 2018 17:29:17 +0000 (+0200) Subject: backport: re PR c++/84767 (ICE with pointer to VLA) X-Git-Tag: releases/gcc-6.5.0~212 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dda2750c77f9133fe72d2f166afa14b5a0e93c27;p=thirdparty%2Fgcc.git backport: re PR c++/84767 (ICE with pointer to VLA) Backported from mainline 2018-03-09 Jakub Jelinek 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8903a771e3f3..2873eb9a01cc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,12 @@ 2018-06-25 Jakub Jelinek Backported from mainline + 2018-03-09 Jakub Jelinek + + 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 PR tree-optimization/84739 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 48022ed15b6a..1c42c350d879 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2018-06-25 Jakub Jelinek Backported from mainline + 2018-03-09 Jakub Jelinek + + PR c++/84767 + * g++.dg/ext/vla18.C: New test. + 2018-03-08 Jakub Jelinek 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 index 000000000000..31a1bb32f1af --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/vla18.C @@ -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; diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 93bdf3e2bb5f..607e70c382ff 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -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