Commit ff4f0ed0 by Arnaud Charlet

[multiple changes]

2011-08-29  Robert Dewar  <dewar@adacore.com>

	* sem_ch8.adb: Minor reformatting.

2011-08-29  Bob Duff  <duff@adacore.com>

	* par-ch2.adb (P_Identifier): Warn that "some" is reserved in Ada 2012.
	* par-ch4.adb (P_Quantified_Expression): Remove unnecessary code for
	treating "some" as unreserved in earlier Ada versions. This is now
	handled in Snames.Is_Keyword_Name. Parse "for some" using Tok_Some,
	rather than Name_Some, since Tok_Some is now recognized as reserved.
	* scans.adb (Initialize_Ada_Keywords): Handle Tok_Some like any other
	reserved word.
	* scans.ads: Minor comment fixes.
	* snames.adb-tmpl (Is_Keyword_Name): Handle Ada 2012 reserved words as
	for other language versions.
	* scn.adb (Scan_Reserved_Identifier): Remove unnecessary code for
	treating "some" as unreserved in earlier Ada versions. This is now
	handled in Snames.Is_Keyword_Name.
	* par-ch3.adb (P_Defining_Identifier): Warn that "some" is reserved in
	Ada 2012.
	(P_Subtype_Mark_Resync): Remove unnecessary code for treating "some" as
	unreserved in earlier Ada versions. This is now handled in
	Snames.Is_Keyword_Name.
	* snames.ads-tmpl (Ada_2012_Reserved_Words): Handle Ada 2012 reserved
	words as for other language versions.
	* gnat_ugn.texi (-gnatwy): Fix documentation: this switch applies to
	Ada 2012, not just Ada 2005.

From-SVN: r178191
parent d941cee6
2011-08-29 Robert Dewar <dewar@adacore.com>
* sem_ch8.adb: Minor reformatting.
2011-08-29 Bob Duff <duff@adacore.com>
* par-ch2.adb (P_Identifier): Warn that "some" is reserved in Ada 2012.
* par-ch4.adb (P_Quantified_Expression): Remove unnecessary code for
treating "some" as unreserved in earlier Ada versions. This is now
handled in Snames.Is_Keyword_Name. Parse "for some" using Tok_Some,
rather than Name_Some, since Tok_Some is now recognized as reserved.
* scans.adb (Initialize_Ada_Keywords): Handle Tok_Some like any other
reserved word.
* scans.ads: Minor comment fixes.
* snames.adb-tmpl (Is_Keyword_Name): Handle Ada 2012 reserved words as
for other language versions.
* scn.adb (Scan_Reserved_Identifier): Remove unnecessary code for
treating "some" as unreserved in earlier Ada versions. This is now
handled in Snames.Is_Keyword_Name.
* par-ch3.adb (P_Defining_Identifier): Warn that "some" is reserved in
Ada 2012.
(P_Subtype_Mark_Resync): Remove unnecessary code for treating "some" as
unreserved in earlier Ada versions. This is now handled in
Snames.Is_Keyword_Name.
* snames.ads-tmpl (Ada_2012_Reserved_Words): Handle Ada 2012 reserved
words as for other language versions.
* gnat_ugn.texi (-gnatwy): Fix documentation: this switch applies to
Ada 2012, not just Ada 2005.
2011-08-29 Ed Schonberg <schonberg@adacore.com> 2011-08-29 Ed Schonberg <schonberg@adacore.com>
* sem_ch13.adb: Additional semantic checks for aspects involved in * sem_ch13.adb: Additional semantic checks for aspects involved in
......
...@@ -5780,12 +5780,14 @@ This switch disables warnings for exception usage when pragma Restrictions ...@@ -5780,12 +5780,14 @@ This switch disables warnings for exception usage when pragma Restrictions
(No_Exception_Propagation) is in effect. (No_Exception_Propagation) is in effect.
@item -gnatwy @item -gnatwy
@emph{Activate warnings for Ada 2005 compatibility issues.} @emph{Activate warnings for Ada compatibility issues.}
@cindex @option{-gnatwy} (@command{gcc}) @cindex @option{-gnatwy} (@command{gcc})
@cindex Ada 2005 compatibility issues warnings @cindex Ada compatibility issues warnings
For the most part Ada 2005 is upwards compatible with Ada 95, For the most part, newer versions of Ada are upwards compatible
but there are some exceptions (for example the fact that with older versions. For example, Ada 2005 programs will almost
@code{interface} is now a reserved word in Ada 2005). This always work when compiled as Ada 2012.
However there are some exceptions (for example the fact that
@code{some} is now a reserved word in Ada 2012). This
switch activates several warnings to help in identifying switch activates several warnings to help in identifying
and correcting such incompatibilities. The default is that and correcting such incompatibilities. The default is that
these warnings are generated. Note that at one point Ada 2005 these warnings are generated. Note that at one point Ada 2005
...@@ -5793,11 +5795,11 @@ was called Ada 0Y, hence the choice of character. ...@@ -5793,11 +5795,11 @@ was called Ada 0Y, hence the choice of character.
This warning can also be turned on using @option{-gnatwa}. This warning can also be turned on using @option{-gnatwa}.
@item -gnatwY @item -gnatwY
@emph{Disable warnings for Ada 2005 compatibility issues.} @emph{Disable warnings for Ada compatibility issues.}
@cindex @option{-gnatwY} (@command{gcc}) @cindex @option{-gnatwY} (@command{gcc})
@cindex Ada 2005 compatibility issues warnings @cindex Ada compatibility issues warnings
This switch suppresses several warnings intended to help in identifying This switch suppresses the warnings intended to help in identifying
incompatibilities between Ada 95 and Ada 2005. incompatibilities between Ada language versions.
@item -gnatwz @item -gnatwz
@emph{Activate warnings on unchecked conversions.} @emph{Activate warnings on unchecked conversions.}
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -76,6 +76,16 @@ package body Ch2 is ...@@ -76,6 +76,16 @@ package body Ch2 is
end if; end if;
end if; end if;
-- Similarly, warn about Ada 2012 reserved words
if Ada_Version in Ada_95 .. Ada_2005
and then Warn_On_Ada_2012_Compatibility
then
if Token_Name = Name_Some then
Error_Msg_N ("& is a reserved word in Ada 2012?", Token_Node);
end if;
end if;
Ident_Node := Token_Node; Ident_Node := Token_Node;
Scan; -- past Identifier Scan; -- past Identifier
return Ident_Node; return Ident_Node;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -229,6 +229,16 @@ package body Ch3 is ...@@ -229,6 +229,16 @@ package body Ch3 is
end if; end if;
end if; end if;
-- Similarly, warn about Ada 2012 reserved words
if Ada_Version in Ada_95 .. Ada_2005
and then Warn_On_Ada_2012_Compatibility
then
if Token_Name = Name_Some then
Error_Msg_N ("& is a reserved word in Ada 2012?", Token_Node);
end if;
end if;
-- If we have a reserved identifier, manufacture an identifier with -- If we have a reserved identifier, manufacture an identifier with
-- a corresponding name after posting an appropriate error message -- a corresponding name after posting an appropriate error message
...@@ -1125,16 +1135,6 @@ package body Ch3 is ...@@ -1125,16 +1135,6 @@ package body Ch3 is
Discard_Junk_Node (P_Array_Type_Definition); Discard_Junk_Node (P_Array_Type_Definition);
return Error; return Error;
-- If Some becomes a keyword, the following is needed to make it
-- acceptable in older versions of Ada.
elsif Token = Tok_Some
and then Ada_Version < Ada_2012
then
Scan_Reserved_Identifier (False);
Scan;
return Token_Node;
else else
Type_Node := P_Qualified_Simple_Name_Resync; Type_Node := P_Qualified_Simple_Name_Resync;
......
...@@ -1432,19 +1432,9 @@ package body Ch4 is ...@@ -1432,19 +1432,9 @@ package body Ch4 is
-- that doesn't belong to us! -- that doesn't belong to us!
if Token in Token_Class_Eterm then if Token in Token_Class_Eterm then
Error_Msg_AP
-- If Some becomes a keyword, the following is needed to make it ("expecting expression or component association");
-- acceptable in older versions of Ada. exit;
if Token = Tok_Some
and then Ada_Version < Ada_2012
then
Scan_Reserved_Identifier (False);
else
Error_Msg_AP
("expecting expression or component association");
exit;
end if;
end if; end if;
-- Deal with misused box -- Deal with misused box
...@@ -2564,13 +2554,7 @@ package body Ch4 is ...@@ -2564,13 +2554,7 @@ package body Ch4 is
if Token = Tok_All then if Token = Tok_All then
Set_All_Present (Node1); Set_All_Present (Node1);
-- We treat Some as a non-reserved keyword, so it appears to the scanner elsif Token /= Tok_Some then
-- as an identifier. If Some is made into a reserved word, the check
-- below is against Tok_Some.
elsif Token /= Tok_Identifier
or else Chars (Token_Node) /= Name_Some
then
Error_Msg_AP ("missing quantifier"); Error_Msg_AP ("missing quantifier");
raise Error_Resync; raise Error_Resync;
end if; end if;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -118,13 +118,6 @@ package body Scans is ...@@ -118,13 +118,6 @@ package body Scans is
Set_Reserved (Name_Reverse, Tok_Reverse); Set_Reserved (Name_Reverse, Tok_Reverse);
Set_Reserved (Name_Select, Tok_Select); Set_Reserved (Name_Select, Tok_Select);
Set_Reserved (Name_Separate, Tok_Separate); Set_Reserved (Name_Separate, Tok_Separate);
-- We choose to make Some into a non-reserved word, so it is handled
-- like a regular identifier in most contexts. Uncomment the following
-- line if a pedantic Ada2012 mode is required.
-- Set_Reserved (Name_Some, Tok_Some);
Set_Reserved (Name_Subtype, Tok_Subtype); Set_Reserved (Name_Subtype, Tok_Subtype);
Set_Reserved (Name_Tagged, Tok_Tagged); Set_Reserved (Name_Tagged, Tok_Tagged);
Set_Reserved (Name_Task, Tok_Task); Set_Reserved (Name_Task, Tok_Task);
...@@ -140,9 +133,13 @@ package body Scans is ...@@ -140,9 +133,13 @@ package body Scans is
-- Ada 2005 reserved words -- Ada 2005 reserved words
Set_Reserved (Name_Interface, Tok_Interface); Set_Reserved (Name_Interface, Tok_Interface);
Set_Reserved (Name_Overriding, Tok_Overriding); Set_Reserved (Name_Overriding, Tok_Overriding);
Set_Reserved (Name_Synchronized, Tok_Synchronized); Set_Reserved (Name_Synchronized, Tok_Synchronized);
-- Ada 2012 reserved words
Set_Reserved (Name_Some, Tok_Some);
end Initialize_Ada_Keywords; end Initialize_Ada_Keywords;
......
...@@ -47,7 +47,7 @@ package Scans is ...@@ -47,7 +47,7 @@ package Scans is
-- Note: Namet.Is_Keyword_Name depends on the fact that the first entry in -- Note: Namet.Is_Keyword_Name depends on the fact that the first entry in
-- this type declaration is *not* for a reserved word. For details on why -- this type declaration is *not* for a reserved word. For details on why
-- there is this requirement, see Scans.Initialize_Ada_Keywords. -- there is this requirement, see Initialize_Ada_Keywords below.
type Token_Type is ( type Token_Type is (
...@@ -341,7 +341,9 @@ package Scans is ...@@ -341,7 +341,9 @@ package Scans is
-- Flag array used to test for reserved word -- Flag array used to test for reserved word
procedure Initialize_Ada_Keywords; procedure Initialize_Ada_Keywords;
-- Set up Token_Type values in Names table entries for Ada reserved words -- Set up Token_Type values in Names table entries for Ada reserved
-- words. This ignores Ada_Version; Ada_Version is taken into account in
-- Snames.Is_Keyword_Name.
-------------------------- --------------------------
-- Scan State Variables -- -- Scan State Variables --
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -472,18 +472,9 @@ package body Scn is ...@@ -472,18 +472,9 @@ package body Scn is
Token_Name := Name_Find; Token_Name := Name_Find;
if not Used_As_Identifier (Token) or else Force_Msg then if not Used_As_Identifier (Token) or else Force_Msg then
Error_Msg_Name_1 := Token_Name;
-- If "some" is made into a reserved work in Ada2012, the following Error_Msg_SC ("reserved word* cannot be used as identifier!");
-- check will make it into a regular identifier in earlier versions Used_As_Identifier (Token) := True;
-- of the language.
if Token = Tok_Some and then Ada_Version < Ada_2012 then
null;
else
Error_Msg_Name_1 := Token_Name;
Error_Msg_SC ("reserved word* cannot be used as identifier!");
Used_As_Identifier (Token) := True;
end if;
end if; end if;
Token := Tok_Identifier; Token := Tok_Identifier;
......
...@@ -2425,9 +2425,11 @@ package body Sem_Ch8 is ...@@ -2425,9 +2425,11 @@ package body Sem_Ch8 is
if Old_S /= Any_Id then if Old_S /= Any_Id then
if Is_Actual and then From_Default (N) then if Is_Actual and then From_Default (N) then
-- This is an implicit reference to the default actual -- This is an implicit reference to the default actual
Generate_Reference (Old_S, Nam, Typ => 'i', Force => True); Generate_Reference (Old_S, Nam, Typ => 'i', Force => True);
else else
Generate_Reference (Old_S, Nam); Generate_Reference (Old_S, Nam);
end if; end if;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -379,7 +379,9 @@ package body Snames is ...@@ -379,7 +379,9 @@ package body Snames is
and then (Ada_Version >= Ada_95 and then (Ada_Version >= Ada_95
or else N not in Ada_95_Reserved_Words) or else N not in Ada_95_Reserved_Words)
and then (Ada_Version >= Ada_2005 and then (Ada_Version >= Ada_2005
or else N not in Ada_2005_Reserved_Words); or else N not in Ada_2005_Reserved_Words)
and then (Ada_Version >= Ada_2012
or else N not in Ada_2012_Reserved_Words);
end Is_Keyword_Name; end Is_Keyword_Name;
---------------------------- ----------------------------
......
...@@ -953,12 +953,8 @@ package Snames is ...@@ -953,12 +953,8 @@ package Snames is
Name_All_Checks : constant Name_Id := N + $; Name_All_Checks : constant Name_Id := N + $;
Last_Check_Name : constant Name_Id := N + $; Last_Check_Name : constant Name_Id := N + $;
-- Names corresponding to reserved keywords, excluding those already -- Ada 83 reserved words, excluding those already declared in the attribute
-- declared in the attribute list (Access, Delta, Digits, Mod, Range). -- list (Access, Delta, Digits, Mod, Range).
-- Note: Name_Some is here even though for now we do not treat it as being
-- reserved. We treat it instead as an unreserved keyword. This may change
-- in the future, but in any case it belongs in the following list.
Name_Abort : constant Name_Id := N + $; Name_Abort : constant Name_Id := N + $;
Name_Abs : constant Name_Id := N + $; Name_Abs : constant Name_Id := N + $;
...@@ -1008,7 +1004,6 @@ package Snames is ...@@ -1008,7 +1004,6 @@ package Snames is
Name_Reverse : constant Name_Id := N + $; Name_Reverse : constant Name_Id := N + $;
Name_Select : constant Name_Id := N + $; Name_Select : constant Name_Id := N + $;
Name_Separate : constant Name_Id := N + $; Name_Separate : constant Name_Id := N + $;
Name_Some : constant Name_Id := N + $;
Name_Subtype : constant Name_Id := N + $; Name_Subtype : constant Name_Id := N + $;
Name_Task : constant Name_Id := N + $; Name_Task : constant Name_Id := N + $;
Name_Terminate : constant Name_Id := N + $; Name_Terminate : constant Name_Id := N + $;
...@@ -1053,7 +1048,7 @@ package Snames is ...@@ -1053,7 +1048,7 @@ package Snames is
Name_Free : constant Name_Id := N + $; Name_Free : constant Name_Id := N + $;
-- Reserved words used only in Ada 95 -- Ada 95 reserved words
First_95_Reserved_Word : constant Name_Id := N + $; First_95_Reserved_Word : constant Name_Id := N + $;
Name_Abstract : constant Name_Id := N + $; Name_Abstract : constant Name_Id := N + $;
...@@ -1227,7 +1222,7 @@ package Snames is ...@@ -1227,7 +1222,7 @@ package Snames is
Name_No_Element : constant Name_Id := N + $; Name_No_Element : constant Name_Id := N + $;
Name_Previous : constant Name_Id := N + $; Name_Previous : constant Name_Id := N + $;
-- Ada 05 reserved words -- Ada 2005 reserved words
First_2005_Reserved_Word : constant Name_Id := N + $; First_2005_Reserved_Word : constant Name_Id := N + $;
Name_Interface : constant Name_Id := N + $; Name_Interface : constant Name_Id := N + $;
...@@ -1238,6 +1233,15 @@ package Snames is ...@@ -1238,6 +1233,15 @@ package Snames is
subtype Ada_2005_Reserved_Words is subtype Ada_2005_Reserved_Words is
Name_Id range First_2005_Reserved_Word .. Last_2005_Reserved_Word; Name_Id range First_2005_Reserved_Word .. Last_2005_Reserved_Word;
-- Ada 2012 reserved words
First_2012_Reserved_Word : constant Name_Id := N + $;
Name_Some : constant Name_Id := N + $;
Last_2012_Reserved_Word : constant Name_Id := N + $;
subtype Ada_2012_Reserved_Words is
Name_Id range First_2012_Reserved_Word .. Last_2012_Reserved_Word;
-- Mark last defined name for consistency check in Snames body -- Mark last defined name for consistency check in Snames body
Last_Predefined_Name : constant Name_Id := N + $; Last_Predefined_Name : constant Name_Id := N + $;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment