struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-3547.c
blob8232684f96a45b0245e1878593ba158e1cd3587f
1 /* bug-3547.c
2 Codegen for sm83 could generate an "ex de, hl" (a Z80 instruction not supported on SM83) when passing a struct as function argument while register hl holds another variable.
3 This would then result in an error message from the assembler.
4 */
6 #include <testfwk.h>
8 #pragma disable_warning 85
10 #if !defined(__SDCC_pdk14) && !(defined(__SDCC_mcs51) && defined(__SDCC_MODEL_SMALL)) // Lack of memory
12 #define LINE_SIZE 32
13 #define POINT_AMOUNT 14
14 #define SIDE_AMOUNT 22
16 typedef struct
18 int x;
19 int y;
20 int z;
21 } Point3D;
23 void render(Point3D p1, Point3D p2)
27 void f(void)
29 unsigned int angles[3] = {47, 10, 0};
30 const unsigned char sides[][2] = {
31 {7, 8},
32 {8, 9},
33 {8, 10},
34 {10, 11},
35 {11, 9},
36 {9, 6},
37 {6, 0},
38 {0, 1},
39 {1, 7},
40 {7, 4},
41 {6, 5},
42 {0, 3},
43 {1, 2},
44 {4, 5},
45 {5, 12},
46 {12, 4},
47 {13, 2},
48 {13, 3},
49 {13, 12},
50 {5, 3},
51 {3, 2},
52 {2, 4}};
54 Point3D points[POINT_AMOUNT] = {
55 {LINE_SIZE, LINE_SIZE, 0}, //0
56 {0, LINE_SIZE, 0}, //1
57 {0, LINE_SIZE, LINE_SIZE}, //2
58 {LINE_SIZE, LINE_SIZE, LINE_SIZE}, //3
59 {0, 0, LINE_SIZE}, //4
60 {LINE_SIZE, 0, LINE_SIZE}, //5
61 {LINE_SIZE, 0, 0}, //6
62 {0, 0, 0}, //7
63 {LINE_SIZE / 4, 0, 0}, //8
64 {(LINE_SIZE / 4) + (LINE_SIZE /4), 0, 0}, //9
65 {LINE_SIZE / 4, 0, LINE_SIZE/2},//10
66 {(LINE_SIZE / 4) + (LINE_SIZE /4), 0, LINE_SIZE/2},//11
67 {(LINE_SIZE / 2), 0, LINE_SIZE + (LINE_SIZE/2)}, //12
68 {(LINE_SIZE / 2), LINE_SIZE, LINE_SIZE + (LINE_SIZE/2)}}; //13
70 while (1)
72 for (unsigned char i = 0; i < SIDE_AMOUNT; i++)
74 render(points[sides[i][0]], points[sides[i][1]]); // Invalid assembler instruction generated here.
78 #endif
80 void
81 testBug (void)