x86: Tune Skylake, Cannonlake and Icelake as Haswell
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / builtins / strcspn.c
blobbe392546a545577011a89e5f4117441be057b32a
1 /* Copyright (C) 2000, 2004 Free Software Foundation.
3 Ensure all expected transformations of builtin strcspn occur and
4 perform correctly.
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 *);
13 void
14 main_test (void)
16 const char *const s1 = "hello world";
17 char dst[64], *d2;
19 if (strcspn (s1, "hello") != 0)
20 abort();
21 if (strcspn (s1, "z") != 11)
22 abort();
23 if (strcspn (s1+4, "z") != 7)
24 abort();
25 if (strcspn (s1, "hello world") != 0)
26 abort();
27 if (strcspn (s1, "") != 11)
28 abort();
29 strcpy (dst, s1);
30 if (strcspn (dst, "") != 11)
31 abort();
32 strcpy (dst, s1); d2 = dst;
33 if (strcspn (++d2, "") != 10 || d2 != dst+1)
34 abort();
35 strcpy (dst, s1); d2 = dst;
36 if (strcspn (++d2+5, "") != 5 || d2 != dst+1)
37 abort();
38 if (strcspn ("", s1) != 0)
39 abort();
40 strcpy (dst, s1);
41 if (strcspn ("", dst) != 0)
42 abort();
43 strcpy (dst, s1); d2 = dst;
44 if (strcspn ("", ++d2) != 0 || d2 != dst+1)
45 abort();
46 strcpy (dst, s1); d2 = dst;
47 if (strcspn ("", ++d2+5) != 0 || d2 != dst+1)
48 abort();
50 /* Test at least one instance of the __builtin_ style. We do this
51 to ensure that it works and that the prototype is correct. */
52 if (__builtin_strcspn (s1, "z") != 11)
53 abort();