| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-fdump-tree-alias-details" } */ |
| 3 |
/* { dg-skip-if "" { *-*-* } { "-O0" "-fno-fat-lto-objects" } { "" } } */ |
| 4 |
|
| 5 |
extern void abort (void); |
| 6 |
int *g; |
| 7 |
int dummy; |
| 8 |
|
| 9 |
int * __attribute__((noinline,const,noipa)) |
| 10 |
foo_const(int *p) { return p; } |
| 11 |
|
| 12 |
int * __attribute__((noinline,pure,noipa)) |
| 13 |
foo_pure(int *p) { return p + dummy; } |
| 14 |
|
| 15 |
int * __attribute__((noinline,noipa)) |
| 16 |
foo_normal(int *p) { g = p; return p; } |
| 17 |
|
| 18 |
void test_const(void) |
| 19 |
{ |
| 20 |
int i; |
| 21 |
int *p = &i; |
| 22 |
int *q_const = foo_const(p); |
| 23 |
*p = 1; |
| 24 |
*q_const = 2; |
| 25 |
if (*p != 2) |
| 26 |
abort (); |
| 27 |
} |
| 28 |
|
| 29 |
void test(void) |
| 30 |
{ |
| 31 |
int i; |
| 32 |
int *p = &i; |
| 33 |
int *q_normal = foo_normal(p); |
| 34 |
*p = 1; |
| 35 |
*q_normal = 2; |
| 36 |
if (*p != 2) |
| 37 |
abort (); |
| 38 |
} |
| 39 |
|
| 40 |
void test_pure(void) |
| 41 |
{ |
| 42 |
int i; |
| 43 |
int *p = &i; |
| 44 |
int *q_pure = foo_pure(p); |
| 45 |
*p = 1; |
| 46 |
*q_pure = 2; |
| 47 |
if (*p != 2) |
| 48 |
abort (); |
| 49 |
} |
| 50 |
|
| 51 |
int main() |
| 52 |
{ |
| 53 |
test_const(); |
| 54 |
test(); |
| 55 |
test_pure(); |
| 56 |
return 0; |
| 57 |
} |
| 58 |
|
| 59 |
/* { dg-final { scan-tree-dump "q_const_. = { NONLOCAL i }" "alias" } } */ |
| 60 |
/* { dg-final { scan-tree-dump "q_pure_. = { ESCAPED NONLOCAL i }" "alias" } } */ |
| 61 |
/* { dg-final { scan-tree-dump "q_normal_. = { ESCAPED NONLOCAL i }" "alias" } } */ |