1 /* 2 pr60822.c from the execute part of the gcc torture tests. 3 */ 4 5 #include <testfwk.h> 6 7 #ifdef __SDCC 8 #pragma std_c99 9 #endif 10 11 #include <limits.h> 12 #include <string.h> 13 14 /* PR rtl-optimization/63843 */ 15 16 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Bug #2874 17 static inline foo(unsigned short v)18unsigned short foo (unsigned short v) 19 { 20 return (v << 8) | (v >> 8); 21 } 22 23 unsigned short bar(unsigned char * x)24bar (unsigned char *x) 25 { 26 unsigned int a; 27 unsigned short b; 28 memcpy (&a, &x[0], sizeof (a)); 29 a ^= 0x80808080U; 30 memcpy (&x[0], &a, sizeof (a)); 31 memcpy (&b, &x[2], sizeof (b)); 32 return foo (b); 33 } 34 #endif 35 36 void testTortureExecute(void)37testTortureExecute (void) 38 { 39 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Bug #2874 40 unsigned char x[8] = { 0x01, 0x01, 0x01, 0x01 }; 41 if (CHAR_BIT == 8 42 && sizeof (short) == 2 43 && sizeof (int) == 4 44 && bar (x) != 0x8181U) 45 ASSERT (0); 46 return; 47 #endif 48 } 49