]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Revert to old pretty-printing of internal entities for CodePeer
authorPiotr Trojanek <trojanek@adacore.com>
Tue, 14 Feb 2023 16:05:59 +0000 (17:05 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 23 May 2023 07:50:59 +0000 (09:50 +0200)
Add some defensive code to get pretty-printed CodePeer outputs for ACATS
back to shape. At least some of this code appears to be redundant and
perhaps unnecessary, but we can this up later.

Expression pretty-printer should not be called with
N_Defining_Identifier nodes at all, since they are not expressions.
However, for those that come not from source, CodePeer expects that the
Ident_Image routine will convert the internal names like "xL" to their
corresponding human-readable representation like "x'Accesibility_Level".

gcc/ada/

* pprint.adb (Expression_Image): Restore some of the old pretty-printing
for CodePeer.

gcc/ada/pprint.adb

index bcc7a257630fd43d87299167d450ef24217cd5ef..3843ec203b0dcc8dd23f96dba3306200f9bbaa7f 100644 (file)
@@ -731,9 +731,11 @@ package body Pprint is
       --  itself, but for now simply return the default (if present) or print
       --  name of the defining identifier.
 
-      if Nkind (Expr) not in N_Subexpr then
+      if Nkind (Expr) = N_Defining_Identifier then
          pragma Assert (CodePeer_Mode);
-         if Nkind (Expr) = N_Defining_Identifier then
+         if Comes_From_Source (Expr)
+           or else Opt.Debug_Generated_Code
+         then
             if Default = "" then
                declare
                   Nam : constant Name_Id := Chars (Expr);
@@ -748,10 +750,24 @@ package body Pprint is
                return Default;
             end if;
          else
-            raise Program_Error;
+            declare
+               S : constant String :=
+                 Ident_Image
+                   (Expr => Expr, Orig_Expr => Expr, Expand_Type => True);
+            begin
+               if S = "..." then
+                  return Default;
+               else
+                  return S;
+               end if;
+            end;
          end if;
+      else
+         pragma Assert (Nkind (Expr) in N_Subexpr);
       end if;
 
+      --  ??? The following should be primarily needed for CodePeer
+
       if not Comes_From_Source (Expr)
         or else Opt.Debug_Generated_Code
       then