Blame SOURCES/gcc32-rh186252.patch

4ac4fd
2004-05-01 Ulrich Weigand <weigand@de.ibm.com>
4ac4fd
4ac4fd
	PR middle-end/15054
4ac4fd
	* expr.c (expand_expr_real): Do not call preserve_temp_slots 
4ac4fd
	on a TARGET_EXPR temp.
4ac4fd
	* function.c (assign_stack_temp_for_type): Set 'keep' flag for
4ac4fd
	TARGET_EXPR temp slots.
4ac4fd
4ac4fd
	* g++.dg/opt/pr15054.C: New test.
4ac4fd
4ac4fd
2006-04-25  Jakub Jelinek  <jakub@redhat.com>
4ac4fd
4ac4fd
	* g++.dg/opt/pr15054-2.C: New test.
4ac4fd
4ac4fd
--- gcc/expr.c.orig	2006-02-24 04:51:46.000000000 -0300
4ac4fd
+++ gcc/expr.c	2006-04-11 03:53:02.000000000 -0300
4ac4fd
@@ -8676,8 +8676,6 @@ expand_expr (exp, target, tmode, modifie
4ac4fd
 	    else
4ac4fd
 	      {
4ac4fd
 		target = assign_temp (type, 2, 0, 1);
4ac4fd
-		/* All temp slots at this level must not conflict.  */
4ac4fd
-		preserve_temp_slots (target);
4ac4fd
 		SET_DECL_RTL (slot, target);
4ac4fd
 		if (TREE_ADDRESSABLE (slot))
4ac4fd
 		  put_var_into_stack (slot);
4ac4fd
--- gcc/function.c.orig	2006-02-24 04:51:52.000000000 -0300
4ac4fd
+++ gcc/function.c	2006-04-11 03:53:02.000000000 -0300
4ac4fd
@@ -803,7 +803,7 @@ assign_stack_temp_for_type (mode, size, 
4ac4fd
   if (keep == 2)
4ac4fd
     {
4ac4fd
       p->level = target_temp_slot_level;
4ac4fd
-      p->keep = 0;
4ac4fd
+      p->keep = 1;
4ac4fd
     }
4ac4fd
   else if (keep == 3)
4ac4fd
     {
4ac4fd
--- gcc/testsuite/g++.dg/opt/pr15054.C	1970-01-01 00:00:00.000000000 +0000
4ac4fd
+++ gcc/testsuite/g++.dg/opt/pr15054.C	2006-04-11 03:54:31.000000000 -0300
4ac4fd
@@ -0,0 +1,36 @@
4ac4fd
+// PR middle-end/15054
4ac4fd
+// This used to abort due to overlapping stack temporaries.
4ac4fd
+
4ac4fd
+// { dg-do run }
4ac4fd
+// { dg-options "-O" }
4ac4fd
+
4ac4fd
+extern "C" void abort (void);
4ac4fd
+
4ac4fd
+struct pointer
4ac4fd
+{
4ac4fd
+  void* ptr;
4ac4fd
+
4ac4fd
+  pointer(void* x = 0) : ptr(x) {}
4ac4fd
+  pointer(const pointer& x) : ptr(x.ptr) {}
4ac4fd
+};
4ac4fd
+
4ac4fd
+struct element
4ac4fd
+{
4ac4fd
+  int canary;
4ac4fd
+
4ac4fd
+  element() : canary(123) { }
4ac4fd
+  ~element() { pointer(); if (canary != 123) abort (); }
4ac4fd
+};
4ac4fd
+
4ac4fd
+inline pointer
4ac4fd
+insert(const element& x)
4ac4fd
+{
4ac4fd
+  return pointer(new element(x));
4ac4fd
+}
4ac4fd
+
4ac4fd
+int
4ac4fd
+main (void)
4ac4fd
+{
4ac4fd
+  insert(element());
4ac4fd
+  return 0;
4ac4fd
+}
4ac4fd
--- gcc/testsuite/g++.dg/opt/pr15054-2.C	2006-04-19 19:21:31.748476000 +0200
4ac4fd
+++ gcc/testsuite/g++.dg/opt/pr15054-2.C	2006-04-25 15:55:07.000000000 +0200
4ac4fd
@@ -0,0 +1,39 @@
4ac4fd
+// PR middle-end/15054
4ac4fd
+
4ac4fd
+// { dg-do run }
4ac4fd
+// { dg-options "-O2" }
4ac4fd
+
4ac4fd
+extern "C" void abort (void);
4ac4fd
+
4ac4fd
+void
4ac4fd
+__attribute__((noinline))
4ac4fd
+check (long x, long y)
4ac4fd
+{
4ac4fd
+  if (x != y)
4ac4fd
+    abort ();
4ac4fd
+}
4ac4fd
+
4ac4fd
+struct A
4ac4fd
+{
4ac4fd
+  A() : a(2) { check (a, 2); }
4ac4fd
+  ~A() { check (a, 2); }
4ac4fd
+private:
4ac4fd
+  long a;
4ac4fd
+};
4ac4fd
+
4ac4fd
+class B {
4ac4fd
+  long b;
4ac4fd
+  B& operator =(const B& );
4ac4fd
+public:
4ac4fd
+  B (long p) : b(p) { check (b, 6); }
4ac4fd
+  B (const B& p) : b(p.b) { check (b, 6); }
4ac4fd
+  ~B () { check (b, 6); A obj; check (b, 6); }
4ac4fd
+  B foo() { return B(*this); }
4ac4fd
+};
4ac4fd
+
4ac4fd
+int main ()
4ac4fd
+{
4ac4fd
+  B o(6);
4ac4fd
+  o.foo().foo();
4ac4fd
+  return 0;
4ac4fd
+}