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 warnings on useless formals in subprograms


This patch allows a better detection of unused formals in subprogram bodies.
Previously the use of a formal as the selector in a parameter association was
treated as a proper reference, thus missing otherwise unused entities.

The following command :

   gcc -c -gnatwa k.adb

must yield:

   k.adb:2:22: warning: formal parameter "X" is not referenced

---
procedure K is
  procedure Suspect (X : Integer) is
   begin
      for I in 1 .. 10 loop null; end loop;
   end;

begin
   Suspect (X => 15);
   Suspect (X => 15);
   Suspect (X => 15);
end;

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

2011-09-06  Ed Schonberg  <schonberg@adacore.com>

	* lib-xref.adb (OK_To_Set_Referenced): A reference to a formal
	in a parameter association must not set the Referenced flag on
	the formal.
	* prj-nmsc.adb (Check_File_Naming_Schemes): Remove useless formal

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]