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] Additional warnings on redundant use clauses in subprogram bodies.


Tested on i686-linux, committed on trunk

The circuitry that detects redundant use clauses did not examine subprogram
bodies and subunits, where a use clause in the body may be redundant because
of a use clause in the context of the unit.

the command
gcc -c -gnatwa toto.adb

must produce:

toto.adb:3:11:
warning: "Text_IO" is already use-visible through previous use clause at line 1

with Ada.Text_IO; use Ada.Text_IO;
procedure Toto is
   use Ada.Text_IO;
begin
   Put_Line ("hello world!");
end Toto;

Also, it is legal to declare stream attributes for interface types.
The corresponding
operations are abstract or null. Previous code only handled primitive functions
of abstract types. In the case of interfaces, all stream operations are made
abstract by default, to ensure that they are properly overriden in all its
descendents, and all of them can be overriden with another primitive.

See gnat.dg/tf_interface_1.ad[sb]

2008-05-20  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch8.adb
	(Note_Redundant_Use): Diagnose a redundant use within a subprogram body
	when there is a use clause for the same entity in the context.
	(Analyze_Subprogram_Renaming): A renaming_as_body is legal if it is
	created for a stream attribute of an abstract type or interface type.

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]