PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / pr81292-1.c
blob931e4c37c171f7c7d2cad5f766bc6123002f8189
1 /* { dg-do run } */
2 /* { dg-options "-O2 -fdump-tree-strlen" } */
4 #include "strlenopt.h"
6 char a[10];
8 int __attribute__ ((noinline, noclone))
9 f1 (int n)
11 a[0] = '1';
12 a[1] = '2';
13 return strlen (a + 1) < n ? strlen (a) : 100;
16 int __attribute__ ((noinline, noclone))
17 f2 (char *a, int n)
19 a[0] = '1';
20 a[1] = '2';
21 return strlen (a + 1) < n ? strlen (a) : 100;
24 int
25 main (void)
27 char b[10];
28 strcpy (a + 2, "345");
29 strcpy (b + 2, "34567");
30 if (f1 (100) != 5 || f2 (b, 100) != 7)
31 __builtin_abort ();
32 return 0;
35 /* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen" } } */