Debian Codegraph @

gcc/testsuite/gcc.dg/strlenopt-97.c

raw
1 /* PR tree-optimization/125079 */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -fdump-tree-strlen1" } */
4 /* { dg-final { scan-tree-dump-times "__builtin___strcpy_chk \\\(" 1 "strlen1" } } */
5 /* { dg-final { scan-tree-dump-not "__builtin___strcpy_chk \\\(\[^\n\r]*, 64\\\)" "strlen1" } } */
6 /* { dg-final { scan-tree-dump-times "__builtin___stpcpy_chk \\\(" 1 "strlen1" } } */
7 /* { dg-final { scan-tree-dump-not "__builtin___stpcpy_chk \\\(\[^\n\r]*, 128\\\)" "strlen1" } } */
8
9 typedef __SIZE_TYPE__ size_t;
10 void foo (char *, int);
11 char *stpcpy (char *, const char *);
12
13 size_t
14 bar (char *r)
15 {
16 char buf[64];
17 foo (buf, 0);
18 size_t ret = __builtin_strlen (buf);
19 __builtin___strcat_chk (buf, r, 64);
20 foo (buf, 1);
21 return ret;
22 }
23
24 size_t
25 baz (char *r)
26 {
27 char buf[128];
28 foo (buf, 2);
29 __builtin___strcat_chk (buf, r, 128);
30 size_t ret = __builtin_strlen (buf);
31 foo (buf, 3);
32 return ret;
33 }