opt.ads (Old_Checksums, [...]): New Boolean flags, defaulted to False.
2010-10-26 Vincent Celier <celier@adacore.com> * opt.ads (Old_Checksums, Old_Old_Checksums): New Boolean flags, defaulted to False. * prj-nmsc.adb (Process_Project_Level_Array_Attributes): When processing attribute Toolchain_Version ("Ada"), set Opt.Old_Checksums and Opt.Old_Old_Checksums depending on the GNAT version. * scng.adb (Accumulate_Token_Checksum_Old): New procedure. (Accumulate_Token_Checksum_Old_Old): New procedure. (Scan): For keywords, when Opt.Old_Checksums is True, call one of the alternative procedures Accumulate_Token_Checksum_Old or Accumulate_Token_Checksum_Old_Old, instead of Accumulate_Token_Checksum. From-SVN: r165959
This commit is contained in:
parent
39ab2e8fc9
commit
1ce9dff334
|
@ -1,3 +1,16 @@
|
|||
2010-10-26 Vincent Celier <celier@adacore.com>
|
||||
|
||||
* opt.ads (Old_Checksums, Old_Old_Checksums): New Boolean flags,
|
||||
defaulted to False.
|
||||
* prj-nmsc.adb (Process_Project_Level_Array_Attributes): When
|
||||
processing attribute Toolchain_Version ("Ada"), set Opt.Old_Checksums
|
||||
and Opt.Old_Old_Checksums depending on the GNAT version.
|
||||
* scng.adb (Accumulate_Token_Checksum_Old): New procedure.
|
||||
(Accumulate_Token_Checksum_Old_Old): New procedure.
|
||||
(Scan): For keywords, when Opt.Old_Checksums is True, call one of the
|
||||
alternative procedures Accumulate_Token_Checksum_Old or
|
||||
Accumulate_Token_Checksum_Old_Old, instead of Accumulate_Token_Checksum.
|
||||
|
||||
2010-10-26 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
|
||||
|
||||
* gcc-interface/utils2.c (build_compound_expr): New function.
|
||||
|
|
|
@ -933,6 +933,13 @@ 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;
|
||||
-- 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.
|
||||
|
||||
One_Compilation_Per_Obj_Dir : Boolean := False;
|
||||
-- GNATMAKE, GPRBUILD
|
||||
-- Set to True with switch --single-compile-per-obj-dir. When True, there
|
||||
|
|
|
@ -2399,6 +2399,53 @@ 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
|
||||
declare
|
||||
Vers : constant String :=
|
||||
Get_Name_String (Element.Value.Value);
|
||||
pragma Assert (Vers'First = 1);
|
||||
|
||||
begin
|
||||
if Vers'Length >= 8
|
||||
and then Vers (1 .. 5) = "GNAT "
|
||||
and then Vers (7) = '.'
|
||||
and then
|
||||
(Vers (6) < '6'
|
||||
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.
|
||||
|
||||
if Vers (6) < '5'
|
||||
or else (Vers (6) = '5'
|
||||
and then Vers (Vers'Last) < '4')
|
||||
then
|
||||
Opt.Old_Old_Checksums := True;
|
||||
end if;
|
||||
end if;
|
||||
end;
|
||||
end if;
|
||||
|
||||
when Name_Runtime_Library_Dir =>
|
||||
|
||||
-- Attribute Runtime_Library_Dir (<language>)
|
||||
|
|
152
gcc/ada/scng.adb
152
gcc/ada/scng.adb
|
@ -64,6 +64,21 @@ package body Scng is
|
|||
|
||||
procedure Accumulate_Token_Checksum;
|
||||
pragma Inline (Accumulate_Token_Checksum);
|
||||
-- Called after each numeric literal and identifier/keyword. For keywords,
|
||||
-- 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
|
||||
-- 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.
|
||||
|
||||
procedure Accumulate_Checksum (C : Character);
|
||||
pragma Inline (Accumulate_Checksum);
|
||||
|
@ -120,6 +135,127 @@ package body Scng is
|
|||
Character'Val (Token_Type'Pos (Token)));
|
||||
end Accumulate_Token_Checksum;
|
||||
|
||||
-----------------------------------
|
||||
-- Accumulate_Token_Checksum_Old --
|
||||
-----------------------------------
|
||||
|
||||
procedure Accumulate_Token_Checksum_Old is
|
||||
begin
|
||||
-- Individual values of Token_Type are used, instead of subranges, so
|
||||
-- that additions or suppressions of enumerated values in type
|
||||
-- Token_Type are detected by the compiler.
|
||||
|
||||
case Token is
|
||||
when Tok_Integer_Literal | Tok_Real_Literal | Tok_String_Literal |
|
||||
Tok_Char_Literal | Tok_Operator_Symbol | Tok_Identifier |
|
||||
Tok_Double_Asterisk | Tok_Ampersand | Tok_Minus | Tok_Plus |
|
||||
Tok_Asterisk | Tok_Mod | Tok_Rem | Tok_Slash | Tok_New |
|
||||
Tok_Abs | Tok_Others | Tok_Null | Tok_Dot | Tok_Apostrophe |
|
||||
Tok_Left_Paren | Tok_Delta | Tok_Digits | Tok_Range |
|
||||
Tok_Right_Paren | Tok_Comma | Tok_And | Tok_Or | Tok_Xor |
|
||||
Tok_Less | Tok_Equal | Tok_Greater | Tok_Not_Equal |
|
||||
Tok_Greater_Equal | Tok_Less_Equal | Tok_In | Tok_Not |
|
||||
Tok_Box | Tok_Colon_Equal | Tok_Colon | Tok_Greater_Greater |
|
||||
Tok_Abstract | Tok_Access | Tok_Aliased | Tok_All | Tok_Array |
|
||||
Tok_At | Tok_Body | Tok_Constant | Tok_Do | Tok_Is |
|
||||
Tok_Interface | Tok_Limited | Tok_Of | Tok_Out | Tok_Record |
|
||||
Tok_Renames | Tok_Reverse =>
|
||||
|
||||
System.CRC32.Update
|
||||
(System.CRC32.CRC32 (Checksum),
|
||||
Character'Val (Token_Type'Pos (Token)));
|
||||
|
||||
when Tok_Some =>
|
||||
|
||||
System.CRC32.Update
|
||||
(System.CRC32.CRC32 (Checksum),
|
||||
Character'Val (Token_Type'Pos (Tok_Identifier)));
|
||||
|
||||
when Tok_Tagged | Tok_Then | Tok_Less_Less | Tok_Abort | Tok_Accept |
|
||||
Tok_Case | Tok_Delay | Tok_Else | Tok_Elsif | Tok_End |
|
||||
Tok_Exception | Tok_Exit | Tok_Goto | Tok_If | Tok_Pragma |
|
||||
Tok_Raise | Tok_Requeue | Tok_Return | Tok_Select |
|
||||
Tok_Terminate | Tok_Until | Tok_When | Tok_Begin | Tok_Declare |
|
||||
Tok_For | Tok_Loop | Tok_While | Tok_Entry | Tok_Protected |
|
||||
Tok_Task | Tok_Type | Tok_Subtype | Tok_Overriding |
|
||||
Tok_Synchronized | Tok_Use | Tok_Function | Tok_Generic |
|
||||
Tok_Package | Tok_Procedure | Tok_Private | Tok_With |
|
||||
Tok_Separate | Tok_EOF | Tok_Semicolon | Tok_Arrow |
|
||||
Tok_Vertical_Bar | Tok_Dot_Dot | Tok_Project | Tok_Extends |
|
||||
Tok_External | Tok_External_As_List | Tok_Comment |
|
||||
Tok_End_Of_Line | Tok_Special | No_Token =>
|
||||
|
||||
System.CRC32.Update
|
||||
(System.CRC32.CRC32 (Checksum),
|
||||
Character'Val (Token_Type'Pos (Token_Type'Pred (Token))));
|
||||
end case;
|
||||
end Accumulate_Token_Checksum_Old;
|
||||
|
||||
---------------------------------------
|
||||
-- Accumulate_Token_Checksum_Old_Old --
|
||||
---------------------------------------
|
||||
|
||||
procedure Accumulate_Token_Checksum_Old_Old is
|
||||
begin
|
||||
-- Individual values of Token_Type are used, instead of subranges, so
|
||||
-- that additions or suppressions of enumerated values in type
|
||||
-- Token_Type are detected by the compiler.
|
||||
|
||||
case Token is
|
||||
when Tok_Integer_Literal | Tok_Real_Literal | Tok_String_Literal |
|
||||
Tok_Char_Literal | Tok_Operator_Symbol | Tok_Identifier |
|
||||
Tok_Double_Asterisk | Tok_Ampersand | Tok_Minus | Tok_Plus |
|
||||
Tok_Asterisk | Tok_Mod | Tok_Rem | Tok_Slash | Tok_New |
|
||||
Tok_Abs | Tok_Others | Tok_Null | Tok_Dot | Tok_Apostrophe |
|
||||
Tok_Left_Paren | Tok_Delta | Tok_Digits | Tok_Range |
|
||||
Tok_Right_Paren | Tok_Comma | Tok_And | Tok_Or | Tok_Xor |
|
||||
Tok_Less | Tok_Equal | Tok_Greater | Tok_Not_Equal |
|
||||
Tok_Greater_Equal | Tok_Less_Equal | Tok_In | Tok_Not |
|
||||
Tok_Box | Tok_Colon_Equal | Tok_Colon | Tok_Greater_Greater |
|
||||
Tok_Abstract | Tok_Access | Tok_Aliased | Tok_All | Tok_Array |
|
||||
Tok_At | Tok_Body | Tok_Constant | Tok_Do | Tok_Is =>
|
||||
|
||||
System.CRC32.Update
|
||||
(System.CRC32.CRC32 (Checksum),
|
||||
Character'Val (Token_Type'Pos (Token)));
|
||||
|
||||
when Tok_Interface | Tok_Some | Tok_Overriding | Tok_Synchronized =>
|
||||
System.CRC32.Update
|
||||
(System.CRC32.CRC32 (Checksum),
|
||||
Character'Val (Token_Type'Pos (Tok_Identifier)));
|
||||
|
||||
when Tok_Limited | Tok_Of | Tok_Out | Tok_Record |
|
||||
Tok_Renames | Tok_Reverse =>
|
||||
|
||||
System.CRC32.Update
|
||||
(System.CRC32.CRC32 (Checksum),
|
||||
Character'Val (Token_Type'Pos (Token) - 1));
|
||||
|
||||
when Tok_Tagged | Tok_Then | Tok_Less_Less | Tok_Abort | Tok_Accept |
|
||||
Tok_Case | Tok_Delay | Tok_Else | Tok_Elsif | Tok_End |
|
||||
Tok_Exception | Tok_Exit | Tok_Goto | Tok_If | Tok_Pragma |
|
||||
Tok_Raise | Tok_Requeue | Tok_Return | Tok_Select |
|
||||
Tok_Terminate | Tok_Until | Tok_When | Tok_Begin | Tok_Declare |
|
||||
Tok_For | Tok_Loop | Tok_While | Tok_Entry | Tok_Protected |
|
||||
Tok_Task | Tok_Type | Tok_Subtype =>
|
||||
|
||||
System.CRC32.Update
|
||||
(System.CRC32.CRC32 (Checksum),
|
||||
Character'Val (Token_Type'Pos (Token) - 2));
|
||||
|
||||
when Tok_Use | Tok_Function | Tok_Generic |
|
||||
Tok_Package | Tok_Procedure | Tok_Private | Tok_With |
|
||||
Tok_Separate | Tok_EOF | Tok_Semicolon | Tok_Arrow |
|
||||
Tok_Vertical_Bar | Tok_Dot_Dot | Tok_Project | Tok_Extends |
|
||||
Tok_External | Tok_External_As_List | Tok_Comment |
|
||||
Tok_End_Of_Line | Tok_Special | No_Token =>
|
||||
|
||||
System.CRC32.Update
|
||||
(System.CRC32.CRC32 (Checksum),
|
||||
Character'Val (Token_Type'Pos (Token) - 4));
|
||||
end case;
|
||||
end Accumulate_Token_Checksum_Old_Old;
|
||||
|
||||
----------------------------
|
||||
-- Determine_Token_Casing --
|
||||
----------------------------
|
||||
|
@ -2413,12 +2549,23 @@ package body Scng is
|
|||
-- checksum is independent of the Ada version.
|
||||
|
||||
Token := Tok_Identifier;
|
||||
Accumulate_Token_Checksum;
|
||||
|
||||
-- Here is where we check if it was a keyword
|
||||
|
||||
if Is_Keyword_Name (Token_Name) then
|
||||
Token := Token_Type'Val (Get_Name_Table_Byte (Token_Name));
|
||||
if Opt.Old_Checksums 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;
|
||||
end if;
|
||||
|
||||
else
|
||||
Accumulate_Token_Checksum;
|
||||
Token := Token_Type'Val (Get_Name_Table_Byte (Token_Name));
|
||||
end if;
|
||||
|
||||
-- Keyword style checks
|
||||
|
||||
|
@ -2475,6 +2622,7 @@ package body Scng is
|
|||
-- It is an identifier after all
|
||||
|
||||
else
|
||||
Accumulate_Token_Checksum;
|
||||
Post_Scan;
|
||||
return;
|
||||
end if;
|
||||
|
|
Loading…
Reference in New Issue