PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / pr24287.c
blob6fc6be1edea950506ade42eb2bf1cd2a9f5ec793
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-optimized" } */
3 int g1(int);
4 int h(int *a, int *b)__attribute__((pure));
5 void link_error();
7 /* The calls to link_error should be eliminated, since nothing escapes to
8 non-pure functions. */
9 int g(void)
11 int t = 0, t1 = 2;
12 /* ??? That's not true. The pointers escape to the integer return
13 value which we do not track in PTA. */
14 int t2 = h(&t, &t1);
15 if (t != 0)
16 link_error ();
17 if (t1 != 2)
18 link_error ();
19 /* ??? And it would finally escape here even if we did. */
20 g1(t2);
21 if (t != 0)
22 link_error ();
23 if (t1 != 2)
24 link_error ();
25 return t2 == 2;
27 /* We are allowed to optimize the first two link_error calls. */
28 /* { dg-final { scan-tree-dump-times "link_error" 2 "optimized" } } */