preprocessor: Create the parser before handling command-line includes [PR115312]
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / builtins / strstr-asm-lib.c
bloba912332466ac7521b55af18b0597dca23021d707
1 extern void abort (void);
2 typedef __SIZE_TYPE__ size_t;
3 extern size_t strlen(const char *);
4 extern char *strchr(const char *, int);
5 extern int strcmp(const char *, const char *);
6 extern int strncmp(const char *, const char *, size_t);
7 extern int inside_main;
8 extern const char *p;
10 __attribute__ ((used))
11 char *
12 my_strstr (const char *s1, const char *s2)
14 const size_t len = strlen (s2);
16 #ifdef __OPTIMIZE__
17 /* If optimizing, we should be called only in the strstr (foo + 2, p)
18 case. All other cases should be optimized. */
19 if (inside_main)
20 if (s2 != p || strcmp (s1, "hello world" + 2) != 0)
21 abort ();
22 #endif
23 if (len == 0)
24 return (char *) s1;
25 for (s1 = strchr (s1, *s2); s1; s1 = strchr (s1 + 1, *s2))
26 if (strncmp (s1, s2, len) == 0)
27 return (char *) s1;
28 return (char *) 0;
31 char *
32 strstr (const char *s1, const char *s2)
34 if (inside_main)
35 abort ();
37 return my_strstr (s1, s2);