public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Warnings for ineffective use clauses unclear
@ 2017-10-09 15:19 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2017-10-09 15:19 UTC (permalink / raw)
  To: gcc-patches; +Cc: Justin Squirek

[-- Attachment #1: Type: text/plain, Size: 1510 bytes --]

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 #2: difs --]
[-- Type: text/plain, Size: 892 bytes --]

Index: sem_ch8.adb
===================================================================
--- sem_ch8.adb	(revision 253546)
+++ sem_ch8.adb	(working copy)
@@ -9069,7 +9069,7 @@
                              (Current_Use_Clause (Associated_Node (N))))
                   then
                      Error_Msg_Node_1 := Entity (N);
-                     Error_Msg_NE ("ineffective use clause for package &?",
+                     Error_Msg_NE ("use clause for package &? has no effect",
                                    Curr, Entity (N));
                   end if;
 
@@ -9077,7 +9077,7 @@
 
                else
                   Error_Msg_Node_1 := Etype (N);
-                  Error_Msg_NE ("ineffective use clause for }?",
+                  Error_Msg_NE ("use clause for }? has no effect",
                                  Curr, Etype (N));
                end if;
             end if;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-10-09 15:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-09 15:19 [Ada] Warnings for ineffective use clauses unclear Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).