]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR modula2/102989: reimplement overflow detection in ztype though WIDE_INT_MAX_PRECISION
authorGaius Mulley <gaiusmod2@gmail.com>
Wed, 1 Nov 2023 09:05:10 +0000 (09:05 +0000)
committerGaius Mulley <gaiusmod2@gmail.com>
Wed, 1 Nov 2023 09:05:10 +0000 (09:05 +0000)
commit9693459e030977d6e906ea7eb587ed09ee4fddbd
treef16330852f8130c2c774201a7784abd2c5684281
parent084ea7ea5aa9054569c6bbb980ba1cfa59b3e5f1
PR modula2/102989: reimplement overflow detection in ztype though WIDE_INT_MAX_PRECISION

The ZTYPE in iso modula2 is used to denote intemediate ordinal type const
expressions and these are always converted into the
approriate language or user ordinal type prior to code generation.
The increase of bits supported by _BitInt causes the modula2 largeconst.mod
regression failure tests to pass.  The largeconst.mod test has been
increased to fail, however the char at a time overflow check is now too slow
to detect failure.  The overflow detection for the ZTYPE has been
rewritten to check against exceeding WIDE_INT_MAX_PRECISION (many orders of
magnitude faster).

gcc/m2/ChangeLog:

PR modula2/102989
* gm2-compiler/SymbolTable.mod (OverflowZType): Import from m2expr.
(ConstantStringExceedsZType): Remove import.
(GetConstLitType): Replace ConstantStringExceedsZType with OverflowZType.
* gm2-gcc/m2decl.cc (m2decl_ConstantStringExceedsZType): Remove.
(m2decl_BuildConstLiteralNumber): Re-write.
* gm2-gcc/m2decl.def (ConstantStringExceedsZType): Remove.
* gm2-gcc/m2decl.h (m2decl_ConstantStringExceedsZType): Remove.
* gm2-gcc/m2expr.cc (m2expr_StrToWideInt): Rewrite to check overflow.
(m2expr_OverflowZType): New function.
(ToWideInt): New function.
* gm2-gcc/m2expr.def (OverflowZType): New procedure function declaration.
* gm2-gcc/m2expr.h (m2expr_OverflowZType): New prototype.

gcc/testsuite/ChangeLog:

PR modula2/102989
* gm2/pim/fail/largeconst.mod: Updated foo to an outrageous value.
* gm2/pim/fail/largeconst2.mod: Duplicate test removed.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
gcc/m2/gm2-compiler/SymbolTable.mod
gcc/m2/gm2-gcc/m2decl.cc
gcc/m2/gm2-gcc/m2decl.def
gcc/m2/gm2-gcc/m2decl.h
gcc/m2/gm2-gcc/m2expr.cc
gcc/m2/gm2-gcc/m2expr.def
gcc/m2/gm2-gcc/m2expr.h
gcc/testsuite/gm2/pim/fail/largeconst.mod
gcc/testsuite/gm2/pim/fail/largeconst2.mod [deleted file]