1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdelete-null-pointer-checks -fisolate-erroneous-paths-attribute -fdump-tree-isolate-paths -fdump-tree-forwprop3" } */
3 /* { dg-skip-if "" keeps_null_pointer_checks } */
4
5
6 int z;
7 int y;
8
9 int * foo(int a) __attribute__((returns_nonnull));
10 int * bar(void) __attribute__((returns_nonnull));
11
12 int *
foo(int a)13 foo(int a)
14
15 {
16 switch (a)
17 {
18 case 0:
19 return &z;
20 default:
21 return (int *)0;
22 }
23 }
24
25
26 int *
bar(void)27 bar (void)
28 {
29 return 0;
30 }
31
32 /* We testing that the path isolation code can take advantage of the
33 returns non-null attribute to isolate a path where NULL flows into
34 a return statement. We test this twice, once where the NULL flows
35 from a PHI, the second with an explicit return 0 in the IL.
36
37 We also verify that after isolation cprop simplifies the
38 return statement so that it returns &z directly. */
39 /* { dg-final { scan-tree-dump-times "__builtin_trap" 2 "isolate-paths"} } */
40 /* { dg-final { scan-tree-dump-times "return &z;" 1 "forwprop3"} } */
41
42
43