[gcc r16-6609] ada: Fix missing diagnostic with "T'Constructor" syntax
Marc Poulhies
dkm@gcc.gnu.org
Fri Jan 9 11:01:18 GMT 2026
https://gcc.gnu.org/g:df67cd14022815273c38bd9419fbdd1e6eb9ffc9
commit r16-6609-gdf67cd14022815273c38bd9419fbdd1e6eb9ffc9
Author: Ronan Desplanques <desplanques@adacore.com>
Date: Tue Dec 2 10:58:48 2025 +0100
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:
---
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 252821126dd9..3e40c74da083 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
More information about the Gcc-cvs
mailing list