1 /* Copyright (C) 2000, 2003 Free Software Foundation.
3 Ensure all expected transformations of builtin strchr and index
4 occur and perform correctly.
6 Written by Jakub Jelinek, 11/7/2000. */
8 extern void abort (void);
9 extern char *strchr (const char *, int);
10 extern char *index (const char *, int);
15 const char *const foo
= "hello world";
17 if (strchr (foo
, 'x'))
19 if (strchr (foo
, 'o') != foo
+ 4)
21 if (strchr (foo
+ 5, 'o') != foo
+ 7)
23 if (strchr (foo
, '\0') != foo
+ 11)
25 /* Test only one instance of index since the code path is the same
27 if (index ("hello", 'z') != 0)
30 /* Test at least one instance of the __builtin_ style. We do this
31 to ensure that it works and that the prototype is correct. */
32 if (__builtin_strchr (foo
, 'o') != foo
+ 4)
34 if (__builtin_index (foo
, 'o') != foo
+ 4)