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] Warn on redefinition of standard entities


A new warning flag -gnatw.k causes the compiler to emit a warning
if a declaration redefines an entity of package Standard. Such
redefinitions are usually not a good idea, since these entities
are directly visible, and this can lead to confusion. This warning
is off by default.

The following, compiled with -gnatw.k shows the warning in action:

     1. package StandNames is
     2.    type Integer is new Natural;
                |
        >>> warning: redefinition of entity "Integer" in Standard

     3.    type Exceptions is (Tasking_Error, Storage_Error);
                               |
        >>> warning: redefinition of entity "Tasking_Error" in Standard

     4. end StandNames;

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

2012-10-29  Robert Dewar  <dewar@adacore.com>

	* i-cstrea.ads: Avoid redefinition of standard symbol string.
	* prj-makr.adb: Add comment for OK redefinition of Stadard.
	* prj.ads: Add comment for OK redefinition of Stadard.
	* s-crtl.ads: Avoid redefinition of standard symbol string.
	* sinfo-cn.adb (Change_Identifier_To_Defining_Identifier):
	Generate warning for standard redefinition if
	Warn_On_Standard_Definition set.
	* usage.adb: Add lines for -gnatw.k and -gnatw.K
	* warnsw.adb: Set/reset Warn_On_Standard_Redefinition
	appropriately.
	* warnsw.ads (Warn_On_Standard_Redefinition): New flag.
	* s-stratt-xdr.adb: Avoid new warning.

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]