--- /dev/null
+/* 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);
+}
--- /dev/null
+/* 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);
+}
--- /dev/null
+/* 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);
+}
+/* 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" );
+}
--- /dev/null
+/* 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);
+}
int leftShiftIntMasked (int v) {
- /* PENDING: Disabled.
- return ((v & 0xff00U) << 3);
- */
- return v;
+ return ((v & 0xff00U) << 3);
}
int leftShiftIntMasked2 (int v) {
+/* 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;
--- /dev/null
+/* 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);
+}
--- /dev/null
+/* 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');
+}