aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonan Desplanques <desplanques@adacore.com>2023-12-19 17:13:20 +0100
committerMarc Poulhiès <poulhies@adacore.com>2024-05-06 11:11:27 +0200
commit0b591735952e006c00be23e5b64631809bd93d10 (patch)
tree15afb76630c00cc115bf79798f13c602e5c5422c
parente5a71415c32db32bf2c20a597f6191990ed1a0be (diff)
downloadgcc-0b591735952e006c00be23e5b64631809bd93d10.zip
gcc-0b591735952e006c00be23e5b64631809bd93d10.tar.gz
gcc-0b591735952e006c00be23e5b64631809bd93d10.tar.bz2
ada: Fix spurious warning emission
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.
-rw-r--r--gcc/ada/exp_imgv.adb3
-rw-r--r--gcc/ada/gen_il-fields.ads1
-rw-r--r--gcc/ada/gen_il-gen-gen_nodes.adb1
-rw-r--r--gcc/ada/sem_aggr.adb13
-rw-r--r--gcc/ada/sinfo.ads5
5 files changed, 13 insertions, 10 deletions
diff --git a/gcc/ada/exp_imgv.adb b/gcc/ada/exp_imgv.adb
index ec0126a..6dc59f2 100644
--- a/gcc/ada/exp_imgv.adb
+++ b/gcc/ada/exp_imgv.adb
@@ -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
diff --git a/gcc/ada/gen_il-fields.ads b/gcc/ada/gen_il-fields.ads
index cdd9b95..7cf6a38 100644
--- a/gcc/ada/gen_il-fields.ads
+++ b/gcc/ada/gen_il-fields.ads
@@ -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,
diff --git a/gcc/ada/gen_il-gen-gen_nodes.adb b/gcc/ada/gen_il-gen-gen_nodes.adb
index 72280025..d7cc39b 100644
--- a/gcc/ada/gen_il-gen-gen_nodes.adb
+++ b/gcc/ada/gen_il-gen-gen_nodes.adb
@@ -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),
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index e381af1..508c86b 100644
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -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" &
diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads
index 803f5df..4e97715 100644
--- a/gcc/ada/sinfo.ads
+++ b/gcc/ada/sinfo.ads
@@ -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