public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix tree-inline.c INDIRECT_REF handling (PR c++/84767)
@ 2018-03-09 18:35 Jakub Jelinek
  2018-03-09 19:10 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2018-03-09 18:35 UTC (permalink / raw)
  To: Richard Biener, Jeff Law; +Cc: gcc-patches

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.

--- 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;

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix tree-inline.c INDIRECT_REF handling (PR c++/84767)
  2018-03-09 18:35 [PATCH] Fix tree-inline.c INDIRECT_REF handling (PR c++/84767) Jakub Jelinek
@ 2018-03-09 19:10 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2018-03-09 19:10 UTC (permalink / raw)
  To: Jakub Jelinek, Richard Biener; +Cc: gcc-patches

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-09 19:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-09 18:35 [PATCH] Fix tree-inline.c INDIRECT_REF handling (PR c++/84767) Jakub Jelinek
2018-03-09 19:10 ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).