public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-1739] PR modula2/110189 Using an unknown TYPE as argument to VAL gives ICE
@ 2023-06-12 23:55 Gaius Mulley
0 siblings, 0 replies; only message in thread
From: Gaius Mulley @ 2023-06-12 23:55 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:8089f26b94f47d9923d3bc0c05aae09363983b2e
commit r14-1739-g8089f26b94f47d9923d3bc0c05aae09363983b2e
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date: Tue Jun 13 00:53:53 2023 +0100
PR modula2/110189 Using an unknown TYPE as argument to VAL gives ICE
This patch tidies P3Build.bnf and fixes error format specs in
M2Quads.mod when encountering unknown symbols.
gcc/m2/ChangeLog:
PR modula2/110189
* gm2-compiler/M2Quads.mod (BuildAbsFunction): Replace abort
format specifier.
(BuildValFunction): Replace abort format specifier.
(BuildCastFunction): Replace abort format specifier.
(BuildMinFunction): Replace abort format specifier.
(BuildMaxFunction): Replace abort format specifier.
(BuildTruncFunction): Replace abort format specifier.
* gm2-compiler/P3Build.bnf (Pass1): Remove.
(Pass2): Remove.
(Pass3): Remove.
(Expect): Add Pass1.
(AsmStatement): Remove Pass3.
(AsmOperands): Remove Pass3.
(AsmOperandSpec): Remove Pass3.
(AsmInputElement): Remove Pass3.
(AsmOutputElement): Remove Pass3.
(AsmTrashList): Remove Pass3.
gcc/testsuite/ChangeLog:
PR modula2/110189
* gm2/pim/fail/foovaltype.mod: New test.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Diff:
---
gcc/m2/gm2-compiler/M2Quads.mod | 30 +++---
gcc/m2/gm2-compiler/P3Build.bnf | 165 ++++++++++++------------------
gcc/testsuite/gm2/pim/fail/foovaltype.mod | 7 ++
3 files changed, 85 insertions(+), 117 deletions(-)
diff --git a/gcc/m2/gm2-compiler/M2Quads.mod b/gcc/m2/gm2-compiler/M2Quads.mod
index 081e9311ae8..399a09f32c9 100644
--- a/gcc/m2/gm2-compiler/M2Quads.mod
+++ b/gcc/m2/gm2-compiler/M2Quads.mod
@@ -8501,7 +8501,7 @@ BEGIN
PushTFtok (Res, GetSType (Var), combinedtok)
ELSE
MetaErrorT1 (combinedtok,
- 'the parameter to {%A1kABS} must be a variable or constant, seen {%E1ad}',
+ 'the parameter to {%A1kABS} must be a variable or constant, seen {%1ad}',
Var)
END
ELSE
@@ -9072,7 +9072,7 @@ BEGIN
THEN
(* not sensible to try and recover when we dont know the return type. *)
MetaErrorT1 (typetok,
- 'undeclared type found in builtin procedure function {%AkVAL} {%A1ad}',
+ 'undeclared type found in builtin procedure function {%AkVAL} {%1ad}',
Type)
(* non recoverable error. *)
ELSIF (IsSet (Type) OR IsEnumeration (Type) OR IsSubrange (Type) OR
@@ -9090,7 +9090,7 @@ BEGIN
ELSE
(* not sensible to try and recover when we dont know the return type. *)
MetaErrorT0 (functok,
- 'the builtin procedure {%AkVAL} has thw following formal parameter declaration {%kVAL} (type, expression)')
+ 'the builtin procedure {%AkVAL} has the following formal parameter declaration {%kVAL} (type, expression)')
(* non recoverable error. *)
END
ELSE
@@ -9182,7 +9182,7 @@ BEGIN
ELSE
(* not sensible to try and recover when we dont know the return type. *)
MetaErrorT0 (functok,
- 'the second parameter to the builtin procedure {%AkCAST} must either be a variable, constant or a procedure. The formal parameters to cast are CAST(type, variable or constant or procedure)')
+ 'the second parameter to the builtin procedure {%AkCAST} must either be a variable, constant or a procedure. The formal parameters to cast are {%kCAST} (type, variable or constant or procedure)')
(* non recoverable error. *)
END
ELSE
@@ -9350,7 +9350,7 @@ BEGIN
ELSIF GetSType (type) = NulSym
THEN
MetaErrorT1 (tok,
- 'unable to obtain the {%AkMIN} value for type {%1Aad}', type) ;
+ 'unable to obtain the {%AkMIN} value for type {%1ad}', type) ;
(* non recoverable error. *)
InternalError ('MetaErrorT1 {%AkMIN} should call abort')
ELSE
@@ -9388,7 +9388,7 @@ BEGIN
ELSIF GetSType (type) = NulSym
THEN
MetaErrorT1 (tok,
- 'unable to obtain the {%AkMAX} value for type {%1Aad}', type) ;
+ 'unable to obtain the {%AkMAX} value for type {%1ad}', type) ;
(* non recoverable error. *)
InternalError ('MetaErrorT1 {%AkMAX} should call abort')
ELSE
@@ -9444,14 +9444,14 @@ BEGIN
ELSE
(* we dont know the type therefore cannot fake a return. *)
MetaErrorT1 (vartok,
- 'parameter to {%AkMIN} must be a type or a variable, seen {%1Aad}',
+ 'parameter to {%AkMIN} must be a type or a variable, seen {%1ad}',
Var)
(* non recoverable error. *)
END
ELSE
(* we dont know the type therefore cannot fake a return. *)
MetaErrorT1 (functok,
- 'the pseudo builtin procedure function {%AkMIN} only has one parameter, seen {%1An}',
+ 'the pseudo builtin procedure function {%AkMIN} only has one parameter, seen {%1n}',
NoOfParam)
(* non recoverable error. *)
END
@@ -9505,14 +9505,14 @@ BEGIN
ELSE
(* we dont know the type therefore cannot fake a return. *)
MetaErrorT1 (vartok,
- 'parameter to {%AkMAX} must be a type or a variable, seen {%1Aad}',
+ 'parameter to {%AkMAX} must be a type or a variable, seen {%1ad}',
Var)
(* non recoverable error. *) ;
END
ELSE
(* we dont know the type therefore cannot fake a return. *)
MetaErrorT1 (functok,
- 'the pseudo builtin procedure function {%AkMAX} only has one parameter, seen {%1An}',
+ 'the pseudo builtin procedure function {%AkMAX} only has one parameter, seen {%1n}',
NoOfParam)
(* non recoverable error. *)
END
@@ -9600,7 +9600,7 @@ BEGIN
ELSE
(* we dont know the type therefore cannot fake a return. *)
MetaErrorT1 (functok,
- 'the pseudo builtin procedure function {%AkTRUNC} only has one parameter, seen {%1An}', NoOfParam)
+ 'the pseudo builtin procedure function {%AkTRUNC} only has one parameter, seen {%1n}', NoOfParam)
(* non recoverable error. *)
END
END BuildTruncFunction ;
@@ -10071,18 +10071,18 @@ BEGIN
THEN
paramtok := OperandTok (1) ;
resulttok := MakeVirtualTok (functok, functok, paramtok) ;
- BuildSizeCheckEnd (ProcSym) ; (* quadruple generation now on *)
+ BuildSizeCheckEnd (ProcSym) ; (* Quadruple generation now on. *)
ReturnVar := MakeTemporary (resulttok, ImmediateValue) ;
GenQuadO (resulttok, SizeOp, ReturnVar, NulSym, OperandT(1), TRUE)
ELSIF IsVar (OperandT (1))
THEN
- BuildSizeCheckEnd (ProcSym) ; (* quadruple generation now on *)
+ BuildSizeCheckEnd (ProcSym) ; (* Quadruple generation now on. *)
Type := GetSType (OperandT (1)) ;
paramtok := OperandTok (1) ;
resulttok := MakeVirtualTok (functok, functok, paramtok) ;
IF IsUnbounded (Type)
THEN
- (* eg. SIZE(a) ; where a is unbounded dereference HIGH and multiply by the TYPE *)
+ (* Eg. SIZE(a) ; where a is unbounded dereference HIGH and multiply by the TYPE. *)
dim := OperandD (1) ;
IF dim = 0
THEN
@@ -10106,7 +10106,7 @@ BEGIN
OperandT (1)) ;
ReturnVar := MakeConstLit (resulttok, MakeKey('0'), Cardinal)
END ;
- PopN (NoOfParam+1) ; (* destroy the arguments and function *)
+ PopN (NoOfParam+1) ; (* Destroy the arguments and function. *)
PushTFtok (ReturnVar, GetSType(ProcSym), resulttok)
END BuildSizeFunction ;
diff --git a/gcc/m2/gm2-compiler/P3Build.bnf b/gcc/m2/gm2-compiler/P3Build.bnf
index e3cf96f5b42..e50620e0a4e 100644
--- a/gcc/m2/gm2-compiler/P3Build.bnf
+++ b/gcc/m2/gm2-compiler/P3Build.bnf
@@ -179,9 +179,6 @@ IMPORT M2Error ;
CONST
Debugging = FALSE ;
- Pass1 = FALSE ; (* permanently disabled for the time being *)
- Pass2 = FALSE ;
- Pass3 = TRUE ; (* permanently disabled for the time being *)
DebugAsm = FALSE ;
VAR
@@ -368,6 +365,8 @@ END PeepToken ;
*)
PROCEDURE Expect (t: toktype; stopset0: SetOfStop0; stopset1: SetOfStop1; stopset2: SetOfStop2) ;
+CONST
+ Pass1 = FALSE ;
BEGIN
IF currenttoken=t
THEN
@@ -1463,108 +1462,84 @@ Definition := "CONST" { ConstantDeclaration ";" } |
DefProcedureHeading ";" =:
AsmStatement := % VAR CurrentAsm: CARDINAL ; %
- 'ASM' % IF Pass3
- THEN
- PushAutoOn ;
- PushT(0) ; (* operand count *)
- PushT(MakeGnuAsm())
- END
+ 'ASM' % PushAutoOn ;
+ PushT(0) ; (* operand count *)
+ PushT(MakeGnuAsm())
%
- [ 'VOLATILE' % IF Pass3
- THEN
- PopT(CurrentAsm) ;
- PutGnuAsmVolatile(CurrentAsm) ;
- PushT(CurrentAsm)
- END
+ [ 'VOLATILE' % PopT(CurrentAsm) ;
+ PutGnuAsmVolatile(CurrentAsm) ;
+ PushT(CurrentAsm)
%
- ] '(' AsmOperands % IF Pass3
- THEN
- PopNothing ; (* throw away interface sym *)
- BuildInline ;
- PopNothing ; (* throw away count *)
- PopAuto
- END
+ ] '(' AsmOperands % PopNothing ; (* throw away interface sym *)
+ BuildInline ;
+ PopNothing ; (* throw away count *)
+ PopAuto
%
')' =:
AsmOperands := % VAR CurrentAsm, count: CARDINAL ;
str: CARDINAL ;
%
- ConstExpression % IF Pass3
+ ConstExpression % PopT(str) ;
+ PopT(CurrentAsm) ;
+ Assert(IsGnuAsm(CurrentAsm) OR IsGnuAsmVolatile(CurrentAsm)) ;
+ PopT(count) ;
+ IF DebugAsm
THEN
- PopT(str) ;
- PopT(CurrentAsm) ;
- Assert(IsGnuAsm(CurrentAsm) OR IsGnuAsmVolatile(CurrentAsm)) ;
- PopT(count) ;
- IF DebugAsm
- THEN
- printf1('1: count of asm operands: %d\n', count)
- END ;
- PushT(count) ;
- (* adds the name/instruction for this asm *)
- PutGnuAsm(CurrentAsm, str) ;
- PushT(CurrentAsm) ;
- PushT(NulSym) (* the InterfaceSym *)
- END
+ printf1('1: count of asm operands: %d\n', count)
+ END ;
+ PushT(count) ;
+ (* adds the name/instruction for this asm *)
+ PutGnuAsm(CurrentAsm, str) ;
+ PushT(CurrentAsm) ;
+ PushT(NulSym) (* the InterfaceSym *)
%
( AsmOperandSpec | % (* epsilon *)
- IF Pass3
- THEN
- PutGnuAsmSimple(CurrentAsm)
- END
+ PutGnuAsmSimple(CurrentAsm)
%
)
=:
AsmOperandSpec := % VAR CurrentAsm, outputs, inputs, trash, count: CARDINAL ;
%
- ':' AsmOutputList % IF Pass3
+ ':' AsmOutputList % PopT(outputs) ;
+ PopT(CurrentAsm) ;
+ Assert(IsGnuAsm(CurrentAsm) OR IsGnuAsmVolatile(CurrentAsm)) ;
+ PopT(count) ;
+ IF DebugAsm
THEN
- PopT(outputs) ;
- PopT(CurrentAsm) ;
- Assert(IsGnuAsm(CurrentAsm) OR IsGnuAsmVolatile(CurrentAsm)) ;
- PopT(count) ;
- IF DebugAsm
- THEN
- printf1('2: output count of asm operands: %d\n', count)
- END ;
- PutGnuAsmOutput(CurrentAsm, outputs) ;
- PushT(0) ; (* reset count *)
- PushT(CurrentAsm) ;
- PushT(NulSym) (* the InterfaceSym *)
- END
+ printf1('2: output count of asm operands: %d\n', count)
+ END ;
+ PutGnuAsmOutput(CurrentAsm, outputs) ;
+ PushT(0) ; (* reset count *)
+ PushT(CurrentAsm) ;
+ PushT(NulSym) (* the InterfaceSym *)
%
- [ ':' AsmInputList % IF Pass3
+ [ ':' AsmInputList % PopT(inputs) ;
+ PopT(CurrentAsm) ;
+ Assert(IsGnuAsm(CurrentAsm) OR IsGnuAsmVolatile(CurrentAsm)) ;
+ PopT(count) ;
+ IF DebugAsm
THEN
- PopT(inputs) ;
- PopT(CurrentAsm) ;
- Assert(IsGnuAsm(CurrentAsm) OR IsGnuAsmVolatile(CurrentAsm)) ;
- PopT(count) ;
- IF DebugAsm
- THEN
- printf1('3: input count of asm operands: %d\n', count)
- END ;
- PutGnuAsmInput(CurrentAsm, inputs) ;
- PushT(0) ; (* reset count *)
- PushT(CurrentAsm) ;
- PushT(NulSym) (* the InterfaceSym *)
- END
+ printf1('3: input count of asm operands: %d\n', count)
+ END ;
+ PutGnuAsmInput(CurrentAsm, inputs) ;
+ PushT(0) ; (* reset count *)
+ PushT(CurrentAsm) ;
+ PushT(NulSym) (* the InterfaceSym *)
%
- [ ':' AsmTrashList % IF Pass3
+ [ ':' AsmTrashList % PopT(trash) ;
+ PopT(CurrentAsm) ;
+ Assert(IsGnuAsm(CurrentAsm) OR IsGnuAsmVolatile(CurrentAsm)) ;
+ PopT(count) ;
+ IF DebugAsm
THEN
- PopT(trash) ;
- PopT(CurrentAsm) ;
- Assert(IsGnuAsm(CurrentAsm) OR IsGnuAsmVolatile(CurrentAsm)) ;
- PopT(count) ;
- IF DebugAsm
- THEN
- printf1('4: trash count of asm operands: %d\n', count)
- END ;
- PutGnuAsmTrash(CurrentAsm, trash) ;
- PushT(0) ; (* reset count *)
- PushT(CurrentAsm) ;
- PushT(NulSym) (* the InterfaceSym *)
- END
+ printf1('4: trash count of asm operands: %d\n', count)
+ END ;
+ PutGnuAsmTrash(CurrentAsm, trash) ;
+ PushT(0) ; (* reset count *)
+ PushT(CurrentAsm) ;
+ PushT(NulSym) (* the InterfaceSym *)
%
] ]
=:
@@ -1578,41 +1553,27 @@ NamedOperand := '[' Ident ']' =:
AsmOperandName := ( NamedOperand
| % IF IsAutoPushOn()
THEN
- PushTF(NulName, identtok)
+ PushTF (NulName, identtok)
END
%
)
=:
AsmInputElement := AsmOperandName
- ConstExpression '(' Expression % IF Pass3
- THEN
- BuildAsmElement (TRUE, FALSE)
- END
+ ConstExpression '(' Expression % BuildAsmElement (TRUE, FALSE)
%
')'
=:
AsmOutputElement := AsmOperandName
- ConstExpression '(' Expression % IF Pass3
- THEN
- BuildAsmElement (FALSE, TRUE)
- END
+ ConstExpression '(' Expression % BuildAsmElement (FALSE, TRUE)
%
')'
=:
-AsmTrashList := % VAR expr, tokpos: CARDINAL ; %
- [ ConstExpression % IF Pass3
- THEN
- BuildAsmTrash
- END
-
+AsmTrashList := [ ConstExpression % BuildAsmTrash
%
- ] { ',' ConstExpression % IF Pass3
- THEN
- BuildAsmTrash
- END
+ ] { ',' ConstExpression % BuildAsmTrash
%
} =:
diff --git a/gcc/testsuite/gm2/pim/fail/foovaltype.mod b/gcc/testsuite/gm2/pim/fail/foovaltype.mod
new file mode 100644
index 00000000000..10a3d8eef66
--- /dev/null
+++ b/gcc/testsuite/gm2/pim/fail/foovaltype.mod
@@ -0,0 +1,7 @@
+MODULE foovaltype;
+
+VAR x: INTEGER;
+
+BEGIN
+ x := VAL(abcd, 0);
+END foovaltype.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-06-12 23:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-12 23:55 [gcc r14-1739] PR modula2/110189 Using an unknown TYPE as argument to VAL gives ICE Gaius Mulley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).