]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR modula2/115957 ICE on procedure local const declaration
authorGaius Mulley <gaiusmod2@gmail.com>
Tue, 16 Jul 2024 14:27:21 +0000 (15:27 +0100)
committerGaius Mulley <gaiusmod2@gmail.com>
Tue, 16 Jul 2024 14:27:21 +0000 (15:27 +0100)
commitd9709fafb2c498ba2f4c920f953c9b78fa3bf114
tree8ff6e117c7380613598921f7833c8c30f1f2ddcc
parent616627245fb06106f7c5bc4a36784acc8ec166f0
PR modula2/115957 ICE on procedure local const declaration

An ICE would occur if a constant was declared using a variable term.
This fix catches variable terms in constant expressions and generates
an unrecoverable error.

gcc/m2/ChangeLog:

PR modula2/115957
* gm2-compiler/M2StackAddress.mod (PopAddress): Detect tail=NIL
and generate an internal error.
* gm2-compiler/PCBuild.bnf (InConstParameter): New variable.
(InConstBlock): New variable.
(ErrorString): Rewrite using MetaErrorStringT0.
(ErrorArrayAt): Rewrite using MetaErrorStringT0.
(WarnMissingToken): Use MetaErrorStringT0.
(CompilationUnit): Set seenError FALSE.
(init): Initialize InConstParameter and InConstBlock.
(ConstantDeclaration): Set InConstBlock.
(ConstSetOrQualidentOrFunction): Call CheckNotVar if not
InConstParameter and InConstBlock.
(ConstActualParameters): Set InConstParameter TRUE and restore
value at the end.
* gm2-compiler/PCSymBuild.def (CheckNotVar): New procedure.
Remove all unnecessary export qualified list.
* gm2-compiler/PCSymBuild.mod (CheckNotVar): New procedure.

gcc/testsuite/ChangeLog:

PR modula2/115957
* gm2/errors/fail/badconst.mod: New test.
* gm2/pim/fail/tinyadr.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
gcc/m2/gm2-compiler/M2StackAddress.mod
gcc/m2/gm2-compiler/PCBuild.bnf
gcc/m2/gm2-compiler/PCSymBuild.def
gcc/m2/gm2-compiler/PCSymBuild.mod
gcc/testsuite/gm2/errors/fail/badconst.mod [new file with mode: 0644]
gcc/testsuite/gm2/pim/fail/tinyadr.mod [new file with mode: 0644]