diff mbox series

Fix tree-inline.c INDIRECT_REF handling (PR c++/84767)

Message ID 20180309180614.GG8577@tucnak
State New
Headers show
Series Fix tree-inline.c INDIRECT_REF handling (PR c++/84767) | expand

Commit Message

Jakub Jelinek March 9, 2018, 6:06 p.m. UTC
Hi!

On the following testcase we ICE because when cloning the ctor using
tree-inline.c infrastructure we don't remap the type of INDIRECT_REF,
which needs to be remapped if it a variable length type, otherwise we
refer to the parameters of the original ctor rather than of the base
or complete ctor.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

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.


	Jakub

Comments

Jeff Law March 9, 2018, 7:09 p.m. UTC | #1
On 03/09/2018 11:06 AM, Jakub Jelinek wrote:
> Hi!
> 
> On the following testcase we ICE because when cloning the ctor using
> tree-inline.c infrastructure we don't remap the type of INDIRECT_REF,
> which needs to be remapped if it a variable length type, otherwise we
> refer to the parameters of the original ctor rather than of the base
> or complete ctor.
> 
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
> 
> 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.
OK.
jeff
diff mbox series

Patch

--- gcc/tree-inline.c.jj	2018-02-13 21:21:38.000000000 +0100
+++ gcc/tree-inline.c	2018-03-09 13:05:10.355154860 +0100
@@ -1192,6 +1192,7 @@  copy_tree_body_r (tree *tp, int *walk_su
 	      *tp = gimple_fold_indirect_ref (ptr);
 	      if (! *tp)
 	        {
+		  type = remap_type (type, id);
 		  if (TREE_CODE (ptr) == ADDR_EXPR)
 		    {
 		      *tp
--- gcc/testsuite/g++.dg/ext/vla18.C.jj	2018-03-09 13:11:27.863229118 +0100
+++ gcc/testsuite/g++.dg/ext/vla18.C	2018-03-09 13:10:54.319222521 +0100
@@ -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;