[Ada] Support 'Reduce under -gnatX
authorArnaud Charlet <charlet@adacore.com>
Mon, 3 Feb 2020 10:22:57 +0000 (05:22 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 5 Jun 2020 12:17:55 +0000 (08:17 -0400)
2020-06-05  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

* scng.adb (Scan): Fix typo to take into account all future
versions of Ada.
* sem_attr.ads (Attribute_Impl_Def): Add Attribute_Reduce for
now.
* sem_attr.adb (Analyze_Attribute): Only allow 'Reduce under
-gnatX.
* snames.ads-tmpl (Name_Reduce): Update comment.

gcc/ada/scng.adb
gcc/ada/sem_attr.adb
gcc/ada/sem_attr.ads
gcc/ada/snames.ads-tmpl

index e3da051..db32694 100644 (file)
@@ -1701,7 +1701,7 @@ package body Scng is
             if Source (Scan_Ptr + 1) = '"' then
                goto Scan_Wide_Character;
 
-            elsif Ada_Version = Ada_2020 then
+            elsif Ada_Version >= Ada_2020 then
                Scan_Ptr := Scan_Ptr + 1;
                Token := Tok_Left_Bracket;
                return;
index 5e6ad38..5fef9c2 100644 (file)
@@ -5572,6 +5572,11 @@ package body Sem_Attr is
       when Attribute_Reduce =>
          Check_E2;
 
+         if not Extensions_Allowed then
+            Error_Attr
+              ("% attribute only supported under -gnatX", P);
+         end if;
+
          declare
             Stream : constant Node_Id := Prefix (N);
             Typ    : Entity_Id;
index 16b902e..b118a97 100644 (file)
@@ -397,6 +397,13 @@ package Sem_Attr is
       --  as Range applied to the array itself. The result is of type universal
       --  integer.
 
+      ------------
+      -- Reduce --
+      ------------
+
+      Attribute_Reduce => True,
+      --  See AI12-0262-1
+
       ---------
       -- Ref --
       ---------
index 9534bff..968f80e 100644 (file)
@@ -976,7 +976,7 @@ package Snames is
    Name_Priority                       : constant Name_Id := N + $; -- Ada 05
    Name_Range                          : constant Name_Id := N + $;
    Name_Range_Length                   : constant Name_Id := N + $; -- GNAT
-   Name_Reduce                         : constant Name_Id := N + $;
+   Name_Reduce                         : constant Name_Id := N + $; -- GNAT
    Name_Ref                            : constant Name_Id := N + $; -- GNAT
    Name_Restriction_Set                : constant Name_Id := N + $; -- GNAT
    Name_Result                         : constant Name_Id := N + $; -- GNAT