This patch corrects an issue whereby index actuals in calls to entry families
were not being properly flagged as referenced leading to spurious warnings
when compiling with -gnatwu.

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

gcc/ada/

2017-09-25  Justin Squirek  <squi...@adacore.com>

        * sem_res.adb (Resolve_Entry): Generate reference for index entities.

gcc/testsuite/

2017-09-25  Justin Squirek  <squi...@adacore.com>

        * gnat.dg/entry_family.adb: New testcase

Index: sem_res.adb
===================================================================
--- sem_res.adb (revision 253134)
+++ sem_res.adb (working copy)
@@ -7474,6 +7474,15 @@
          Index := First (Expressions (Entry_Name));
          Resolve (Index, Entry_Index_Type (Nam));
 
+         --  Generate a reference for the index entity when the index is not a
+         --  literal.
+
+         if Nkind (Index) in N_Has_Entity
+           and then Nkind (Entity (Index)) in N_Entity
+         then
+            Generate_Reference (Entity (Index), Nam, ' ');
+         end if;
+
          --  Up to this point the expression could have been the actual in a
          --  simple entry call, and be given by a named association.
 
Index: ../testsuite/gnat.dg/entry_family.adb
===================================================================
--- ../testsuite/gnat.dg/entry_family.adb       (revision 0)
+++ ../testsuite/gnat.dg/entry_family.adb       (revision 0)
@@ -0,0 +1,28 @@
+--  { dg-do compile }
+--  { dg-options "-gnatwu" }
+
+with Ada.Numerics.Discrete_Random; use Ada.Numerics;
+
+procedure Entry_Family is
+   protected Family is
+      entry Call (Boolean);
+   end Family;
+
+   protected body Family is
+      entry Call (for P in Boolean) when True is
+      begin
+         null;
+      end Call;
+
+   end Family;
+
+   package Random_Boolean is new Discrete_Random (Result_Subtype => Boolean);
+   use Random_Boolean;
+
+   Boolean_Generator : Generator;
+
+   B : constant Boolean := Random (Boolean_Generator);
+
+begin
+   Family.Call (B);
+end Entry_Family;

Reply via email to