From: No Author Date: Sun, 16 May 2004 20:27:22 +0000 (+0000) Subject: This commit was manufactured by cvs2svn to create branch X-Git-Tag: releases/gcc-3.3.4~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=47543d574b692f881242abf95237fc884f401054;p=thirdparty%2Fgcc.git This commit was manufactured by cvs2svn to create branch 'gcc-3_3-branch'. From-SVN: r81923 --- diff --git a/gcc/testsuite/g++.dg/opt/pr15054.C b/gcc/testsuite/g++.dg/opt/pr15054.C new file mode 100644 index 000000000000..cfc48cf24989 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr15054.C @@ -0,0 +1,36 @@ +// PR middle-end/15054 +// This used to abort due to overlapping stack temporaries. + +// { dg-do run } +// { dg-options "-O" } + +extern "C" void abort (void); + +struct pointer +{ + void* ptr; + + pointer(void* x = 0) : ptr(x) {} + pointer(const pointer& x) : ptr(x.ptr) {} +}; + +struct element +{ + int canary; + + element() : canary(123) { } + ~element() { pointer(); if (canary != 123) abort (); } +}; + +inline pointer +insert(const element& x) +{ + return pointer(new element(x)); +} + +int +main (void) +{ + insert(element()); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr15296.c b/gcc/testsuite/gcc.c-torture/execute/pr15296.c new file mode 100644 index 000000000000..d2468e425afa --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr15296.c @@ -0,0 +1,73 @@ +/* PR optimization/15296. The delayed-branch scheduler caused code that + SEGV:d for CRIS; a register was set to -1 in a delay-slot for the + fall-through code, while that register held a pointer used in code at + the branch target. */ + +typedef int __attribute__ ((mode (__pointer__))) intptr_t; +typedef intptr_t W; +union u0 +{ + union u0 *r; + W i; +}; +struct s1 +{ + union u0 **m0; + union u0 m1[4]; +}; + +void f (void *, struct s1 *, const union u0 *, W, W, W) + __attribute__ ((__noinline__)); +void g (void *, char *) __attribute__ ((__noinline__)); + +void +f (void *a, struct s1 *b, const union u0 *h, W v0, W v1, W v4) +{ + union u0 *e = 0; + union u0 *k = 0; + union u0 **v5 = b->m0; + union u0 *c = b->m1; + union u0 **d = &v5[0]; +l0:; + if (v0 < v1) + goto l0; + if (v0 == 0) + goto l3; + v0 = v4; + if (v0 != 0) + goto l3; + c[0].r = *d; + v1 = -1; + e = c[0].r; + if (e != 0) + g (a, ""); + k = e + 3; + k->i = v1; + goto l4; +l3:; + c[0].i = v0; + e = c[1].r; + if (e != 0) + g (a, ""); + e = c[0].r; + if (e == 0) + g (a, ""); + k = e + 2; + k->r = c[1].r; +l4:; +} + +void g (void *a, char *b) { abort (); } + +int +main () +{ + union u0 uv[] = {{ .i = 111 }, { .i = 222 }, { .i = 333 }, { .i = 444 }}; + struct s1 s = { 0, {{ .i = 555 }, { .i = 0 }, { .i = 999 }, { .i = 777 }}}; + f (0, &s, 0, 20000, 10000, (W) uv); + if (s.m1[0].i != (W) uv || s.m1[1].i != 0 || s.m1[2].i != 999 + || s.m1[3].i != 777 || uv[0].i != 111 || uv[1].i != 222 + || uv[2].i != 0 || uv[3].i != 444) + abort (); + exit (0); +}