2 string-opt-5.c from the execute part of the gcc torture tests.
11 /* Copyright (C) 2000 Free Software Foundation.
13 Ensure builtin strlen, strcmp, strchr, strrchr and strncpy
16 Written by Jakub Jelinek, 11/7/2000. */
22 const char *bar
= "hi world";
26 testTortureExecute (void)
28 #if !defined(__SDCC_pic16) && !defined(__SDCC_pdk14) // Lack of memory
29 const char *const foo
= "hello world";
30 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
34 if (strlen (bar
) != 8)
36 if (strlen (bar
+ (++x
& 2)) != 6)
40 if (strlen (foo
+ (x
++, 6)) != 5)
44 if (strlen (foo
+ (++x
& 1)) != 10)
48 if (strcmp (foo
+ (x
-= 6), "lo world"))
52 if (strcmp (foo
, bar
) >= 0)
54 if (strcmp (foo
, bar
+ (x
++ & 1)) >= 0)
58 if (strchr (foo
+ (x
++ & 7), 'l') != foo
+ 9)
62 if (strchr (bar
, 'o') != bar
+ 4)
64 if (strchr (bar
, '\0') != bar
+ 8)
66 if (strrchr (bar
, 'x'))
68 if (strrchr (bar
, 'o') != bar
+ 4)
70 if (strcmp (foo
+ (x
++ & 1), "ello world" + (--y
& 1)))
74 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
79 if (strncpy (dst
+ 1, foo
+ (x
++ & 3), 4) != dst
+ 1
81 || strcmp (dst
+ 1, "ello "))
83 memset (dst
, ' ', sizeof dst
);
84 if (strncpy (dst
+ (++x
& 1), (y
++ & 3) + "foo", 10) != dst
+ 1
87 || memcmp (dst
, " oo\0\0\0\0\0\0\0\0 ", 12))
89 memset (dst
, ' ', sizeof dst
);
90 if (strncpy (dst
, "hello", 8) != dst
|| memcmp (dst
, "hello\0\0\0 ", 9))
93 memset (buf
, ' ', sizeof buf
);
94 if (memset (buf
, x
++, ++y
) != buf
97 || memcmp (buf
, "!!!", 3))
99 if (memset (buf
+ y
++, '-', 8) != buf
+ 3
101 || memcmp (buf
, "!!!--------", 11))
104 if (memset (buf
+ ++x
, 0, y
++) != buf
+ 11
107 || memcmp (buf
+ 8, "---\0\0\0", 7))
110 if (memset (buf
+ (x
+= 4), 0, 6) != buf
+ 15
112 || memcmp (buf
+ 10, "-\0\0\0\0\0\0\0\0\0", 11))