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] Improved warning message


Tested on x86-linux, committed on mainline.

This is an improvement on warning messages for unreferenced entities.

Test case, expected output:
$ gcc -c -gnatwaf k.adb
k.adb:14:15: warning: pragma Unreferenced given for "t1"
k.adb:27:15: warning: pragma Unreferenced given for "t2"
k.adb:34:17: warning: "t3" is not referenced
k.adb:38:17: warning: "t4" is not referenced
--
procedure k is
   pragma Warnings (Off);
   m : integer;
   task t is
      entry a (t1 : integer); entry b (t2 : integer);
      entry c (t3 : integer); entry d (t4 : integer);
   end t;
   pragma Warnings (On);

   task body t is
   begin
      accept a (t1 : integer) do
         pragma Unreferenced (t1);
         m := t1;    --  warning expected.
      end;

      accept a (t1 : integer) do
         m := t1;   -- NO warning expected
      end;

      accept b (t2 : integer) do
         m := t2;    --  NO warning expected.
      end;

      accept b (t2 : integer) do
         pragma Unreferenced (t2);
         m := t2;    --  warning expected.
      end b;

      accept c (t3 : integer) do
         m := t3;    --  NO warning expected.
      end;

      accept c (t3 : integer) do
         null;       --  warning expected.
      end;

      accept d (t4 : integer) do    --  warning expected.
         null;       --  warning expected.
      end;

      accept d (t4 : integer) do
         m := t4;    --  NO warning expected.
      end;
   end t;

begin null; end;


2004-12-07  Ed Schonberg  <schonberg@adacore.com>

	* lib-xref.adb: 
	(Generate_Reference): Handle properly a reference to an entry formal,
	 when an accept statement has a pragma Unreferenced for it.

	* sem_ch9.adb (Analyze_Accept_Statement): Reset the Is_Referenced flag
	and the Has_Pragma_Unreferenced flag for each formal before analyzing
	the body, to ensure that warnings are properly emitted for each accept
	statement of a given task entry.

Attachment: difs.16
Description: Text document


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