* src/SDCCglue.c, support/regression/tests/bug2655200.c:
authorfrief <frief@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 12 Mar 2009 20:57:55 +0000 (20:57 +0000)
committerfrief <frief@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 12 Mar 2009 20:57:55 +0000 (20:57 +0000)
applied modified patch from Robert Larice <larice AT vidisys.de>
fixing original report of bug #2655200: pointer to pdata memory not correctly initialized

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5411 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCglue.c
support/regression/tests/bug2655200.c [new file with mode: 0644]

index 38e335861680085ec93d035c90edde7e4a22a8b1..2a561471fe58c8e97a765eb9d43d8368dc96645f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-03-12 Frieder Ferlemann <Frieder.Ferlemann AT web.de>
+
+       * src/SDCCglue.c,
+         support/regression/tests/bug2655200.c:
+         applied modified patch from Robert Larice <larice AT vidisys.de>
+         fixing original report of bug #2655200: pointer to pdata memory
+         not correctly initialized
+
 2009-03-11 Borut Razem <borut.razem AT siol.net>
 
        * as/asranlib/asranlib.c: retain the original file mode
index 19c452ea17571170913290e4404f3bea74cee696..f753441a01b4b846a60e6821771ccac47b8c472d 100644 (file)
@@ -370,6 +370,8 @@ initPointer (initList * ilist, sym_link *toType)
         DCL_TYPE (val->type) = CPOINTER;
         DCL_PTR_CONST (val->type) = port->mem.code_ro;
       }
+      else if (SPEC_SCLS (expr->left->etype) == S_PDATA)
+        DCL_TYPE (val->type) = PPOINTER;
       else if (SPEC_SCLS (expr->left->etype) == S_XDATA)
         DCL_TYPE (val->type) = FPOINTER;
       else if (SPEC_SCLS (expr->left->etype) == S_XSTACK)
@@ -429,6 +431,8 @@ initPointer (initList * ilist, sym_link *toType)
       DCL_TYPE (val->type) = CPOINTER;
       DCL_PTR_CONST (val->type) = port->mem.code_ro;
     }
+    else if (SPEC_SCLS (expr->right->etype) == S_PDATA)
+      DCL_TYPE (val->type) = PPOINTER;
     else if (SPEC_SCLS (expr->right->etype) == S_XDATA)
       DCL_TYPE (val->type) = FPOINTER;
     else if (SPEC_SCLS (expr->right->etype) == S_XSTACK)
diff --git a/support/regression/tests/bug2655200.c b/support/regression/tests/bug2655200.c
new file mode 100644 (file)
index 0000000..1a4573a
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * [ 2655200 ] pointer to pdata memory not correctly initialized
+ *
+ * test_array[..] = &thing_pdata
+ * was incorrect
+ *
+ * SDCCclue.c(initPointer)
+ * ... SPEC_SCLS (expr->left->etype) == S_PDATA)
+ * was not handeled
+ */
+
+#include <testfwk.h>
+#include <stdint.h>
+
+#if !defined (SDCC_mcs51) && !defined (SDCC_ds390)
+# define __code
+#endif
+
+char thing;
+#if defined (SDCC_mcs51) || defined (SDCC_ds390)
+__code char thing_code = 0;
+__data char thing_data;
+__idata char thing_idata;
+__xdata char thing_xdata;
+__pdata char thing_pdata;
+__pdata char thing_apdata[2];
+#endif
+
+
+char * __code test_array[] = {
+ &thing
+#if defined (SDCC_mcs51) || defined (SDCC_ds390)
+ , &thing_code
+ , &thing_data, &thing_idata, &thing_xdata, &thing_pdata
+ , thing_apdata, (char *)thing_apdata
+#endif
+};
+
+
+char *gime_thing() { return &thing; }
+#if defined (SDCC_mcs51) || defined (SDCC_ds390)
+char *gime_thing_code() { return &thing_code; }
+char *gime_thing_data() { return &thing_data; }
+char *gime_thing_idata() { return &thing_idata; }
+char *gime_thing_xdata() { return &thing_xdata; }
+char *gime_thing_pdata() { return &thing_pdata; }
+char *gime_thing_apdata() { return thing_apdata; }
+#endif
+
+
+void
+testBug(void)
+{
+#if !defined (SDCC_MODEL_MEDIUM)        /* test-mcs51-medium fails */
+ ASSERT(test_array[0] == gime_thing());
+#endif
+
+#if defined (SDCC_mcs51) || defined (SDCC_ds390)
+ ASSERT(test_array[1] == gime_thing_code());
+ ASSERT(test_array[2] == gime_thing_data());
+ ASSERT(test_array[3] == gime_thing_idata());
+ ASSERT(test_array[4] == gime_thing_xdata());
+ ASSERT(test_array[5] == gime_thing_pdata());
+ ASSERT(test_array[6] == gime_thing_apdata());
+ ASSERT(test_array[7] == gime_thing_apdata());
+#endif
+}