From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Bob Duff <duff@adacore.com>
Subject: [COMMITTED] ada: Fix inherited postconditions in inlined subprograms
Date: Mon, 7 Nov 2022 09:41:08 +0100 [thread overview]
Message-ID: <20221107084108.151693-1-poulhies@adacore.com> (raw)
From: Bob Duff <duff@adacore.com>
Protect the building of postcondition pragmas in case the
postcondition is not present due to inlining.
gcc/ada/
* freeze.adb
(Build_Inherited_Condition_Pragmas): Do nothing if A_Post is
empty.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/freeze.adb | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index 888e2ecb7af..1fdc9d0d60e 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -1718,11 +1718,16 @@ package body Freeze is
end;
end if;
- New_Prag := New_Copy_Tree (A_Post);
- Rewrite
- (Expression (First (Pragma_Argument_Associations (New_Prag))),
- Class_Post);
- Append (New_Prag, Decls);
+ -- A_Post can be null here if the postcondition was inlined in the
+ -- called subprogram.
+
+ if Present (A_Post) then
+ New_Prag := New_Copy_Tree (A_Post);
+ Rewrite
+ (Expression (First (Pragma_Argument_Associations (New_Prag))),
+ Class_Post);
+ Append (New_Prag, Decls);
+ end if;
end if;
end Build_Inherited_Condition_Pragmas;
--
2.34.1
reply other threads:[~2022-11-07 8:41 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=20221107084108.151693-1-poulhies@adacore.com \
--to=poulhies@adacore.com \
--cc=duff@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).