Patchwork [Ada] Fix bad warning message for Unreferenced

login
register
mail settings
Submitter Arnaud Charlet
Date June 18, 2010, 8:18 a.m.
Message ID <20100618081847.GA11416@adacore.com>
Download mbox | patch
Permalink /patch/56148/
State New
Headers show

Comments

Arnaud Charlet - June 18, 2010, 8:18 a.m.
This patch fixes an incorrect warning suggesting use of Unreferenced
instead of Warnings (Off), when in fact Unreferenced was incorrect.
For the following m.adb should compile clean with no warnings:

generic
package D is
  type Handle_Type is private;
  function Create_Handle return Handle_Type;
private
  type Handle_Type is
  record
    Initialised : Boolean;
  end record;
end D;

with D;
generic
  with package My_D is new D;
  with procedure Method (Client : in out My_D.Handle_Type);
package M is
private
  procedure Call_Method;
end M;

package body D is
  function Create_Handle return Handle_Type is
  begin
    return (Initialised => False);
  end Create_Handle;
end D;

package body M is
  procedure Call_Method is
    Handle : My_D.Handle_Type := My_D.Create_Handle;
    pragma Warnings (Off, Handle);
  begin
    Method(Client => Handle);
  end Call_Method;
end M;

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

2010-06-18  Robert Dewar  <dewar@adacore.com>

	* lib-xref.adb (Generate_Reference): Fix bad reference to
	Has_Pragma_Unreferenced (clients should always use Has_Unreferenced).

Patch

Index: lib-xref.adb
===================================================================
--- lib-xref.adb	(revision 160959)
+++ lib-xref.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1998-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1998-2010, 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- --
@@ -666,7 +666,7 @@  package body Lib.Xref is
          --  Check for pragma Unreferenced given and reference is within
          --  this source unit (occasion for possible warning to be issued).
 
-         if Has_Pragma_Unreferenced (E)
+         if Has_Unreferenced (E)
            and then In_Same_Extended_Unit (E, N)
          then
             --  A reference as a named parameter in a call does not count