OSDN Git Service

2010-10-26 Vincent Celier <celier@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 26 Oct 2010 13:15:05 +0000 (13:15 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 26 Oct 2010 13:15:05 +0000 (13:15 +0000)
* opt.ads (Checksum_Accumulate_Token_Checksum): New Boolean flag,
defaulted to True.
(Checksum_GNAT_6_3): New name of Old_Checksums
(Checksum_GNAT_5_03): New name of Old_Old_Checksums
* prj-nmsc.adb (Process_Project_Level_Array_Attributes): Adapt to new
names of Opt flags.
Set Checksum_Accumulate_Token_Checksum to False if GNAT version is 5.03
or before.
* scng.adb (Accumulate_Token_Checksum_GNAT_6_3): New name of procedure
Accumulate_Token_Checksum_Old.
(Accumulate_Token_Checksum_GNAT_5_03): New name of procedure
Accumulate_Token_Checksum_Old_Old.
(Nlit): Call Accumulate_Token_Checksum only if
Opt.Checksum_Accumulate_Token_Checksum is True.
(Scan): Ditto

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165961 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/opt.ads
gcc/ada/prj-nmsc.adb
gcc/ada/scng.adb

index b5ecd08..58e75aa 100644 (file)
@@ -1,3 +1,21 @@
+2010-10-26  Vincent Celier  <celier@adacore.com>
+
+       * opt.ads (Checksum_Accumulate_Token_Checksum): New Boolean flag,
+       defaulted to True.
+       (Checksum_GNAT_6_3): New name of Old_Checksums
+       (Checksum_GNAT_5_03): New name of Old_Old_Checksums
+       * prj-nmsc.adb (Process_Project_Level_Array_Attributes): Adapt to new
+       names of Opt flags.
+       Set Checksum_Accumulate_Token_Checksum to False if GNAT version is 5.03
+       or before.
+       * scng.adb (Accumulate_Token_Checksum_GNAT_6_3): New name of procedure
+       Accumulate_Token_Checksum_Old.
+       (Accumulate_Token_Checksum_GNAT_5_03): New name of procedure
+       Accumulate_Token_Checksum_Old_Old.
+       (Nlit): Call Accumulate_Token_Checksum only if
+       Opt.Checksum_Accumulate_Token_Checksum is True.
+       (Scan): Ditto
+
 2010-10-26  Robert Dewar  <dewar@adacore.com>
 
        * sem_ch13.adb (Build_Invariant_Procedure): New calling sequence.
index 9c577c7..1bc9729 100644 (file)
@@ -933,12 +933,25 @@ package Opt is
    --  GNATMAKE
    --  Set to True when an object directory is specified with option -D
 
-   Old_Checksums     : Boolean := False;
-   Old_Old_Checksums : Boolean := False;
+   Checksum_Accumulate_Token_Checksum : Boolean := True;
    --  GPRBUILD
-   --  Set to True when the old ways of computing checksums needs to be used.
-   --  For reserved words, the old ways were to use the token value, while the
-   --  new way is to use Tok_Identifier for reserved word too.
+   --  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
index e0df107..6786e92 100644 (file)
@@ -2399,23 +2399,44 @@ package body Prj.Nmsc is
                         Lang_Index.Config.Toolchain_Version :=
                           Element.Value.Value;
 
-                        --  We need a complete comment section discussing the
-                        --  need for three versions of the checksum algorithm
-                        --  and what is going on here??? Also Old and Old_Old
-                        --  are rather poor names I would say. How about
-
-                        --    Opt.Checksum_503
-                        --    Opt.Checksum_63
-
-                        --  If the Ada compiler is version 6.3 or before, then
-                        --  checksums need to be computed using the old way.
-
-                        --  Also, how about an abstraction for checking
-                        --  version numbers, something like ???
-
-                        --    if Version_Is_Before (5, 3) ....
-
                         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.
+
                            declare
                               Vers : constant String :=
                                        Get_Name_String (Element.Value.Value);
@@ -2430,17 +2451,20 @@ package body Prj.Nmsc is
                                     or else
                                       (Vers (6) = '6' and then Vers (8) < '4'))
                               then
-                                 Opt.Old_Checksums := True;
-
-                                 --  If the Ada compiler is version 5.03 or
-                                 --  before, then checksums need to be computed
-                                 --  using the other old way.
+                                 Checksum_GNAT_6_3 := True;
 
                                  if Vers (6) < '5'
                                    or else (Vers (6) = '5'
                                              and then Vers (Vers'Last) < '4')
                                  then
-                                    Opt.Old_Old_Checksums := True;
+                                    Checksum_GNAT_5_03 := True;
+
+                                    if Vers (6) /= '5'
+                                      or else Vers (Vers'Last) < '3'
+                                    then
+                                       Checksum_Accumulate_Token_Checksum :=
+                                       False;
+                                    end if;
                                  end if;
                               end if;
                            end;
index 1e1be01..f1386f8 100644 (file)
@@ -68,17 +68,18 @@ package body Scng is
    --  the token used is Tok_Identifier. This allows to detect additional
    --  spaces added in sources when using the builder switch -m.
 
-   procedure Accumulate_Token_Checksum_Old;
-   --  Used in place of Accumulate_Token_Checksum for previous releases, when
-   --  Tok_Some was not included in Token_Type and the actual Token_Type was
-   --  used for keywords. This procedure is never used in the compiler or
-   --  gnatmake.
-
-   procedure Accumulate_Token_Checksum_Old_Old;
-   --  Used in place of Accumulate_Token_Checksum for previous releases, when
+   procedure Accumulate_Token_Checksum_GNAT_6_3;
+   --  Used in place of Accumulate_Token_Checksum for GNAT versions 5.04 to
+   --  6.3, when Tok_Some was not included in Token_Type and the actual
+   --  Token_Type was used for keywords. This procedure is never used in the
+   --  compiler or gnatmake, only in gprbuild.
+
+   procedure Accumulate_Token_Checksum_GNAT_5_03;
+   --  Used in place of Accumulate_Token_Checksum for GNAT version 5.03, when
    --  Tok_Interface, Tok_Some, Tok_Synchronized and Tok_Overriding were not
    --  included in Token_Type and the actual Token_Type was used for keywords.
-   --  This procedure is never used in the compiler or gnatmake.
+   --  This procedure is never used in the compiler or gnatmake, only in
+   --  gprbuild.
 
    procedure Accumulate_Checksum (C : Character);
    pragma Inline (Accumulate_Checksum);
@@ -135,11 +136,11 @@ package body Scng is
          Character'Val (Token_Type'Pos (Token)));
    end Accumulate_Token_Checksum;
 
-   -----------------------------------
-   -- Accumulate_Token_Checksum_Old --
-   -----------------------------------
+   ----------------------------------------
+   -- Accumulate_Token_Checksum_GNAT_6_3 --
+   ----------------------------------------
 
-   procedure Accumulate_Token_Checksum_Old is
+   procedure Accumulate_Token_Checksum_GNAT_6_3 is
    begin
       --  Individual values of Token_Type are used, instead of subranges, so
       --  that additions or suppressions of enumerated values in type
@@ -189,13 +190,13 @@ package body Scng is
               (System.CRC32.CRC32 (Checksum),
                Character'Val (Token_Type'Pos (Token_Type'Pred (Token))));
       end case;
-   end Accumulate_Token_Checksum_Old;
+   end Accumulate_Token_Checksum_GNAT_6_3;
 
-   ---------------------------------------
-   -- Accumulate_Token_Checksum_Old_Old --
-   ---------------------------------------
+   -----------------------------------------
+   -- Accumulate_Token_Checksum_GNAT_5_03 --
+   -----------------------------------------
 
-   procedure Accumulate_Token_Checksum_Old_Old is
+   procedure Accumulate_Token_Checksum_GNAT_5_03 is
    begin
       --  Individual values of Token_Type are used, instead of subranges, so
       --  that additions or suppressions of enumerated values in type
@@ -254,7 +255,7 @@ package body Scng is
               (System.CRC32.CRC32 (Checksum),
                Character'Val (Token_Type'Pos (Token) - 4));
       end case;
-   end Accumulate_Token_Checksum_Old_Old;
+   end Accumulate_Token_Checksum_GNAT_5_03;
 
    ----------------------------
    -- Determine_Token_Casing --
@@ -891,7 +892,10 @@ package body Scng is
             end if;
          end if;
 
-         Accumulate_Token_Checksum;
+         if Checksum_Accumulate_Token_Checksum then
+            Accumulate_Token_Checksum;
+         end if;
+
          return;
       end Nlit;
 
@@ -2553,13 +2557,15 @@ package body Scng is
          --  Here is where we check if it was a keyword
 
          if Is_Keyword_Name (Token_Name) then
-            if Opt.Old_Checksums then
+            if Opt.Checksum_GNAT_6_3 then
                Token := Token_Type'Val (Get_Name_Table_Byte (Token_Name));
 
-               if Opt.Old_Old_Checksums then
-                  Accumulate_Token_Checksum_Old_Old;
-               else
-                  Accumulate_Token_Checksum_Old;
+               if Checksum_Accumulate_Token_Checksum then
+                  if Checksum_GNAT_5_03 then
+                     Accumulate_Token_Checksum_GNAT_5_03;
+                  else
+                     Accumulate_Token_Checksum_GNAT_6_3;
+                  end if;
                end if;
 
             else
@@ -2622,7 +2628,10 @@ package body Scng is
          --  It is an identifier after all
 
          else
-            Accumulate_Token_Checksum;
+            if Checksum_Accumulate_Token_Checksum then
+               Accumulate_Token_Checksum;
+            end if;
+
             Post_Scan;
             return;
          end if;