]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR modula2/109496 Fix constant char parameter passing to an array of char
authorGaius Mulley <gaiusmod2@gmail.com>
Thu, 13 Apr 2023 16:02:48 +0000 (17:02 +0100)
committerGaius Mulley <gaiusmod2@gmail.com>
Thu, 13 Apr 2023 16:02:48 +0000 (17:02 +0100)
commita1afdc6e2aa77d0a990e1a82aceeffc837b7e50c
tree914badeca002aff6b9ecf223c05cb749804e7f4d
parent66946624b96b762985de56444d726a0ebd4e0df5
PR modula2/109496 Fix constant char parameter passing to an array of char

This patch fixes PR modula2/109496 and PR modula2/109497.  The fix for
PR modula2/109496 promotes a char constant to a string.  The PR
modula2/109497 allows for constant chars to be added to form a string.
The fixes for both PR's occur in M2GenGCC.mod and M2GCCDeclare.mod
after the resolving of constant declarations.

gcc/m2/ChangeLog:

* gm2-compiler/M2ALU.def (PopChar): New procedure function.
* gm2-compiler/M2ALU.mod (PopChar): New procedure function.
* gm2-compiler/M2GCCDeclare.mod (PromoteToString): Detect
a single constant char and build a C string.
* gm2-compiler/M2GenGCC.mod (IsConstStr): New procedure
function.
(GetStr): New procedure function.
(FoldAdd): Use IsConstStr.
* gm2-compiler/M2Quads.mod: Formatting changes.
* gm2-gcc/m2expr.cc (m2expr_GetCstInteger): New function.
* gm2-gcc/m2expr.def (GetCstInteger): New procedure function.
* gm2-gcc/m2expr.h (m2expr_GetCstInteger): New prototype.

gcc/testsuite/ChangeLog:

PR modula2/109497
* gm2/pim/run/pass/addcharconst.mod: New test.
PR modula2/109496
* gm2/pim/run/pass/singlechar.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
gcc/m2/gm2-compiler/M2ALU.def
gcc/m2/gm2-compiler/M2ALU.mod
gcc/m2/gm2-compiler/M2GCCDeclare.mod
gcc/m2/gm2-compiler/M2GenGCC.mod
gcc/m2/gm2-compiler/M2Quads.mod
gcc/m2/gm2-gcc/m2expr.cc
gcc/m2/gm2-gcc/m2expr.def
gcc/m2/gm2-gcc/m2expr.h
gcc/testsuite/gm2/pim/run/pass/addcharconst.mod [new file with mode: 0644]
gcc/testsuite/gm2/pim/run/pass/singlechar.mod [new file with mode: 0644]