From: Ronan Desplanques Date: Tue, 2 Dec 2025 09:58:48 +0000 (+0100) Subject: ada: Fix missing diagnostic with "T'Constructor" syntax X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df67cd14022815273c38bd9419fbdd1e6eb9ffc9;p=thirdparty%2Fgcc.git ada: Fix missing diagnostic with "T'Constructor" syntax Before this patch, procedures of the form "T'Constructor" without separate specs were incorrectly accepted in some cases. This patch fixes the issue. gcc/ada/ChangeLog: * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Check direct attribute definitions for specs. --- diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 252821126dd..3e40c74da08 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -4158,6 +4158,14 @@ package body Sem_Ch6 is Style.Body_With_No_Spec (N); end if; + -- Subprograms defined with direct attribute definitions must always + -- have separate specs. + if Nkind (Defining_Unit_Name (Original_Node (Body_Spec))) + = N_Attribute_Reference + then + Error_Msg_N ("subprogram must have a spec", N); + end if; + -- First set Acts_As_Spec if appropriate if Nkind (N) /= N_Subprogram_Body_Stub then