]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Add guard for detection of class-wide precondition subprograms
authorPiotr Trojanek <trojanek@adacore.com>
Tue, 11 Jul 2023 14:37:23 +0000 (16:37 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Fri, 28 Jul 2023 07:28:14 +0000 (09:28 +0200)
When skipping check on subprograms built for class-wide preconditions
we must deal with the current scope not being a subprogram, e.g. it
could be a declare-block.

gcc/ada/

* sem_res.adb (Resolve_Actuals): Add guard for the call to
Class_Preconditions_Subprogram.

gcc/ada/sem_res.adb

index 2c8efec524b37431efed84faaca357d53916d08d..d3a0192fb099f0c0068d614da5f63ebe8cc7f6ec 100644 (file)
@@ -5146,7 +5146,10 @@ package body Sem_Res is
             if Is_EVF_Expression (A)
               and then Extensions_Visible_Status (Nam) =
                        Extensions_Visible_True
-              and then No (Class_Preconditions_Subprogram (Current_Scope))
+              and then not
+               (Is_Subprogram (Current_Scope)
+                  and then
+                Present (Class_Preconditions_Subprogram (Current_Scope)))
             then
                Error_Msg_N
                  ("formal parameter cannot act as actual parameter when "