re PR rtl-optimization/48542 (unchanged variables in code which calls setjmp may be clobbered (including the return-address))

PR rtl-optimization/48542
	* gcc.dg/torture/pr48542.c: New test.

From-SVN: r175133
This commit is contained in:
Hans-Peter Nilsson 2011-06-17 02:20:11 +00:00 committed by Hans-Peter Nilsson
parent 9a2091cd0a
commit 041efc9a53
2 changed files with 62 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2011-06-17 Hans-Peter Nilsson <hp@axis.com>
PR rtl-optimization/48542
* gcc.dg/torture/pr48542.c: New test.
2011-06-16 Jason Merrill <jason@redhat.com>
PR c++/44160

View File

@ -0,0 +1,57 @@
/* { dg-do run } */
/* The return-address was clobbered. */
#include <stdlib.h>
#include <setjmp.h>
jmp_buf env;
extern void sub(void);
extern void sub3(void);
int called;
__attribute__ ((__noinline__))
int sjtest()
{
int i;
if (setjmp(env))
return 99;
for (i = 0; i < 10; i++)
sub();
longjmp(env, 1);
}
__attribute__ ((__noinline__))
void sub(void)
{
called++;
}
int called3;
__attribute__ ((__noinline__))
int sjtest3()
{
int i;
if (setjmp(env))
return 42;
for (i = 0; i < 10; i++)
sub3();
return 0;
}
__attribute__ ((__noinline__))
void sub3(void)
{
called3++;
if (called3 == 10)
longjmp (env, 1);
}
int main(void)
{
if (sjtest() != 99 || called != 10)
abort();
if (sjtest3() != 42 || called3 != 10)
abort();
exit (0);
}