| 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 -Wclobbered -Wextra -Wall" } */ |
| 6 |
/* { dg-skip-if "" { ! nonlocal_goto } } */ |
| 7 |
|
| 8 |
#include <setjmp.h> |
| 9 |
|
| 10 |
extern void set_float_handler (jmp_buf *); |
| 11 |
|
| 12 |
#define EQ 0x01 |
| 13 |
#define LT 0x02 |
| 14 |
#define GT 0x04 |
| 15 |
|
| 16 |
int |
| 17 |
compare_float (double a, double b) /* { dg-bogus "clobbered" "spurious clobbered warning" } */ |
| 18 |
{ |
| 19 |
jmp_buf handler; |
| 20 |
int result; |
| 21 |
|
| 22 |
a += 1.0; |
| 23 |
|
| 24 |
if (setjmp (handler)) |
| 25 |
{ |
| 26 |
set_float_handler (0); |
| 27 |
return 0; |
| 28 |
} |
| 29 |
|
| 30 |
set_float_handler (&handler); |
| 31 |
if (a == b) result = EQ; |
| 32 |
else if (a > b) result = LT; |
| 33 |
else if (a < b) result = GT; |
| 34 |
else result = 0; |
| 35 |
set_float_handler (0); |
| 36 |
return result; |
| 37 |
} |