]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR modula2/119504: ICE when attempting to access an element of a constant string
authorGaius Mulley <gaiusmod2@gmail.com>
Fri, 28 Mar 2025 15:25:55 +0000 (15:25 +0000)
committerGaius Mulley <gaiusmod2@gmail.com>
Fri, 28 Mar 2025 15:25:55 +0000 (15:25 +0000)
commitb69945d511b394ef092c888c6475f8c72bee0c03
tree546b8167b0f94a6074b7a4d55adbd8ce28a422e2
parentb9f08c8631c2c1a393d7d2bdd41b1b0fe76b1663
PR modula2/119504: ICE when attempting to access an element of a constant string

This patch prevents an ICE and generates an error if an array access to a
constant string is attempted.  The patch also allows HIGH ("string").

gcc/m2/ChangeLog:

PR modula2/119504
* gm2-compiler/M2Quads.mod (BuildHighFunction): Defend against
Type = NulSym and fall into BuildConstHighFromSym.
(BuildDesignatorArray): Rewrite to detect an array access to
a constant string.
(BuildDesignatorArrayStaticDynamic): New procedure.

gcc/testsuite/ChangeLog:

PR modula2/119504
* gm2/iso/fail/conststrarray2.mod: New test.
* gm2/iso/run/pass/constarray2.mod: New test.
* gm2/pim/pass/hexstring.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
gcc/m2/gm2-compiler/M2Quads.mod
gcc/testsuite/gm2/iso/fail/conststrarray2.mod [new file with mode: 0644]
gcc/testsuite/gm2/iso/run/pass/constarray2.mod [new file with mode: 0644]
gcc/testsuite/gm2/pim/pass/hexstring.mod [new file with mode: 0644]