1 /* { dg-do run } */
2 /* { dg-options "-O2 -fdump-tree-strlen" } */
3
4 #include "strlenopt.h"
5
6 __attribute__((noinline, noclone)) size_t
bar(char * p,char * q)7 bar (char *p, char *q)
8 {
9 size_t l1, l2, l3;
10 char *r = strchr (p, '\0');
11 strcpy (r, "abcde");
12 char *s = strchr (r, '\0');
13 strcpy (s, q);
14 l1 = strlen (p);
15 l2 = strlen (r);
16 l3 = strlen (s);
17 return l1 + l2 + l3;
18 }
19
20 int
main()21 main ()
22 {
23 char buf[16] = "01234";
24
25 if (bar (buf, "56789") != 30)
26 abort ();
27
28 if (memcmp (buf, "01234abcde56789", 16) != 0)
29 abort ();
30
31 return 0;
32 }
33
34 /* { dg-final { scan-tree-dump-times "strlen \\(" 4 "strlen" } } */
35 /* { dg-final { scan-tree-dump-times "memcpy \\(" 1 "strlen" } } */
36 /* { dg-final { scan-tree-dump-times "strcpy \\(" 1 "strlen" } } */
37 /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" } } */
38 /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen" } } */
39 /* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen" } } */
40