Patchwork [Ada] Avoid uninitialized variable in Pop_End_Context

login
register
mail settings
Submitter Arnaud Charlet
Date April 12, 2013, 12:48 p.m.
Message ID <20130412124820.GA11644@adacore.com>
Download mbox | patch
Permalink /patch/236078/
State New
Headers show

Comments

Arnaud Charlet - April 12, 2013, 12:48 p.m.
This patch initializes the top Sloc in the scope stack, which is read in
Pop_End_Context and was previously uninitialized.

Tested on x86_64-pc-linux-gnu, committed on trunk

2013-04-12  Bob Duff  <duff@adacore.com>

	* par-ch7.adb (P_Package): Initialize Sloc in the newly-pushed scope
	stack entry.

Patch

Index: par-ch7.adb
===================================================================
--- par-ch7.adb	(revision 197897)
+++ par-ch7.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -138,6 +138,7 @@ 
          end if;
 
          T_Body;
+         Scope.Table (Scope.Last).Sloc := Token_Ptr;
          Name_Node := P_Defining_Program_Unit_Name;
          Scope.Table (Scope.Last).Labl := Name_Node;
          TF_Is;
@@ -182,6 +183,7 @@ 
       --  Cases other than Package_Body
 
       else
+         Scope.Table (Scope.Last).Sloc := Token_Ptr;
          Name_Node := P_Defining_Program_Unit_Name;
          Scope.Table (Scope.Last).Labl := Name_Node;