[C++ PATCH] Deprecate -ffriend-injection
[official-gcc.git] / gcc / testsuite / gcc.dg / strlenopt-28.c
blob03fb01781bd4fe92687fe30c1fb89573965139e9
1 /* { dg-do run } */
2 /* { dg-options "-O2 -fdump-tree-strlen" } */
4 #include "strlenopt.h"
6 volatile int v;
8 size_t
9 f1 (void)
11 char a[30];
12 v += 1;
13 memcpy (a, "1234567", 8);
14 memcpy (a + 7, "89abcdefg", 10);
15 memcpy (a + 16, "h", 2);
16 return strlen (a); // This strlen should be optimized into 17.
19 size_t
20 f2 (void)
22 char a[30];
23 v += 2;
24 strcpy (a, "1234567");
25 strcpy (a + 7, "89abcdefg");
26 strcpy (a + 16, "h");
27 return strlen (a); // This strlen should be optimized into 17.
30 size_t
31 f3 (char *a)
33 v += 3;
34 memcpy (a, "1234567", 8);
35 memcpy (a + 7, "89abcdefg", 10);
36 memcpy (a + 16, "h", 2);
37 return strlen (a); // This strlen should be optimized into 17.
40 size_t
41 f4 (char *a)
43 v += 4;
44 strcpy (a, "1234567");
45 strcpy (a + 7, "89abcdefg");
46 strcpy (a + 16, "h");
47 return strlen (a); // This strlen should be optimized into 17.
50 int
51 main ()
53 char a[30];
54 if (f1 () != 17 || f2 () != 17 || f3 (a) != 17 || f4 (a) != 17)
55 abort ();
56 return 0;
59 /* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen" } } */