* device/lib/z80/mul.s (__mulsuchar_rrx_s, __muluschar_rrx_s),
[fw/sdcc] / support / regression / tests / bug1839277.c
index 78dae846f22326b6f56eafdbcbe59e445f175875..4c4732840df71363da15b0fb6db6014fabe37bae 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    bug 1839277
+    bug 1839277 & 1839299
 */
 
 #include <testfwk.h>
@@ -11,7 +11,7 @@ code struct Value {
 char i=1;
 
 void
-testBug(void)
+testBug1839277(void)
 {
        volatile char code* * p;
        unsigned long v = 0;
@@ -48,3 +48,27 @@ testBug(void)
        ASSERT((unsigned char)(v>>16)==0x80);
 #endif
 }
+
+void
+testBug1839299(void)
+{
+       volatile char code* * p;
+       unsigned long v = 0;
+//'Values[0].Name' subexpression is evaluated as follows first:
+//mov     r2,#_Values
+//mov     r3,#(_Values >> 8)
+//mov     r4,#(_Values >> 16) ;this is wrong - see bug 1839277
+  p= i ? Values[0].Name : Values[1].Name;
+//this assignment has some sideeffect on the following one
+//in fact it is the evaluation of 'Values[0].Name' itself has the effect, not the assignment
+  p= Values[0].Name;
+//'Values[0].Name' subexpression is evaluated as follows second:
+//mov     r2,#_Values
+//mov     r3,#(_Values >> 8)
+//mov     r4,#0x00 ;this is different from first occurrence but also wrong
+  p= i ? Values[0].Name : Values[1].Name;
+#if defined(SDCC_mcs51)
+       v = (unsigned long)p;
+       ASSERT((unsigned char)(v>>16)==0x80);
+#endif
+}