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