[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Mon, 29 Aug 2011 10:29:09 +0000 (12:29 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 29 Aug 2011 10:29:09 +0000 (12:29 +0200)
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

gcc/ada/ChangeLog
gcc/ada/gnat_ugn.texi
gcc/ada/par-ch2.adb
gcc/ada/par-ch3.adb
gcc/ada/par-ch4.adb
gcc/ada/scans.adb
gcc/ada/scans.ads
gcc/ada/scn.adb
gcc/ada/sem_ch8.adb
gcc/ada/snames.adb-tmpl
gcc/ada/snames.ads-tmpl

index 6799af82e999e2cdf64c3783399848e1de114a1a..00a24d264587f0719889a157fb912fd39472d75a 100644 (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
index 9fb068db6f118facb7166b739ab10f7023c803fd..cc30638fff329bbc7f0059dfbecc35d930268d18 100644 (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.}
index 4892c8cc80746d83ebd3be619dfde25632d993d5..67d52f6790738f36ee57a8ea376876a8f70adbba 100644 (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;
index 0d62eb8b0fa6ee934d5c6a09bc1662a074087725..642de80755fadc5efeb9365697e739dff675cce9 100644 (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;
 
index cbe68cfddaa150e399333ecfe4a0a92f6d8b4e13..f2758ae125b266910640d85665ddb7e2b94174cb 100644 (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;
index 7f6b808a56529d62f823792d01d6762d4585a41c..0c51891f369d0e08478774c82bca60a88a527451 100644 (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;
 
index 137f616ccc24d0b5f60e0d91ee9fb42bff71990d..ca2a5bb904ebcff8fb3657a14025e96307c7a846 100644 (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 --
index 2862a0afa0859bfeba87e3f4f308665bee17eefb..ed6b1a87bebf9836b163fa232ecb3ccaf9891120 100644 (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;
index 0b9ab13b4bdb79b93248ccb3f0af8bef2ded61c6..6340b2a0229d5a474dcca97aa6ec4f6a2ed62655 100644 (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;
index d6c385183b4ed8ea1199ce29e3815b94d1b42536..197cb350fb48ac17718988e9b3e9d24f1c5538ac 100644 (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;
 
    ----------------------------
index 53b4365277fc493195a8f4243858cc61c88f72c2..18cf0f82f2e62aef2eeab0607c7e70202d6542c1 100644 (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 + $;