1 /* Copyright (C) 2000 Free Software Foundation.
3 Ensure all expected transformations of builtin strcspn 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 strcspn (const char *, const char *);
11 extern char *strcpy (char *, const char *);
15 const char *const s1 = "hello world";
18 if (strcspn (s1, "hello") != 0)
20 if (strcspn (s1, "z") != 11)
22 if (strcspn (s1+4, "z") != 7)
24 if (strcspn (s1, "hello world") != 0)
26 if (strcspn (s1, "") != 11)
29 if (strcspn (dst, "") != 11)
31 strcpy (dst, s1); d2 = dst;
32 if (strcspn (++d2, "") != 10 || d2 != dst+1)
34 strcpy (dst, s1); d2 = dst;
35 if (strcspn (++d2+5, "") != 5 || d2 != dst+1)
37 if (strcspn ("", s1) != 0)
40 if (strcspn ("", dst) != 0)
42 strcpy (dst, s1); d2 = dst;
43 if (strcspn ("", ++d2) != 0 || d2 != dst+1)
45 strcpy (dst, s1); d2 = dst;
46 if (strcspn ("", ++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_strcspn (s1, "z") != 11)
58 /* When optimizing, all the above cases should be transformed into
59 something else. So any remaining calls to the original function
62 strcspn (const char *s1, const char *s2)