[modula2] Variable analysis understands DISPOSE and NIL
This patch allows the uninitialized variable analysis to detect pointer
through NIL and incorrectly reusing a pointer after a call to DISPOSE.
gcc/m2/ChangeLog:
* gm2-compiler/M2Quads.mod (BuildRealFuncProcCall): Set the trash
parameter value to NIL if DEALLOCATE is detected.
* gm2-compiler/M2SymInit.mod (CheckDeferredRecordAccess): Pass
tok to SetVarInitialized. Pass tok to GetVarComponentInitialized.
(ComponentFindVar): Add tok parameter. Check aliased pointer
against Nil and generate warning if necessary.
(deRefComponent): Add tok and sym parameters and pass them to
getContent.
(SetVarComponentInitialized): Add tok parameter. Pass tok to
ComponentFindVar. Pass tok and sym to deRefComponent.
(GetVarComponentInitialized): Add tok parameter. Pass tok to
ComponentFindVar. Pass tok to deRefComponent.
(SetVarInitialized): Add tok parameter. Pass tok to
SetVarComponentInitialized.
(doGetVarInitialized): Add tok parameter. Pass tok to
GetVarComponentInitialized.
(CheckXIndr): Pass lhs and lhstok to getContent.
(CheckIndrX): Pass rhs and rhstok to getContent.
(CheckBecomes): Pass destok to ComponentFindVar. Pass des and
destok to deRefComponent.
(CheckAddr): Pass contenttok to GetVarInitialized. Pass ptrtok
to SetVarInitialized.
(CheckReadBeforeInitQuad): Pass op1tok to SetVarInitialized for
op1 cases and op3tok for op3 cases.
(trashParam): Get operand tokens. Pass op3tok to
SetVarInitialized. Pass op3 and op3tok to getContent.
Alias ptr to NIL if procedure is DEALLOCATE. Pass op3tok to
SetVarInitialized.
(IsDeallocate): New procedure function.
(DetectTrash): Use IsDeallocate.
(SetupLAlias): Allow exp to be Nil.
(getContent): Generate warning message if ptr is Nil.
gcc/testsuite/ChangeLog:
* gm2/switches/uninit-variable-checking/procedures/fail/testdispose.mod: New test.
* gm2/switches/uninit-variable-checking/procedures/fail/testdispose2.mod: New test.
* gm2/switches/uninit-variable-checking/procedures/fail/testnil.mod: New test.