From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 892823858415; Sun, 30 Jul 2023 01:20:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 892823858415 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690680019; bh=/MZoWxzzxRFn5Ip2LpfiTQp0rROpbFB4P3VwBbR+zhk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HnkFXnRJS3+qy6rux06IoOx9evzxxHdHfD+vgV0OeM9Tz5dZ6LKdWpNthx6W2EJAf alLTue8CZDMm+bYUNLscTLi9jtAJbxwSVluN1VutG6NrgpaSoRqhRpRX2+HJyMeGkz 6TIAymwZdDeApgIBQLYURfQ5Z5UoobpvWzzU2/uU= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug modula2/110125] Variables are reported as uninitialized when only set inside WITH statement Date: Sun, 30 Jul 2023 01:20:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: modula2 X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: gaius at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110125 --- Comment #7 from CVS Commits --- The releases/gcc-13 branch has been updated by Gaius Mulley : https://gcc.gnu.org/g:3fd979bf568d91016b797818e6c9c940b6f389bd commit r13-7650-g3fd979bf568d91016b797818e6c9c940b6f389bd Author: Gaius Mulley Date: Sun Jul 30 02:18:57 2023 +0100 PR modula2/110125 variables reported as uninitialized when set inside W= ITH The modula-2 static analysis incorrectly identifies variables as uninitialized if they are initialized within a WITH statement. This bug fix re-implements the variable static analysis and will detect simple pointer record fields being accessed before being initialized. The static analysis is limited to the first basic block in a procedure. It does not check variant records, arrays or sets. A new option -Wuninit-variable-checking will turn on the new semantic checking (-Wall also enables the new checking). gcc/ChangeLog: PR modula2/110125 * doc/gm2.texi (Semantic checking): Include examples using -Wuninit-variable-checking. gcc/m2/ChangeLog: PR modula2/110125 * Make-lang.in (GM2-COMP-BOOT-DEFS): Add M2SymInit.def. (GM2-COMP-BOOT-MODS): Add M2SymInit.mod. * gm2-compiler/M2BasicBlock.mod: Formatting changes. * gm2-compiler/M2Code.mod: Remove import of VariableAnalysis fr= om M2Quads. Import VariableAnalysis from M2SymInit.mod. * gm2-compiler/M2GCCDeclare.mod (PrintVerboseFromList): Add debugging print for a component. (TypeConstFullyDeclared): Call RememberType for every type. * gm2-compiler/M2GenGCC.mod (CodeReturnValue): Add parameter to GetQuadOtok. (CodeBecomes): Add parameter to GetQuadOtok. (CodeXIndr): Add parameter to GetQuadOtok. * gm2-compiler/M2Optimize.mod (ReduceBranch): Reformat and preserve operand token positions when reducing the branch quadruples. (ReduceGoto): Reformat. (FoldMultipleGoto): Reformat. (KnownReachable): Reformat. * gm2-compiler/M2Options.def (UninitVariableChecking): New variable declared and exported. (SetUninitVariableChecking): New procedure. * gm2-compiler/M2Options.mod (SetWall): Set UninitVariableChecking. (SetUninitVariableChecking): New procedure. * gm2-compiler/M2Quads.def (PutQuadOtok): Exported and declared. (VariableAnalysis): Removed. * gm2-compiler/M2Quads.mod (PutQuadOtok): New procedure. (doVal): Reformatted. (MarkAsWrite): Reformatted. (MarkArrayAsWritten): Reformatted. (doIndrX): Use PutQuadOtok. (MakeRightValue): Use GenQuadOtok. (MakeLeftValue): Use GenQuadOtok. (CheckReadBeforeInitialized): Remove. (IsNeverAltered): Reformat. (DebugLocation): New procedure. (BuildDesignatorPointer): Use GenQuadO to preserve operand token position. (BuildRelOp): Use GenQuadOtok ditto. * gm2-compiler/SymbolTable.def (VarCheckReadInit): New procedur= e. (VarInitState): New procedure. (PutVarInitialized): New procedure. (PutVarFieldInitialized): New procedure function. (GetVarFieldInitialized): New procedure function. (PrintInitialized): New procedure. * gm2-compiler/SymbolTable.mod (VarCheckReadInit): New procedur= e. (VarInitState): New procedure. (PutVarInitialized): New procedure. (PutVarFieldInitialized): New procedure function. (GetVarFieldInitialized): New procedure function. (PrintInitialized): New procedure. (LRInitDesc): New type. (SymVar): InitState new field. (MakeVar): Initialize InitState. * gm2-gcc/m2options.h (M2Options_SetUninitVariableChecking): New function declaration. * gm2-lang.cc (gm2_langhook_handle_option): Detect OPT_Wuninit_variable_checking and call SetUninitVariableCheckin= g. * lang.opt: Add Wuninit-variable-checking. * gm2-compiler/M2SymInit.def: New file. * gm2-compiler/M2SymInit.mod: New file. gcc/testsuite/ChangeLog: PR modula2/110125 * gm2/switches/uninit-variable-checking/fail/testinit.mod: New test. * gm2/switches/uninit-variable-checking/fail/testlarge.mod: New test. * gm2/switches/uninit-variable-checking/fail/testlarge2.mod: New test. * gm2/switches/uninit-variable-checking/fail/testrecinit.mod: N= ew test. * gm2/switches/uninit-variable-checking/fail/testrecinit2.mod: = New test. * gm2/switches/uninit-variable-checking/fail/testrecinit5.mod: = New test. * gm2/switches/uninit-variable-checking/fail/testsmallrec.mod: = New test. * gm2/switches/uninit-variable-checking/fail/testsmallrec2.mod:= New test. * gm2/switches/uninit-variable-checking/fail/testsmallvec.mod: = New test. * gm2/switches/uninit-variable-checking/fail/testvarinit.mod: N= ew test. * gm2/switches/uninit-variable-checking/fail/testwithnoptr.mod:= New test. * gm2/switches/uninit-variable-checking/fail/testwithptr.mod: N= ew test. * gm2/switches/uninit-variable-checking/fail/testwithptr2.mod: = New test. * gm2/switches/uninit-variable-checking/fail/testwithptr3.mod: = New test. * gm2/switches/uninit-variable-checking/pass/testrecinit3.mod: = New test. * gm2/switches/uninit-variable-checking/pass/testrecinit5.mod: = New test. * gm2/switches/uninit-variable-checking/pass/testsmallrec.mod: = New test. * gm2/switches/uninit-variable-checking/pass/testsmallrec2.mod:= New test. * gm2/switches/uninit-variable-checking/pass/testvarinit.mod: N= ew test. * gm2/switches/uninit-variable-checking/pass/testwithptr.mod: N= ew test. * gm2/switches/uninit-variable-checking/pass/testwithptr2.mod: = New test. * gm2/switches/uninit-variable-checking/pass/testwithptr3.mod: = New test. (cherry picked from commit b0762d4c7e7894845e70e839c8513ae4c9e9d42e) Signed-off-by: Gaius Mulley =