PR modula2/109423 cc1gm2 ICE if an INCL or EXCL is performed on an unknown set

This patch fixes an ICE if attempting to INCL or EXCL on an unknown
set.  The fix was to correct an error format string.  Also included in
the patch are patches to remove unused variables.  The patch also
marks a variable as written in BuildAdr.

gcc/m2/ChangeLog:

	PR modula2/109423
	* gm2-compiler/M2Base.def (Unbounded): Remove.
	* gm2-compiler/M2Error.def (ErrorAbort0): Add noreturn
	attribute.
	* gm2-compiler/M2Quads.mod (BuildInclProcedure): Correct
	error format string.
	(BuildExceptProcedure): Correct error format string.
	(BuildAdrFunction): Call PutWriteQuad when taking the
	address of a variable.
	* gm2-libs-ch/SysExceptions.c (_M2_SysExceptions_init): Add
	parameters.
	* gm2-libs-ch/wrapc.c (_M2_wrapc_init): Add parameters.
	* gm2-libs/DynamicStrings.mod (DumpStringInfo): Remove t.
	(PopAllocationExemption): Remove f.
	* gm2-libs/FIO.mod (BufferedWrite): Remove result.
	* gm2-libs/FormatStrings.mod (Copy): Remove endpos and
	afterperc.
	(HandlePercent): Remove result.
	* gm2-libs/Indexing.mod (RemoveIndiceFromIndex): Remove k.
	* gm2-libs/M2Dependent.mod (CreateModule): Remove p0
	and p1.
	(DumpModuleData): Remove mptr.
	(ConstructModules): Remove nulp.
	* gm2-libs/RTExceptions.mod (PopHandler): Remove i.
	* gm2-libs/RTint.mod (Listen): Remove b4s, b4m, afs
	and afm.
	* gm2-libs/SFIO.mod (ReadS): Remove c.
	* gm2-libs/StringConvert.mod (doDecimalPlaces): Remove
	whole and fraction.

gcc/testsuite/ChangeLog:

	* gm2/pim/fail/setunknown.mod: New test.
	PR modula2/109423
	* gm2/pim/fail/setunknown2.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
This commit is contained in:
Gaius Mulley
2023-04-05 23:07:46 +01:00
parent 3bfd0420e4
commit 1bd13193fa
16 changed files with 27 additions and 32 deletions
-1
View File
@@ -126,7 +126,6 @@ VAR
LongReal, ShortReal,
Complex, LongComplex,
ShortComplex,
Unbounded,
High, LengthS,
Cap, Abs, Odd,
Convert, Val,
+1 -1
View File
@@ -226,7 +226,7 @@ PROCEDURE FlushWarnings ;
ErrorAbort0 - aborts compiling, it flushes all warnings and errors before aborting.
*)
PROCEDURE ErrorAbort0 (a: ARRAY OF CHAR) ;
PROCEDURE ErrorAbort0 (a: ARRAY OF CHAR) <* noreturn *> ;
(*
+5 -4
View File
@@ -7232,12 +7232,12 @@ BEGIN
GenQuadO (proctok, InclOp, VarSym, NulSym, DerefSym, FALSE)
ELSE
MetaErrorT1 (proctok,
'the first parameter to {%EkINCL} must be a set variable but is {%E1d}',
'the first parameter to {%EkINCL} must be a set variable but is {%1Ed}',
VarSym)
END
ELSE
MetaErrorT1 (proctok,
'base procedure {%EkINCL} expects a variable as a parameter but is {%E1d}',
'base procedure {%EkINCL} expects a variable as a parameter but is {%1Ed}',
VarSym)
END
ELSE
@@ -7298,12 +7298,12 @@ BEGIN
GenQuadO (proctok, ExclOp, VarSym, NulSym, DerefSym, FALSE)
ELSE
MetaErrorT1 (proctok,
'the first parameter to {%EkEXCL} must be a set variable but is {%E1d}',
'the first parameter to {%EkEXCL} must be a set variable but is {%1Ed}',
VarSym)
END
ELSE
MetaErrorT1 (proctok,
'base procedure {%EkEXCL} expects a variable as a parameter but is {%E1d}',
'base procedure {%EkEXCL} expects a variable as a parameter but is {%1Ed}',
VarSym)
END
ELSE
@@ -9996,6 +9996,7 @@ BEGIN
ELSE
GenQuadO (combinedTok, AddrOp, returnVar, NulSym, OperandT (1), FALSE)
END ;
PutWriteQuad (OperandT (1), GetMode (OperandT (1)), NextQuad-1) ;
rw := OperandMergeRW (1) ;
Assert (IsLegal (rw))
END ;
+1 -1
View File
@@ -230,7 +230,7 @@ SysExceptions_InitExceptionHandlers (void *indexf, void *range, void *casef,
/* GNU Modula-2 linking fodder. */
void
_M2_SysExceptions_init (void)
_M2_SysExceptions_init (int argc, char *argv[], char *envp[])
{
}
+1 -1
View File
@@ -228,7 +228,7 @@ wrapc_isfinitef (float x)
/* init - init/finish functions for the module */
void
_M2_wrapc_init ()
_M2_wrapc_init (int argc, char *argv[], char *envp[])
{
}
-3
View File
@@ -129,8 +129,6 @@ END writeNspace ;
*)
PROCEDURE DumpStringInfo (s: String; i: CARDINAL) ;
VAR
t: String ;
BEGIN
IF s # NIL
THEN
@@ -164,7 +162,6 @@ END stop ;
PROCEDURE PopAllocationExemption (halt: BOOLEAN; e: String) : String ;
VAR
s: String ;
f: frame ;
b: BOOLEAN ;
BEGIN
Init ;
-2
View File
@@ -667,7 +667,6 @@ END ReadNBytes ;
PROCEDURE BufferedRead (f: File; nBytes: CARDINAL; a: ADDRESS) : INTEGER ;
VAR
t : ADDRESS ;
result: INTEGER ;
total,
n : INTEGER ;
p : POINTER TO BYTE ;
@@ -1236,7 +1235,6 @@ END WriteNBytes ;
PROCEDURE BufferedWrite (f: File; nBytes: CARDINAL; a: ADDRESS) : INTEGER ;
VAR
t : ADDRESS ;
result: INTEGER ;
total,
n : INTEGER ;
p : POINTER TO BYTE ;
+1 -3
View File
@@ -301,8 +301,7 @@ VAR
c,
width,
nextperc,
afterperc,
endpos : INTEGER ;
afterperc: INTEGER ;
leader,
ch, ch2 : CHAR ;
p : String ;
@@ -444,7 +443,6 @@ END Copy ;
PROCEDURE HandlePercent (fmt, s: String; startpos: INTEGER) : String ;
VAR
prevpos: INTEGER ;
result : String ;
BEGIN
IF (startpos = VAL (INTEGER, Length (fmt))) OR (startpos < 0)
THEN
+3 -3
View File
@@ -261,9 +261,9 @@ END IsIndiceInIndex ;
PROCEDURE RemoveIndiceFromIndex (i: Index; a: ADDRESS) ;
VAR
j, k: CARDINAL ;
p : PtrToAddress ;
b : PtrToByte ;
j: CARDINAL ;
p: PtrToAddress ;
b: PtrToByte ;
BEGIN
WITH i^ DO
j := Low ;
+1 -5
View File
@@ -85,8 +85,7 @@ PROCEDURE CreateModule (name, libname: ADDRESS;
init, fini: ArgCVEnvP;
dependencies: PROC) : ModuleChain ;
VAR
mptr : ModuleChain ;
p0, p1: ADDRESS ;
mptr: ModuleChain ;
BEGIN
NEW (mptr) ;
mptr^.name := name ;
@@ -595,8 +594,6 @@ END DisplayModuleInfo ;
*)
PROCEDURE DumpModuleData (flag: BOOLEAN) ;
VAR
mptr: ModuleChain ;
BEGIN
IF flag
THEN
@@ -767,7 +764,6 @@ PROCEDURE ConstructModules (applicationmodule, libname,
argc: INTEGER; argv, envp: ADDRESS) ;
VAR
mptr: ModuleChain ;
nulp: ArgCVEnvP ;
BEGIN
CheckInitialized ;
DynamicInitialization := TRUE ; (* This procedure is only called if we desire dynamic initialization. *)
+1 -1
View File
@@ -531,7 +531,7 @@ END PushHandler ;
PROCEDURE PopHandler (e: EHBlock; number: CARDINAL) ;
VAR
h, i: Handler ;
h: Handler ;
BEGIN
h := findHandler(e, number) ;
IF h#NIL
-4
View File
@@ -673,10 +673,6 @@ VAR
vec : Vector ;
inSet,
outSet : SetOfFd ;
b4s,
b4m,
afs,
afm,
sec,
micro : CARDINAL ;
maxFd : INTEGER ;
-1
View File
@@ -128,7 +128,6 @@ END WriteS ;
PROCEDURE ReadS (file: File) : String ;
VAR
s: String ;
c: CARDINAL ;
BEGIN
s := InitString ('') ;
WHILE (NOT EOLN (file)) AND (NOT EOF (file)) AND IsNoError (file) DO
-2
View File
@@ -1099,8 +1099,6 @@ VAR
i, l,
point : INTEGER ;
t,
whole,
fraction,
tenths,
hundreths: String ;
BEGIN
@@ -0,0 +1,8 @@
MODULE setunknown ;
VAR
set: SET OF [0..7] ;
BEGIN
INCL (set, unknownVariable)
END setunknown.
@@ -0,0 +1,5 @@
MODULE setunknown2 ;
BEGIN
INCL (unknownSet, unknownVariable)
END setunknown2.