[COMMITTED 13/45] ada: Fix missing diagnostic with "T'Constructor" syntax

Marc Poulhiès poulhies@adacore.com
Fri Jan 9 10:59:58 GMT 2026


From: Ronan Desplanques <desplanques@adacore.com>

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.

Tested on x86_64-pc-linux-gnu (before the recent bootstrap breakage), committed on master.

---
 gcc/ada/sem_ch6.adb | 8 ++++++++
 1 file changed, 8 insertions(+)

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
-- 
2.51.0



More information about the Gcc-patches mailing list