1 /* { dg-do run } */ 2 /* { dg-options "-O -fdump-tree-alias-details -fdelete-null-pointer-checks" } */ 3 4 int *i; 5 void __attribute__((noinline)) foo(void)6foo (void) 7 { 8 *i = 1; 9 } 10 int __attribute__((noinline)) bar(int local_p)11bar(int local_p) 12 { 13 int x = 0; 14 int *j; 15 int **p; 16 if (local_p) 17 p = &j; 18 else 19 p = &i; 20 *p = &x; /* This makes x escape. */ 21 foo (); 22 return x; 23 } 24 extern void abort (void); main()25int main() 26 { 27 int k = 2; 28 i = &k; 29 if (bar (1) != 0 || k != 1) 30 abort (); 31 if (bar (0) != 1) 32 abort (); 33 return 0; 34 } 35 36 /* { dg-final { scan-tree-dump "ESCAPED = { NULL ESCAPED NONLOCAL x }" "alias" { target { ! keeps_null_pointer_checks } } } } */ 37 /* { dg-final { scan-tree-dump "ESCAPED = { ESCAPED NONLOCAL x }" "alias" { target { keeps_null_pointer_checks } } } } */ 38