mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-01-10 16:45:14 +08:00
Bugfix to allow testsuite/gm2/pim/pass/arraybool.mod to compile on ppc64le
This bug is exposed on the ppc64le platform. The expression parser P3Build.bnf (and PHBuild.bnf) BuiltNot omitted to record the current token position on the quad stack. The patch changes all occurances of NEW to newBoolFrame to ensure that the tokenno recorded in the bool frame is set to a sensible value. BuildNot is fixed and improved to generate a virtual token recording the position of the subexpression. gcc/m2/ChangeLog: * gm2-compiler/M2LexBuf.mod (isSrcToken): Add block comment. Remove dead code. * gm2-compiler/M2Quads.def (BuildNot): Add notTokPos parameter. * gm2-compiler/M2Quads.mod (BuildNot): Add notTokPos parameter. Create and push virtual token. (PopBooltok): New procedure. (PushBooltok): New procedure. (PushBool): Re-implement using PushBooltok. (PopBool): Re-implement using PopBooltok. * gm2-compiler/P3Build.bnf (ConstFactor): Record token position of NOT. (Factor): Record token position of NOT. * gm2-compiler/PHBuild.bnf (ConstFactor): Record token position of NOT. (Relation): Push token position. (UnaryOrConstTerm): Push token position. (AddOperator): Push token position. (MulOperator): Push token position. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
This commit is contained in:
parent
4dc4584b60
commit
c8f2be5d43
@ -1117,7 +1117,8 @@ END PrintTokenNo ;
|
||||
|
||||
|
||||
(*
|
||||
isSrcToken -
|
||||
isSrcToken - returns TRUE if tokenno is associated with
|
||||
program source code.
|
||||
*)
|
||||
|
||||
PROCEDURE isSrcToken (tokenno: CARDINAL) : BOOLEAN ;
|
||||
@ -1138,10 +1139,6 @@ VAR
|
||||
bufLeft, bufRight: TokenBucket ;
|
||||
lc, ll, lr : location_t ;
|
||||
BEGIN
|
||||
IF FALSE
|
||||
THEN
|
||||
RETURN caret
|
||||
END ;
|
||||
IF isSrcToken (caret) AND isSrcToken (left) AND isSrcToken (right)
|
||||
THEN
|
||||
lc := TokenToLocation (caret) ;
|
||||
|
@ -2064,7 +2064,7 @@ PROCEDURE PopConstructor ;
|
||||
|------------| |------------|
|
||||
*)
|
||||
|
||||
PROCEDURE BuildNot ;
|
||||
PROCEDURE BuildNot (notTokPos: CARDINAL) ;
|
||||
|
||||
|
||||
(*
|
||||
|
@ -12872,13 +12872,16 @@ END BuildRelOp ;
|
||||
|------------| |------------|
|
||||
*)
|
||||
|
||||
PROCEDURE BuildNot ;
|
||||
PROCEDURE BuildNot (notTokPos: CARDINAL) ;
|
||||
VAR
|
||||
t, f: CARDINAL ;
|
||||
combinedTok,
|
||||
exprTokPos : CARDINAL ;
|
||||
t, f : CARDINAL ;
|
||||
BEGIN
|
||||
CheckBooleanId ;
|
||||
PopBool (t, f) ;
|
||||
PushBool (f, t)
|
||||
PopBooltok (t, f, exprTokPos) ;
|
||||
combinedTok := MakeVirtualTok (notTokPos, notTokPos, exprTokPos) ;
|
||||
PushBooltok (f, t, combinedTok)
|
||||
END BuildNot ;
|
||||
|
||||
|
||||
@ -13662,11 +13665,11 @@ END OperandTtok ;
|
||||
|
||||
|
||||
(*
|
||||
PopBool - Pops a True and a False exit quad number from the True/False
|
||||
stack.
|
||||
PopBooltok - Pops a True and a False exit quad number from the True/False
|
||||
stack.
|
||||
*)
|
||||
|
||||
PROCEDURE PopBool (VAR True, False: CARDINAL) ;
|
||||
PROCEDURE PopBooltok (VAR True, False: CARDINAL; VAR tokno: CARDINAL) ;
|
||||
VAR
|
||||
f: BoolFrame ;
|
||||
BEGIN
|
||||
@ -13674,9 +13677,47 @@ BEGIN
|
||||
WITH f^ DO
|
||||
True := TrueExit ;
|
||||
False := FalseExit ;
|
||||
tokno := tokenno ;
|
||||
Assert (BooleanOp)
|
||||
END ;
|
||||
DISPOSE (f)
|
||||
END PopBooltok ;
|
||||
|
||||
|
||||
(*
|
||||
PushBooltok - Push a True and a False exit quad numbers onto the
|
||||
True/False stack.
|
||||
*)
|
||||
|
||||
PROCEDURE PushBooltok (True, False: CARDINAL; tokno: CARDINAL) ;
|
||||
VAR
|
||||
f: BoolFrame ;
|
||||
BEGIN
|
||||
Assert (True<=NextQuad) ;
|
||||
Assert (False<=NextQuad) ;
|
||||
f := newBoolFrame () ;
|
||||
WITH f^ DO
|
||||
TrueExit := True ;
|
||||
FalseExit := False ;
|
||||
BooleanOp := TRUE ;
|
||||
tokenno := tokno ;
|
||||
Annotation := NIL
|
||||
END ;
|
||||
PushAddress (BoolStack, f) ;
|
||||
Annotate ('<q%1d>|<q%2d>||true quad|false quad')
|
||||
END PushBooltok ;
|
||||
|
||||
|
||||
(*
|
||||
PopBool - Pops a True and a False exit quad number from the True/False
|
||||
stack.
|
||||
*)
|
||||
|
||||
PROCEDURE PopBool (VAR True, False: CARDINAL) ;
|
||||
VAR
|
||||
tokno: CARDINAL ;
|
||||
BEGIN
|
||||
PopBooltok (True, False, tokno)
|
||||
END PopBool ;
|
||||
|
||||
|
||||
@ -13686,20 +13727,8 @@ END PopBool ;
|
||||
*)
|
||||
|
||||
PROCEDURE PushBool (True, False: CARDINAL) ;
|
||||
VAR
|
||||
f: BoolFrame ;
|
||||
BEGIN
|
||||
Assert(True<=NextQuad) ;
|
||||
Assert(False<=NextQuad) ;
|
||||
NEW(f) ;
|
||||
WITH f^ DO
|
||||
TrueExit := True ;
|
||||
FalseExit := False ;
|
||||
BooleanOp := TRUE ;
|
||||
Annotation := NIL
|
||||
END ;
|
||||
PushAddress (BoolStack, f) ;
|
||||
Annotate ('<q%1d>|<q%2d>||true quad|false quad')
|
||||
PushBooltok (True, False, UnknownTokenNo)
|
||||
END PushBool ;
|
||||
|
||||
|
||||
@ -14571,7 +14600,7 @@ PROCEDURE newBoolFrame () : BoolFrame ;
|
||||
VAR
|
||||
f: BoolFrame ;
|
||||
BEGIN
|
||||
NEW(f) ;
|
||||
NEW (f) ;
|
||||
WITH f^ DO
|
||||
TrueExit := 0 ;
|
||||
FalseExit := 0 ;
|
||||
@ -14618,7 +14647,7 @@ BEGIN
|
||||
WITH f^ DO
|
||||
TrueExit := True
|
||||
END ;
|
||||
PushAddress(BoolStack, f)
|
||||
PushAddress (BoolStack, f)
|
||||
END PushT ;
|
||||
|
||||
|
||||
@ -14630,7 +14659,7 @@ PROCEDURE PopT (VAR True: WORD) ;
|
||||
VAR
|
||||
f: BoolFrame ;
|
||||
BEGIN
|
||||
f := PopAddress(BoolStack) ;
|
||||
f := PopAddress (BoolStack) ;
|
||||
WITH f^ DO
|
||||
True := TrueExit ;
|
||||
Assert(NOT BooleanOp)
|
||||
|
@ -723,8 +723,10 @@ MulOperator := "*" % Pus
|
||||
RecordOp %
|
||||
=:
|
||||
|
||||
ConstFactor := Number | ConstString | ConstSetOrQualidentOrFunction |
|
||||
"(" ConstExpression ")" | "NOT" ConstFactor % BuildNot %
|
||||
ConstFactor := % VAR tokpos: CARDINAL ; %
|
||||
Number | ConstString | ConstSetOrQualidentOrFunction |
|
||||
"(" ConstExpression ")" | "NOT" % tokpos := GetTokenNo() -1 %
|
||||
ConstFactor % BuildNot (tokpos) %
|
||||
| ConstAttribute =:
|
||||
|
||||
-- to help satisfy LL1
|
||||
@ -1087,11 +1089,14 @@ UnaryOrTerm := "+" % Pus
|
||||
Term % BuildUnaryOp %
|
||||
| Term =:
|
||||
|
||||
Term := Factor { MulOperator Factor % BuildBinaryOp %
|
||||
Term := Factor
|
||||
{ MulOperator Factor % BuildBinaryOp %
|
||||
} =:
|
||||
|
||||
Factor := Number | string | SetOrDesignatorOrFunction |
|
||||
"(" Expression ")" | "NOT" ( Factor % BuildNot %
|
||||
Factor := % VAR tokpos: CARDINAL ; %
|
||||
Number | string | SetOrDesignatorOrFunction |
|
||||
"(" Expression ")" | "NOT" % tokpos := GetTokenNo ()-1 %
|
||||
( Factor % BuildNot (tokpos) %
|
||||
| ConstAttribute
|
||||
) =:
|
||||
|
||||
|
@ -53,7 +53,8 @@ FROM M2Printf IMPORT printf0 ;
|
||||
FROM M2Debug IMPORT Assert ;
|
||||
FROM P2SymBuild IMPORT BuildString, BuildNumber ;
|
||||
|
||||
FROM M2Quads IMPORT PushT, PopT, PushTF, PopTF, PopNothing, PushTFtok, PopTFtok, PopTtok,
|
||||
FROM M2Quads IMPORT PushT, PopT, PushTF, PopTF, PopNothing, Annotate,
|
||||
PushTtok, PushTFtok, PopTtok, PopTFtok, OperandTok,
|
||||
StartBuildDefFile, StartBuildModFile,
|
||||
BuildModuleStart,
|
||||
EndBuildFile,
|
||||
@ -630,56 +631,58 @@ ConstExpression := % VAR
|
||||
] % PopAuto %
|
||||
=:
|
||||
|
||||
Relation := "=" % PushT(EqualTok) %
|
||||
| "#" % PushT(HashTok) %
|
||||
| "<>" % PushT(LessGreaterTok) %
|
||||
| "<" % PushT(LessTok) %
|
||||
| "<=" % PushT(LessEqualTok) %
|
||||
| ">" % PushT(GreaterTok) %
|
||||
| ">=" % PushT(GreaterEqualTok) %
|
||||
| "IN" % PushT(InTok) %
|
||||
Relation := "=" % PushTtok(EqualTok, GetTokenNo() -1) %
|
||||
| "#" % PushTtok(HashTok, GetTokenNo() -1) %
|
||||
| "<>" % PushTtok(LessGreaterTok, GetTokenNo() -1) %
|
||||
| "<" % PushTtok(LessTok, GetTokenNo() -1) %
|
||||
| "<=" % PushTtok(LessEqualTok, GetTokenNo() -1) %
|
||||
| ">" % PushTtok(GreaterTok, GetTokenNo() -1) %
|
||||
| ">=" % PushTtok(GreaterEqualTok, GetTokenNo() -1) %
|
||||
| "IN" % PushTtok(InTok, GetTokenNo() -1) %
|
||||
=:
|
||||
|
||||
SimpleConstExpr := UnaryOrConstTerm { AddOperator ConstTerm % BuildBinaryOp %
|
||||
} =:
|
||||
|
||||
UnaryOrConstTerm := "+" % PushT(PlusTok) %
|
||||
UnaryOrConstTerm := "+" % PushTtok(PlusTok, GetTokenNo() -1) %
|
||||
ConstTerm % BuildUnaryOp %
|
||||
|
|
||||
"-" % PushT(MinusTok) %
|
||||
"-" % PushTtok(MinusTok, GetTokenNo() -1) %
|
||||
ConstTerm % BuildUnaryOp %
|
||||
|
|
||||
ConstTerm =:
|
||||
|
||||
AddOperator := "+" % PushT(PlusTok) ;
|
||||
AddOperator := "+" % PushTtok(PlusTok, GetTokenNo() -1) ;
|
||||
RecordOp %
|
||||
| "-" % PushT(MinusTok) ;
|
||||
| "-" % PushTtok(MinusTok, GetTokenNo() -1) ;
|
||||
RecordOp %
|
||||
| "OR" % PushT(OrTok) ;
|
||||
| "OR" % PushTtok(OrTok, GetTokenNo() -1) ;
|
||||
RecordOp %
|
||||
=:
|
||||
|
||||
ConstTerm := ConstFactor { MulOperator ConstFactor % BuildBinaryOp %
|
||||
} =:
|
||||
|
||||
MulOperator := "*" % PushT(TimesTok) ;
|
||||
MulOperator := "*" % PushTtok(TimesTok, GetTokenNo() -1) ;
|
||||
RecordOp %
|
||||
| "/" % PushT(DivideTok) ;
|
||||
| "/" % PushTtok(DivideTok, GetTokenNo() -1) ;
|
||||
RecordOp %
|
||||
| "DIV" % PushT(DivTok) ;
|
||||
| "DIV" % PushTtok(DivTok, GetTokenNo() -1) ;
|
||||
RecordOp %
|
||||
| "MOD" % PushT(ModTok) ;
|
||||
| "MOD" % PushTtok(ModTok, GetTokenNo() -1) ;
|
||||
RecordOp %
|
||||
| "REM" % PushT(RemTok) ;
|
||||
| "REM" % PushTtok(RemTok, GetTokenNo() -1) ;
|
||||
RecordOp %
|
||||
| "AND" % PushT(AndTok) ;
|
||||
| "AND" % PushTtok(AndTok, GetTokenNo() -1) ;
|
||||
RecordOp %
|
||||
| "&" % PushT(AmbersandTok) ;
|
||||
| "&" % PushTtok(AmbersandTok, GetTokenNo() -1) ;
|
||||
RecordOp %
|
||||
=:
|
||||
|
||||
ConstFactor := Number | ConstString | ConstSetOrQualidentOrFunction |
|
||||
"(" ConstExpression ")" | "NOT" ConstFactor % BuildNot %
|
||||
ConstFactor := % VAR tokpos: CARDINAL ; %
|
||||
Number | ConstString | ConstSetOrQualidentOrFunction |
|
||||
"(" ConstExpression ")" | "NOT" % tokpos := GetTokenNo() -1 %
|
||||
ConstFactor % BuildNot (tokpos) %
|
||||
| ConstAttribute =:
|
||||
|
||||
-- to help satisfy LL1
|
||||
|
Loading…
Reference in New Issue
Block a user