Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-struct-ret-1.c
blob4d0b946e5082a75f01f4fb6acc38420ca6b7c25a
1 /*
2 struct-ret-1.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #pragma disable_warning 93
9 #include <stdio.h>
10 #include <string.h>
12 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
13 char out[100];
14 #if !defined(__SDCC_mcs51) && !defined(__SDCC_ds390) && !defined(__SDCC_hc08) && !defined(__SDCC_s08) && !defined(__SDCC_mos6502) && !defined(__SDCC_mos65c02) // Todo: enable when struct parmeters are supported!
16 typedef struct { double d; int i[3]; } B;
17 typedef struct { char c[33],c1; } X;
19 char c1 = 'a';
20 char c2 = 127;
21 char c3 = (char)128;
22 char c4 = (char)255;
23 char c5 = -1;
25 double d1 = 0.1;
26 double d2 = 0.2;
27 double d3 = 0.3;
28 double d4 = 0.4;
29 double d5 = 0.5;
30 double d6 = 0.6;
31 double d7 = 0.7;
32 double d8 = 0.8;
33 double d9 = 0.9;
35 B B1 = {0.1,{1,2,3}};
36 B B2 = {0.2,{5,4,3}};
37 X X1 = {"abcdefghijklmnopqrstuvwxyzABCDEF", 'G'};
38 X X2 = {"123",'9'};
39 X X3 = {"return-return-return",'R'};
41 X f (B a, char b, double c, B d)
43 static X xr = {"return val", 'R'};
44 X r;
45 r = xr;
46 r.c1 = b;
47 sprintf (out, "X f(B,char,double,B):({%g,{%d,%d,%d}},'%c',%g,{%g,{%d,%d,%d}})",
48 a.d, a.i[0], a.i[1], a.i[2], b, c, d.d, d.i[0], d.i[1], d.i[2]);
49 return r;
52 X (*fp) (B, char, double, B) = &f;
53 #endif
54 #endif
56 void
57 testTortureExecute (void)
59 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
60 #if !defined(__SDCC_mcs51) && !defined(__SDCC_ds390) && !defined(__SDCC_hc08) && !defined(__SDCC_s08) && !defined(__SDCC_mos6502) && !defined(__SDCC_mos65c02) // Todo: enable when struct parmeters are supported!
61 X Xr;
62 char tmp[100];
64 Xr = f (B1, c2, d3, B2);
65 strcpy (tmp, out);
66 Xr.c[0] = Xr.c1 = '\0';
67 Xr = (*fp) (B1, c2, d3, B2);
68 if (strcmp (tmp, out))
69 ASSERT (0);
71 return;
72 #endif
73 #endif