This patch checks for a NulSym type during WalkConvert PCSymBuild
and ignores it.  The NulSym type presented to BuildConstructor in
M2Quads generates an error message at the typename or '{' if the
typename is absent.  It would be good to spell check the typename
at some future point.

gcc/m2/ChangeLog:

        PR modula2/127469
        * gm2-compiler/M2Quads.mod (BuildConstructor): Check for
        tok UnknownTokenNo and if not equal generate an error message
        at tok stating the type is unknown.
        * gm2-compiler/PCSymBuild.mod (WalkConvert): Check totype for
        NulSym and if so return FALSE.

Signed-off-by: Gaius Mulley <[email protected]>
---
 gcc/m2/gm2-compiler/M2Quads.mod    | 10 ++++++++--
 gcc/m2/gm2-compiler/PCSymBuild.mod |  5 ++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/gcc/m2/gm2-compiler/M2Quads.mod b/gcc/m2/gm2-compiler/M2Quads.mod
index dd8eb95ffe7..8e92e52f7c0 100644
--- a/gcc/m2/gm2-compiler/M2Quads.mod
+++ b/gcc/m2/gm2-compiler/M2Quads.mod
@@ -12671,8 +12671,14 @@ BEGIN
    PushValue (constValue) ;
    IF type = NulSym
    THEN
-      MetaErrorT0 (tokcbrpos,
-                   '{%E}constructor requires a type before the opening %{')
+      IF tok = UnknownTokenNo
+      THEN
+         MetaErrorT0 (tokcbrpos,
+                      '{%E}constructor requires a type before the opening %{')
+      ELSE
+         MetaErrorT0 (tok,
+                      '{%E}the constructor type before the opening %{ is 
unknown')
+      END
    ELSE
       ChangeToConstructor (tok, type) ;
       PutConstructorFrom (constValue, type) ;
diff --git a/gcc/m2/gm2-compiler/PCSymBuild.mod 
b/gcc/m2/gm2-compiler/PCSymBuild.mod
index b514ba2b531..0597a548180 100644
--- a/gcc/m2/gm2-compiler/PCSymBuild.mod
+++ b/gcc/m2/gm2-compiler/PCSymBuild.mod
@@ -1839,7 +1839,10 @@ BEGIN
       RETURN( FALSE )
    ELSE
       WITH e^.econvert DO
-         IF isTypeResolved(totype)
+         IF totype = NulSym
+         THEN
+            RETURN( FALSE )
+         ELSIF isTypeResolved(totype)
          THEN
             assignType(e, totype) ;
             RETURN( TRUE )
-- 
2.47.3

Reply via email to