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/bug2947189.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/bug2947189.c')
| -rw-r--r-- | support/regression/tests/bug2947189.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/support/regression/tests/bug2947189.c b/support/regression/tests/bug2947189.c new file mode 100644 index 0000000..f0912f0 --- /dev/null +++ b/support/regression/tests/bug2947189.c @@ -0,0 +1,61 @@ +/* + bug2947189.c + */ + +#include <testfwk.h> + +typedef struct { + unsigned int c : 1; + unsigned int b : 2; + unsigned int a : 3; +} TStruct; + +TStruct s = {1, 2, 3}; +unsigned char u = 3; + +void testBug(void) +{ + unsigned char a = 0; + + // too small for a jumptable + switch (s.c) { + case 0: a += 3; break; + case 1: a += 2; break; + } + + // bug 2947189: jumptable need not check bounds and should not generate + // warning 94: comparison is always true resp. false due to limited range of data type + switch (s.b) { + case 0: a += 3; break; + case 1: a += 2; break; + case 2: a += 1; break; + case 3: a += 0; break; + } + + // bug 3069862: jumptable should not use signed comparison for bounds check + switch (s.a) { + case 0: a += 4; break; + case 1: a += 3; break; + case 2: a += 1; break; + case 3: a += 5; break; + + case 4: a += 4; break; + case 5: a += 3; break; + case 6: a += 1; break; + // no case 7: + } + + switch (u) { + case 0: a += 4; break; + case 1: a += 3; break; + case 2: a += 1; break; + case 3: a += 5; break; + + case 4: a += 4; break; + case 5: a += 3; break; + case 6: a += 1; break; + // no case 7: + } + + ASSERT (a == (2 + 1 + 5 + 5)); +} |
