* [Bug modula2/112946] Assignment of string to enumeration or set crashes
2023-12-10 20:09 [Bug modula2/112946] New: Assignment of string to enumeration or set crashes juriad at gmail dot com
@ 2023-12-12 11:23 ` gaius at gcc dot gnu.org
2023-12-15 15:14 ` gaius at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-12-12 11:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112946
Gaius Mulley <gaius at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2023-12-12
Status|UNCONFIRMED |ASSIGNED
--- Comment #1 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Confirmed - many thanks for the bug report and test code!
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug modula2/112946] Assignment of string to enumeration or set crashes
2023-12-10 20:09 [Bug modula2/112946] New: Assignment of string to enumeration or set crashes juriad at gmail dot com
2023-12-12 11:23 ` [Bug modula2/112946] " gaius at gcc dot gnu.org
@ 2023-12-15 15:14 ` gaius at gcc dot gnu.org
2023-12-15 15:27 ` cvs-commit at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-12-15 15:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112946
--- Comment #2 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Created attachment 56886
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56886&action=edit
Proposed fix
Here is the proposed fix.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug modula2/112946] Assignment of string to enumeration or set crashes
2023-12-10 20:09 [Bug modula2/112946] New: Assignment of string to enumeration or set crashes juriad at gmail dot com
2023-12-12 11:23 ` [Bug modula2/112946] " gaius at gcc dot gnu.org
2023-12-15 15:14 ` gaius at gcc dot gnu.org
@ 2023-12-15 15:27 ` cvs-commit at gcc dot gnu.org
2023-12-15 15:28 ` gaius at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-15 15:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112946
--- Comment #3 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:7d7a480eedf0a195318d0fce2c9c57acae43ec9d
commit r14-6596-g7d7a480eedf0a195318d0fce2c9c57acae43ec9d
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date: Fri Dec 15 15:26:48 2023 +0000
PR modula2/112946 ICE assignment of string to enumeration or set
This patch introduces type checking during FoldBecomes and also
adds set/string/enum checking to the type checker. FoldBecomes
has been re-written, tidied up and re-factored.
gcc/m2/ChangeLog:
PR modula2/112946
* gm2-compiler/M2Check.mod (checkConstMeta): New procedure
function.
(checkConstEquivalence): New procedure function.
(doCheckPair): Add call to checkConstEquivalence.
* gm2-compiler/M2GenGCC.mod (ResolveConstantExpressions): Call
FoldBecomes with reduced parameters.
(FoldBecomes): Re-write.
(TryDeclareConst): New procedure.
(RemoveQuads): New procedure.
(DeclaredOperandsBecomes): New procedure function.
(TypeCheckBecomes): New procedure function.
(PerformFoldBecomes): New procedure.
* gm2-compiler/M2Range.mod (FoldAssignment): Call
AssignmentTypeCompatible to check des expr compatibility.
* gm2-compiler/M2SymInit.mod (CheckReadBeforeInitQuad): Remove
parameter lst.
(FilterCheckReadBeforeInitQuad): Remove parameter lst.
(CheckReadBeforeInitFirstBasicBlock): Remove parameter lst.
Call FilterCheckReadBeforeInitQuad without lst.
gcc/testsuite/ChangeLog:
PR modula2/112946
* gm2/iso/fail/badassignment.mod: New test.
* gm2/iso/fail/badexpression.mod: New test.
* gm2/iso/fail/badexpression2.mod: New test.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug modula2/112946] Assignment of string to enumeration or set crashes
2023-12-10 20:09 [Bug modula2/112946] New: Assignment of string to enumeration or set crashes juriad at gmail dot com
` (2 preceding siblings ...)
2023-12-15 15:27 ` cvs-commit at gcc dot gnu.org
@ 2023-12-15 15:28 ` gaius at gcc dot gnu.org
2023-12-15 15:42 ` gaiusmod2 at gmail dot com
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-12-15 15:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112946
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 now the patch has been applied.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug modula2/112946] Assignment of string to enumeration or set crashes
2023-12-10 20:09 [Bug modula2/112946] New: Assignment of string to enumeration or set crashes juriad at gmail dot com
` (3 preceding siblings ...)
2023-12-15 15:28 ` gaius at gcc dot gnu.org
@ 2023-12-15 15:42 ` gaiusmod2 at gmail dot com
2023-12-16 7:27 ` gaius at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: gaiusmod2 at gmail dot com @ 2023-12-15 15:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112946
--- Comment #5 from gaiusmod2 at gmail dot com ---
many thanks for the bug report - all fixed in gcc master branch.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug modula2/112946] Assignment of string to enumeration or set crashes
2023-12-10 20:09 [Bug modula2/112946] New: Assignment of string to enumeration or set crashes juriad at gmail dot com
` (4 preceding siblings ...)
2023-12-15 15:42 ` gaiusmod2 at gmail dot com
@ 2023-12-16 7:27 ` gaius at gcc dot gnu.org
2024-01-10 20:01 ` gaius at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-12-16 7:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112946
Gaius Mulley <gaius at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |---
--- Comment #6 from Gaius Mulley <gaius at gcc dot gnu.org> ---
MODULE badexpression3 ;
TYPE
enums = (red, blue, green) ;
set = SET OF enums ;
VAR
setvar : set;
enumvar: enums;
BEGIN
setvar := set {red, blue} ;
setvar := setvar + green ; (* Should detect an error here. *)
IF NOT (green IN setvar)
THEN
HALT
END
END badexpression3.
successfully compiles - and it should detect an error at "setvar + green".
M2GenGCC.mod:FoldBinary (and FoldUnary) need the same treatment as FoldBecomes
in the original patch.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug modula2/112946] Assignment of string to enumeration or set crashes
2023-12-10 20:09 [Bug modula2/112946] New: Assignment of string to enumeration or set crashes juriad at gmail dot com
` (5 preceding siblings ...)
2023-12-16 7:27 ` gaius at gcc dot gnu.org
@ 2024-01-10 20:01 ` gaius at gcc dot gnu.org
2024-01-11 0:54 ` cvs-commit at gcc dot gnu.org
2024-01-11 0:56 ` gaius at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-01-10 20:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112946
--- Comment #7 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Created attachment 57025
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57025&action=edit
Proposed fix v2
The proposed patch fixes the expression type mismatch case presented above. It
also fixes a number of related expression (foo IN setval) and all binary sets
arithmetic is checked and virtual tokens are used to highlight sub expressions
in error.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug modula2/112946] Assignment of string to enumeration or set crashes
2023-12-10 20:09 [Bug modula2/112946] New: Assignment of string to enumeration or set crashes juriad at gmail dot com
` (6 preceding siblings ...)
2024-01-10 20:01 ` gaius at gcc dot gnu.org
@ 2024-01-11 0:54 ` cvs-commit at gcc dot gnu.org
2024-01-11 0:56 ` gaius at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-11 0:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112946
--- Comment #8 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:96a9355a3d5b24f010fa6ad0b51bba5cc3f334f1
commit r14-7123-g96a9355a3d5b24f010fa6ad0b51bba5cc3f334f1
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date: Thu Jan 11 00:53:56 2024 +0000
PR modula2/112946 set expression type checking
This patch adds type checking for binary set operators.
It also checks the IN operator and improves the := type checking.
gcc/m2/ChangeLog:
PR modula2/112946
* gm2-compiler/M2GenGCC.mod (IsExpressionCompatible): Import.
(ExpressionTypeCompatible): Import.
(CodeStatement): Remove op1, op2, op3 parameters from CodeSetOr,
CodeSetAnd, CodeSetSymmetricDifference, CodeSetLogicalDifference.
(checkArrayElements): Rename op1 to des and op3 to expr.
Use despos and exprpos instead of CurrentQuadToken.
(checkRecordTypes): Rename op1 to des and op2 to expr.
Use virtpos instead of CurrentQuadToken.
(checkIncorrectMeta): Ditto.
(checkBecomes): Rename op1 to des and op3 to expr.
Use virtpos instead of CurrentQuadToken.
(NoWalkProcedure): New procedure stub.
(CheckBinaryExpressionTypes): New procedure function.
(CheckElementSetTypes): New procedure function.
(CodeBinarySet): Re-write.
(FoldBinarySet): Re-write.
(CodeSetOr): Remove parameters op1, op2 and op3.
(CodeSetAnd): Ditto.
(CodeSetLogicalDifference): Ditto.
(CodeSetSymmetricDifference): Ditto.
(CodeIfIn): Call CheckBinaryExpressionTypes and
CheckElementSetTypes.
* gm2-compiler/M2Quads.mod (BuildRotateFunction): Correct
parameters to MakeVirtualTok to reflect parameter block
passed to Rotate.
gcc/testsuite/ChangeLog:
PR modula2/112946
* gm2/pim/fail/badbecomes.mod: New test.
* gm2/pim/fail/badexpression.mod: New test.
* gm2/pim/fail/badexpression2.mod: New test.
* gm2/pim/fail/badifin.mod: New test.
* gm2/pim/pass/goodifin.mod: New test.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug modula2/112946] Assignment of string to enumeration or set crashes
2023-12-10 20:09 [Bug modula2/112946] New: Assignment of string to enumeration or set crashes juriad at gmail dot com
` (7 preceding siblings ...)
2024-01-11 0:54 ` cvs-commit at gcc dot gnu.org
@ 2024-01-11 0:56 ` gaius at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-01-11 0:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112946
Gaius Mulley <gaius at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|REOPENED |RESOLVED
--- Comment #9 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Closing now that the patch has been applied.
^ permalink raw reply [flat|nested] 10+ messages in thread