Skip to content
Snippets Groups Projects
Commit ac7c9954 authored by Gaius Mulley's avatar Gaius Mulley
Browse files

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: default avatarGaius Mulley <gaiusmod2@gmail.com>
parent 46579775
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment