struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-920810-1.c
blob2573c400c542dff3560f0b8426240ab7f8b80540
1 /*
2 920810-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 #include <stdio.h>
12 #include <string.h>
13 #include <stdlib.h>
15 #if !defined(__SDCC_pdk14) // Lack of memory
16 typedef struct { void* super; int name; int size; } t;
18 t* f(t*clas, int size)
20 t* child = (t*)malloc(size);
21 memcpy(child, clas, clas->size);
22 child->super=clas;
23 child->name=0;
24 child->size=size;
25 return child;
27 #endif
29 void
30 testTortureExecute (void)
32 #if !defined(__SDCC_pdk14) // Lack of memory
33 t foo, *bar;
34 memset(&foo, 37, sizeof(t));
35 foo.size=sizeof(t);
36 bar=f(&foo,sizeof(t));
37 ASSERTFALSE (bar->super!=&foo||bar->name!=0||bar->size!=sizeof(t));
38 return;
39 #endif