From: Piotr Trojanek Date: Tue, 11 Jul 2023 14:37:23 +0000 (+0200) Subject: ada: Add guard for detection of class-wide precondition subprograms X-Git-Tag: basepoints/gcc-15~7297 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8dcd763ac6203904339ccc87cfee28892dbb7231;p=thirdparty%2Fgcc.git ada: Add guard for detection of class-wide precondition subprograms 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. --- diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 2c8efec524b3..d3a0192fb099 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -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 "