diff mbox series

[COMMITTED,12/16] ada: Implicit_Dereference aspect specification for subtype incorrectly accepted

Message ID 20240823085359.1399344-12-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,01/16] ada: First controlling parameter aspect | expand

Commit Message

Marc Poulhiès Aug. 23, 2024, 8:53 a.m. UTC
From: Steve Baird <baird@adacore.com>

Implicit_Dereference is a type-specific aspect and therefore cannot be
legally specified as part of a subtype declaration.

gcc/ada/

	* sem_ch13.adb (Analyze_Aspect_Implicit_Dereference): Generate
	error if an aspect specification specifies the
	Implicit_Dereference aspect of a non-first subtype.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_ch13.adb | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 0546aa37de7..a55ba3c7bd9 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -1982,6 +1982,11 @@  package body Sem_Ch13 is
                   Error_Msg_N
                     ("aspect must apply to a type with discriminants", Expr);
 
+               elsif not Is_First_Subtype (E) then
+                  Error_Msg_N
+                    ("aspect not specifiable in a subtype declaration",
+                     Aspect);
+
                elsif not Is_Entity_Name (Expr) then
                   Error_Msg_N
                     ("aspect must name a discriminant of current type", Expr);