struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-3172.c.in
blobd3084adccca71865d7e3f14bda715bbc69d54868
1 /*
2 bug-3172.c
3 An issue in variable-argument argument promotion. Most backends, when not using --std-cXX, omit integer promotion on explicitly variable cast arguments.
5 promotion: PROMOTE, NOPROMOTE
6 */
8 #include <testfwk.h>
10 #define {promotion}
12 #if defined(__SDCC) && defined(PROMOTE)
13 #pragma std_c99
14 #elif defined(__SDCC) && defined(NOPROMOTE)
15 #pragma std_sdcc99
16 #endif
18 #include <stdarg.h>
20 void
21 receive(const char *s, ...)
23 va_list ap;
25 va_start(ap, s);
26 #if defined(__SDCC) && defined(NOPROMOTE) && !defined(__SDCC_pdk13) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15)
27 #if 0 // Bug #3172 not yet fixed.
28 ASSERT(va_arg(ap, unsigned char) == 0x5a);
29 ASSERT(va_arg(ap, unsigned char) == 0xa5);
30 #endif
31 #else
32 ASSERT(va_arg(ap, int) == 0x5a);
33 ASSERT(va_arg(ap, int) == 0xa5);
34 #endif
35 va_end(ap);
38 void
39 testPass(void)
41 receive(0, (unsigned char)0x5a, (unsigned char)0xa5);
43 unsigned char i1 = 0x5a;
44 unsigned char i2 = 0xa5;
45 receive(0, (unsigned char)i1, (unsigned char)i2);
47 unsigned char *p1 = &i1;
48 unsigned char *p2 = &i2;
49 receive(0, (unsigned char)(*p1), (unsigned char)(*p2));