1 /* Copyright (C) 2000 Free Software Foundation.
3 Ensure all expected transformations of builtin strspn occur and
6 Written by Kaveh R. Ghazi, 11/27/2000. */
8 extern void abort (void);
9 typedef __SIZE_TYPE__
size_t;
10 extern size_t strspn (const char *, const char *);
11 extern char *strcpy (char *, const char *);
15 const char *const s1
= "hello world";
18 if (strspn (s1
, "hello") != 5)
20 if (strspn (s1
+4, "hello") != 1)
22 if (strspn (s1
, "z") != 0)
24 if (strspn (s1
, "hello world") != 11)
26 if (strspn (s1
, "") != 0)
29 if (strspn (dst
, "") != 0)
31 strcpy (dst
, s1
); d2
= dst
;
32 if (strspn (++d2
, "") != 0 || d2
!= dst
+1)
34 strcpy (dst
, s1
); d2
= dst
;
35 if (strspn (++d2
+5, "") != 0 || d2
!= dst
+1)
37 if (strspn ("", s1
) != 0)
40 if (strspn ("", dst
) != 0)
42 strcpy (dst
, s1
); d2
= dst
;
43 if (strspn ("", ++d2
) != 0 || d2
!= dst
+1)
45 strcpy (dst
, s1
); d2
= dst
;
46 if (strspn ("", ++d2
+5) != 0 || d2
!= dst
+1)
49 /* Test at least one instance of the __builtin_ style. We do this
50 to ensure that it works and that the prototype is correct. */
51 if (__builtin_strspn (s1
, "hello") != 5)
58 /* When optimizing, all the above cases should be transformed into
59 something else. So any remaining calls to the original function
61 __attribute__ ((noinline
))
63 strspn (const char *s1
, const char *s2
)