void main_test (void) { const char *const foo = "hello world"; if (strstr (foo, "") != foo) abort (); if (strstr (foo + 4, "") != foo + 4) abort (); if (strstr (foo, "h") != foo) abort (); if (strstr (foo, "w") != foo + 6) abort (); if (strstr (foo + 6, "o") != foo + 7) abort (); if (strstr (foo + 1, "world") != foo + 6) abort (); if (strstr (foo + 2, p) != foo + 8) abort (); if (strstr (q, "") != q) abort (); if (strstr (q + 1, "o") != q + 4) abort (); if (__builtin_strstr (foo + 1, "world") != foo + 6) abort (); }
void f5(char *s) { char *t1 = __builtin_strstr (s, "hello"); void foo_f5(void); if (t1 != s) foo_f5(); }
void c (void) { __builtin_strcat (d, "12345"); if (__builtin_strstr (b, d) == b) a (); }
_Bool f7(char *s) { void foo_f7(char *); char *t1 = __builtin_strstr (s, "hello"); foo_f7 (t1); return (t1 == s); }
_Bool f4() { char *foo_f4(void); char *t1 = foo_f4(); char *t2 = __builtin_strstr (t1, "hello"); _Bool t3 = t2 == t1; return t3; }
void foo (void) { const char *p = "abcdef"; const char *q = "def"; p++; q++; if (__builtin_strstr (p, q) != p + 3) link_error (); }
void foo (struct A *p) { char s[4096]; const char *u = p->a; const char *t; while ((t = __builtin_strstr (u, "gcc/"))) u = t + 4; /* Verfiy the following doesn't emit a warning. */ __builtin_sprintf (s, "%s:%i (%s)", u, p->b, p->c); bar (s); }
void main_test (void) { const char *const foo = "hello world"; if (strstr (foo, "") != foo) abort(); if (strstr (foo + 4, "") != foo + 4) abort(); if (strstr (foo, "h") != foo) abort(); if (strstr (foo, "w") != foo + 6) abort(); if (strstr (foo + 6, "o") != foo + 7) abort(); if (strstr (foo + 1, "world") != foo + 6) abort(); /* Test at least one instance of the __builtin_ style. We do this to ensure that it works and that the prototype is correct. */ if (__builtin_strstr (foo + 1, "world") != foo + 6) abort(); }
// CHECK: call i8* @strstr{{.*}} nounwind char* f2(char* a, char* b) { return __builtin_strstr(a, b); }
_Bool f6(char *s, char *t) { return __builtin_strstr (s, t) == s; }
_Bool f1(char *s) { return __builtin_strstr (s, "hello") == s; }
_Bool f3(char *s) { return s != __builtin_strstr (s, "hello"); }
_Bool f2(char *s) { return s == __builtin_strstr (s, "hello"); }
char * baz (const char *p) { return __builtin_strstr (p, "d"); }
char * bar (const char *p) { return __builtin_strstr (p, ""); }