struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-string-opt-17.c
blob71ad0b44987303764cd0f40fe3caef666bf63a25
1 /*
2 string-opt-17.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
11 /* Copyright (C) 2003 Free Software Foundation.
13 Test strcpy optimizations don't evaluate side-effects twice.
15 Written by Jakub Jelinek, June 23, 2003. */
17 #include <string.h>
19 size_t
20 test1 (char *s, size_t i)
22 strcpy (s, "foobarbaz" + i++);
23 return i;
26 size_t
27 check2 (void)
29 static size_t r = 5;
30 if (r != 5)
31 ASSERT (0);
32 return ++r;
35 void
36 test2 (char *s)
38 strcpy (s, "foobarbaz" + check2 ());
41 void
42 testTortureExecute (void)
44 char buf[10];
45 if (test1 (buf, 7) != 8 || memcmp (buf, "az", 3))
46 ASSERT (0);
47 test2 (buf);
48 if (memcmp (buf, "baz", 4))
49 ASSERT (0);
50 return;