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, "foo.bar"); 14 a[3] = b; 15 a[4] = 0; 16 return strlen (a); 17 } 18 19 size_t __attribute__ ((noinline, noclone)) f2(char * a,char b)20f2 (char *a, char b) 21 { 22 v += 2; 23 strcpy (a, "foo.bar"); 24 a[3] = b; 25 a[4] = 0; 26 return strlen (a); 27 } 28 29 int main()30main () 31 { 32 char a[30]; 33 if (f1 ('_') != 4 || f1 (0) != 3 || f2 (a, '_') != 4 || f2 (a, 0) != 3) 34 abort (); 35 return 0; 36 } 37 38 /* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen1" } } */ 39