]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR modula2/111675 Incorrect packed record field value passed to a procedure
authorGaius Mulley <gaiusmod2@gmail.com>
Wed, 11 Oct 2023 12:26:47 +0000 (13:26 +0100)
committerGaius Mulley <gaiusmod2@gmail.com>
Wed, 11 Oct 2023 12:26:47 +0000 (13:26 +0100)
commit2b783fe2e8103d97db7c5d6c1514ba16091f39f6
treec9e1235e6341009e6d6db6ca153f455ea1d27f3d
parentf6c5e247b2913f0a7b3be986fe96afbed29c1d5e
PR modula2/111675 Incorrect packed record field value passed to a procedure

This patch allows a packed field to be extracted and passed to a
procedure.  It ensures that the subrange type is the same for both the
procedure and record field.  It also extends the <* bytealignment (0) *>
to cover packed subrange types.

gcc/m2/ChangeLog:

PR modula2/111675
* gm2-compiler/M2CaseList.mod (appendTree): Replace
InitStringCharStar with InitString.
* gm2-compiler/M2GCCDeclare.mod: Import AreConstantsEqual.
(DeclareSubrange): Add zero alignment test and call
BuildSmallestTypeRange if necessary.
(WalkSubrangeDependants): Walk the align expression.
(IsSubrangeDependants): Test the align expression.
* gm2-compiler/M2Quads.mod (BuildStringAdrParam): Correct end name.
* gm2-compiler/P2SymBuild.mod (BuildTypeAlignment): Allow subranges
to be zero aligned (packed).
* gm2-compiler/SymbolTable.mod (Subrange): Add Align field.
(MakeSubrange): Set Align to NulSym.
(PutAlignment): Assign Subrange.Align to align.
(GetAlignment): Return Subrange.Align.
* gm2-gcc/m2expr.cc (noBitsRequired): Rewrite.
(calcNbits): Rename ...
(m2expr_calcNbits): ... to this and test for negative values.
(m2expr_BuildTBitSize): Replace calcNBits with m2expr_calcNbits.
* gm2-gcc/m2expr.def (calcNbits): Export.
* gm2-gcc/m2expr.h (m2expr_calcNbits): New prototype.
* gm2-gcc/m2type.cc (noBitsRequired): Remove.
(m2type_BuildSmallestTypeRange): Call m2expr_calcNbits.
(m2type_BuildSubrangeType): Create range_type from
build_range_type (type, lowval, highval).

gcc/testsuite/ChangeLog:

PR modula2/111675
* gm2/extensions/run/pass/packedrecord3.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/M2Quads.mod
gcc/m2/gm2-compiler/P2SymBuild.mod
gcc/m2/gm2-compiler/SymbolTable.mod
gcc/m2/gm2-gcc/m2expr.cc
gcc/m2/gm2-gcc/m2expr.def
gcc/m2/gm2-gcc/m2expr.h
gcc/m2/gm2-gcc/m2type.cc
gcc/testsuite/gm2/extensions/run/pass/packedrecord3.mod [new file with mode: 0644]