PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / pr19831-3.c
blobf5cb72daa330d4dd8b3155f8cf2f05a6f6edec55
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fno-ipa-icf -fdump-tree-optimized" } */
4 void test2(void)
6 int *p = __builtin_malloc (sizeof (int) * 4);
7 if (p == (void *)0)
8 __builtin_abort ();
9 __builtin_free (p);
12 void test5(int b)
14 int *p = __builtin_malloc (sizeof (int) * 4);
15 if (p)
16 __builtin_free (p);
19 void test6(void)
21 int *p = __builtin_malloc (sizeof (int) * 4);
22 if (p == (void *)0)
23 __builtin_abort ();
24 if (p)
25 __builtin_free (p);
28 /* We should be able to remove all malloc/free pairs with CDDCE.
29 Assume p was non-NULL for test2.
30 For test5, it doesn't matter if p is NULL or non-NULL. */
32 /* { dg-final { scan-tree-dump-times "free" 0 "optimized" { xfail *-*-* } } } */
33 /* { dg-final { scan-tree-dump-times "malloc" 0 "optimized" { xfail *-*-* } } } */
35 /* But make sure we don't partially optimize for now. */
37 /* { dg-final { scan-tree-dump-times "free" 3 "optimized" } } */
38 /* { dg-final { scan-tree-dump-times "malloc" 3 "optimized" } } */