+2019-07-11 Justin Squirek <squirek@adacore.com>
+
+ * exp_ch9.adb (Build_Private_Protected_Declaration): Add
+ exception for the moving of pragmas to internally generated
+ specs for pragma Unreferenced.
+
2019-07-11 Bob Duff <duff@adacore.com>
* doc/gnat_ugn/gnat_utility_programs.rst: Fix inconsistent
procedure Move_Pragmas (From : Node_Id; To : Node_Id);
-- Find all suitable source pragmas at the top of subprogram body From's
-- declarations and insert them after arbitrary node To.
+ --
+ -- Very similar to Move_Pragmas in sem_ch6 ???
---------------------
-- Analyze_Pragmas --
Next_Decl := Next (Decl);
- if Nkind (Decl) = N_Pragma then
+ -- We add an exception here for Unreferenced pragmas since the
+ -- internally generated spec gets analyzed within
+ -- Build_Private_Protected_Declaration and will lead to spurious
+ -- warnings due to the way references are checked.
+
+ if Nkind (Decl) = N_Pragma
+ and then Pragma_Name_Unmapped (Decl) /= Name_Unreferenced
+ then
Remove (Decl);
Insert_After (Insert_Nod, Decl);
Insert_Nod := Decl;
+2019-07-11 Justin Squirek <squirek@adacore.com>
+
+ * gnat.dg/unreferenced2.adb: New testcase.
+
2019-07-11 Hristian Kirtchev <kirtchev@adacore.com>
* gnat.dg/self_ref1.adb: New testcase.
--- /dev/null
+-- { dg-do compile }
+-- { dg-options "-gnatf" }
+
+procedure Unreferenced2 is
+
+ protected Example is
+ procedure Callme;
+ end Example;
+
+ procedure Other (X : Boolean) is
+ begin
+ null;
+ end;
+
+ protected body Example is
+
+ procedure Internal (X : Boolean) is
+ pragma Unreferenced (X);
+ Y : Integer;
+ begin
+ Y := 3;
+ end Internal;
+
+ procedure Callme is
+ begin
+ Internal (X => True);
+ end Callme;
+
+ end Example;
+
+begin
+ Example.Callme;
+ Other (True);
+end Unreferenced2;