diff options
author | Hans-Peter Nilsson <hp@axis.com> | 2011-06-17 11:25:53 +0000 |
---|---|---|
committer | Hans-Peter Nilsson <hp@gcc.gnu.org> | 2011-06-17 11:25:53 +0000 |
commit | 1b6f601a310a58d7a71c3e5fda0386f8b5d091ee (patch) | |
tree | 9380097a2ccbd45c0bd4c95a03ff10a4ce10f819 | |
parent | 04c462aab45a3296d5efb539d4479717b12e7eac (diff) | |
download | gcc-1b6f601a310a58d7a71c3e5fda0386f8b5d091ee.tar.gz |
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: r175147
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr48542.c | 57 |
2 files changed, 65 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0ce09c12549..9d58ad88d6f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2011-06-17 Hans-Peter Nilsson <hp@axis.com> + + Backport from mainline + 2011-06-17 Hans-Peter Nilsson <hp@axis.com> + + PR rtl-optimization/48542 + * gcc.dg/torture/pr48542.c: New test. + 2011-06-05 Kaz Kojima <kkojima@gcc.gnu.org> Backport from mainline diff --git a/gcc/testsuite/gcc.dg/torture/pr48542.c b/gcc/testsuite/gcc.dg/torture/pr48542.c new file mode 100644 index 00000000000..e3e49489f7d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr48542.c @@ -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); +} |