PR modula2/110161 Comparing a typed procedure variable to 0 gives ICE or assertion
This patch allows a proc type to be compared against an address. gcc/m2/ChangeLog: PR modula2/110161 * gm2-compiler/M2Check.mod (checkProcTypeEquivalence): New procedure function. (checkTypeKindEquivalence): Call checkProcTypeEquivalence if either left or right is a proc type. * gm2-compiler/M2Quads.mod (BuildRelOp): Create combinedTok prior to creating the range check quadruple. Use combinedTok when creating the range check quadruple. gcc/testsuite/ChangeLog: PR modula2/110161 * gm2/pim/fail/badxproc.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
This commit is contained in:
parent
6cb2f2c7f3
commit
8bf244e32a
3 changed files with 43 additions and 9 deletions
|
@ -901,6 +901,37 @@ BEGIN
|
|||
END checkPointerType ;
|
||||
|
||||
|
||||
(*
|
||||
checkProcTypeEquivalence - allow proctype to be compared against another
|
||||
proctype or procedure. It is legal to be compared
|
||||
against an address.
|
||||
*)
|
||||
|
||||
PROCEDURE checkProcTypeEquivalence (result: status; tinfo: tInfo;
|
||||
left, right: CARDINAL) : status ;
|
||||
BEGIN
|
||||
IF isFalse (result)
|
||||
THEN
|
||||
RETURN result
|
||||
ELSIF IsProcedure (left) AND IsProcType (right)
|
||||
THEN
|
||||
RETURN checkProcedure (result, tinfo, right, left)
|
||||
ELSIF IsProcType (left) AND IsProcedure (right)
|
||||
THEN
|
||||
RETURN checkProcedure (result, tinfo, left, right)
|
||||
ELSIF IsProcType (left) AND IsProcType (right)
|
||||
THEN
|
||||
RETURN checkProcType (result, tinfo, left, right)
|
||||
ELSIF (left = Address) OR (right = Address)
|
||||
THEN
|
||||
RETURN true
|
||||
ELSE
|
||||
RETURN false
|
||||
END
|
||||
END checkProcTypeEquivalence ;
|
||||
|
||||
|
||||
|
||||
(*
|
||||
checkTypeKindEquivalence -
|
||||
*)
|
||||
|
@ -928,15 +959,9 @@ BEGIN
|
|||
ELSIF IsEnumeration (left) AND IsEnumeration (right)
|
||||
THEN
|
||||
RETURN checkEnumerationEquivalence (result, left, right)
|
||||
ELSIF IsProcedure (left) AND IsProcType (right)
|
||||
THEN
|
||||
RETURN checkProcedure (result, tinfo, right, left)
|
||||
ELSIF IsProcType (left) AND IsProcedure (right)
|
||||
THEN
|
||||
RETURN checkProcedure (result, tinfo, left, right)
|
||||
ELSIF IsProcType (left) OR IsProcType (right)
|
||||
THEN
|
||||
RETURN checkProcType (result, tinfo, left, right)
|
||||
RETURN checkProcTypeEquivalence (result, tinfo, right, left)
|
||||
ELSIF IsReallyPointer (left) AND IsReallyPointer (right)
|
||||
THEN
|
||||
RETURN checkPointerType (result, left, right)
|
||||
|
|
|
@ -12969,11 +12969,13 @@ BEGIN
|
|||
|
||||
CheckVariableOrConstantOrProcedure (rightpos, right) ;
|
||||
CheckVariableOrConstantOrProcedure (leftpos, left) ;
|
||||
combinedTok := MakeVirtualTok (optokpos, leftpos, rightpos) ;
|
||||
|
||||
IF (left#NulSym) AND (right#NulSym)
|
||||
THEN
|
||||
(* BuildRange will check the expression later on once gcc knows about all data types. *)
|
||||
BuildRange (InitTypesExpressionCheck (optokpos, left, right, TRUE, Op = InTok))
|
||||
BuildRange (InitTypesExpressionCheck (combinedTok, left, right, TRUE,
|
||||
Op = InTok))
|
||||
END ;
|
||||
|
||||
(* Must dereference LeftValue operands. *)
|
||||
|
@ -12993,7 +12995,6 @@ BEGIN
|
|||
doIndrX (leftpos, t, left) ;
|
||||
left := t
|
||||
END ;
|
||||
combinedTok := MakeVirtualTok (optokpos, leftpos, rightpos) ;
|
||||
|
||||
IF DebugTokPos
|
||||
THEN
|
||||
|
|
8
gcc/testsuite/gm2/pim/fail/badxproc.mod
Normal file
8
gcc/testsuite/gm2/pim/fail/badxproc.mod
Normal file
|
@ -0,0 +1,8 @@
|
|||
MODULE badxproc ;
|
||||
|
||||
TYPE xProc = PROCEDURE(): BOOLEAN;
|
||||
VAR x: xProc;
|
||||
|
||||
BEGIN
|
||||
IF x = 0 THEN END;
|
||||
END badxproc.
|
Loading…
Add table
Reference in a new issue