M2Size.def \
M2StackAddress.def \
M2StackWord.def \
+ M2StateCheck.def \
M2Students.def \
M2Swig.def \
M2SymInit.def \
M2Size.mod \
M2StackAddress.mod \
M2StackWord.mod \
+ M2StateCheck.mod \
M2Students.mod \
M2Swig.mod \
M2SymInit.mod \
M2Size.def \
M2StackAddress.def \
M2StackWord.def \
+ M2StateCheck.def \
M2Students.def \
M2Swig.def \
M2SymInit.def \
M2Size.mod \
M2StackAddress.mod \
M2StackWord.mod \
+ M2StateCheck.mod \
M2Students.mod \
M2Swig.mod \
M2SymInit.mod \
PopTFtok (Sym, Type, tok) ;
DebugLocation (tok, "expression") ;
Type := SkipType (Type) ;
-
- Ref := MakeTemporary (tok, LeftValue) ;
- PutVar (Ref, Type) ;
- IF GetMode (Sym) = LeftValue
+ IF Type = NulSym
THEN
- (* Copy LeftValue. *)
- GenQuadO (tok, BecomesOp, Ref, NulSym, Sym, TRUE)
+ MetaErrorT1 (tok,
+ '{%1Aa} {%1d} has a no type, the {%kWITH} statement requires a variable or parameter of a {%kRECORD} type',
+ Sym)
ELSE
- (* Calculate the address of Sym. *)
- GenQuadO (tok, AddrOp, Ref, NulSym, Sym, TRUE)
- END ;
+ Ref := MakeTemporary (tok, LeftValue) ;
+ PutVar (Ref, Type) ;
+ IF GetMode (Sym) = LeftValue
+ THEN
+ (* Copy LeftValue. *)
+ GenQuadO (tok, BecomesOp, Ref, NulSym, Sym, TRUE)
+ ELSE
+ (* Calculate the address of Sym. *)
+ GenQuadO (tok, AddrOp, Ref, NulSym, Sym, TRUE)
+ END ;
- PushWith (Sym, Type, Ref, tok) ;
- DebugLocation (tok, "with ref") ;
- IF Type = NulSym
- THEN
- MetaError1 ('{%1Ea} {%1d} has a no type, the {%kWITH} statement requires a variable or parameter of a {%kRECORD} type',
- Sym)
- ELSIF NOT IsRecord(Type)
- THEN
- MetaError1 ('the {%kWITH} statement requires that {%1Ea} {%1d} be of a {%kRECORD} {%1tsa:type rather than {%1tsa}}',
- Sym)
+ PushWith (Sym, Type, Ref, tok) ;
+ DebugLocation (tok, "with ref") ;
+ IF NOT IsRecord(Type)
+ THEN
+ MetaErrorT1 (tok,
+ 'the {%kWITH} statement requires that {%1Ea} {%1d} be of a {%kRECORD} {%1tsa:type rather than {%1tsa}}',
+ Sym)
+ END ;
+ StartScope (Type)
END ;
- StartScope (Type)
- ; DisplayStack ;
+ DisplayStack ;
END StartBuildWith ;
--- /dev/null
+(* M2StateCheck.def provide state check tracking for declarations.
+
+Copyright (C) 2024 Free Software Foundation, Inc.
+Contributed by Gaius Mulley <gaiusmod2@gmail.com>.
+
+This file is part of GNU Modula-2.
+
+GNU Modula-2 is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GNU Modula-2 is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Modula-2; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. *)
+
+DEFINITION MODULE M2StateCheck ;
+
+(* This module provides state tracking for VAR, TYPE and CONST
+ declarations. It should be used by any pass creating
+ symbols in these blocks and it will detect a constant
+ being created from a variable, type from a variable,
+ variable from a constant (instead of type) etc. *)
+
+TYPE
+ StateCheck ;
+
+
+(*
+ InitState - returns a new initialized StateCheck.
+*)
+
+PROCEDURE InitState () : StateCheck ;
+
+
+(*
+ KillState - destructor for StateCheck.
+*)
+
+PROCEDURE KillState (VAR s: StateCheck) ;
+
+
+(*
+ PushState - duplicates the StateCheck s and chains the new copy to s.
+ Return the copy.
+*)
+
+PROCEDURE PushState (VAR s: StateCheck) ;
+
+
+(*
+ PopState - pops the current state.
+*)
+
+PROCEDURE PopState (VAR s: StateCheck) ;
+
+
+(*
+ InclVar - s := s + {var}.
+*)
+
+PROCEDURE InclVar (s: StateCheck) ;
+
+
+(*
+ InclConst - s := s + {const}.
+*)
+
+PROCEDURE InclConst (s: StateCheck) ;
+
+
+(*
+ InclType - s := s + {type}.
+*)
+
+PROCEDURE InclType (s: StateCheck) ;
+
+
+(*
+ InclConstFunc - s := s + {constfunc}.
+*)
+
+PROCEDURE InclConstFunc (s: StateCheck) ;
+
+
+(*
+ InclVarParam - s := s + {varparam}.
+*)
+
+PROCEDURE InclVarParam (s: StateCheck) ;
+
+
+(*
+ InclConstructor - s := s + {constructor}.
+*)
+
+PROCEDURE InclConstructor (s: StateCheck) ;
+
+
+(*
+ ExclVar - s := s + {var}.
+*)
+
+PROCEDURE ExclVar (s: StateCheck) ;
+
+
+(*
+ ExclConst - s := s + {const}.
+*)
+
+PROCEDURE ExclConst (s: StateCheck) ;
+
+
+(*
+ ExclType - s := s + {type}.
+*)
+
+PROCEDURE ExclType (s: StateCheck) ;
+
+
+(*
+ ExclConstFunc - s := s + {constfunc}.
+*)
+
+PROCEDURE ExclConstFunc (s: StateCheck) ;
+
+
+(*
+ ExclVarParam - s := s + {varparam}.
+*)
+
+PROCEDURE ExclVarParam (s: StateCheck) ;
+
+
+(*
+ ExclConstructor - s := s - {varparam}.
+*)
+
+PROCEDURE ExclConstructor (s: StateCheck) ;
+
+
+(*
+ CheckQualident - checks to see that qualident sym is allowed in the state s.
+*)
+
+PROCEDURE CheckQualident (tok: CARDINAL; s: StateCheck; sym: CARDINAL) ;
+
+
+END M2StateCheck.
--- /dev/null
+(* M2StateCheck.mod provide state check tracking for declarations.
+
+Copyright (C) 2024 Free Software Foundation, Inc.
+Contributed by Gaius Mulley <gaiusmod2@gmail.com>.
+
+This file is part of GNU Modula-2.
+
+GNU Modula-2 is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GNU Modula-2 is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Modula-2; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. *)
+
+IMPLEMENTATION MODULE M2StateCheck ;
+
+FROM Storage IMPORT ALLOCATE ;
+FROM M2MetaError IMPORT MetaErrorStringT1 ;
+FROM DynamicStrings IMPORT String, InitString, ConCat, Mark ;
+FROM SymbolTable IMPORT NulSym, IsType, IsVar, IsConst ;
+
+
+TYPE
+ StateCheck = POINTER TO RECORD
+ state: StateSet ;
+ stack,
+ next : StateCheck ;
+ END ;
+
+ State = (const, var, type, constfunc, varparam, constructor) ;
+
+ StateSet = SET OF State ;
+
+VAR
+ FreeList: StateCheck ;
+
+
+(*
+ InitState - returns a new initialized StateCheck.
+*)
+
+PROCEDURE InitState () : StateCheck ;
+VAR
+ s: StateCheck ;
+BEGIN
+ s := New () ;
+ WITH s^ DO
+ state := StateSet {} ;
+ stack := NIL ;
+ next := NIL
+ END ;
+ RETURN s
+END InitState ;
+
+
+(*
+ New - returns an uninitialized StateCheck.
+*)
+
+PROCEDURE New () : StateCheck ;
+VAR
+ s: StateCheck ;
+BEGIN
+ IF FreeList = NIL
+ THEN
+ NEW (s)
+ ELSE
+ s := FreeList ;
+ FreeList := FreeList^.next
+ END ;
+ RETURN s
+END New ;
+
+
+(*
+ PushState - duplicates the StateCheck s and chains the new copy to s.
+ Return the copy.
+*)
+
+PROCEDURE PushState (VAR s: StateCheck) ;
+VAR
+ copy: StateCheck ;
+BEGIN
+ copy := InitState () ;
+ copy^.state := s^.state ;
+ copy^.stack := s ;
+ s := copy
+END PushState ;
+
+
+(*
+ KillState - destructor for StateCheck.
+*)
+
+PROCEDURE KillState (VAR s: StateCheck) ;
+VAR
+ t: StateCheck ;
+BEGIN
+ WHILE s^.stack # NIL DO
+ t := s^.stack ;
+ s^.stack := t^.stack ;
+ Dispose (t)
+ END ;
+ Dispose (s)
+END KillState ;
+
+
+(*
+ Dispose - place s onto the FreeList and set s to NIL.
+*)
+
+PROCEDURE Dispose (VAR s: StateCheck) ;
+BEGIN
+ s^.next := FreeList ;
+ FreeList := s
+END Dispose ;
+
+
+(*
+ InclVar - s := s + {var}.
+*)
+
+PROCEDURE InclVar (s: StateCheck) ;
+BEGIN
+ INCL (s^.state, var)
+END InclVar ;
+
+
+(*
+ InclConst - s := s + {const}.
+*)
+
+PROCEDURE InclConst (s: StateCheck) ;
+BEGIN
+ INCL (s^.state, const)
+END InclConst ;
+
+
+(*
+ InclType - s := s + {type}.
+*)
+
+PROCEDURE InclType (s: StateCheck) ;
+BEGIN
+ INCL (s^.state, type)
+END InclType ;
+
+
+(*
+ InclConstFunc - s := s + {constfunc}.
+*)
+
+PROCEDURE InclConstFunc (s: StateCheck) ;
+BEGIN
+ INCL (s^.state, constfunc)
+END InclConstFunc ;
+
+
+(*
+ InclVarParam - s := s + {varparam}.
+*)
+
+PROCEDURE InclVarParam (s: StateCheck) ;
+BEGIN
+ INCL (s^.state, varparam)
+END InclVarParam ;
+
+
+(*
+ InclConstructor - s := s + {constructor}.
+*)
+
+PROCEDURE InclConstructor (s: StateCheck) ;
+BEGIN
+ INCL (s^.state, constructor)
+END InclConstructor ;
+
+
+(*
+ ExclVar - s := s - {var}.
+*)
+
+PROCEDURE ExclVar (s: StateCheck) ;
+BEGIN
+ EXCL (s^.state, var)
+END ExclVar ;
+
+
+(*
+ ExclConst - s := s - {const}.
+*)
+
+PROCEDURE ExclConst (s: StateCheck) ;
+BEGIN
+ EXCL (s^.state, const)
+END ExclConst ;
+
+
+(*
+ ExclType - s := s - {type}.
+*)
+
+PROCEDURE ExclType (s: StateCheck) ;
+BEGIN
+ EXCL (s^.state, type)
+END ExclType ;
+
+
+(*
+ ExclConstFunc - s := s - {constfunc}.
+*)
+
+PROCEDURE ExclConstFunc (s: StateCheck) ;
+BEGIN
+ EXCL (s^.state, constfunc)
+END ExclConstFunc ;
+
+
+(*
+ ExclVarParam - s := s - {varparam}.
+*)
+
+PROCEDURE ExclVarParam (s: StateCheck) ;
+BEGIN
+ EXCL (s^.state, varparam)
+END ExclVarParam ;
+
+
+(*
+ ExclConstructor - s := s - {varparam}.
+*)
+
+PROCEDURE ExclConstructor (s: StateCheck) ;
+BEGIN
+ EXCL (s^.state, constructor)
+END ExclConstructor ;
+
+
+(*
+ PopState - pops the current state.
+*)
+
+PROCEDURE PopState (VAR s: StateCheck) ;
+VAR
+ t: StateCheck ;
+BEGIN
+ t := s ;
+ s := s^.stack ;
+ t^.stack := NIL ;
+ Dispose (t)
+END PopState ;
+
+
+(*
+ CheckQualident - checks to see that qualident sym is allowed in the state s.
+*)
+
+PROCEDURE CheckQualident (tok: CARDINAL; s: StateCheck; sym: CARDINAL) ;
+BEGIN
+ IF sym = NulSym
+ THEN
+ (* Ignore. *)
+ ELSIF IsType (sym)
+ THEN
+ IF (constfunc IN s^.state) OR (constructor IN s^.state)
+ THEN
+ (* Ok. *)
+ ELSIF const IN s^.state
+ THEN
+ GenerateError (tok, s, sym)
+ END
+ ELSIF IsConst (sym)
+ THEN
+ IF (constfunc IN s^.state) OR (constructor IN s^.state)
+ THEN
+ (* Ok. *)
+ ELSIF (var IN s^.state) OR (type IN s^.state)
+ THEN
+ GenerateError (tok, s, sym)
+ END
+ ELSIF IsVar (sym)
+ THEN
+ IF constfunc IN s^.state
+ THEN
+ (* Ok. *)
+ ELSIF (const IN s^.state) OR (type IN s^.state) OR (var IN s^.state)
+ THEN
+ GenerateError (tok, s, sym)
+ END
+ END
+END CheckQualident ;
+
+
+(*
+ GenerateError - generates an unrecoverable error string based on the state and sym.
+*)
+
+PROCEDURE GenerateError (tok: CARDINAL; s: StateCheck; sym: CARDINAL) ;
+VAR
+ str: String ;
+BEGIN
+ str := InitString ('not expecting a {%1Ad} {%1a: }in a ') ;
+ IF const IN s^.state
+ THEN
+ str := ConCat (str, Mark (InitString ('{%kCONST} block')))
+ ELSIF type IN s^.state
+ THEN
+ str := ConCat (str, Mark (InitString ('{%kTYPE} block')))
+ ELSIF var IN s^.state
+ THEN
+ str := ConCat (str, Mark (InitString ('{%kVAR} block')))
+ END ;
+ IF constfunc IN s^.state
+ THEN
+ str := ConCat (str, Mark (InitString (' and within a constant procedure function actual parameter')))
+ END ;
+ IF constructor IN s^.state
+ THEN
+ str := ConCat (str, Mark (InitString (' and within a constructor')))
+ END ;
+ MetaErrorStringT1 (tok, str, sym)
+END GenerateError ;
+
+
+(*
+ init - initialize the global variables in the module.
+*)
+
+PROCEDURE init ;
+BEGIN
+ FreeList := NIL
+END init ;
+
+
+BEGIN
+ init
+END M2StateCheck.
PushInConstExpression, PopInConstExpression,
PushInConstParameters, PopInConstParameters, IsInConstParameters,
BuildDefaultFieldAlignment, BuildPragmaField,
+ OperandT, OperandTok,
IsAutoPushOn, PushAutoOff, PushAutoOn, PopAuto ;
FROM P3SymBuild IMPORT P3StartBuildProgModule,
FROM M2CaseList IMPORT BeginCaseList, EndCaseList ;
+FROM M2StateCheck IMPORT StateCheck,
+ InitState, PushState, PopState,
+ InclConst, ExclConst,
+ InclType, ExclType,
+ InclVar, ExclVar,
+ InclConstructor, ExclConstructor,
+ InclConstFunc, CheckQualident ;
+
IMPORT M2Error ;
CONST
DebugAsm = FALSE ;
VAR
- WasNoError: BOOLEAN ;
+ seenError : BOOLEAN ;
+ BlockState: StateCheck ;
PROCEDURE ErrorString (s: String) ;
BEGIN
- ErrorStringAt(s, GetTokenNo ()) ;
- WasNoError := FALSE
+ ErrorStringAt (s, GetTokenNo ()) ;
+ seenError := TRUE
END ErrorString ;
PROCEDURE ErrorArray (a: ARRAY OF CHAR) ;
BEGIN
- ErrorString(InitString(a))
+ ErrorString (InitString (a))
END ErrorArray ;
PROCEDURE CompilationUnit () : BOOLEAN ;
BEGIN
- WasNoError := TRUE ;
+ seenError := FALSE ;
FileUnit(SetOfStop0{eoftok}, SetOfStop1{}, SetOfStop2{}) ;
- RETURN( WasNoError )
+ RETURN NOT seenError
END CompilationUnit ;
END Real ;
% module P3Build end
+BEGIN
+ BlockState := InitState ()
END P3Build.
% rules
error 'ErrorArray' 'ErrorString'
{ "." Ident } % END %
=:
+
+QualidentCheck := % PushAutoOn %
+ Qualident
+ % PopAuto %
+ % CheckQualident (OperandTok (1), BlockState, OperandT (1)) %
+ % IF NOT IsAutoPushOn ()
+ THEN
+ PopNothing
+ END %
+ =:
+
ConstantDeclaration := % VAR tokno: CARDINAL ; %
+ % InclConst (BlockState) %
% PushAutoOn %
( Ident "=" % tokno := GetTokenNo () -1 %
% BuildConst %
ConstExpression ) % BuildAssignConstant (tokno) %
% PopAuto %
+ % ExclConst (BlockState) %
=:
ConstExpression := % VAR tokpos: CARDINAL ; %
Constructor := % VAR tokpos: CARDINAL ; %
% DisplayStack %
+ % InclConstructor (BlockState) %
+ % CheckQualident (OperandTok (1), BlockState, OperandT (1)) %
'{' % tokpos := GetTokenNo () -1 %
% BuildConstructorStart (tokpos) %
[ ArraySetRecordValue ] % BuildConstructorEnd (tokpos, GetTokenNo()) %
- '}' =:
+ '}'
+ % ExclConstructor (BlockState) %
+ =:
ConstSetOrQualidentOrFunction := % VAR tokpos: CARDINAL ; %
% tokpos := GetTokenNo () %
Constructor
) =:
-ConstActualParameters := % PushInConstParameters %
+ConstActualParameters := % PushState (BlockState) %
+ % InclConstFunc (BlockState) %
+ % CheckQualident (OperandTok (1), BlockState, OperandT (1)) %
+ % PushInConstParameters %
ActualParameters % PopInConstParameters %
+ % PopState (BlockState) %
=:
ConstAttribute := "__ATTRIBUTE__" "__BUILTIN__" "(" "(" % PushAutoOn %
Alignment := [ ByteAlignment ] =:
-TypeDeclaration := Ident "=" Type Alignment
+TypeDeclaration := % InclType (BlockState) %
+ Ident "=" Type Alignment
+ % ExclType (BlockState) %
=:
Type :=
| ProcedureType ) % PopAuto %
=:
-SimpleType := Qualident [ SubrangeType ] | Enumeration | SubrangeType =:
+SimpleType := QualidentCheck [ SubrangeType ] | Enumeration | SubrangeType =:
Enumeration := "("
( IdentList
TagIdent := [ Ident ] =:
-CaseTag := TagIdent [":" Qualident ] =:
+CaseTag := TagIdent [":" QualidentCheck ] =:
Varient := [ % BeginVarientList %
VarientCaseLabelList ":" FieldListSequence % EndVarientList %
FormalReturn := [ ":" OptReturnType ] =:
-OptReturnType := "[" Qualident "]" | Qualident =:
+OptReturnType := "[" QualidentCheck "]" | QualidentCheck =:
ProcedureParameters := ProcedureParameter
{ "," ProcedureParameter } =:
=:
VariableDeclaration := VarIdentList ":"
+ % InclVar (BlockState) %
Type Alignment
+ % ExclVar (BlockState) %
=:
-Designator := Qualident % CheckWithReference %
+Designator := QualidentCheck % CheckWithReference %
{ SubDesignator } =:
SubDesignator := "." % VAR Sym, Type, tok,
DefOptArg := "[" Ident ":" FormalType "=" ConstExpression % BuildOptArgInitializer %
"]" =:
-FormalType := { "ARRAY" "OF" } Qualident =:
+FormalType := { "ARRAY" "OF" } QualidentCheck =:
ModuleDeclaration := % VAR modulet: CARDINAL ; %
% modulet := GetTokenNo () %
OrTok, TimesTok, DivTok, DivideTok, ModTok, RemTok,
AndTok, AmbersandTok, PeriodPeriodTok, ByTok ;
-FROM M2Quads IMPORT Top, PushT, PopT, PushTF, PopTF, PopNothing, OperandT, PushTFA,
+FROM M2Quads IMPORT Top, PushT, PopT, PushTF, PopTF, PopNothing, OperandT, OperandTok,
+ PushTFA,
PushTFn, PopTFn, PushTFtok, PopTtok, PopTFtok, PushTtok, PushTFntok,
PushT, PushTF, IsAutoPushOn, PushAutoOff, PushAutoOn, PopAuto,
BuildTypeForConstructor, BuildConstructor, BuildConstructorEnd,
FROM M2Batch IMPORT IsModuleKnown ;
+FROM M2StateCheck IMPORT StateCheck,
+ InitState, PushState, PopState, InclConst, ExclConst,
+ InclConstructor, ExclConstructor,
+ InclConstFunc, CheckQualident ;
+
IMPORT M2Error ;
Pass1 = FALSE ;
VAR
- InConstParameter,
- InConstBlock,
- seenError : BOOLEAN ;
+ BlockState: StateCheck ;
+ seenError : BOOLEAN ;
PROCEDURE ErrorString (s: String) ;
% module PCBuild end
BEGIN
- InConstParameter := FALSE ;
- InConstBlock := FALSE
+ BlockState := InitState ()
END PCBuild.
% rules
error 'ErrorArray' 'ErrorString'
=:
ConstantDeclaration := % VAR top: CARDINAL ; %
- % InConstBlock := TRUE %
+ % InclConst (BlockState) %
% top := Top() %
% PushAutoOn %
( Ident "=" % StartDesConst %
% EndDesConst %
% PopAuto %
% Assert(top=Top()) %
- % InConstBlock := FALSE %
+ % ExclConst (BlockState) %
=:
ConstExpression := % VAR top: CARDINAL ; %
ArraySetRecordValue := ComponentValue { ',' % NextConstructorField %
ComponentValue } =:
-Constructor := '{' % PushConstructorCastType %
+Constructor := '{' % InclConstructor (BlockState) %
+ % CheckQualident (OperandTok (1), BlockState, OperandT (1)) %
+ % PushConstructorCastType %
% PushInConstructor %
% BuildConstructor (GetTokenNo ()-1) %
[ ArraySetRecordValue ] % PopConstructor %
'}' % PopInConstructor %
+ % ExclConstructor (BlockState) %
=:
ConstructorOrConstActualParameters := Constructor | ConstActualParameters % PushConstFunctionType %
% VAR tokpos: CARDINAL ; %
% tokpos := GetTokenNo () %
(
- PushQualident % IF (NOT InConstParameter) AND InConstBlock
- THEN
- CheckNotVar (tokpos)
- END %
- ( ConstructorOrConstActualParameters | % PushConstType %
+ PushQualident
+ ( ConstructorOrConstActualParameters | % CheckQualident (OperandTok (1), BlockState, OperandT (1)) %
+ % PushConstType %
% PopNothing %
)
| % BuildTypeForConstructor (tokpos) %
Constructor ) % PopAuto %
=:
-ConstActualParameters := % VAR oldConstParameter: BOOLEAN ; %
- % oldConstParameter := InConstParameter %
- % InConstParameter := TRUE %
+ConstActualParameters := % PushState (BlockState) %
+ % InclConstFunc (BlockState) %
+ % CheckQualident (OperandTok (1), BlockState, OperandT (1)) %
% PushT(0) %
"(" [ ConstExpList ] ")"
- % InConstParameter := oldConstParameter %
+ % PopState (BlockState) %
=:
ConstExpList := % VAR n: CARDINAL ; %
SimpleDes [ ActualParameters ]
=:
-SetOrDesignatorOrFunction := % PushAutoOff %
- % VAR tokpos: CARDINAL ; %
+SetOrDesignatorOrFunction := % VAR tokpos: CARDINAL ; %
% tokpos := GetTokenNo () %
+ % PushAutoOff %
(
PushQualident
( ConstructorOrSimpleDes | % PopNothing %
EXTERN void _M2_M2Check_init (int argc, char *argv[], char *envp[]);
EXTERN void _M2_M2SSA_init (int argc, char *argv[], char *envp[]);
EXTERN void _M2_M2SymInit_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_M2StateCheck_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_P3Build_init (int argc, char *argv[], char *envp[]);
EXTERN void exit (int);
EXTERN void M2Comp_compile (const char *filename);
EXTERN void RTExceptions_DefaultErrorCatch (void);
_M2_M2SymInit_init (0, NULL, NULL);
_M2_M2Check_init (0, NULL, NULL);
_M2_M2LangDump_init (0, NULL, NULL);
+ _M2_M2StateCheck_init (0, NULL, NULL);
+ _M2_P3Build_init (0, NULL, NULL);
M2Comp_compile (filename);
}
MODULE array1 ;
+PROCEDURE init ;
VAR
a: ARRAY [FALSE..TRUE] OF CARDINAL ;
i, j: CARDINAL ;
BEGIN
a[i=j] := j
+END init ;
+
+BEGIN
+ init
END array1.
--- /dev/null
+MODULE badtype ;
+
+PROCEDURE bar (VAR a: CARDINAL) ;
+TYPE
+ Foo = a ;
+BEGIN
+END bar ;
+
+BEGIN
+END badtype.
--- /dev/null
+MODULE badvar ;
+
+PROCEDURE bar (VAR a: CARDINAL) ;
+VAR
+ Foo: a ;
+BEGIN
+END bar ;
+
+BEGIN
+END badvar.
# load support procs
load_lib gm2-torture.exp
-gm2_init_pim "${srcdir}/gm2/errors/fail" -Wpedantic -Wstudents -Wunused-variable
+gm2_init_iso "${srcdir}/gm2/errors/fail" -Wpedantic -Wunused-variable -Wuninit-variable-checking=all
foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
# If we're only testing specific files and this isn't one of them, skip it.
FROM StrIO IMPORT WriteString, WriteLn ;
FROM FIO IMPORT Exists, OpenToRead, Close, File, IsNoError, EOF, ReadChar ;
+PROCEDURE init ;
VAR
i: INTEGER ;
f: File ;
c: CARDINAL ;
a: ARRAY [0..20] OF CHAR ;
BEGIN
+ IF f = 0
+ THEN
+ END ;
WriteString('testfio starting') ; WriteLn ;
c := 1 ;
WHILE GetArg(a, c) DO
END ;
INC(c)
END
+END init ;
+
+BEGIN
+ init
END testfio.
FROM FIO IMPORT IsNoError, Close, EOF ;
+PROCEDURE init ;
VAR
i: INTEGER ;
BEGIN
IF EOF(i)
THEN
END
+END init ;
+
+BEGIN
+ init
END testparam.