diff --git a/gcc/m2/gm2-compiler/M2Quads.mod b/gcc/m2/gm2-compiler/M2Quads.mod index 081e9311ae8a91f50a72626e9d55ad97b27e10ad..399a09f32c9a49562dc047483c4b6e8de4e48424 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 e3cf96f5b4253d2469d250589033daee7725ee8e..e50620e0a4e339ae77b16b1a6241a13181704841 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 0000000000000000000000000000000000000000..10a3d8eef66dad0e6599ad4620bf35fa5be72915 --- /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.