modernc.org/ccgo/v3@v3.16.14/lib/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/execute/builtins/strchr.c (about) 1 /* Copyright (C) 2000, 2003 Free Software Foundation. 2 3 Ensure all expected transformations of builtin strchr and index 4 occur and perform correctly. 5 6 Written by Jakub Jelinek, 11/7/2000. */ 7 8 extern void abort (void); 9 extern char *strchr (const char *, int); 10 extern char *index (const char *, int); 11 12 void 13 main_test (void) 14 { 15 const char *const foo = "hello world"; 16 17 if (strchr (foo, 'x')) 18 abort (); 19 if (strchr (foo, 'o') != foo + 4) 20 abort (); 21 if (strchr (foo + 5, 'o') != foo + 7) 22 abort (); 23 if (strchr (foo, '\0') != foo + 11) 24 abort (); 25 /* Test only one instance of index since the code path is the same 26 as that of strchr. */ 27 if (index ("hello", 'z') != 0) 28 abort (); 29 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) 33 abort (); 34 if (__builtin_index (foo, 'o') != foo + 4) 35 abort (); 36 }