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