summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-895992.c
diff options
context:
space:
mode:
authorXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
committerXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
commit268a53de823a6750d6256ee1fb1e7707b4b45740 (patch)
tree42c1799a9a82b2f7d9790ee9fe181d72a7274751 /support/regression/tests/bug-895992.c
downloadsdcc-gas-268a53de823a6750d6256ee1fb1e7707b4b45740.tar.gz
sdcc-3.9.0 fork implementing GNU assembler syntax
This fork aims to provide better support for stm8-binutils
Diffstat (limited to 'support/regression/tests/bug-895992.c')
-rw-r--r--support/regression/tests/bug-895992.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/support/regression/tests/bug-895992.c b/support/regression/tests/bug-895992.c
new file mode 100644
index 0000000..8492327
--- /dev/null
+++ b/support/regression/tests/bug-895992.c
@@ -0,0 +1,54 @@
+/* bug-895992.c
+
+ Life Range problem with
+ - uninitialized variable
+ - loop
+ - conditional block
+
+ LR problem hits all ports, but this test is mcs51 specific
+ */
+#include <testfwk.h>
+
+char p0 = 2;
+unsigned short loops;
+
+static void
+wait (void)
+{
+ long i, j;
+
+ /* just clobber all registers: */
+ for (i = 0; i < 2; ++i)
+ for (j = 0; j < 2; ++j)
+ ;
+}
+
+#if !defined(PORT_HOST)
+# pragma disable_warning 84
+#endif
+
+static void
+testLR (void)
+{
+ unsigned char number;
+ unsigned char start = 1;
+ unsigned char i;
+
+ do
+ {
+ for (i = 1; i > 0 ; i--)
+ wait (); /* destroys all registers */
+ if (start)
+ {
+ number = p0;
+ start = 0;
+ }
+ number--; /* 'number' might be used before initialization */
+ /* the life range of 'number' must be extended to */
+ /* the whole loop _including_ the conditional block */
+ ++loops;
+ }
+ while (number != 0);
+
+ ASSERT (loops == p0);
+}