Added test cases from the bug list
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 1 Aug 2001 03:32:51 +0000 (03:32 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 1 Aug 2001 03:32:51 +0000 (03:32 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1116 4a8a32a2-be11-0410-ad9d-d568d2c75423

support/regression/tests/bug-221100.c [new file with mode: 0644]
support/regression/tests/bug-221168.c [new file with mode: 0644]
support/regression/tests/bug-221220.c [new file with mode: 0644]
support/regression/tests/bug-223113.c
support/regression/tests/bug-227710.c [new file with mode: 0644]
support/regression/tests/bug-408972.c
support/regression/tests/bug-426632.c
support/regression/tests/bug-435068.c [new file with mode: 0644]
support/regression/tests/bug-441448.c [new file with mode: 0644]

diff --git a/support/regression/tests/bug-221100.c b/support/regression/tests/bug-221100.c
new file mode 100644 (file)
index 0000000..052b8aa
--- /dev/null
@@ -0,0 +1,35 @@
+/* bug-221100.c
+
+   If test_index is char, loses high bit when indexes table 
+   workaround is to use [(unsigned int) test_index] 
+ */
+#include <testfwk.h>
+
+static unsigned int
+testArray[130];
+
+static unsigned int test_int ; 
+static unsigned char test_index ; 
+
+static void 
+fetch(void) 
+{ 
+  test_int = testArray [test_index] ; 
+} 
+
+static void
+testUnsignedCharIndex(void)
+{
+  int i;
+  for (i = 0; i < 130; i++) {
+    testArray[i] = i;
+  }
+
+  test_index = 5;
+  fetch();
+  ASSERT(test_int == 5);
+
+  test_index = 129;
+  fetch();
+  ASSERT(test_int == 129);
+}
diff --git a/support/regression/tests/bug-221168.c b/support/regression/tests/bug-221168.c
new file mode 100644 (file)
index 0000000..623f06b
--- /dev/null
@@ -0,0 +1,19 @@
+/* bug-221168.c
+ */
+#include <testfwk.h>
+
+#define XDATA
+
+XDATA static char x[10][20];
+
+XDATA char *
+getAddrOfCell(unsigned char y, unsigned char z)
+{
+    return &x[y][z];
+}
+
+static void
+testMultiDimensionalAddress(void)
+{
+    ASSERT(getAddrOfCell(5, 6) == (char *)x + 106);
+}
diff --git a/support/regression/tests/bug-221220.c b/support/regression/tests/bug-221220.c
new file mode 100644 (file)
index 0000000..91472e1
--- /dev/null
@@ -0,0 +1,42 @@
+/* bug-221220.c
+   Or an approximation there of.
+*/
+#include <testfwk.h>
+
+typedef struct {
+    int filler;
+    int value;
+} TESTSTRUCT;
+
+static void
+incrementValue(TESTSTRUCT *ps)
+{
+    ps->value++;
+}
+
+static void
+subTestStructVolatile(TESTSTRUCT *ps)
+{
+    int a, b;
+
+    /* sdcc used to cache the value of ps->value into registers, such
+       that as a = ps->value and b = ps->value, then a = b.  However
+       if an intervening function uses the structure then ps->value
+       could change.
+    */
+    a = ps->value;
+    incrementValue(ps);
+    b = ps->value;
+
+    ASSERT(a == 7);
+    ASSERT(b == 8);
+}
+
+static void
+testStructVolatile(void)
+{
+    TESTSTRUCT s;
+
+    s.value = 7;
+    subTestStructVolatile(&s);
+}
index 82a338c63e841ccff8327cb108ff495ded946edd..aacf1387237dbefd312b8636f77fb396ec9e5d68 100644 (file)
@@ -1,33 +1,25 @@
+/* bug-223113.c
+   PENDING
+ */
 #include <testfwk.h>
 
-/* 
- *------------------------------------------------- 
- */ 
-   int putch( int Ch ) 
+int putch( int Ch ) 
 { 
-    return( Ch ); 
+  return( Ch ); 
 } 
- /* 
-  *  *------------------------------------------------- 
-  *  */ 
- int puts( char *Str ) 
+
+int puts( char *Str ) 
 { 
-    char *Ptr; 
+  char *Ptr; 
    
-    for( Ptr = Str; *Ptr != '\0'; Ptr++ ) 
-     { 
-        putch( *Ptr ); 
-     } 
+  for( Ptr = Str; *Ptr != '\0'; Ptr++ ) {
+    putch( *Ptr ); 
+  } 
    
-    return( (Ptr - Str) ); 
+  return( (Ptr - Str) ); 
 } 
- /* 
-  *  *-------------------------------------------------- 
-  *  */ 
- void __main( void ) 
+
+void __main( void ) 
 { 
-    puts( "hello world\n" ); 
-} 
- /* 
-  *  *---------------------------------------------------- 
-  *  */
+  puts( "hello world\n" ); 
+}
diff --git a/support/regression/tests/bug-227710.c b/support/regression/tests/bug-227710.c
new file mode 100644 (file)
index 0000000..ccf98a5
--- /dev/null
@@ -0,0 +1,30 @@
+/* bug-227710.c
+ */
+#include <testfwk.h>
+
+static unsigned char _data[] = {
+    1, 2, 3, 4
+};
+
+unsigned char *p; 
+
+struct { 
+    unsigned char index; 
+} s; 
+
+static unsigned char 
+foo(void) 
+{ 
+    // BUG, there will be a PRE-increment 
+    return p[s.index++];
+} 
+
+static void
+testPostIncrement(void)
+{
+    p = _data;
+    ASSERT(foo() == 1);
+    ASSERT(foo() == 2);
+    ASSERT(foo() == 3);
+    ASSERT(foo() == 4);
+}
index ab8ded70544fa143f588dc9dc72f29988005e9b5..23988240e9a94e41bc6382fbabff03a2cd9edc5f 100644 (file)
@@ -11,10 +11,7 @@ long leftShiftLong (long l) {
 
 
 int leftShiftIntMasked (int v) { 
-  /* PENDING: Disabled.
-     return ((v & 0xff00U) << 3); 
-  */
-  return v;
+  return ((v & 0xff00U) << 3); 
 } 
 
 int leftShiftIntMasked2 (int v) { 
index 8d29050f8b7afe878c02141ea89190c25076a956..ff9db32b76e00bd23b358f8c05634258f60604fc 100644 (file)
@@ -1,12 +1,12 @@
+/* bug-436632.c
+   PENDING
+*/
 #include <testfwk.h>
 
 typedef struct { 
-    unsigned char year; /* Current 
-                        * year (with offset 1900) */ 
-    unsigned char month; /* Month (1 = 
-                         * Jan., ..., 12 = Dec.) */ 
-    unsigned char day; /* Day of 
-                       * month (1 to 31) */ 
+    unsigned char year; /* Current year (with offset 1900) */ 
+    unsigned char month; /* Month (1 = Jan., ..., 12 = Dec.) */ 
+    unsigned char day; /* Day of month (1 to 31) */ 
 } DATE_STRUCT; 
 
 unsigned char year; 
diff --git a/support/regression/tests/bug-435068.c b/support/regression/tests/bug-435068.c
new file mode 100644 (file)
index 0000000..f6789a4
--- /dev/null
@@ -0,0 +1,17 @@
+/* bug-435068.c
+ */
+#include <testfwk.h>
+
+char c, d; 
+
+static void
+testQuestion(void)
+{
+    volatile char c, d;
+
+    c = (0x100 & 0x100) ? 4 : 8; // ok 
+    d = ((0x100 & 0x100) ? 4 : 8) + 1; 
+
+    ASSERT(c == 4);
+    ASSERT(d == 5);
+} 
diff --git a/support/regression/tests/bug-441448.c b/support/regression/tests/bug-441448.c
new file mode 100644 (file)
index 0000000..5ab0ac2
--- /dev/null
@@ -0,0 +1,26 @@
+/* bug-441448.c
+   PENDING
+ */
+#include <testfwk.h>
+
+#define DATA
+
+typedef struct 
+{ 
+    unsigned char buffer[0x20]; 
+    unsigned char OutPtr, InPtr; 
+    unsigned char Count; 
+} Fifo; 
+
+DATA Fifo TxFifo={"ABCD", 0, 0, 0}, RxFifo={"FGHI", 0, 0, 0}; 
+DATA unsigned char dummy1, dummy2; 
+
+void 
+testPrePostIncrement(void) 
+{ 
+    dummy2 = TxFifo.buffer[++TxFifo.OutPtr]; 
+    dummy1 = RxFifo.buffer[RxFifo.OutPtr++];
+
+    ASSERT(dummy2 == 'B');
+    ASSERT(dummy1 == 'F');
+}