This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Warnings for ineffective use clauses unclear


This patch modifies the warnings denoting ineffective use-clauses to be more
explicit and user-friendly.

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

--  unused_a.adb

with Ada.Text_IO;
with Interfaces;

procedure Unused_A is
   use type Interfaces.Unsigned_8;
begin
   Ada.Text_IO.Put_Line ("Hello, World!");
end;

--  unused_b.adb

with Ada.Text_IO;
with Interfaces;

procedure Unused_B is
   use type Interfaces.Unsigned_32;
   Val : Interfaces.Unsigned_32 := 5;
begin
   Ada.Text_IO.Put_Line ("Hello, World!" & Interfaces.Unsigned_32'Image (Val));
end;

--  unused_c.adb

with Ada.Text_IO;
with Interfaces;

procedure Unused_C is
   Val : Interfaces.Unsigned_32 := 5;
begin
   Ada.Text_IO.Put_Line ("Hello, World!" & Interfaces.Unsigned_32'Image (Val));

   declare
      use Interfaces; -- no warning that this is useless here
   begin
      Ada.Text_IO.Put_Line ("Goodbye!");
   end;

end;

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

& gnatmake -gnatwu -q unused_a.adb
& gnatmake -gnatwu -q unused_b.adb
& gnatmake -gnatwu -q unused_c.adb

unused_a.adb:5:04: warning: use clause for type "Interfaces.Unsigned_8"
 has no effect
unused_b.adb:5:04: warning: use clause for type "Interfaces.Unsigned_32"
 has no effect
unused_c.adb:10:07: warning: use clause for package "Interfaces" has no effect

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

2017-10-09  Justin Squirek  <squirek@adacore.com>

	* sem_ch8.adb (Update_Chain_In_Scope): Modify warning messages.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]