Make tree-ssa-strlen.c handle partial unterminated strings
[official-gcc.git] / gcc / testsuite / gcc.dg / strlenopt-34.c
blobc9433c0399e01e194dc067a7aada9316f8c06f8d
1 /* { dg-do run } */
2 /* { dg-options "-O2 -fdump-tree-strlen" } */
4 #include "strlenopt.h"
6 volatile int v;
8 size_t __attribute__ ((noinline, noclone))
9 f1 (char b)
11 char a[30];
12 v += 1;
13 strcpy (a, "foo.bar");
14 a[3] = b;
15 a[4] = 0;
16 return strlen (a);
19 size_t __attribute__ ((noinline, noclone))
20 f2 (char *a, char b)
22 v += 2;
23 strcpy (a, "foo.bar");
24 a[3] = b;
25 a[4] = 0;
26 return strlen (a);
29 int
30 main ()
32 char a[30];
33 if (f1 ('_') != 4 || f1 (0) != 3 || f2 (a, '_') != 4 || f2 (a, 0) != 3)
34 abort ();
35 return 0;
38 /* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen" } } */