diff mbox

[Ada] Use of names in input_list of aspect/pragma Initializes

Message ID 20131015102814.GA12034@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Oct. 15, 2013, 10:28 a.m. UTC
This patch corrects the analysis of an initialization item with an input_list
to catch cases where input items come from the same related package.

------------
-- Source --
------------

--  init.ads

package Init
   with Abstract_State => S,
        Initializes    => (S => (Emb.SS, Emb.XX, Emb.YY))
is
   package Emb
      with Abstract_State => SS
   is
      XX : Integer;
   private
      YY : Integer;
   end Emb;
end Init;

----------------------------
-- Compilation and output --
----------------------------

$ gcc -c -gnatd.V init.ads
init.ads:3:37: input item "SS" cannot denote a visible variable or state of
  package "Init"
init.ads:3:45: input item "XX" cannot denote a visible variable or state of
  package "Init"
init.ads:3:53: "YY" is not a visible entity of "Emb"

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

2013-10-15  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_prag.adb (Analyze_Input_Item): Emit an
	error when the input item comes from the related package.
diff mbox

Patch

Index: sem_prag.adb
===================================================================
--- sem_prag.adb	(revision 203568)
+++ sem_prag.adb	(working copy)
@@ -2353,9 +2353,9 @@ 
                   if Ekind_In (Input_Id, E_Abstract_State, E_Variable) then
 
                      --  The input cannot denote states or variables declared
-                     --  within the visible declarations of the package.
+                     --  within the related package.
 
-                     if Contains (States_And_Vars, Input_Id) then
+                     if In_Same_Code_Unit (Item, Input) then
                         Error_Msg_Name_1 := Chars (Pack_Id);
                         Error_Msg_NE
                           ("input item & cannot denote a visible variable or "