[Ada] Fix bad warning message for Unreferenced
Arnaud Charlet
charlet@adacore.com
Fri Jun 18 08:59:00 GMT 2010
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).
-------------- next part --------------
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
More information about the Gcc-patches
mailing list