111
|
1 /* { dg-do run { target *-*-linux* *-*-gnu* } } */
|
|
2 /* { dg-do run } */
|
|
3 /* { dg-options "-O2 -fdump-tree-strlen" } */
|
|
4
|
|
5 #define USE_GNU
|
|
6 #include "strlenopt.h"
|
|
7
|
|
8 volatile int v;
|
|
9
|
|
10 size_t __attribute__ ((noinline, noclone))
|
|
11 f1 (char *b)
|
|
12 {
|
|
13 char a[30];
|
|
14 v += 1;
|
|
15 // Should be converted to stpcpy.
|
|
16 strcpy (a, b);
|
|
17 int len1 = strlen (a);
|
|
18 a[0] = '_';
|
|
19 a[1] = 0;
|
|
20 return len1 + strlen (a);
|
|
21 }
|
|
22
|
|
23 size_t __attribute__ ((noinline, noclone))
|
|
24 f2 (char *a, char *b)
|
|
25 {
|
|
26 v += 2;
|
|
27 // Should be converted to stpcpy.
|
|
28 strcpy (a, b);
|
|
29 int len1 = strlen (a);
|
|
30 a[0] = '_';
|
|
31 a[1] = 0;
|
|
32 return len1 + strlen (a);
|
|
33 }
|
|
34
|
|
35 int
|
|
36 main ()
|
|
37 {
|
|
38 char a[30];
|
|
39 if (f1 ("foo") != 4 || f2 (a, "foobar") != 7)
|
|
40 abort ();
|
|
41 return 0;
|
|
42 }
|
|
43
|
|
44 /* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen" } } */
|
|
45 /* { dg-final { scan-tree-dump-times "stpcpy \\(" 2 "strlen" } } */
|