[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
This commit is contained in:
Arnaud Charlet 2011-08-29 12:29:09 +02:00
parent d941cee6ff
commit ff4f0ed093
11 changed files with 101 additions and 78 deletions

View File

@ -1,3 +1,32 @@
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>
* sem_ch13.adb: Additional semantic checks for aspects involved in

View File

@ -5780,12 +5780,14 @@ This switch disables warnings for exception usage when pragma Restrictions
(No_Exception_Propagation) is in effect.
@item -gnatwy
@emph{Activate warnings for Ada 2005 compatibility issues.}
@emph{Activate warnings for Ada compatibility issues.}
@cindex @option{-gnatwy} (@command{gcc})
@cindex Ada 2005 compatibility issues warnings
For the most part Ada 2005 is upwards compatible with Ada 95,
but there are some exceptions (for example the fact that
@code{interface} is now a reserved word in Ada 2005). This
@cindex Ada compatibility issues warnings
For the most part, newer versions of Ada are upwards compatible
with older versions. For example, Ada 2005 programs will almost
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
and correcting such incompatibilities. The default is that
these warnings are generated. Note that at one point Ada 2005
@ -5793,11 +5795,11 @@ was called Ada 0Y, hence the choice of character.
This warning can also be turned on using @option{-gnatwa}.
@item -gnatwY
@emph{Disable warnings for Ada 2005 compatibility issues.}
@emph{Disable warnings for Ada compatibility issues.}
@cindex @option{-gnatwY} (@command{gcc})
@cindex Ada 2005 compatibility issues warnings
This switch suppresses several warnings intended to help in identifying
incompatibilities between Ada 95 and Ada 2005.
@cindex Ada compatibility issues warnings
This switch suppresses the warnings intended to help in identifying
incompatibilities between Ada language versions.
@item -gnatwz
@emph{Activate warnings on unchecked conversions.}

View File

@ -6,7 +6,7 @@
-- --
-- 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 --
-- terms of the GNU General Public License as published by the Free Soft- --
@ -76,6 +76,16 @@ package body Ch2 is
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;
Scan; -- past Identifier
return Ident_Node;

View File

@ -6,7 +6,7 @@
-- --
-- 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 --
-- terms of the GNU General Public License as published by the Free Soft- --
@ -229,6 +229,16 @@ package body Ch3 is
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
-- a corresponding name after posting an appropriate error message
@ -1125,16 +1135,6 @@ package body Ch3 is
Discard_Junk_Node (P_Array_Type_Definition);
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
Type_Node := P_Qualified_Simple_Name_Resync;

View File

@ -1432,19 +1432,9 @@ package body Ch4 is
-- that doesn't belong to us!
if Token in Token_Class_Eterm then
-- If Some becomes a keyword, the following is needed to make it
-- acceptable in older versions of Ada.
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;
Error_Msg_AP
("expecting expression or component association");
exit;
end if;
-- Deal with misused box
@ -2564,13 +2554,7 @@ package body Ch4 is
if Token = Tok_All then
Set_All_Present (Node1);
-- We treat Some as a non-reserved keyword, so it appears to the scanner
-- 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
elsif Token /= Tok_Some then
Error_Msg_AP ("missing quantifier");
raise Error_Resync;
end if;

View File

@ -6,7 +6,7 @@
-- --
-- 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 --
-- terms of the GNU General Public License as published by the Free Soft- --
@ -118,13 +118,6 @@ package body Scans is
Set_Reserved (Name_Reverse, Tok_Reverse);
Set_Reserved (Name_Select, Tok_Select);
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_Tagged, Tok_Tagged);
Set_Reserved (Name_Task, Tok_Task);
@ -140,9 +133,13 @@ package body Scans is
-- Ada 2005 reserved words
Set_Reserved (Name_Interface, Tok_Interface);
Set_Reserved (Name_Overriding, Tok_Overriding);
Set_Reserved (Name_Synchronized, Tok_Synchronized);
Set_Reserved (Name_Interface, Tok_Interface);
Set_Reserved (Name_Overriding, Tok_Overriding);
Set_Reserved (Name_Synchronized, Tok_Synchronized);
-- Ada 2012 reserved words
Set_Reserved (Name_Some, Tok_Some);
end Initialize_Ada_Keywords;

View File

@ -47,7 +47,7 @@ package Scans is
-- 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
-- there is this requirement, see Scans.Initialize_Ada_Keywords.
-- there is this requirement, see Initialize_Ada_Keywords below.
type Token_Type is (
@ -341,7 +341,9 @@ package Scans is
-- Flag array used to test for reserved word
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 --

View File

@ -6,7 +6,7 @@
-- --
-- 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 --
-- terms of the GNU General Public License as published by the Free Soft- --
@ -472,18 +472,9 @@ package body Scn is
Token_Name := Name_Find;
if not Used_As_Identifier (Token) or else Force_Msg then
-- If "some" is made into a reserved work in Ada2012, the following
-- check will make it into a regular identifier in earlier versions
-- 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;
Error_Msg_Name_1 := Token_Name;
Error_Msg_SC ("reserved word* cannot be used as identifier!");
Used_As_Identifier (Token) := True;
end if;
Token := Tok_Identifier;

View File

@ -2425,9 +2425,11 @@ package body Sem_Ch8 is
if Old_S /= Any_Id then
if Is_Actual and then From_Default (N) then
-- This is an implicit reference to the default actual
Generate_Reference (Old_S, Nam, Typ => 'i', Force => True);
else
Generate_Reference (Old_S, Nam);
end if;

View File

@ -6,7 +6,7 @@
-- --
-- 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 --
-- terms of the GNU General Public License as published by the Free Soft- --
@ -379,7 +379,9 @@ package body Snames is
and then (Ada_Version >= Ada_95
or else N not in Ada_95_Reserved_Words)
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;
----------------------------

View File

@ -953,12 +953,8 @@ package Snames is
Name_All_Checks : constant Name_Id := N + $;
Last_Check_Name : constant Name_Id := N + $;
-- Names corresponding to reserved keywords, excluding those already
-- declared in the attribute 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.
-- Ada 83 reserved words, excluding those already declared in the attribute
-- list (Access, Delta, Digits, Mod, Range).
Name_Abort : constant Name_Id := N + $;
Name_Abs : constant Name_Id := N + $;
@ -1008,7 +1004,6 @@ package Snames is
Name_Reverse : constant Name_Id := N + $;
Name_Select : constant Name_Id := N + $;
Name_Separate : constant Name_Id := N + $;
Name_Some : constant Name_Id := N + $;
Name_Subtype : constant Name_Id := N + $;
Name_Task : constant Name_Id := N + $;
Name_Terminate : constant Name_Id := N + $;
@ -1053,7 +1048,7 @@ package Snames is
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 + $;
Name_Abstract : constant Name_Id := N + $;
@ -1227,7 +1222,7 @@ package Snames is
Name_No_Element : 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 + $;
Name_Interface : constant Name_Id := N + $;
@ -1238,6 +1233,15 @@ package Snames is
subtype Ada_2005_Reserved_Words is
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
Last_Predefined_Name : constant Name_Id := N + $;