From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Eric Botcazou <ebotcazou@adacore.com>
Subject: [COMMITTED] ada: Fix couple of issues with arrays indexed by enumeration type
Date: Fri, 4 Nov 2022 14:58:56 +0100 [thread overview]
Message-ID: <20221104135856.87236-1-poulhies@adacore.com> (raw)
From: Eric Botcazou <ebotcazou@adacore.com>
The first one is that Remove_Warning_Messages reinstates the Original_Node
of an N_Raise_Constraint_Error node in the tree for no clear reasons, and
the Original_Node may contain constructs whose expansion has been stopped
when the Constraint_Error was asserted, eventually causing gigi to stop.
The second one is that a path in Build_Array_Aggr_Code.Gen_Loop does not
copy the loop bounds, unlike other paths, thus triggering a sharing issue.
gcc/ada/
* errout.adb (Remove_Warning_Messages.Check_For_Warning): Do not
reinstate the Original_Node in the tree.
* exp_aggr.adb (Build_Array_Aggr_Code.Gen_Loop): Copy the bounds
on all paths.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/errout.adb | 16 +++-------------
gcc/ada/exp_aggr.adb | 4 ++--
2 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
index 85931552970..5730a543ee1 100644
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -3383,23 +3383,13 @@ package body Errout is
E := Errors.Table (E).Next;
end loop;
+ -- Warnings may have been posted on subexpressions of original tree
+
if Nkind (N) = N_Raise_Constraint_Error
and then Is_Rewrite_Substitution (N)
and then No (Condition (N))
then
- -- Warnings may have been posted on subexpressions of the original
- -- tree. We place the original node back on the tree to remove
- -- those warnings, whose sloc do not match those of any node in
- -- the current tree. Given that we are in unreachable code, this
- -- modification to the tree is harmless.
-
- if Is_List_Member (N) then
- Set_Condition (N, Original_Node (N));
- Check_All_Warnings (Condition (N));
- else
- Rewrite (N, Original_Node (N));
- Check_All_Warnings (N);
- end if;
+ Check_All_Warnings (Original_Node (N));
end if;
return OK;
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index 185705544e9..dde49d1e289 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -2058,7 +2058,7 @@ package body Exp_Aggr is
-- to do that if we already have the base type at hand.
if Etype (L) = Index_Base then
- L_L := L;
+ L_L := New_Copy_Tree (L);
else
L_L :=
Make_Qualified_Expression (Loc,
@@ -2067,7 +2067,7 @@ package body Exp_Aggr is
end if;
if Etype (H) = Index_Base then
- L_H := H;
+ L_H := New_Copy_Tree (H);
else
L_H :=
Make_Qualified_Expression (Loc,
--
2.34.1
reply other threads:[~2022-11-04 13:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221104135856.87236-1-poulhies@adacore.com \
--to=poulhies@adacore.com \
--cc=ebotcazou@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).