diff options
author | Ronan Desplanques <desplanques@adacore.com> | 2023-12-19 17:13:20 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-05-06 11:11:27 +0200 |
commit | 0b591735952e006c00be23e5b64631809bd93d10 (patch) | |
tree | 15afb76630c00cc115bf79798f13c602e5c5422c /gcc/ada/sem_aggr.adb | |
parent | e5a71415c32db32bf2c20a597f6191990ed1a0be (diff) | |
download | gcc-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.
Diffstat (limited to 'gcc/ada/sem_aggr.adb')
-rw-r--r-- | gcc/ada/sem_aggr.adb | 13 |
1 files changed, 12 insertions, 1 deletions
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" & |