diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-02-20 13:52:08 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-02-20 13:52:08 +0000 |
commit | 32de816bbbe685dfa9c2b491b15579cf379d03e4 (patch) | |
tree | 6f9c2f011ad7373733907f5eea8eb01d6244e444 | |
parent | eb4f7efad4f3a03ac2f9b8162f7d2179c46fb644 (diff) | |
download | gcc-32de816bbbe685dfa9c2b491b15579cf379d03e4.tar.gz |
2014-02-20 Vincent Celier <celier@adacore.com>
* errutil.adb (Initialize): Properly initialize entry in table
Warnings when warnings are suppressed.
2014-02-20 Robert Dewar <dewar@adacore.com>
* s-os_lib.ads: Add warning about non-portability of Rename_File.
* sem_util.ads, sem_util.adb (Is_Junk_Name): New function.
* sem_warn.adb: Use Is_Junk_Name to suppress some warnings.
* gnat_ugn.texi: Document no warnings on junk variable names.
* layout.adb: Minor code reorganization (use Ekind_In).
* stringt.adb: Move initialization of Null_String_Id to Initialize
routine.
2014-02-20 Ed Schonberg <schonberg@adacore.com>
* sem_ch13.adb: Initialize optional Element_Id.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@207947 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ada/ChangeLog | 19 | ||||
-rw-r--r-- | gcc/ada/errutil.adb | 9 | ||||
-rw-r--r-- | gcc/ada/gnat_rm.texi | 14 | ||||
-rw-r--r-- | gcc/ada/gnat_ugn.texi | 7 | ||||
-rw-r--r-- | gcc/ada/layout.adb | 4 | ||||
-rw-r--r-- | gcc/ada/s-os_lib.ads | 11 | ||||
-rw-r--r-- | gcc/ada/sem_ch13.adb | 1 | ||||
-rw-r--r-- | gcc/ada/sem_util.adb | 39 | ||||
-rw-r--r-- | gcc/ada/sem_util.ads | 10 | ||||
-rw-r--r-- | gcc/ada/sem_warn.adb | 4 | ||||
-rw-r--r-- | gcc/ada/stringt.adb | 12 |
11 files changed, 113 insertions, 17 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index ccd4d0e1c8f..998272e6cf0 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,22 @@ +2014-02-20 Vincent Celier <celier@adacore.com> + + * errutil.adb (Initialize): Properly initialize entry in table + Warnings when warnings are suppressed. + +2014-02-20 Robert Dewar <dewar@adacore.com> + + * s-os_lib.ads: Add warning about non-portability of Rename_File. + * sem_util.ads, sem_util.adb (Is_Junk_Name): New function. + * sem_warn.adb: Use Is_Junk_Name to suppress some warnings. + * gnat_ugn.texi: Document no warnings on junk variable names. + * layout.adb: Minor code reorganization (use Ekind_In). + * stringt.adb: Move initialization of Null_String_Id to Initialize + routine. + +2014-02-20 Ed Schonberg <schonberg@adacore.com> + + * sem_ch13.adb: Initialize optional Element_Id. + 2014-02-20 Robert Dewar <dewar@adacore.com> * s-os_lib.ads (Rename_File): Minor commment addition. diff --git a/gcc/ada/errutil.adb b/gcc/ada/errutil.adb index 8053bb51ae7..0d4af6c49c8 100644 --- a/gcc/ada/errutil.adb +++ b/gcc/ada/errutil.adb @@ -31,6 +31,7 @@ with Opt; use Opt; with Output; use Output; with Scans; use Scans; with Sinput; use Sinput; +with Stringt; use Stringt; with Stylesw; use Stylesw; package body Errutil is @@ -599,9 +600,11 @@ package body Errutil is Warnings.Init; if Warning_Mode = Suppress then - Warnings.Increment_Last; - Warnings.Table (Warnings.Last).Start := Source_Ptr'First; - Warnings.Table (Warnings.Last).Stop := Source_Ptr'Last; + Warnings.Append + (New_Val => + (Start => Source_Ptr'First, + Stop => Source_Ptr'Last, + Reason => Null_String_Id)); end if; end Initialize; diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index 4de43932dbe..c02169f74c1 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -7133,6 +7133,13 @@ This is particularly useful for clearly signaling that a particular parameter is not modified, even though the spec suggests that it might be. +For the variable case, warnings are never given for unreferenced variables +whose name contains one of the substrings +@code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names +are typically to be used in cases where such warnings are expected. +Thus it is never necessary to use @code{pragma Unmodified} for such +variables, though it is harmless to do so. + @node Pragma Unreferenced @unnumberedsec Pragma Unreferenced @findex Unreferenced @@ -7183,6 +7190,13 @@ mentioned in @code{with} clauses (similar to the usage of pragma @code{Elaborate_All}. The effect is to suppress warnings about unreferenced units and unreferenced entities within these units. +For the variable case, warnings are never given for unreferenced variables +whose name contains one of the substrings +@code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names +are typically to be used in cases where such warnings are expected. +Thus it is never necessary to use @code{pragma Unreferenced} for such +variables, though it is harmless to do so. + @node Pragma Unreferenced_Objects @unnumberedsec Pragma Unreferenced_Objects @findex Unreferenced_Objects diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index b97ece0fd96..b61254db521 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -4852,7 +4852,12 @@ Internal GNAT unit @code{with}'ed by application unit Values known to be out of range at compile time @item -Unreferenced labels and variables +Unreferenced or unmodified variables. Note that a special +exemption applies to variables which contain any of the substrings +@code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED}, in any casing. Such variables +are considered likely to be intentionally used in a situation where +otherwise a warning would be given, so warnings of this kind are +always suppressed for such variables. @item Address overlays that could clobber memory diff --git a/gcc/ada/layout.adb b/gcc/ada/layout.adb index 75957c53fc1..ada36de8c75 100644 --- a/gcc/ada/layout.adb +++ b/gcc/ada/layout.adb @@ -2276,9 +2276,7 @@ package body Layout is -- original, nothing else needs to be done in this case, since the -- components themselves are all shared. - if (Ekind (E) = E_Record_Subtype - or else - Ekind (E) = E_Class_Wide_Subtype) + if Ekind_In (E, E_Record_Subtype, E_Class_Wide_Subtype) and then Present (Cloned_Subtype (E)) then Set_Esize (E, Esize (Cloned_Subtype (E))); diff --git a/gcc/ada/s-os_lib.ads b/gcc/ada/s-os_lib.ads index 00aebc24e1a..03557b65597 100644 --- a/gcc/ada/s-os_lib.ads +++ b/gcc/ada/s-os_lib.ads @@ -301,9 +301,14 @@ package System.OS_Lib is New_Name : String; Success : out Boolean); -- Rename a file. Success is set True or False indicating if the rename is - -- successful or not. Note that on some Systems (notably Windows), if there - -- is already an existing file with the name New_Name, that is one of the - -- conditions that can cause failure. + -- successful or not. + -- + -- WARNING: In one very important respect, this function is significantly + -- non-portable. If New_Name already exists then on Unix systems, the call + -- deletes the existing file, and the call signals success. On Windows, the + -- call fails, without doing the rename operation. See also the procedure + -- Ada.Directories.Rename, which portably provides the windows semantics, + -- i.e. fails if the output file already exists. -- The following defines the mode for the Copy_File procedure below. Note -- that "time stamps and other file attributes" in the descriptions below diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 1e81110fec6..79ca903cc62 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -11493,6 +11493,7 @@ package body Sem_Ch13 is First_Id := Empty; Next_Id := Empty; Has_Element_Id := Empty; + Element_Id := Empty; -- Each expression must resolve to a function with the proper signature diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index ceedb7d9d6a..435db38f42b 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -10369,6 +10369,45 @@ package body Sem_Util is end if; end Is_Iterator; + ------------------ + -- Is_Junk_Name -- + ------------------ + + function Is_Junk_Name (N : Name_Id) return Boolean is + function Match (S : String) return Boolean; + -- Return true if substring S is found in Name_Buffer (1 .. Name_Len) + + ----------- + -- Match -- + ----------- + + function Match (S : String) return Boolean is + Slen1 : constant Integer := S'Length - 1; + + begin + for J in 1 .. Name_Len - S'Length + 1 loop + if Name_Buffer (J .. J + Slen1) = S then + return True; + end if; + end loop; + + return False; + end Match; + + -- Start of processing for Is_Junk_Name + + begin + Get_Unqualified_Decoded_Name_String (N); + Set_All_Upper_Case; + + return + Match ("DISCARD") or else + Match ("DUMMY") or else + Match ("IGNORE") or else + Match ("JUNK") or else + Match ("UNUSED"); + end Is_Junk_Name; + ------------ -- Is_LHS -- ------------ diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index 3377c7cc01f..94e446523b4 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -1214,6 +1214,16 @@ package Sem_Util is -- AI05-0139-2: Check whether Typ is one of the predefined interfaces in -- Ada.Iterator_Interfaces, or it is derived from one. + function Is_Junk_Name (N : Name_Id) return Boolean; + -- Returns True if the given name contains any of the following substrings + -- discard + -- dummy + -- ignore + -- junk + -- unused + -- Used to suppress warnings on names matching these patterns. The contents + -- of Name_Buffer and Name_Len are desteoyed by this call. + type Is_LHS_Result is (Yes, No, Unknown); function Is_LHS (N : Node_Id) return Is_LHS_Result; -- Returns Yes if N is definitely used as Name in an assignment statement. diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb index 6193a8f705a..e73a54e615a 100644 --- a/gcc/ada/sem_warn.adb +++ b/gcc/ada/sem_warn.adb @@ -1265,6 +1265,7 @@ package body Sem_Warn is if Referenced (E1) then if not Has_Unmodified (E1) and then not Warnings_Off_E1 + and then not Is_Junk_Name (Chars (E1)) then Output_Reference_Error ("?v?variable& is read but never assigned!"); @@ -1272,6 +1273,7 @@ package body Sem_Warn is elsif not Has_Unreferenced (E1) and then not Warnings_Off_E1 + and then not Is_Junk_Name (Chars (E1)) then Output_Reference_Error -- CODEFIX ("?v?variable& is never read and never assigned!"); @@ -3899,6 +3901,7 @@ package body Sem_Warn is if not Referenced_Check_Spec (E) and then not Has_Pragma_Unreferenced_Check_Spec (E) and then not Warnings_Off_Check_Spec (E) + and then not Is_Junk_Name (Chars (Spec_E)) then case Ekind (E) is when E_Variable => @@ -4105,6 +4108,7 @@ package body Sem_Warn is and then not Is_Exported (Ent) and then Safe_To_Capture_Value (N, Ent) and then not Has_Pragma_Unreferenced_Check_Spec (Ent) + and then not Is_Junk_Name (Chars (Ent)) then -- Before we issue the message, check covering exception handlers. -- Search up tree for enclosing statement sequences and handlers. diff --git a/gcc/ada/stringt.adb b/gcc/ada/stringt.adb index e5d1573abe1..5a0c89c7d04 100644 --- a/gcc/ada/stringt.adb +++ b/gcc/ada/stringt.adb @@ -121,6 +121,11 @@ package body Stringt is begin String_Chars.Init; Strings.Init; + + -- Set up the null string + + Start_String; + Null_String_Id := End_String; end Initialize; ---------- @@ -472,11 +477,4 @@ package body Stringt is end if; end Write_String_Table_Entry; --- Setup the null string - -begin - Initialize; - Start_String; - Null_String_Id := End_String; - end Stringt; |