public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-523] [Ada] Implement calls to abstract subprograms in class-wide pre/post-conditions
@ 2022-05-17 8:27 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-17 8:27 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:a08f366ae875ae70fba5014c94956cdbf7bf91db
commit r13-523-ga08f366ae875ae70fba5014c94956cdbf7bf91db
Author: Javier Miranda <miranda@adacore.com>
Date: Tue Mar 15 13:20:24 2022 -0700
[Ada] Implement calls to abstract subprograms in class-wide pre/post-conditions
In some special cases involving class-wide pre/post conditions, Ada
allows a non-dispatching call to an abstract function (which is usually
illegal). Fix a bug in the implementation of Ada's rules about the
run-time behavior of such a call. Thanks to Javier Miranda for producing
this patch.
gcc/ada/
* contracts.adb (Build_Call_Helper_Body): Improve handling of
the case of a (legal) non-dispatching call to an abstract
subprogram.
Diff:
---
gcc/ada/contracts.adb | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/gcc/ada/contracts.adb b/gcc/ada/contracts.adb
index 7ce3cfac91d..9463642556f 100644
--- a/gcc/ada/contracts.adb
+++ b/gcc/ada/contracts.adb
@@ -3899,7 +3899,16 @@ package body Contracts is
Set_Corresponding_Body (Helper_Decl, Body_Id);
Set_Must_Override (Body_Spec, False);
- if Present (Class_Preconditions (Subp_Id)) then
+ if Present (Class_Preconditions (Subp_Id))
+ -- Evaluate the expression if we are building a dynamic helper
+ -- or we are building a static helper for a non-abstract tagged
+ -- type; for abstract tagged types the helper just returns True
+ -- since it is called by the indirect call wrapper (ICW).
+ and then
+ (Is_Dynamic
+ or else
+ not Is_Abstract_Type (Find_Dispatching_Type (Subp_Id)))
+ then
Return_Expr :=
Copy_And_Update_References (Class_Preconditions (Subp_Id));
@@ -3910,7 +3919,8 @@ package body Contracts is
-- enabled.
else
- pragma Assert (Present (Ignored_Class_Preconditions (Subp_Id)));
+ pragma Assert (Present (Ignored_Class_Preconditions (Subp_Id))
+ or else Is_Abstract_Type (Find_Dispatching_Type (Subp_Id)));
Return_Expr := New_Occurrence_Of (Standard_True, Loc);
end if;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-17 8:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-17 8:27 [gcc r13-523] [Ada] Implement calls to abstract subprograms in class-wide pre/post-conditions Pierre-Marie de Rodat
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).