PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / builtins / strpbrk.c
blobcc963a9af5e93590d7d35ad104afd404d2560109
1 /* Copyright (C) 2000 Free Software Foundation.
3 Ensure all expected transformations of builtin strpbrk occur and
4 perform correctly.
6 Written by Kaveh R. Ghazi, 11/6/2000. */
8 extern void abort(void);
9 extern char *strpbrk (const char *, const char *);
10 extern int strcmp (const char *, const char *);
12 void fn (const char *foo, const char *const *bar)
14 if (strcmp(strpbrk ("hello world", "lrooo"), "llo world") != 0)
15 abort();
16 if (strpbrk (foo, "") != 0)
17 abort();
18 if (strpbrk (foo + 4, "") != 0)
19 abort();
20 if (strpbrk (*bar--, "") != 0)
21 abort();
22 if (strpbrk (*bar, "h") != foo)
23 abort();
24 if (strpbrk (foo, "h") != foo)
25 abort();
26 if (strpbrk (foo, "w") != foo + 6)
27 abort();
28 if (strpbrk (foo + 6, "o") != foo + 7)
29 abort();
31 /* Test at least one instance of the __builtin_ style. We do this
32 to ensure that it works and that the prototype is correct. */
33 if (__builtin_strpbrk (foo + 6, "o") != foo + 7)
34 abort();
37 void
38 main_test (void)
40 const char *const foo[] = { "hello world", "bye bye world" };
41 fn (foo[0], foo + 1);