struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-pr63209.c
blob18e2787b802f7ad42b7a78ed0d7b4569d397b72a
1 /*
2 pr63209.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #pragma disable_warning 85
10 #endif
12 static int Sub(int a, int b) {
13 return b - a;
16 static unsigned Select(unsigned a, unsigned b, unsigned c) {
17 const int pa_minus_pb =
18 Sub((a >> 8) & 0xff, (b >> 8) & 0xff) +
19 Sub((a >> 0) & 0xff, (b >> 0) & 0xff);
20 (void)c;
21 return (pa_minus_pb <= 0) ? a : b;
24 unsigned Predictor(unsigned left, const unsigned* const top) {
25 const unsigned pred = Select(top[1], left, top[0]);
26 return pred;
29 void
30 testTortureExecute (void) {
31 const unsigned top[2] = {0xff7a7a7a, 0xff7a7a7a};
32 const unsigned left = 0xff7b7b7b;
33 const unsigned pred = Predictor(left, top /*+ 1*/);
34 ASSERT (pred == left);