summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr81292-1.c
blob: 2a454df88a1b2343114fd48930794c210e060236 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* { dg-do run } */
/* { dg-options "-O2 -fdump-tree-strlen" } */

#include "strlenopt.h"

char a[10];

int __attribute__ ((noinline, noclone))
f1 (int n)
{
  a[0] = '1';
  a[1] = '2';
  return strlen (a + 1) < n ? strlen (a) : 100;
}

int __attribute__ ((noinline, noclone))
f2 (char *a, int n)
{
  a[0] = '1';
  a[1] = '2';
  return strlen (a + 1) < n ? strlen (a) : 100;
}

int
main (void)
{
  char b[10];
  strcpy (a + 2, "345");
  strcpy (b + 2, "34567");
  if (f1 (100) != 5 || f2 (b, 100) != 7)
    __builtin_abort ();
  return 0;
}

/* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen1" } } */