]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR modula2/117120: case ch with a nul char constant causes ICE
authorGaius Mulley <gaiusmod2@gmail.com>
Tue, 10 Dec 2024 20:47:36 +0000 (20:47 +0000)
committerGaius Mulley <gaiusmod2@gmail.com>
Tue, 10 Dec 2024 20:47:36 +0000 (20:47 +0000)
commite0ab8816ea53e2a343f7e945f4718172bff5ce95
treec4074c22ce1dc3602b27bee0cc20bcdd832824fe
parentb26d92f4f71594206385d6f645ff626c0bf9b59c
PR modula2/117120: case ch with a nul char constant causes ICE

This patch fixes the ICE caused when a case clause contains
a character constant ''.  The fix was to walk the caselist and
convert any 0 length string into a char constant of value 0.

gcc/m2/ChangeLog:

PR modula2/117120
* gm2-compiler/M2CaseList.mod (CaseBoundsResolved): Rewrite.
(ConvertNulStr2NulChar): New procedure function.
(NulStr2NulChar): Ditto.
(GetCaseExpression): Ditto.
(OverlappingCaseBound): Rewrite.
* gm2-compiler/M2GCCDeclare.mod (CheckResolveSubrange): Allow
'' to be used as the subrange low limit.
* gm2-compiler/M2GenGCC.mod (FoldConvert): Rewrite.
(PopKindTree): Ditto.
(BuildHighFromString): Reformat.
* gm2-compiler/SymbolTable.mod (PushConstString): Add test for
length 0 and PushChar (nul).

gcc/testsuite/ChangeLog:

PR modula2/117120
* gm2/pim/pass/forloopnulchar.mod: New test.
* gm2/pim/pass/nulcharcase.mod: New test.
* gm2/pim/pass/nulcharvar.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
gcc/m2/gm2-compiler/M2CaseList.mod
gcc/m2/gm2-compiler/M2GCCDeclare.mod
gcc/m2/gm2-compiler/M2GenGCC.mod
gcc/m2/gm2-compiler/SymbolTable.mod
gcc/testsuite/gm2/pim/pass/forloopnulchar.mod [new file with mode: 0644]
gcc/testsuite/gm2/pim/pass/nulcharcase.mod [new file with mode: 0644]
gcc/testsuite/gm2/pim/pass/nulcharvar.mod [new file with mode: 0644]