public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-1764] ada: Fix internal error on imported function with post-condition
@ 2023-06-13 7:34 Marc Poulhi?s
0 siblings, 0 replies; only message in thread
From: Marc Poulhi?s @ 2023-06-13 7:34 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:54dd56f5c82ff26e46e8b24214d0988da8e3ad8a
commit r14-1764-g54dd56f5c82ff26e46e8b24214d0988da8e3ad8a
Author: Eric Botcazou <ebotcazou@adacore.com>
Date: Mon Apr 24 17:11:01 2023 +0200
ada: Fix internal error on imported function with post-condition
The problem, which is also present for an expression function, is that the
function is invoked in the initializing expression of a variable declared
in the same declarative part as the function, which causes the freezing of
its artificial body before the post-condition is analyzed on its spec.
gcc/ada/
* contracts.adb (Analyze_Entry_Or_Subprogram_Body_Contract): For a
subprogram body that has no contracts and does not come from source,
make sure that contracts on its corresponding spec are analyzed, if
any, before expanding them.
Diff:
---
gcc/ada/contracts.adb | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/gcc/ada/contracts.adb b/gcc/ada/contracts.adb
index 7625abf9554..ae9e07ffc16 100644
--- a/gcc/ada/contracts.adb
+++ b/gcc/ada/contracts.adb
@@ -598,6 +598,22 @@ package body Contracts is
else
Set_Analyzed (Items);
end if;
+
+ -- When this is a subprogram body not coming from source, for example an
+ -- expression function, it does not cause freezing of previous contracts
+ -- (see Analyze_Subprogram_Body_Helper), in particular not of those on
+ -- its spec if it exists. In this case make sure they have been properly
+ -- analyzed before being expanded below, as we may be invoked during the
+ -- freezing of the subprogram in the middle of its enclosing declarative
+ -- part because the declarative part contains e.g. the declaration of a
+ -- variable initialized by means of a call to the subprogram.
+
+ elsif Nkind (Body_Decl) = N_Subprogram_Body
+ and then not Comes_From_Source (Original_Node (Body_Decl))
+ and then Present (Corresponding_Spec (Body_Decl))
+ and then Present (Contract (Corresponding_Spec (Body_Decl)))
+ then
+ Analyze_Entry_Or_Subprogram_Contract (Corresponding_Spec (Body_Decl));
end if;
-- Due to the timing of contract analysis, delayed pragmas may be
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-06-13 7:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-13 7:34 [gcc r14-1764] ada: Fix internal error on imported function with post-condition Marc Poulhi?s
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).