[COMMITTED] ada: Revert to old pretty-printing of internal entities for CodePeer
Checks
Commit Message
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(-)
@@ -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