This bug fix checks the qualified ident processing for spell checking
candidates.
gcc/m2/ChangeLog:
PR modula2/125512
* gm2-compiler/P3Build.bnf (SubDesignator): Rewrite to
include spell checking.
gcc/testsuite/ChangeLog:
PR modula2/125512
* gm2.dg/spell/iso/fail/badmodule.mod: New test.
* gm2.dg/spell/iso/fail/badrecord.mod: New test.
* gm2.dg/spell/iso/fail/color.def: New test.
Signed-off-by: Gaius Mulley <[email protected]>
---
gcc/m2/gm2-compiler/P3Build.bnf | 31 +++++++++++++------
.../gm2.dg/spell/iso/fail/badmodule.mod | 17 ++++++++++
.../gm2.dg/spell/iso/fail/badrecord.mod | 20 ++++++++++++
gcc/testsuite/gm2.dg/spell/iso/fail/color.def | 5 +++
4 files changed, 63 insertions(+), 10 deletions(-)
create mode 100644 gcc/testsuite/gm2.dg/spell/iso/fail/badmodule.mod
create mode 100644 gcc/testsuite/gm2.dg/spell/iso/fail/badrecord.mod
create mode 100644 gcc/testsuite/gm2.dg/spell/iso/fail/color.def
diff --git a/gcc/m2/gm2-compiler/P3Build.bnf b/gcc/m2/gm2-compiler/P3Build.bnf
index e1e96249ce7..ae067c4a02a 100644
--- a/gcc/m2/gm2-compiler/P3Build.bnf
+++ b/gcc/m2/gm2-compiler/P3Build.bnf
@@ -54,7 +54,7 @@ FROM DynamicStrings IMPORT String, InitString, KillString,
Mark, ConCat, ConCatC
FROM M2Printf IMPORT printf0, printf1 ;
FROM M2Debug IMPORT Assert ;
FROM P2SymBuild IMPORT BuildString, BuildNumber ;
-FROM M2MetaError IMPORT MetaErrorT0, MetaErrorT2 ;
+FROM M2MetaError IMPORT MetaErrorT0, MetaErrorT1, MetaErrorT2 ;
FROM M2CaseList IMPORT ElseCase ;
FROM M2StackSpell IMPORT GetRecordField ;
@@ -174,8 +174,9 @@ FROM SymbolTable IMPORT MakeGnuAsm, PutGnuAsmVolatile,
PutGnuAsm, PutGnuAsmInput
PutIncluded,
IsVarParam, IsProcedure, IsDefImp, IsModule,
IsProcType,
IsRecord,
- RequestSym, IsExported, IsImported,
- GetSym, GetLocalSym ;
+ RequestSym, IsExported, IsImported, IsUnknown,
+ GetSym, GetLocalSym,
+ UnknownReported ;
FROM M2Batch IMPORT IsModuleKnown ;
@@ -1115,25 +1116,35 @@ Designator := QualidentCheck
% Che
{ SubDesignator } =:
SubDesignator := "." %
VAR Sym, Type, tok,
-
dotpostok : CARDINAL ;
-
name, n1 : Name ; %
+
dotpostok: CARDINAL ;
+
name : Name ; %
%
dotpostok := GetTokenNo () -1 ;
PopTFtok (Sym, Type, tok) ;
Type := SkipType(Type) ;
PushTFtok(Sym, Type, tok) ;
IF Type=NulSym
THEN
-
n1 := GetSymName(Sym) ;
IF IsModuleKnown(GetSymName(Sym))
THEN
-
WriteFormat2('%a looks like a module which has not been globally imported
(eg. suggest that you IMPORT %a)',
-
n1, n1)
+
MetaErrorT1 (tok, '{%1a} looks like a module which has not been globally
imported (eg. suggest that you IMPORT {%1a}', Sym)
ELSE
-
WriteFormat1('%a is not a record variable', n1)
+
IF IsUnknown (Sym)
+
THEN
+
MetaErrorT1 (tok, 'the qualifier {%1Ua} is unknown {%1&siD}', Sym) ;
+
UnknownReported (Sym)
+
ELSE
+
MetaErrorT1 (tok, "the type of {%1ad} is not a record (but {%1tad})",
Sym)
+
END
END
ELSIF NOT IsRecord(Type)
THEN
-
MetaErrorT2 (tok, "the type of {%1ad} is not a record (but {%2ad}) and
therefore it has no field", Sym, Type) ;
+
IF IsUnknown (Type)
+
THEN
+
MetaErrorT1 (tok, 'the qualifier {%1Ua} is unknown {%1&siD}', Type) ;
+
UnknownReported (Type)
+
ELSE
+
MetaErrorT2 (tok, "the type of {%1ad} is not a record (but {%2ad}) and
therefore it has no field", Sym, Type)
+
END
END ;
StartScope(Type) %
Ident
diff --git a/gcc/testsuite/gm2.dg/spell/iso/fail/badmodule.mod
b/gcc/testsuite/gm2.dg/spell/iso/fail/badmodule.mod
new file mode 100644
index 00000000000..9e1972bd1bd
--- /dev/null
+++ b/gcc/testsuite/gm2.dg/spell/iso/fail/badmodule.mod
@@ -0,0 +1,17 @@
+
+(* { dg-do compile } *)
+(* { dg-options "-g" } *)
+
+MODULE badmodule ;
+
+IMPORT color ;
+
+PROCEDURE Init ;
+BEGIN
+ colors.Clear
+(* { dg-error "the qualifier 'colors' is unknown, did you mean color?"
"colors" { target *-*-* } 11 } *)
+END Init ;
+
+BEGIN
+ Init
+END badmodule.
diff --git a/gcc/testsuite/gm2.dg/spell/iso/fail/badrecord.mod
b/gcc/testsuite/gm2.dg/spell/iso/fail/badrecord.mod
new file mode 100644
index 00000000000..8d9b8ccba82
--- /dev/null
+++ b/gcc/testsuite/gm2.dg/spell/iso/fail/badrecord.mod
@@ -0,0 +1,20 @@
+
+(* { dg-do compile } *)
+(* { dg-options "-g" } *)
+
+MODULE badrecord ;
+
+TYPE
+ color = RECORD
+ red, blue, green: CARDINAL ;
+ END ;
+
+PROCEDURE Init ;
+BEGIN
+ colors.red := 1 ;
+(* { dg-error "the qualifier 'colors' is unknown, did you mean color?"
"colors" { target *-*-* } 14 } *)
+END Init ;
+
+BEGIN
+ Init
+END badrecord.
diff --git a/gcc/testsuite/gm2.dg/spell/iso/fail/color.def
b/gcc/testsuite/gm2.dg/spell/iso/fail/color.def
new file mode 100644
index 00000000000..25fe68b8216
--- /dev/null
+++ b/gcc/testsuite/gm2.dg/spell/iso/fail/color.def
@@ -0,0 +1,5 @@
+DEFINITION MODULE color ;
+
+PROCEDURE Clear ;
+
+END color.
--
2.47.3