From 35a035c210e57ea2172078ff59b76bb75baf3b6d Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Tue, 14 Feb 2023 17:05:59 +0100 Subject: ada: Revert to old pretty-printing of internal entities for CodePeer 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 | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/pprint.adb b/gcc/ada/pprint.adb index bcc7a25..3843ec2 100644 --- a/gcc/ada/pprint.adb +++ b/gcc/ada/pprint.adb @@ -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 -- cgit v1.1