struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20121108-1.c
blob4dce8e0621bd165f103abfa329c378c909c75469
1 /*
2 20121108-1.c from the execute part of the gcc torture suite.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
11 #pragma disable_warning 196
12 #pragma disable_warning 84
13 #pragma disable_warning 85
15 #include <stdio.h>
17 char temp[] = "192.168.190.160";
18 unsigned result = (((((192u<<8)|168u)<<8)|190u)<<8)|160u;
20 int strtoul1(const char *a, char **b, int c);
21 int strtoul1(const char *a, char **b, int c)
23 *b = a+3;
24 if (a == temp)
25 return 192;
26 else if (a == temp+4)
27 return 168;
28 else if (a == temp+8)
29 return 190;
30 else if (a == temp+12)
31 return 160;
32 ASSERT (0);
35 int string_to_ip(const char *s);
36 int string_to_ip(const char *s)
38 int addr;
39 char *e;
40 int i;
42 if (s == 0)
43 return(0);
45 for (addr=0, i=0; i<4; ++i) {
46 int val = s ? strtoul1(s, &e, 10) : 0;
47 addr <<= 8;
48 addr |= (val & 0xFF);
49 if (s) {
50 s = (*e) ? e+1 : e;
54 return addr;
57 void
58 testTortureExecute (void)
60 #if !defined( __SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
61 int t = string_to_ip (temp);
62 printf ("%x\n", t);
63 printf ("%x\n", result);
64 if (t != result)
65 ASSERT (0);
66 printf ("WORKS.\n");
67 #endif
70 #if !defined(PORT_HOST)
71 int putchar(int c)
75 #endif