Match: Support imm form for unsigned scalar .SAT_ADD
[official-gcc.git] / gcc / testsuite / gcc.dg / strlenopt-8.c
blobb47a23b231120dee88359aab0dfdcb35f83d434c
1 /* { dg-do run } */
2 /* { dg-options "-O2 -fdump-tree-strlen" } */
4 #include "strlenopt.h"
6 /* Yes, there are people who write code like this. */
8 __attribute__((noinline, noclone)) char *
9 foo (int r)
11 char buf[10] = "";
12 strcat (buf, r ? "r" : "w");
13 strcat (buf, "b");
14 return strdup (buf);
17 __attribute__((noinline, noclone)) char *
18 bar (int r)
20 char buf[10] = {};
21 strcat (buf, r ? "r" : "w");
22 strcat (buf, "b");
23 return strdup (buf);
26 int
27 main ()
29 char *q = foo (1);
30 if (q != NULL)
32 if (strcmp (q, "rb"))
33 abort ();
34 free (q);
36 q = bar (0);
37 if (q != NULL)
39 if (strcmp (q, "wb"))
40 abort ();
41 free (q);
43 return 0;
46 /* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen1" } } */
47 /* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */
48 /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */
49 /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */
50 /* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */