From: Gaius Mulley Date: Fri, 22 Mar 2024 01:47:31 +0000 (+0000) Subject: PR modula2/114422 Attempting to declare a set of unknown type causes ICE X-Git-Tag: basepoints/gcc-15~537 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1542e8a44cc35e63233d3557afbf501c5ff84c55;p=thirdparty%2Fgcc.git PR modula2/114422 Attempting to declare a set of unknown type causes ICE This patch corrects an error message directive which did not escape the { character. The patch also contains test cases to stress set declaration errors. gcc/m2/ChangeLog: PR modula2/114422 * gm2-compiler/M2Quads.mod (BuildConstructor): Add escape character. gcc/testsuite/ChangeLog: PR modula2/114422 * gm2/iso/fail/badset.mod: New test. * gm2/iso/fail/badset2.mod: New test. * gm2/iso/fail/badset3.mod: New test. Signed-off-by: Gaius Mulley --- diff --git a/gcc/m2/gm2-compiler/M2Quads.mod b/gcc/m2/gm2-compiler/M2Quads.mod index ac654e89c917..52d72f6cd628 100644 --- a/gcc/m2/gm2-compiler/M2Quads.mod +++ b/gcc/m2/gm2-compiler/M2Quads.mod @@ -12172,7 +12172,7 @@ BEGIN IF type = NulSym THEN MetaErrorT0 (tokcbrpos, - '{%E}constructor requires a type before the opening {') + '{%E}constructor requires a type before the opening %{') ELSE ChangeToConstructor (tok, type) ; PutConstructorFrom (constValue, type) ; diff --git a/gcc/testsuite/gm2/iso/fail/badset.mod b/gcc/testsuite/gm2/iso/fail/badset.mod new file mode 100644 index 000000000000..8bfc49f948e3 --- /dev/null +++ b/gcc/testsuite/gm2/iso/fail/badset.mod @@ -0,0 +1,7 @@ +MODULE badset ; + +VAR + set: set ; +BEGIN + +END badset. diff --git a/gcc/testsuite/gm2/iso/fail/badset2.mod b/gcc/testsuite/gm2/iso/fail/badset2.mod new file mode 100644 index 000000000000..d883d1ffe757 --- /dev/null +++ b/gcc/testsuite/gm2/iso/fail/badset2.mod @@ -0,0 +1,9 @@ +MODULE badset2 ; + +TYPE + userset = SET OF CHAR ; +VAR + set: userset ; +BEGIN + set := set {} +END badset2. diff --git a/gcc/testsuite/gm2/iso/fail/badset3.mod b/gcc/testsuite/gm2/iso/fail/badset3.mod new file mode 100644 index 000000000000..29131ff4c5a5 --- /dev/null +++ b/gcc/testsuite/gm2/iso/fail/badset3.mod @@ -0,0 +1,9 @@ +MODULE badset3 ; + +TYPE + userset = SET OF CHAR ; +VAR + set: userset ; +BEGIN + set := unknown {} +END badset3.