PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / builtins / lib / strstr.c
blob7d35445063e44d8efbc8d4c59753dbedebf2c756
1 extern void abort (void);
2 extern int inside_main;
4 __attribute__ ((__noinline__))
5 char *
6 strstr(const char *s1, const char *s2)
8 const char *p, *q;
10 #ifdef __OPTIMIZE__
11 if (inside_main)
12 abort ();
13 #endif
15 /* deliberately dumb algorithm */
16 for (; *s1; s1++)
18 p = s1, q = s2;
19 while (*q && *p)
21 if (*q != *p)
22 break;
23 p++, q++;
25 if (*q == 0)
26 return (char *)s1;
28 return 0;