windelbouwman / ppci

A compiler for ARM, X86, MSP430, xtensa and more implemented in pure Python
https://ppci.readthedocs.io/en/latest/
BSD 2-Clause "Simplified" License
337 stars 36 forks source link

Fix issue #111 on switch/case/default statements. Ensure that the swi… #112

Open tstreiff opened 4 years ago

tstreiff commented 4 years ago

…tch expression is of integer type and apply integer promotion on it. Ensure default statements is not used twice for a given switch. Ensure case values (or ranges for the GCC extension) are integer constants, and that no case value or range is in conflict with the preceding cases of the same switch.

codecov-commenter commented 4 years ago

Codecov Report

Merging #112 into master will decrease coverage by 0.02%. The diff coverage is 80.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #112      +/-   ##
==========================================
- Coverage   79.03%   79.01%   -0.03%     
==========================================
  Files         351      351              
  Lines       46650    46705      +55     
==========================================
+ Hits        36872    36906      +34     
- Misses       9778     9799      +21     
Impacted Files Coverage Δ
ppci/lang/c/semantics.py 83.47% <78.26%> (-0.46%) :arrow_down:
ppci/lang/c/parser.py 91.32% <100.00%> (ø)
ppci/arch/mips/instructions.py 86.13% <0.00%> (-1.56%) :arrow_down:
ppci/arch/riscv/registers.py 93.06% <0.00%> (-0.94%) :arrow_down:
ppci/binutils/dbg/debugger.py 87.59% <0.00%> (-0.65%) :arrow_down:
ppci/binutils/dbg/gdb/client.py 53.14% <0.00%> (-0.43%) :arrow_down:
ppci/wasm/util.py 38.70% <0.00%> (-0.43%) :arrow_down:
ppci/arch/token.py 95.73% <0.00%> (ø)
ppci/wasm/components.py 81.71% <0.00%> (+0.28%) :arrow_up:
ppci/lang/tools/lr.py 96.49% <0.00%> (+0.38%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 4e98d2b...31d1070. Read the comment docs.

windelbouwman commented 4 years ago

This change looks very well! Could you add some test cases to prevent this bug from re-appearing? I'm sure you ran some test snippets to test this code. I suggest to add those to either test_c.py or otherwise to a C example snippet in the folder test/samples.