]> gcc.gnu.org Git - gcc.git/commit
PR modula2/114296 ICE when attempting to create a constant set with a variable element
authorGaius Mulley <gaiusmod2@gmail.com>
Sun, 17 Mar 2024 14:49:23 +0000 (14:49 +0000)
committerGaius Mulley <gaiusmod2@gmail.com>
Sun, 17 Mar 2024 14:49:23 +0000 (14:49 +0000)
commitf065c582d9c8e0a4fee7ee563c584ee3b1975bea
tree4f2b10ee44ef0c3144fdd4a05ac6b4e43697f19a
parent2d454f982914c481a268f1c63e431b2682cc3be0
PR modula2/114296 ICE when attempting to create a constant set with a variable element

This patch corrects the virtual token creation for the aggregate constant
and also corrects tokens for constructor components.

gcc/m2/ChangeLog:

PR modula2/114296
* gm2-compiler/M2ALU.mod (ElementsSolved): Add tokenno parameter.
Add constant checks and generate error messages.
(EvalSetValues): Pass tokenno parameter to ElementsSolved.
* gm2-compiler/M2LexBuf.mod (stop): New procedure.
(MakeVirtualTok): Call stop if caret = BadTokenNo.
* gm2-compiler/M2Quads.def (BuildNulExpression): Add tokpos
parameter.
(BuildSetStart): Ditto.
(BuildEmptySet): Ditto.
(BuildConstructorEnd): Add startpos parameter.
(BuildTypeForConstructor): Add tokpos parameter.
* gm2-compiler/M2Quads.mod (BuildNulExpression): Add tokpos
parameter and push tokpos to the quad stack.
(BuildSetStart): Add tokpos parameter and push tokpos.
(BuildSetEnd): Rewrite.
(BuildEmptySet): Add tokpos parameter and push tokpos with
the set type.
(BuildConstructorStart): Pop typepos.
(BuildConstructorEnd): Add startpos parameter.
Create valtok from startpos and cbratokpos.
(BuildTypeForConstructor): Add tokpos parameter.
* gm2-compiler/M2Range.def (InitAssignmentRangeCheck): Rename
d to des and e to expr.
Add destok and exprtok parameters.
* gm2-compiler/M2Range.mod (InitAssignmentRangeCheck): Rename
d to des and e to expr.
Add destok and exprtok parameters.
Save destok and exprtok into range record.
(FoldAssignment): Pass exprtok to TryDeclareConstant.
* gm2-compiler/P3Build.bnf (ComponentValue): Rewrite.
(Constructor): Rewrite.
(ConstSetOrQualidentOrFunction): Rewrite.
(SetOrQualidentOrFunction): Rewrite.
* gm2-compiler/PCBuild.bnf (ConstSetOrQualidentOrFunction): Rewrite.
(SetOrQualidentOrFunction): Rewrite.
* gm2-compiler/PHBuild.bnf (Constructor): Rewrite.
(ConstSetOrQualidentOrFunction): Rewrite.

gcc/testsuite/ChangeLog:

PR modula2/114296
* gm2/pim/fail/badtype2.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
gcc/m2/gm2-compiler/M2ALU.mod
gcc/m2/gm2-compiler/M2LexBuf.mod
gcc/m2/gm2-compiler/M2Quads.def
gcc/m2/gm2-compiler/M2Quads.mod
gcc/m2/gm2-compiler/M2Range.def
gcc/m2/gm2-compiler/M2Range.mod
gcc/m2/gm2-compiler/P3Build.bnf
gcc/m2/gm2-compiler/PCBuild.bnf
gcc/m2/gm2-compiler/PHBuild.bnf
gcc/testsuite/gm2/pim/fail/badtype2.mod [new file with mode: 0644]
This page took 0.073511 seconds and 6 git commands to generate.