1 /* { dg-do run } */ 2 /* { dg-options "-O2 -fdump-tree-strlen" } */ 3 4 #include "strlenopt.h" 5 6 volatile int v; 7 8 size_t __attribute__ ((noinline, noclone)) f1(char * b)9f1 (char *b) 10 { 11 char a[30]; 12 v += 1; 13 strcpy (a, b); 14 // This needs to stay. 15 int len1 = strlen (a); 16 a[0] = '_'; 17 a[1] = 0; 18 return len1 + strlen (a); 19 } 20 21 size_t __attribute__ ((noinline, noclone)) f2(char * a,char * b)22f2 (char *a, char *b) 23 { 24 v += 2; 25 strcpy (a, b); 26 // This needs to stay. 27 int len1 = strlen (a); 28 a[0] = '_'; 29 a[1] = 0; 30 return len1 + strlen (a); 31 } 32 33 int main()34main () 35 { 36 char a[30]; 37 if (f1 ("foo") != 4 || f2 (a, "foobar") != 7) 38 abort (); 39 return 0; 40 } 41 42 /* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen1" } } */ 43