From ac8df12f3defdd51822b09182d2642baa9a86ce5 Mon Sep 17 00:00:00 2001 From: charlet Date: Tue, 26 Oct 2010 13:17:23 +0000 Subject: [PATCH] 2010-10-26 Robert Dewar * opt.ads: Move documentation on checksum stuff here from prj-nmsc * prj-nmsc.adb (Process_Project_Level_Array_Attributes): Move documentation on checksum versions to opt.ads. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165962 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/ChangeLog | 6 +++++ gcc/ada/opt.ads | 70 +++++++++++++++++++++++++++++++++++++--------------- gcc/ada/prj-nmsc.adb | 57 +++++++++++++----------------------------- 3 files changed, 73 insertions(+), 60 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 58e75aa..59e34b3 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2010-10-26 Robert Dewar + + * opt.ads: Move documentation on checksum stuff here from prj-nmsc + * prj-nmsc.adb (Process_Project_Level_Array_Attributes): Move + documentation on checksum versions to opt.ads. + 2010-10-26 Vincent Celier * opt.ads (Checksum_Accumulate_Token_Checksum): New Boolean flag, diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads index 1bc9729..24df38c 100644 --- a/gcc/ada/opt.ads +++ b/gcc/ada/opt.ads @@ -49,6 +49,56 @@ pragma Warnings (On); package Opt is + ---------------------- + -- Checksum Control -- + ---------------------- + + -- Checksums are computed for sources to check for sources being the same + -- from a compilation point of view (e.g. spelling of identifiers and + -- white space layout do not count in this computation). + + -- The way the checksum is computed has evolved across the various versions + -- of GNAT. When gprbuild is called with -m, the checksums must be computed + -- the same way in gprbuild as it was in the GNAT version of the compiler. + -- The different ways are + + -- Version 6.4 and later: + + -- The Accumulate_Token_Checksum procedure is called after each numeric + -- literal and each identifier/keyword. For keywords, Tok_Identifier is + -- used in the call to Accumulate_Token_Checksum. + + -- Versions 5.04 to 6.3: + + -- For keywords, the token value were used in the call to procedure + -- Accumulate_Token_Checksum. Type Token_Type did not include Tok_Some. + + -- Versions 5.03: + + -- For keywords, the token value were used in the call to + -- Accumulate_Token_Checksum. Type Token_Type did not include + -- Tok_Interface, Tok_Overriding, Tok_Synchronized and Tok_Some. + + -- Versions 5.02 and before: + + -- No calls to procedure Accumulate_Token_Checksum (the checksum + -- mechanism was introduced in version 5.03). + + -- To signal to the scanner whether Accumulate_Token_Checksum needs to be + -- called and what versions to call, the following Boolean flags are used: + + Checksum_Accumulate_Token_Checksum : Boolean := True; + -- GPRBUILD + -- Set to False by gprbuild when the version of GNAT is 5.02 or before. + + Checksum_GNAT_6_3 : Boolean := False; + -- GPRBUILD + -- Set to True by gprbuild when the version of GNAT is 6.3 or before. + + Checksum_GNAT_5_03 : Boolean := False; + -- GPRBUILD + -- Set to True by gprbuild when the version of GNAT is 5.03 or before. + ---------------------------------------------- -- Settings of Modes for Current Processing -- ---------------------------------------------- @@ -933,26 +983,6 @@ package Opt is -- GNATMAKE -- Set to True when an object directory is specified with option -D - Checksum_Accumulate_Token_Checksum : Boolean := True; - -- GPRBUILD - -- Set to False by gprbuild when the version of GNAT is 5.02 or before. - -- There were no call to procedure Accumulate_Token_Checksum in these - -- versions. - - Checksum_GNAT_6_3 : Boolean := False; - -- GPRBUILD - -- Set to True by gprbuild when the version of GNAT is 6.3 or before. For - -- GNAT versions 5.04 to 6.3, Accumulate_Token_Checksum were called with - -- the token values of the keywords, instead of Tok_Identifier for later - -- versions, and Tok_Some was not in Token_Type. - - Checksum_GNAT_5_03 : Boolean := False; - -- GPRBUILD - -- Set to True by gprbuild when the version of GNAT is 5.03. For GNAT 5.04, - -- Accumulate_Token_Checksum were called with the token values of the - -- keywords, and Tok_Interface, Tok_Overriding, Tok_Synchronized and - -- Tok_Some were not in Token_Type. - One_Compilation_Per_Obj_Dir : Boolean := False; -- GNATMAKE, GPRBUILD -- Set to True with switch --single-compile-per-obj-dir. When True, there diff --git a/gcc/ada/prj-nmsc.adb b/gcc/ada/prj-nmsc.adb index 6786e92..3865887 100644 --- a/gcc/ada/prj-nmsc.adb +++ b/gcc/ada/prj-nmsc.adb @@ -54,7 +54,10 @@ package body Prj.Nmsc is -- location. type Name_Location is record - Name : File_Name_Type; -- ??? duplicates the key + Name : File_Name_Type; + -- Key is duplicated, so that it is known when using functions Get_First + -- and Get_Next, as these functions only return an Element. + Location : Source_Ptr; Source : Source_Id := No_Source; Listed : Boolean := False; @@ -81,7 +84,10 @@ package body Prj.Nmsc is -- found on the disk. type Unit_Exception is record - Name : Name_Id; -- ??? duplicates the key + Name : Name_Id; + -- Key is duplicated, so that it is known when using functions Get_First + -- and Get_Next, as these functions only return an Element. + Spec : File_Name_Type; Impl : File_Name_Type; end record; @@ -2399,50 +2405,17 @@ package body Prj.Nmsc is Lang_Index.Config.Toolchain_Version := Element.Value.Value; - if Lang_Index.Name = Name_Ada then - -- The way the checksum is computed has evolved - -- across the different versions of GNAT. When - -- gprbuild is called with -m, the checksums need - -- to be computed the same way in gprbuild as it - -- was in the GNAT version of the compiler. - -- The different ways are: - -- - version 6.4 and later: - -- procedure Accumulate_Token_Checksum is - -- called after each numeric literal and each - -- identifier/keyword. For keywords, - -- Tok_Identifier is used in the call to - -- Accumulate_Token_Checksum. - -- - versions 5.04 to 6.3: - -- for keywords, the token value were used in - -- the call to Accumulate_Token_Checksum. Type - -- Token_Type did not include Tok_Some. - -- - versions 5.03: - -- for keywords, the token value were used in - -- the call to Accumulate_Token_Checksum. Type - -- Token_Type did not include Tok_Interface, - -- Tok_Overriding, Tok_Synchronized and - -- Tok_Some. - -- - versions 5.02 and before: - -- no call to Accumulate_Token_Checksum. - -- - -- To signal to the scanner that - -- Accumulate_Token_Checksum needs to be called and - -- what versions to call, 3 Booleans flags are used - -- in Opt: - -- - Checksum_Accumulate_Token_Checksum: True for - -- versions 5.03 and later, False for 5.02 and - -- before. - -- - Checksum_GNAT_6_3: False for versions 6.4 - -- and later, True for versions 6.3 and before. - -- - Checksum_GNAT_5_03: False for versions 5.04 - -- and later, True for versions 5.03 and before. + -- For Ada, set proper checksum computation mode + if Lang_Index.Name = Name_Ada then declare Vers : constant String := Get_Name_String (Element.Value.Value); pragma Assert (Vers'First = 1); begin + -- Version 6.3 or earlier + if Vers'Length >= 8 and then Vers (1 .. 5) = "GNAT " and then Vers (7) = '.' @@ -2453,17 +2426,21 @@ package body Prj.Nmsc is then Checksum_GNAT_6_3 := True; + -- Version 5.03 or earlier + if Vers (6) < '5' or else (Vers (6) = '5' and then Vers (Vers'Last) < '4') then Checksum_GNAT_5_03 := True; + -- Version 5.02 or earlier + if Vers (6) /= '5' or else Vers (Vers'Last) < '3' then Checksum_Accumulate_Token_Checksum := - False; + False; end if; end if; end if; -- 2.7.4