Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/gcc.dg/strlenopt-33g.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
line wrap: on
line source
/* { dg-do run { target *-*-linux* *-*-gnu* } } */ /* { dg-options "-O2 -fdump-tree-strlen" } */ #define USE_GNU #include "strlenopt.h" volatile int v; size_t __attribute__ ((noinline, noclone)) f1 (char *b) { char a[30]; v += 1; // Should be converted to stpcpy. strcpy (a, b); int len1 = strlen (a); a[0] = '_'; a[1] = 0; return len1 + strlen (a); } size_t __attribute__ ((noinline, noclone)) f2 (char *a, char *b) { v += 2; // Should be converted to stpcpy. strcpy (a, b); int len1 = strlen (a); a[0] = '_'; a[1] = 0; return len1 + strlen (a); } int main () { char a[30]; if (f1 ("foo") != 4 || f2 (a, "foobar") != 7) abort (); return 0; } /* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen" } } */ /* { dg-final { scan-tree-dump-times "stpcpy \\(" 2 "strlen" } } */