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