* src/SDCCglue.c: fixed bug #1864582: multiple definition of char
[fw/sdcc] / support / regression / tests / staticinit.c
index 758753203d73ea536733fb9f9b5f4b3a77d0a4fc..942d1033f2834fa7e3ae6d7b8e2e0c336cc944fa 100644 (file)
@@ -3,8 +3,16 @@
 
     type: char, int, long
 */
+
 #include <testfwk.h>
 
+/*--------------------------------------------------
+   regression test for #1864582:
+   multiple definition of char cons w. --model-large
+   compile-time test only */
+char *c = (char *) "Booting";
+/*------------------------------------------------*/
+
 static {type} smallDense[] = {
     1, 2, 3, 4, 5, 6
 };
@@ -20,6 +28,9 @@ testSmallDense(void)
     ASSERT(smallDense[5] == 6);
 }
 
+#ifdef SDCC_mcs51
+idata at 0xa0  /* leave space for the stack */
+#endif
 static {type} smallSparse[] = {
     1, 1, 1, 1, 1, 1, 1, 1, 1
 };
@@ -38,6 +49,9 @@ testSmallSparse(void)
     ASSERT(smallSparse[8] == 1);
 }
 
+#ifdef SDCC_mcs51
+idata at 0xd0
+#endif
 static {type} smallSparseZero[] = {
     0, 0, 0, 0, 0, 0, 0, 0, 0
 };
@@ -58,8 +72,16 @@ testSmallSparseZero(void)
     ASSERT(smallSparseZero[6] == 0);
     ASSERT(smallSparseZero[7] == 0);
     ASSERT(smallSparseZero[8] == 0);
+
+    // Make the compiler happy
+    ASSERT(smallSparseZeroTail[0] == 1);
 }
 
+#ifdef SDCC_mcs51
+xdata
+#elif SDCC_pic16
+code
+#endif
 static {type} largeMixed[] = {
     1, 2, 3, 4, 5, 6, 7,       /* 0-6 */
     1, 1, 1, 1, 1, 1, 1, 1,