| 1 |
/* PR c/90737 - inconsistent address of a local converted to intptr_t |
| 2 |
between callee and caller |
| 3 |
{ dg-do compile } |
| 4 |
{ dg-options "-O1 -Wall -Wreturn-local-addr -fdump-tree-optimized" } */ |
| 5 |
|
| 6 |
typedef __INTPTR_TYPE__ intptr_t; |
| 7 |
|
| 8 |
static inline intptr_t |
| 9 |
return_addr_local_as_int (void) |
| 10 |
{ |
| 11 |
int i; |
| 12 |
if ((intptr_t)&i == 0) |
| 13 |
__builtin_abort (); |
| 14 |
|
| 15 |
return (intptr_t)&i; |
| 16 |
} |
| 17 |
|
| 18 |
void get_addr_local_as_int (void) |
| 19 |
{ |
| 20 |
intptr_t i = return_addr_local_as_int (); |
| 21 |
if (i == 0) |
| 22 |
__builtin_abort (); |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
static inline intptr_t |
| 27 |
return_addr_label_as_int (void) |
| 28 |
{ |
| 29 |
label: |
| 30 |
if ((intptr_t)&&label == 0) |
| 31 |
__builtin_abort (); |
| 32 |
|
| 33 |
return (intptr_t)&&label; |
| 34 |
} |
| 35 |
|
| 36 |
void get_addr_label_as_int (void) |
| 37 |
{ |
| 38 |
intptr_t i = return_addr_label_as_int (); |
| 39 |
if (i == 0) |
| 40 |
__builtin_abort (); |
| 41 |
} |
| 42 |
|
| 43 |
/* Verify that the functions that return the address of the label |
| 44 |
or local variable have been optimized away and so have the calls |
| 45 |
to abort. |
| 46 |
{ dg-final { scan-tree-dump-not "return_addr_" "optimized" } } |
| 47 |
{ dg-final { scan-tree-dump-not "abort" "optimized" } } */ |