* [Ada] Accept calls to abstract subprograms in class-wide pre/post-conditions
@ 2022-05-16 8:43 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-16 8:43 UTC (permalink / raw)
To: gcc-patches; +Cc: Javier Miranda
[-- Attachment #1: Type: text/plain, Size: 670 bytes --]
Fix a regression in the support for Ada 2022's treatment of calls to
abstract subprograms in pre/post-conditions (thanks to Javier Miranda
for producing this patch).
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_disp.adb (Check_Dispatching_Context): When checking to see
whether an expression occurs in a class-wide pre/post-condition,
also check for the possibility that it occurs in a class-wide
preconditions subprogram that was introduced as part of
expansion. Without this fix, some legal calls occuring in
class-wide preconditions may be incorrectly flagged as violating
the "a call to an abstract subprogram must be dispatching" rule.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1519 bytes --]
diff --git a/gcc/ada/sem_disp.adb b/gcc/ada/sem_disp.adb
--- a/gcc/ada/sem_disp.adb
+++ b/gcc/ada/sem_disp.adb
@@ -751,14 +751,22 @@ package body Sem_Disp is
elsif Is_Subprogram (Scop)
and then not Is_Tag_Indeterminate (N)
- and then In_Pre_Post_Condition (Call, Class_Wide_Only => True)
+ and then
+ -- The context is an internally built helper or an indirect
+ -- call wrapper that handles class-wide preconditions
+ (Present (Class_Preconditions_Subprogram (Scop))
- -- The tagged type associated with the called subprogram must be
- -- the same as that of the subprogram with a class-wide aspect.
+ -- ... or the context is a class-wide pre/postcondition.
+ or else
+ (In_Pre_Post_Condition (Call, Class_Wide_Only => True)
- and then Is_Dispatching_Operation (Scop)
- and then
- Find_Dispatching_Type (Subp) = Find_Dispatching_Type (Scop)
+ -- The tagged type associated with the called
+ -- subprogram must be the same as that of the
+ -- subprogram with a class-wide aspect.
+
+ and then Is_Dispatching_Operation (Scop)
+ and then Find_Dispatching_Type (Subp)
+ = Find_Dispatching_Type (Scop)))
then
null;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-16 8:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-16 8:43 [Ada] Accept 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).