This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

fix tree-opt/19108


Tested on i686-linux.


r~


        * tree-sra.c (generate_element_init_1): Handle RANGE_EXPR.

Index: tree-sra.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-sra.c,v
retrieving revision 2.54
diff -u -p -r2.54 tree-sra.c
--- tree-sra.c	9 Mar 2005 11:35:34 -0000	2.54
+++ tree-sra.c	29 Mar 2005 22:41:21 -0000
@@ -1639,10 +1639,31 @@ generate_element_init_1 (struct sra_elt 
     case CONSTRUCTOR:
       for (t = CONSTRUCTOR_ELTS (init); t ; t = TREE_CHAIN (t))
 	{
-	  sub = lookup_element (elt, TREE_PURPOSE (t), NULL, NO_INSERT);
-	  if (sub == NULL)
-	    continue;
-	  result &= generate_element_init_1 (sub, TREE_VALUE (t), list_p);
+	  tree purpose = TREE_PURPOSE (t);
+	  tree value = TREE_VALUE (t);
+
+	  if (TREE_CODE (purpose) == RANGE_EXPR)
+	    {
+	      tree lower = TREE_OPERAND (purpose, 0);
+	      tree upper = TREE_OPERAND (purpose, 1);
+
+	      while (1)
+		{
+	  	  sub = lookup_element (elt, lower, NULL, NO_INSERT);
+		  if (sub != NULL)
+		    result &= generate_element_init_1 (sub, value, list_p);
+		  if (tree_int_cst_equal (lower, upper))
+		    break;
+		  lower = int_const_binop (PLUS_EXPR, lower,
+					   integer_one_node, true);
+		}
+	    }
+	  else
+	    {
+	      sub = lookup_element (elt, purpose, NULL, NO_INSERT);
+	      if (sub != NULL)
+		result &= generate_element_init_1 (sub, value, list_p);
+	    }
 	}
       break;
 
Index: testsuite/g++.dg/opt/pr19108.C
===================================================================
RCS file: testsuite/g++.dg/opt/pr19108.C
diff -N testsuite/g++.dg/opt/pr19108.C
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/g++.dg/opt/pr19108.C	29 Mar 2005 22:41:25 -0000
@@ -0,0 +1,19 @@
+// PR tree-optimization/19108
+// This used to abort due to not handing RANGE_EXPR in SRA.
+
+// { dg-do compile }
+// { dg-options "-O" }
+
+struct A
+{
+    int i[6];
+    A () : i() {}
+};
+
+struct B
+{
+    A a;
+    B(const A& x) : a(x) {}
+};
+
+B b=A();


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]