* src/SDCCglue.c (printIvalBitFields): fixed bug 1806631
[fw/sdcc] / support / regression / tests / zeropad.c
index f791859d106c7d56ce64ff639cef397779f35584..fef5ff50f62b8e766c6af6cfb5f549dc5676a82a 100644 (file)
@@ -1,15 +1,15 @@
 /** Zeropad tests.
 
-    storage: idata, xdata, code,
+    storage: idata, pdata, xdata, code,
 */
 #ifndef STORAGE
 #define STORAGE {storage}
 #endif
 
-#if defined __GNUC__
-  #define FLEXARRAY (__GNUC__ >= 3)
-  //since g fails on GCC 2.95.4 on alpha and I don't know how to detect alpha...
-  #define TEST_G    (__GNUC__ >= 3)
+#if defined (__GNUC__) && defined (__alpha__) && (__GNUC__ < 3)
+  /* since g fails on GCC 2.95.4 on alpha... */
+  #define FLEXARRAY 0
+  #define TEST_G    0
 #else
   #define FLEXARRAY 1
   #define TEST_G    1
 typedef unsigned int size_t;
 #define offsetof(s,m)   (size_t)&(((s *)0)->m)
 
-#if defined(PORT_HOST) || defined(SDCC_z80) || defined(SDCC_gbz80)
-# define idata
-# define xdata
-# define code
+const char *string1 = "\x00\x01";
+const char string2[] = "\x00\x01";
+
+#ifndef PORT_HOST
+#pragma disable_warning 147 //no warning about excess initializers (W_EXCESS_INITIALIZERS)
+//array will be truncated but warning will be suppressed
+//if truncation is incorrect, other ASSERTs will fail with high probability
+char STORAGE trunc[2] = {'a', 'b', 'c'};
 #endif
 
 char STORAGE array[5] = {'a', 'b', 'c'};
@@ -64,6 +68,9 @@ struct y STORAGE incompletestruct = {
 void
 testZeropad(void)
 {
+  ASSERT(string1[1] == '\x01');
+  ASSERT(string2[1] == '\x01');
+
   ASSERT(array[2] == 'c');
   ASSERT(array[4] == 0);