]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR modula2/114055 improve error message when checking the BY constant
authorGaius Mulley <gaiusmod2@gmail.com>
Thu, 22 Feb 2024 15:02:19 +0000 (15:02 +0000)
committerGaius Mulley <gaiusmod2@gmail.com>
Thu, 22 Feb 2024 15:02:19 +0000 (15:02 +0000)
commitc1667b1ef538e4da10cf83bdf1ae62d7bdd96128
tree54170a7b4a25a3f50d1f18c7a8ab956c0fc0669b
parent92c40297991f51e7fa942f29517bc4398fce33f9
PR modula2/114055 improve error message when checking the BY constant

The fix marks a constant created during the default BY clause of the
FOR loop as internal.  The type checker will always return true if
checking against an internal const.

gcc/m2/ChangeLog:

PR modula2/114055
* gm2-compiler/M2Check.mod (Import): IsConstLitInternal and
IsConstLit.
(isInternal): New procedure function.
(doCheck): Test for isInternal in either operand and early
return true.
* gm2-compiler/M2Quads.mod (PushOne): Rewrite with extra
parameter internal.
(BuildPseudoBy): Add TRUE parameter to PushOne call.
(BuildIncProcedure): Add FALSE parameter to PushOne call.
(BuildDecProcedure): Add FALSE parameter to PushOne call.
* gm2-compiler/M2Range.mod (ForLoopBeginTypeCompatible):
Uncomment code and tidy up error string.
* gm2-compiler/SymbolTable.def (PutConstLitInternal):
New procedure.
(IsConstLitInternal): New procedure function.
* gm2-compiler/SymbolTable.mod (PutConstLitInternal):
New procedure.
(IsConstLitInternal): New procedure function.
(SymConstLit): New field IsInternal.
(CreateConstLit): Initialize IsInternal to FALSE.

gcc/testsuite/ChangeLog:

PR modula2/114055
* gm2/pim/fail/forloopby.mod: New test.
* gm2/pim/pass/forloopby2.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
gcc/m2/gm2-compiler/M2Check.mod
gcc/m2/gm2-compiler/M2Quads.mod
gcc/m2/gm2-compiler/M2Range.mod
gcc/m2/gm2-compiler/SymbolTable.def
gcc/m2/gm2-compiler/SymbolTable.mod
gcc/testsuite/gm2/pim/fail/forloopby.mod [new file with mode: 0644]
gcc/testsuite/gm2/pim/pass/forloopby2.mod [new file with mode: 0644]