]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Implicit_Dereference aspect specification for subtype incorrectly accepted
authorSteve Baird <baird@adacore.com>
Tue, 6 Aug 2024 21:44:54 +0000 (14:44 -0700)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 23 Aug 2024 08:51:05 +0000 (10:51 +0200)
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.

gcc/ada/sem_ch13.adb

index 0546aa37de789c6d49fe0ac378da9a26b39785fa..a55ba3c7bd9a7cbaf348179a68c93e7bf8677f17 100644 (file)
@@ -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);