OSDN Git Service

/
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / setjmp-1.c
1 /* Test for bogus "variable `x' may be clobbered by longjmp" warnings.
2    Inspired by cse.c:simplify_relational_operation. */
3
4 /* { dg-do compile } */
5 /* { dg-options "-O -W -Wall" } */
6
7 #include <setjmp.h>
8
9 extern void set_float_handler (jmp_buf *);
10
11 #define EQ 0x01
12 #define LT 0x02
13 #define GT 0x04
14
15 int
16 compare_float (double a, double b)  /* { dg-bogus "clobbered" "spurious clobbered warning" } */
17 {
18   jmp_buf handler;
19   int result;
20
21   a += 1.0;
22
23   if (setjmp (handler))
24     {
25       set_float_handler (0);
26       return 0;
27     }
28
29   set_float_handler (&handler);
30   if (a == b) result = EQ;
31   else if (a > b) result = LT;
32   else if (a < b) result = GT;
33   else result = 0;
34   set_float_handler (0);
35   return result;
36 }