2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / builtins / string-asm-1.c
blob3c3e45dfa5d551c1302186ed42e05191fd18f83b
1 /* Copyright (C) 2000, 2003 Free Software Foundation.
3 Ensure all expected transformations of builtin strstr occur and
4 perform correctly in presence of redirect. */
6 #define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname)
7 #define ASMNAME2(prefix, cname) STRING (prefix) cname
8 #define STRING(x) #x
10 typedef __SIZE_TYPE__ size_t;
11 extern void abort (void);
12 extern char *strstr (const char *, const char *)
13 __asm (ASMNAME ("my_strstr"));
15 const char *p = "rld", *q = "hello world";
17 void
18 main_test (void)
20 const char *const foo = "hello world";
22 if (strstr (foo, "") != foo)
23 abort ();
24 if (strstr (foo + 4, "") != foo + 4)
25 abort ();
26 if (strstr (foo, "h") != foo)
27 abort ();
28 if (strstr (foo, "w") != foo + 6)
29 abort ();
30 if (strstr (foo + 6, "o") != foo + 7)
31 abort ();
32 if (strstr (foo + 1, "world") != foo + 6)
33 abort ();
34 if (strstr (foo + 2, p) != foo + 8)
35 abort ();
36 if (strstr (q, "") != q)
37 abort ();
38 if (strstr (q + 1, "o") != q + 4)
39 abort ();
41 /* Test at least one instance of the __builtin_ style. We do this
42 to ensure that it works and that the prototype is correct. */
43 if (__builtin_strstr (foo + 1, "world") != foo + 6)
44 abort ();