aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorGaius Mulley <gaiusmod2@gmail.com>2024-03-21 18:30:23 +0000
committerGaius Mulley <gaiusmod2@gmail.com>2024-03-21 18:30:23 +0000
commitba744d50ac0360f7992a42494db766f6548913e3 (patch)
tree276e5c526a90bb02c9e80ad86fffbf85a99959f7 /gcc
parent509352069d6f166d396f4b4a86e71ea521f2ca78 (diff)
downloadgcc-ba744d50ac0360f7992a42494db766f6548913e3.zip
gcc-ba744d50ac0360f7992a42494db766f6548913e3.tar.gz
gcc-ba744d50ac0360f7992a42494db766f6548913e3.tar.bz2
PR modula2/114418 missing import of TSIZE from system causes ICE
This patch detects whether the symbol func is NulSym before generating an error and if so just uses the token location and fixed string to generate an error message. gcc/m2/ChangeLog: PR modula2/114418 * gm2-compiler/PCSymBuild.mod (PushConstFunctionType): Check func against NulSym and issue an error. gcc/testsuite/ChangeLog: PR modula2/114418 * gm2/pim/fail/missingtsize.mod: New test. * gm2/pim/fail/missingtsize2.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/m2/gm2-compiler/PCSymBuild.mod48
-rw-r--r--gcc/testsuite/gm2/pim/fail/missingtsize.mod8
-rw-r--r--gcc/testsuite/gm2/pim/fail/missingtsize2.mod8
3 files changed, 53 insertions, 11 deletions
diff --git a/gcc/m2/gm2-compiler/PCSymBuild.mod b/gcc/m2/gm2-compiler/PCSymBuild.mod
index e216540..9a6e8c0 100644
--- a/gcc/m2/gm2-compiler/PCSymBuild.mod
+++ b/gcc/m2/gm2-compiler/PCSymBuild.mod
@@ -1413,6 +1413,38 @@ END buildConstFunction ;
(*
+ ErrorConstFunction - generate an error message at functok using func in the
+ error message providing it is not NulSym.
+*)
+
+PROCEDURE ErrorConstFunction (func: CARDINAL; functok: CARDINAL) ;
+BEGIN
+ IF func = NulSym
+ THEN
+ IF Iso
+ THEN
+ ErrorFormat0 (NewError (functok),
+ 'the only functions permissible in a constant expression are: CAP, CHR, CMPLX, FLOAT, HIGH, IM, LENGTH, MAX, MIN, ODD, ORD, RE, SIZE, TSIZE, TRUNC, VAL and gcc builtins')
+ ELSE
+ ErrorFormat0 (NewError (functok),
+ 'the only functions permissible in a constant expression are: CAP, CHR, FLOAT, HIGH, MAX, MIN, ODD, ORD, SIZE, TSIZE, TRUNC, VAL and gcc builtins')
+ END
+ ELSE
+ IF Iso
+ THEN
+ MetaErrorT1 (functok,
+ 'the only functions permissible in a constant expression are: CAP, CHR, CMPLX, FLOAT, HIGH, IM, LENGTH, MAX, MIN, ODD, ORD, RE, SIZE, TSIZE, TRUNC, VAL and gcc builtins, but not {%1Ead}',
+ func)
+ ELSE
+ MetaErrorT1 (functok,
+ 'the only functions permissible in a constant expression are: CAP, CHR, FLOAT, HIGH, MAX, MIN, ODD, ORD, SIZE, TSIZE, TRUNC, VAL and gcc builtins, but not {%1Ead}',
+ func)
+ END
+ END
+END ErrorConstFunction ;
+
+
+(*
PushConstFunctionType -
*)
@@ -1426,7 +1458,10 @@ BEGIN
PopTtok (func, functok) ;
IF inDesignator
THEN
- IF (func#Convert) AND
+ IF func = NulSym
+ THEN
+ ErrorConstFunction (func, functok)
+ ELSIF (func#Convert) AND
(IsPseudoBaseFunction(func) OR
IsPseudoSystemFunctionConstExpression(func) OR
(IsProcedure(func) AND IsProcedureBuiltin(func)))
@@ -1442,16 +1477,7 @@ BEGIN
WriteFormat0('a constant type conversion can only have one argument')
END
ELSE
- IF Iso
- THEN
- MetaErrorT1 (functok,
- 'the only functions permissible in a constant expression are: CAP, CHR, CMPLX, FLOAT, HIGH, IM, LENGTH, MAX, MIN, ODD, ORD, RE, SIZE, TSIZE, TRUNC, VAL and gcc builtins, but not {%1Ead}',
- func)
- ELSE
- MetaErrorT1 (functok,
- 'the only functions permissible in a constant expression are: CAP, CHR, FLOAT, HIGH, MAX, MIN, ODD, ORD, SIZE, TSIZE, TRUNC, VAL and gcc builtins, but not {%1Ead}',
- func)
- END
+ ErrorConstFunction (func, functok)
END
END ;
PushTtok (func, functok)
diff --git a/gcc/testsuite/gm2/pim/fail/missingtsize.mod b/gcc/testsuite/gm2/pim/fail/missingtsize.mod
new file mode 100644
index 0000000..23ec055
--- /dev/null
+++ b/gcc/testsuite/gm2/pim/fail/missingtsize.mod
@@ -0,0 +1,8 @@
+MODULE missingtsize ;
+
+CONST
+ NoOfBytes = TSIZE (CARDINAL) ;
+
+BEGIN
+
+END missingtsize.
diff --git a/gcc/testsuite/gm2/pim/fail/missingtsize2.mod b/gcc/testsuite/gm2/pim/fail/missingtsize2.mod
new file mode 100644
index 0000000..8e85944
--- /dev/null
+++ b/gcc/testsuite/gm2/pim/fail/missingtsize2.mod
@@ -0,0 +1,8 @@
+MODULE missingtsize2 ;
+
+CONST
+ NoOfBytes = TSIZE (CARDINAL) * 4 ;
+
+BEGIN
+
+END missingtsize2. \ No newline at end of file