public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug modula2/114296] New: ICE when attempting to create a constant set with a variable element
@ 2024-03-10 11:14 gaius at gcc dot gnu.org
2024-03-10 11:14 ` [Bug modula2/114296] " gaius at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-03-10 11:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114296
Bug ID: 114296
Summary: ICE when attempting to create a constant set with a
variable element
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: ---
As reported on the mailing list attempting to create a constant set using a
variable will cause an ICE.
MODULE tiny2 ;
VAR
x: CARDINAL ;
ch: CHAR ;
BEGIN
x := 6 ;
ch := {7 .. x};
END tiny2.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug modula2/114296] ICE when attempting to create a constant set with a variable element
2024-03-10 11:14 [Bug modula2/114296] New: ICE when attempting to create a constant set with a variable element gaius at gcc dot gnu.org
@ 2024-03-10 11:14 ` gaius at gcc dot gnu.org
2024-03-16 18:00 ` gaius at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-03-10 11:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114296
Gaius Mulley <gaius at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2024-03-10
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug modula2/114296] ICE when attempting to create a constant set with a variable element
2024-03-10 11:14 [Bug modula2/114296] New: ICE when attempting to create a constant set with a variable element gaius at gcc dot gnu.org
2024-03-10 11:14 ` [Bug modula2/114296] " gaius at gcc dot gnu.org
@ 2024-03-16 18:00 ` gaius at gcc dot gnu.org
2024-03-17 14:50 ` cvs-commit at gcc dot gnu.org
2024-03-17 14:55 ` gaius at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-03-16 18:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114296
--- Comment #1 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Created attachment 57719
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57719&action=edit
Proposed fix
Here is the proposed fix. It corrects the virtual token creation for the
aggregate constant and also corrects tokens for constructor components.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug modula2/114296] ICE when attempting to create a constant set with a variable element
2024-03-10 11:14 [Bug modula2/114296] New: ICE when attempting to create a constant set with a variable element gaius at gcc dot gnu.org
2024-03-10 11:14 ` [Bug modula2/114296] " gaius at gcc dot gnu.org
2024-03-16 18:00 ` gaius at gcc dot gnu.org
@ 2024-03-17 14:50 ` cvs-commit at gcc dot gnu.org
2024-03-17 14:55 ` gaius at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-03-17 14:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114296
--- Comment #2 from GCC 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:f065c582d9c8e0a4fee7ee563c584ee3b1975bea
commit r14-9506-gf065c582d9c8e0a4fee7ee563c584ee3b1975bea
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date: Sun Mar 17 14:49:23 2024 +0000
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug modula2/114296] ICE when attempting to create a constant set with a variable element
2024-03-10 11:14 [Bug modula2/114296] New: ICE when attempting to create a constant set with a variable element gaius at gcc dot gnu.org
` (2 preceding siblings ...)
2024-03-17 14:50 ` cvs-commit at gcc dot gnu.org
@ 2024-03-17 14:55 ` gaius at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-03-17 14:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114296
Gaius Mulley <gaius at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #3 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Closing now that the patch has been applied. The ICE was caused by assuming
that the set elements were constants. The patch contains a check and also
improves the token accuracy of the set sub expression.
The test code above now causes the following correct error message:
$ gm2 tiny2.mod
tiny2.mod:8:10: error: a constant set can only contain constant set elements,
‘x’ is not a constant
8 | ch := {7 .. x};
| ^~~~~~~~
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-03-17 14:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-10 11:14 [Bug modula2/114296] New: ICE when attempting to create a constant set with a variable element gaius at gcc dot gnu.org
2024-03-10 11:14 ` [Bug modula2/114296] " gaius at gcc dot gnu.org
2024-03-16 18:00 ` gaius at gcc dot gnu.org
2024-03-17 14:50 ` cvs-commit at gcc dot gnu.org
2024-03-17 14:55 ` gaius 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).