]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix spurious warning emission
authorRonan Desplanques <desplanques@adacore.com>
Tue, 19 Dec 2023 16:13:20 +0000 (17:13 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 6 May 2024 09:11:27 +0000 (11:11 +0200)
This patch fixes a bug where GNAT would emit incorrect warnings
about obsolescent syntax for array aggregates with generics and
particular arrangements of Ada version pragmas.

This patch also removes a syntactic field that was introduced to
support the emission of this warning, but is no longer required.

gcc/ada/

* exp_imgv.adb (Append_Table_To): Remove reference to removed
field.
* gen_il-fields.ads: Remove Is_Enum_Array_Aggregate field.
* gen_il-gen-gen_nodes.adb: Likewise.
* sem_aggr.adb: Tweak warning emission condition.
* sinfo.ads: Remove documentation for Is_Enum_Array_Aggregate.

gcc/ada/exp_imgv.adb
gcc/ada/gen_il-fields.ads
gcc/ada/gen_il-gen-gen_nodes.adb
gcc/ada/sem_aggr.adb
gcc/ada/sinfo.ads

index ec0126a7da21977b5ea02894e4bcf378cccae7ea..6dc59f2c6f33c35edb5493ca7a6101b9bd4a179c 100644 (file)
@@ -159,8 +159,7 @@ package body Exp_Imgv is
                    Make_Component_Definition (Loc,
                      Aliased_Present    => False,
                      Subtype_Indication => New_Occurrence_Of (Ctyp, Loc))),
-             Expression          => Make_Aggregate (Loc, Expressions => V,
-                                      Is_Enum_Array_Aggregate => True)));
+             Expression          => Make_Aggregate (Loc, Expressions => V)));
       end Append_Table_To;
 
    --  Start of Build_Enumeration_Image_Tables
index cdd9b9577e2d0862f56ccca8f8b4e32075eb3a4b..7cf6a38faa303ba50cec68c92ef207509d855da9 100644 (file)
@@ -259,7 +259,6 @@ package Gen_IL.Fields is
       Is_Generic_Contract_Pragma,
       Is_Homogeneous_Aggregate,
       Is_Parenthesis_Aggregate,
-      Is_Enum_Array_Aggregate,
       Is_Ignored,
       Is_Ignored_Ghost_Pragma,
       Is_In_Discriminant_Check,
index 722800254987d6243843b64f162a647709b3f0e2..d7cc39bc048ac921793669ddc42e9eacbb59fd0c 100644 (file)
@@ -492,7 +492,6 @@ begin -- Gen_IL.Gen.Gen_Nodes
         Sy (Null_Record_Present, Flag),
         Sy (Is_Parenthesis_Aggregate, Flag),
         Sy (Is_Homogeneous_Aggregate, Flag),
-        Sy (Is_Enum_Array_Aggregate, Flag),
         Sm (Aggregate_Bounds_Or_Ancestor_Type, Node_Id),
         Sm (Entity_Or_Associated_Node, Node_Id), -- just Associated_Node
         Sm (Compile_Time_Known_Aggregate, Flag),
index e381af101c85b3e1bca3c9a987eae89a1e470f01..508c86bc5de7615ea2476b540011be1495dc1196 100644 (file)
@@ -2099,14 +2099,25 @@ package body Sem_Aggr is
 
       --  Disable the warning for GNAT Mode to allow for easier transition.
 
+      --  We don't warn about obsolescent usage of parentheses in generic
+      --  instances for two reasons:
+      --
+      --  1. An equivalent warning has been emitted in the corresponding
+      --     definition.
+      --  2. In cases where a generic definition specifies a version older than
+      --     Ada 2022 through a pragma and rightfully uses parentheses for
+      --     an array aggregate, an incorrect warning would be raised in
+      --     instances of that generic that are in Ada 2022 or later if we
+      --     didn't filter out the instance case.
+
       if Ada_Version_Explicit >= Ada_2022
         and then Warn_On_Obsolescent_Feature
         and then not GNAT_Mode
         and then not Is_Homogeneous_Aggregate (N)
-        and then not Is_Enum_Array_Aggregate (N)
         and then Is_Parenthesis_Aggregate (N)
         and then Nkind (Parent (N)) /= N_Qualified_Expression
         and then Comes_From_Source (N)
+        and then not In_Instance
       then
          Error_Msg_N
            ("?j?array aggregate using () is an" &
index 803f5dfc7598d7b49aba3924afd2c40307cbd62c..4e977152cd0f650ae168774aa56e4ea325db9ca4 100644 (file)
@@ -1715,10 +1715,6 @@ package Sinfo is
    --    nodes which emulate the barrier function of a protected entry body.
    --    The flag is used when checking for incorrect use of Current_Task.
 
-   --  Is_Enum_Array_Aggregate
-   --    A flag set on an aggregate created internally while building the
-   --    images tables for enumerations.
-
    --  Is_Expanded_Build_In_Place_Call
    --    This flag is set in an N_Function_Call node to indicate that the extra
    --    actuals to support a build-in-place style of call have been added to
@@ -4091,7 +4087,6 @@ package Sinfo is
       --  Compile_Time_Known_Aggregate
       --  Expansion_Delayed
       --  Has_Self_Reference
-      --  Is_Enum_Array_Aggregate
       --  Is_Homogeneous_Aggregate
       --  Is_Parenthesis_Aggregate
       --  plus fields for expression