From 9a9ba8d9b1292607bc97da712976937c4d81909d Mon Sep 17 00:00:00 2001
From: Jakub Jelinek <jakub@redhat.com>
Date: Mon, 9 Mar 2009 15:01:29 +0100
Subject: [PATCH] re PR tree-optimization/39394 (ICE in copy_tree_body_r)

	PR tree-optimization/39394
	* gimplify.c (gimplify_type_sizes): Gimplify DECL_SIZE and
	DECL_SIZE_UNIT of variable length FIELD_DECLs.

	* gcc.c-torture/compile/pr39394.c: New test.

From-SVN: r144727
---
 gcc/ChangeLog                                 |  6 ++++
 gcc/gimplify.c                                |  2 ++
 gcc/testsuite/ChangeLog                       |  5 ++++
 gcc/testsuite/gcc.c-torture/compile/pr39394.c | 28 +++++++++++++++++++
 4 files changed, 41 insertions(+)
 create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr39394.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 300507d9c05f..341bcc6155b7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2009-03-09  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/39394
+	* gimplify.c (gimplify_type_sizes): Gimplify DECL_SIZE and
+	DECL_SIZE_UNIT of variable length FIELD_DECLs.
+
 2009-03-09  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
 
 	* recog.c (verfiy_changes): Disallow renaming of hard regs in
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 02d4923aa1e3..b0c65920d814 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -7141,6 +7141,8 @@ gimplify_type_sizes (tree type, gimple_seq *list_p)
 	if (TREE_CODE (field) == FIELD_DECL)
 	  {
 	    gimplify_one_sizepos (&DECL_FIELD_OFFSET (field), list_p);
+	    gimplify_one_sizepos (&DECL_SIZE (field), list_p);
+	    gimplify_one_sizepos (&DECL_SIZE_UNIT (field), list_p);
 	    gimplify_type_sizes (TREE_TYPE (field), list_p);
 	  }
       break;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0651163fb8cf..5329e909d54a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2009-03-09  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/39394
+	* gcc.c-torture/compile/pr39394.c: New test.
+
 2009-03-09  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
 
 	* gcc.target/s390/20090223-1.c: New testcase.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr39394.c b/gcc/testsuite/gcc.c-torture/compile/pr39394.c
new file mode 100644
index 000000000000..325a08ff4704
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr39394.c
@@ -0,0 +1,28 @@
+/* PR tree-optimization/39394 */
+
+char *p;
+int x;
+
+static inline void
+f1 (int n)
+{
+  asm volatile ("" : "=m" (*(struct { char x[n]; } *) p));
+}
+
+static inline void
+f2 (void)
+{
+  x ? f1 (1) : f1 (2);
+}
+
+static inline void
+f3 (void)
+{
+  f2 ();
+}
+
+void
+f4 (void)
+{
+  f3 ();
+}
-- 
GitLab