]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Compiler accepts an illegal Unchecked_Access attribute reference
authorSteve Baird <baird@adacore.com>
Thu, 13 Jun 2024 22:18:31 +0000 (15:18 -0700)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 2 Jul 2024 13:20:35 +0000 (15:20 +0200)
The compiler incorrectly accepts Some_Object'Unchecked_Access'Image.

gcc/ada/

* sem_attr.adb
(Analyze_Image_Attribute.Check_Image_Type): Check for
E_Access_Attribute_Type prefix type.

gcc/ada/sem_attr.adb

index d56c25a79cc86ff38132bf931c11ba781267fe95..0b0adac11266e9ee35b7f6fd2dce239bb635ed0b 100644 (file)
@@ -1582,6 +1582,13 @@ package body Sem_Attr is
             then
                Error_Msg_Ada_2022_Feature ("nonscalar ''Image", Sloc (P));
                Error_Attr;
+
+            elsif Present (Image_Type)
+              and then Ekind (Image_Type) = E_Access_Attribute_Type
+            then
+               --  reject Some_Object'[Unchecked_]Access'[Wide_[Wide_]]Image
+               Error_Msg_N ("illegal Image attribute prefix", N);
+               Error_Attr;
             end if;
          end Check_Image_Type;