From: Mikael Pettersson Date: Mon, 6 Jun 2011 11:43:31 +0000 (+0200) Subject: re PR tree-optimization/49243 (attribute((returns_twice)) doesn't work) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=275311c494a330790748a27d28fa494bd4a18933;p=gcc.git re PR tree-optimization/49243 (attribute((returns_twice)) doesn't work) 2011-06-06 Mikael Pettersson PR tree-optimization/49243 * calls.c (setjmp_call_p): Also check if fndecl has the returns_twice attribute. * gcc.dg/pr49243.c: New. From-SVN: r174695 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3897ba487b0..3f01f25faf0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-06-06 Mikael Pettersson + + PR tree-optimization/49243 + * calls.c (setjmp_call_p): Also check if fndecl has the + returns_twice attribute. + 2011-06-06 Rainer Orth * config/mips/iris6.h (ENDFILE_SPEC): Use crtfastmath.o if diff --git a/gcc/calls.c b/gcc/calls.c index f5592c5a6d9..feb98d21c00 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -567,6 +567,8 @@ special_function_p (const_tree fndecl, int flags) int setjmp_call_p (const_tree fndecl) { + if (DECL_IS_RETURNS_TWICE (fndecl)) + return ECF_RETURNS_TWICE; return special_function_p (fndecl, 0) & ECF_RETURNS_TWICE; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1e904e60485..1c0a71a6ec3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-06-06 Mikael Pettersson + + PR tree-optimization/49243 + * gcc.dg/pr49243.c: New. + 2011-06-06 Eric Botcazou * gnat.dg/specs/cond_expr1.ads: New test. diff --git a/gcc/testsuite/gcc.dg/pr49243.c b/gcc/testsuite/gcc.dg/pr49243.c new file mode 100644 index 00000000000..f896b05b060 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr49243.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/49243 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Winline" } */ + +extern unsigned long jb[]; +extern int my_setjmp(unsigned long jb[]) __attribute__((returns_twice)); +extern int decode(const char*); + +static inline int wrapper(const char **s_ptr) /* { dg-warning "(inlining failed|function 'wrapper' can never be inlined because it uses setjmp)" } */ +{ + if (my_setjmp(jb) == 0) { + const char *s = *s_ptr; + while (decode(s) != 0) + *s_ptr = ++s; + return 0; + } else + return -1; +} + +void parse(const char *data) +{ + const char *s = data; + if (!(wrapper(&s) == -1 && (s - data) == 1)) /* { dg-warning "called from here" } */ + __builtin_abort(); +}