* [COMMITTED] ada: Revert to old pretty-printing of internal entities for CodePeer
@ 2023-05-23 8:07 Marc Poulhiès
0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2023-05-23 8:07 UTC (permalink / raw)
To: gcc-patches; +Cc: Piotr Trojanek
From: Piotr Trojanek <trojanek@adacore.com>
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.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/pprint.adb | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/gcc/ada/pprint.adb b/gcc/ada/pprint.adb
index bcc7a257630..3843ec203b0 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
--
2.40.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-05-23 8:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-23 8:07 [COMMITTED] ada: Revert to old pretty-printing of internal entities for CodePeer Marc Poulhiès
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).