]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix missing diagnostic with "T'Constructor" syntax
authorRonan Desplanques <desplanques@adacore.com>
Tue, 2 Dec 2025 09:58:48 +0000 (10:58 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 9 Jan 2026 10:57:14 +0000 (11:57 +0100)
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.

gcc/ada/sem_ch6.adb

index 252821126dd9ed2c1af8e738f246c6970621e712..3e40c74da083637fcbd9b315743f9682d15fc0fa 100644 (file)
@@ -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