public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug modula2/109729] New: gm2 (14.0.0) does not like a CHAR type FOR loop control variable any more @ 2023-05-04 9:01 gaius at gcc dot gnu.org 2023-05-04 9:07 ` [Bug modula2/109729] " gaius at gcc dot gnu.org ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: gaius at gcc dot gnu.org @ 2023-05-04 9:01 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109729 Bug ID: 109729 Summary: gm2 (14.0.0) does not like a CHAR type FOR loop control variable any more Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: modula2 Assignee: gaius at gcc dot gnu.org Reporter: gaius at gcc dot gnu.org Target Milestone: --- Copied from the gm2 mailing list: """ just recognised that gm2 (14.0.0) does not like a CHAR type FOR loop control variable any more ... :-) Here the simplified code reproducing the error MODULE RealConvert; FROM ConvTypes IMPORT ConvResults; VAR RKonv : ARRAY ['0'..'9'] OF REAL; IKonv : ARRAY ['0'..'9'] OF CARDINAL; KommaZeichen : CHAR; (* Macht 1,0 statt 1.0 in Ausgaben m"oglich. *) Ziffern : ARRAY [0..11] OF CHAR; (* + 0C *) VAR c : CHAR; p : CARDINAL; BEGIN (* Does not work ... *) p:=0; FOR c:='0' TO '9' DO RKonv[c]:=VAL(REAL,p); IKonv[c]:=p; INC(p); END; (* This is essentially doing the same as the loop before - does work *) IKonv["0"] := 0; IKonv["1"] := 1; IKonv["2"] := 2; IKonv["3"] := 3; IKonv["4"] := 4; IKonv["5"] := 5; IKonv["6"] := 6; IKonv["7"] := 7; IKonv["8"] := 8; IKonv["9"] := 9; RKonv["0"] := 0.0; RKonv["1"] := 1.0; RKonv["2"] := 2.0; RKonv["3"] := 3.0; RKonv["4"] := 4.0; RKonv["5"] := 5.0; RKonv["6"] := 6.0; RKonv["7"] := 7.0; RKonv["8"] := 8.0; RKonv["9"] := 9.0; KommaZeichen:='.'; Ziffern := "0123456789"; (* wg. GM2 *) END RealConvert. """ ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug modula2/109729] gm2 (14.0.0) does not like a CHAR type FOR loop control variable any more 2023-05-04 9:01 [Bug modula2/109729] New: gm2 (14.0.0) does not like a CHAR type FOR loop control variable any more gaius at gcc dot gnu.org @ 2023-05-04 9:07 ` gaius at gcc dot gnu.org 2023-05-04 14:18 ` gaius at gcc dot gnu.org ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: gaius at gcc dot gnu.org @ 2023-05-04 9:07 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109729 Gaius Mulley <gaius at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED Ever confirmed|0 |1 Last reconfirmed| |2023-05-04 --- Comment #1 from Gaius Mulley <gaius at gcc dot gnu.org> --- I think this bug was introduced when fixing PR-109497 (adding to constant chars to generate a string). I suspect the internal inc (iterator) in the FOR loop is trying to produce a string! ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug modula2/109729] gm2 (14.0.0) does not like a CHAR type FOR loop control variable any more 2023-05-04 9:01 [Bug modula2/109729] New: gm2 (14.0.0) does not like a CHAR type FOR loop control variable any more gaius at gcc dot gnu.org 2023-05-04 9:07 ` [Bug modula2/109729] " gaius at gcc dot gnu.org @ 2023-05-04 14:18 ` gaius at gcc dot gnu.org 2023-05-04 17:16 ` cvs-commit at gcc dot gnu.org ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: gaius at gcc dot gnu.org @ 2023-05-04 14:18 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109729 Gaius Mulley <gaius at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |gaius at gcc dot gnu.org --- Comment #2 from Gaius Mulley <gaius at gcc dot gnu.org> --- Created attachment 54995 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54995&action=edit Proposed fix Here is a proposed fix and new testsuite entry. It introduces a new quadruple used if the compiler needs to produce an arithmetic add rather than an add which might be overloaded. The FOR loop uses the arithmetic add to increment the iterator. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug modula2/109729] gm2 (14.0.0) does not like a CHAR type FOR loop control variable any more 2023-05-04 9:01 [Bug modula2/109729] New: gm2 (14.0.0) does not like a CHAR type FOR loop control variable any more gaius at gcc dot gnu.org 2023-05-04 9:07 ` [Bug modula2/109729] " gaius at gcc dot gnu.org 2023-05-04 14:18 ` gaius at gcc dot gnu.org @ 2023-05-04 17:16 ` cvs-commit at gcc dot gnu.org 2023-05-04 17:22 ` gaius at gcc dot gnu.org 2023-07-28 14:12 ` cvs-commit at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2023-05-04 17:16 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109729 --- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Gaius Mulley <gaius@gcc.gnu.org>: https://gcc.gnu.org/g:ac7c9954ece9a75c5e7c3b76a4800f2432002487 commit r14-484-gac7c9954ece9a75c5e7c3b76a4800f2432002487 Author: Gaius Mulley <gaiusmod2@gmail.com> Date: Thu May 4 18:15:59 2023 +0100 PR modula2/109729 cannot use a CHAR type as a FOR loop iterator This patch introduces a new quadruple ArithAddOp which is used in the construction of FOR loop to ensure that when constant folding is applied it does not concatenate two constant char operands into a string constant. Overloading only occurs with constant operands. gcc/m2/ChangeLog: PR modula2/109729 * gm2-compiler/M2GenGCC.mod (CodeStatement): Detect ArithAddOp and call CodeAddChecked. (ResolveConstantExpressions): Detect ArithAddOp and call FoldArithAdd. (FoldArithAdd): New procedure. (FoldAdd): Refactor to use FoldArithAdd. * gm2-compiler/M2Quads.def (QuadOperator): Add ArithAddOp. * gm2-compiler/M2Quads.mod: Remove commented imports. (QuadFrame): Changed comments to use GNU coding standards. (ArithPlusTok): New global variable. (BuildForToByDo): Use ArithPlusTok instead of PlusTok. (MakeOp): Detect ArithPlusTok and return ArithAddOp. (WriteQuad): Add ArithAddOp clause. (WriteOperator): Add ArithAddOp clause. (Init): Initialize ArithPlusTok. gcc/testsuite/ChangeLog: PR modula2/109729 * gm2/pim/run/pass/ForChar.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com> ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug modula2/109729] gm2 (14.0.0) does not like a CHAR type FOR loop control variable any more 2023-05-04 9:01 [Bug modula2/109729] New: gm2 (14.0.0) does not like a CHAR type FOR loop control variable any more gaius at gcc dot gnu.org ` (2 preceding siblings ...) 2023-05-04 17:16 ` cvs-commit at gcc dot gnu.org @ 2023-05-04 17:22 ` gaius at gcc dot gnu.org 2023-07-28 14:12 ` cvs-commit at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: gaius at gcc dot gnu.org @ 2023-05-04 17:22 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109729 Gaius Mulley <gaius at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution|--- |FIXED --- Comment #4 from Gaius Mulley <gaius at gcc dot gnu.org> --- Closing after successful bootstrap and patch has been applied. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug modula2/109729] gm2 (14.0.0) does not like a CHAR type FOR loop control variable any more 2023-05-04 9:01 [Bug modula2/109729] New: gm2 (14.0.0) does not like a CHAR type FOR loop control variable any more gaius at gcc dot gnu.org ` (3 preceding siblings ...) 2023-05-04 17:22 ` gaius at gcc dot gnu.org @ 2023-07-28 14:12 ` cvs-commit at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2023-07-28 14:12 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109729 --- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Gaius Mulley <gaius@gcc.gnu.org>: https://gcc.gnu.org/g:3e9aaa9bcb2fc64e64f4e8a2aa0f6f7395a21c52 commit r13-7622-g3e9aaa9bcb2fc64e64f4e8a2aa0f6f7395a21c52 Author: Gaius Mulley <gaiusmod2@gmail.com> Date: Fri Jul 28 15:00:29 2023 +0100 PR modula2/109729 cannot use a CHAR type as a FOR loop iterator This patch introduces a new quadruple ArithAddOp which is used in the construction of FOR loop to ensure that when constant folding is applied it does not concatenate two constant char operands into a string constant. Overloading only occurs with constant operands. gcc/m2/ChangeLog: PR modula2/109729 PR modula2/110246 * gm2-compiler/M2GenGCC.mod (CodeStatement): Detect ArithAddOp and call CodeAddChecked. (ResolveConstantExpressions): Detect ArithAddOp and call FoldArithAdd. (FoldArithAdd): New procedure. (FoldAdd): Refactor to use FoldArithAdd. * gm2-compiler/M2Quads.def (QuadOperator): Add ArithAddOp. * gm2-compiler/M2Quads.mod: Remove commented imports. (QuadFrame): Changed comments to use GNU coding standards. (ArithPlusTok): New global variable. (BuildForToByDo): Use ArithPlusTok instead of PlusTok. (MakeOp): Detect ArithPlusTok and return ArithAddOp. (WriteQuad): Add ArithAddOp clause. (WriteOperator): Add ArithAddOp clause. (Init): Initialize ArithPlusTok. gcc/testsuite/ChangeLog: PR modula2/109729 * gm2/pim/run/pass/ForChar.mod: New test. (cherry picked from commit ac7c9954ece9a75c5e7c3b76a4800f2432002487) Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com> ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-07-28 14:12 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-05-04 9:01 [Bug modula2/109729] New: gm2 (14.0.0) does not like a CHAR type FOR loop control variable any more gaius at gcc dot gnu.org 2023-05-04 9:07 ` [Bug modula2/109729] " gaius at gcc dot gnu.org 2023-05-04 14:18 ` gaius at gcc dot gnu.org 2023-05-04 17:16 ` cvs-commit at gcc dot gnu.org 2023-05-04 17:22 ` gaius at gcc dot gnu.org 2023-07-28 14:12 ` cvs-commit at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).