diff options
author | Gaius Mulley <gaiusmod2@gmail.com> | 2023-07-19 13:38:07 +0100 |
---|---|---|
committer | Gaius Mulley <gaiusmod2@gmail.com> | 2023-07-19 13:38:07 +0100 |
commit | e029635cb72e6db72f1826b6b43fa4b299b2145f (patch) | |
tree | 6ac2d8c6c638bd457c94e9ae179d52f91693f812 /gcc/tree-ssa-phiopt.cc | |
parent | fcb38196423cd5f99a7ee44c882751b3dd37618d (diff) | |
download | gcc-e029635cb72e6db72f1826b6b43fa4b299b2145f.zip gcc-e029635cb72e6db72f1826b6b43fa4b299b2145f.tar.gz gcc-e029635cb72e6db72f1826b6b43fa4b299b2145f.tar.bz2 |
[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.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Diffstat (limited to 'gcc/tree-ssa-phiopt.cc')
0 files changed, 0 insertions, 0 deletions