| 1 |
/* { dg-require-effective-target label_values } */ |
| 2 |
|
| 3 |
/* Labels as values. */ |
| 4 |
|
| 5 |
#include "analyzer-decls.h" |
| 6 |
|
| 7 |
extern void foo (void); |
| 8 |
|
| 9 |
void *x, *y, *z; |
| 10 |
|
| 11 |
void test (void) |
| 12 |
{ |
| 13 |
label0: |
| 14 |
foo (); |
| 15 |
label1: |
| 16 |
foo (); |
| 17 |
label2: |
| 18 |
foo (); |
| 19 |
|
| 20 |
x = &&label0; |
| 21 |
y = &&label1; |
| 22 |
z = &&label2; |
| 23 |
|
| 24 |
__analyzer_eval (x == x); /* { dg-warning "TRUE" } */ |
| 25 |
__analyzer_eval (x == y); /* { dg-warning "FALSE" } */ |
| 26 |
} |
| 27 |
|
| 28 |
void test_2 (int i) |
| 29 |
{ |
| 30 |
static void *array[] = { &&label0, &&label1, &&label2 }; |
| 31 |
goto *array[i]; |
| 32 |
|
| 33 |
label0: |
| 34 |
foo (); |
| 35 |
label1: |
| 36 |
foo (); |
| 37 |
label2: |
| 38 |
foo (); |
| 39 |
} |
| 40 |
|
| 41 |
void test_3 (int i) |
| 42 |
{ |
| 43 |
static const int array[] = { &&label0 - &&label0, |
| 44 |
&&label1 - &&label0, |
| 45 |
&&label2 - &&label0 }; |
| 46 |
goto *(&&label0 + array[i]); |
| 47 |
|
| 48 |
label0: |
| 49 |
foo (); |
| 50 |
label1: |
| 51 |
foo (); |
| 52 |
label2: |
| 53 |
foo (); |
| 54 |
} |