diff options
| author | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-18 00:31:54 +0200 |
|---|---|---|
| committer | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-18 00:31:54 +0200 |
| commit | 268a53de823a6750d6256ee1fb1e7707b4b45740 (patch) | |
| tree | 42c1799a9a82b2f7d9790ee9fe181d72a7274751 /support/regression/tests/bug1875933.c | |
| download | sdcc-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/bug1875933.c')
| -rw-r--r-- | support/regression/tests/bug1875933.c | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/support/regression/tests/bug1875933.c b/support/regression/tests/bug1875933.c new file mode 100644 index 0000000..b1e0a31 --- /dev/null +++ b/support/regression/tests/bug1875933.c @@ -0,0 +1,131 @@ +/* + * bug1875933.c + */ + +#include <testfwk.h> +#include <stdint.h> + +char identity(char x) +{ + return x; +} + +/* + * function genAnd() and genOr() in z80/gen.c + * were not prepared to handle the special case where ifx == 0 + */ + +void void_tand1(char x) +{ + char y = (identity(x) & 1) ? 42 : 43; +} + +void void_tand0(char x) +{ + char y = (identity(x) & 0) ? 42 : 43; +} + +void void_txor1(char x) +{ + char y = (identity(x) ^ 1) ? 42 : 43; +} + +void void_txor0(char x) +{ + char y = (identity(x) ^ 0) ? 42 : 43; +} + + +/* + * function genOr() in z80/gen.c + * assumed identity of "or a, literal" and "or a,a" + * thats definitly not so + */ + +char tor1(char x) +{ + char y = (identity(x) | 1) ? 42 : 43; + return y; +} + +char tor0(char x) +{ + char y = (identity(x) | 0) ? 42 : 43; + return y; +} + +char tand1(char x) +{ + char y = (identity(x) & 1) ? 42 : 43; + return y; +} + +char tand0(char x) +{ + char y = (identity(x) & 0) ? 42 : 43; + return y; +} + +char txor1(char x) +{ + char y = (identity(x) ^ 1) ? 42 : 43; + return y; +} + +char txor0(char x) +{ + char y = (identity(x) ^ 0) ? 42 : 43; + return y; +} + +/* + * mcs51 segmentation fault + * + * function genOr() in mcs51/gen.c + * was not prepeared for ifx==0 + */ + +void void_tor1(char x) +{ + char y = (identity(x) | 1) ? 42 : 43; +} + +void void_tor0(char x) +{ + char y = (identity(x) | 0) ? 42 : 43; +} + +void void_tor(char x) +{ + char y = (identity(x) | x) ? 42 : 43; +} + +void +testBug(void) +{ + void_tand1(1); + void_tand1(0); + void_tand0(1); + void_tand0(0); + void_txor1(1); + void_txor0(0); + + ASSERT(tor1(1) == 42); + ASSERT(tor1(0) == 42); + ASSERT(tor0(1) == 42); + ASSERT(tor0(0) == 43); + ASSERT(tand1(1) == 42); + ASSERT(tand1(0) == 43); + ASSERT(tand0(1) == 43); + ASSERT(tand0(0) == 43); + ASSERT(txor1(1) == 43); + ASSERT(txor1(0) == 42); + ASSERT(txor0(1) == 42); + ASSERT(txor0(0) == 43); + + void_tor1(1); + void_tor1(0); + void_tor0(1); + void_tor0(0); + void_tor(0); +} |
