Rebase.
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / isolate-2.c
blob912d98e224617121ab7d3806f967dd8051276629
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fisolate-erroneous-paths-attribute -fdump-tree-isolate-paths -fdump-tree-phicprop1" } */
3 /* { dg-skip-if "" keeps_null_pointer_checks } */
6 int z;
7 int y;
9 int * foo(int a) __attribute__((returns_nonnull));
10 int * bar(void) __attribute__((returns_nonnull));
12 int *
13 foo(int a)
16 switch (a)
18 case 0:
19 return &z;
20 default:
21 return (int *)0;
26 int *
27 bar (void)
29 return 0;
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.
37 We also verify that after isolation phi-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 "phicprop1"} } */
41 /* { dg-final { cleanup-tree-dump "isolate-paths" } } */
42 /* { dg-final { cleanup-tree-dump "phicprop1" } } */