]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Fix handling of 'Image acting as a prefix of a slice in CodePeer
authorPiotr Trojanek <trojanek@adacore.com>
Tue, 24 Aug 2021 21:58:40 +0000 (23:58 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 4 Oct 2021 08:45:06 +0000 (08:45 +0000)
gcc/ada/

* sem_res.adb (Resolve_Slice): Add custom handling of attribute
Image and similar in CodePeer mode. This complements the
existing custom handling of these attributes in
Expand_N_Attribute_Reference.

gcc/ada/sem_res.adb

index 0d013ba7ec14f51c6450adfb66a59dedd671f8a3..c493d5d34bac8b7478bf5a391e7ddf41679f2f49 100644 (file)
@@ -11275,10 +11275,20 @@ package body Sem_Res is
             end;
          end if;
 
+      --  In CodePeer mode the attribute Image is not expanded, so when it
+      --  acts as a prefix of a slice, we handle it like a call to function
+      --  returning an unconstrained string. Same for the Wide variants of
+      --  attribute Image.
+
       elsif Is_Entity_Name (Name)
         or else Nkind (Name) = N_Explicit_Dereference
         or else (Nkind (Name) = N_Function_Call
                   and then not Is_Constrained (Etype (Name)))
+        or else (CodePeer_Mode
+                  and then Nkind (Name) = N_Attribute_Reference
+                  and then Attribute_Name (Name) in Name_Image
+                                                  | Name_Wide_Image
+                                                  | Name_Wide_Wide_Image)
       then
          Array_Type := Get_Actual_Subtype (Name);