aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/pprint.adb
diff options
context:
space:
mode:
authorSteve Baird <baird@adacore.com>2017-09-06 12:01:13 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2017-09-06 14:01:13 +0200
commit643827e99051c3ce6077d8bb332290741dc90571 (patch)
treee52a39b62571b39e7f56f1931e9f955031101a42 /gcc/ada/pprint.adb
parent66f95f60458a1da2e82c4b879357ebe36fcdb879 (diff)
downloadgcc-643827e99051c3ce6077d8bb332290741dc90571.zip
gcc-643827e99051c3ce6077d8bb332290741dc90571.tar.gz
gcc-643827e99051c3ce6077d8bb332290741dc90571.tar.bz2
exp_util.adb (Side_Effect_Free): For CodePeer (only) treat uses of 'Image and related attributes as having side...
2017-09-06 Steve Baird <baird@adacore.com> * exp_util.adb (Side_Effect_Free): For CodePeer (only) treat uses of 'Image and related attributes as having side effects in order to avoid replicating such uses. * pprint.ads (Expression_Image) Add new generic formal flag Hide_Temp_Derefs. The flag defaults to False; CodePeer will (eventually) override the default. * pprint.adb (Expression_Image) If the new flag is set, then suppress the ".all" suffix when displaying a dereference whose prefix is a use of a value-capturing compiler temp of the sort generated by Expr_Util.Remove_Side_Effects . * exp_attr.adb, g-catiio.adb, inline.adb, sem_attr.adb, sem_ch13.adb, sem_ch7.adb, sem_dim.adb, sem_util.adb, sem_util.ads, sem_warn.adb: Minor reformatting. * inline.adb: Minor wording change. From-SVN: r251784
Diffstat (limited to 'gcc/ada/pprint.adb')
-rw-r--r--gcc/ada/pprint.adb72
1 files changed, 58 insertions, 14 deletions
diff --git a/gcc/ada/pprint.adb b/gcc/ada/pprint.adb
index fcfccd3..912af39 100644
--- a/gcc/ada/pprint.adb
+++ b/gcc/ada/pprint.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 2008-2016, Free Software Foundation, Inc. --
+-- Copyright (C) 2008-2017, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -325,22 +325,66 @@ package body Pprint is
end if;
when N_Explicit_Dereference =>
+ Explicit_Dereference : declare
+ function Deref_Suffix return String;
+ -- Usually returns ".all", but will return "" if
+ -- Hide_Temp_Derefs is true and the prefix is a use of a
+ -- not-from-source object declared as
+ -- X : constant Some_Access_Type := Some_Expr'Reference;
+ -- (as is sometimes done in Exp_Util.Remove_Side_Effects).
- -- Return "Foo" instead of "Parameter_Block.Foo.all"
+ ------------------
+ -- Deref_Suffix --
+ ------------------
- if Hide_Parameter_Blocks
- and then Nkind (Prefix (Expr)) = N_Selected_Component
- and then Present (Etype (Prefix (Expr)))
- and then Is_Access_Type (Etype (Prefix (Expr)))
- and then Is_Param_Block_Component_Type (Etype (Prefix (Expr)))
- then
- return Expr_Name (Selector_Name (Prefix (Expr)));
+ function Deref_Suffix return String is
+ Decl : Node_Id;
- elsif Take_Prefix then
- return Expr_Name (Prefix (Expr)) & ".all";
- else
- return ".all";
- end if;
+ begin
+ if Hide_Temp_Derefs
+ and then Nkind (Prefix (Expr)) = N_Identifier
+ and then Nkind (Entity (Prefix (Expr))) =
+ N_Defining_Identifier
+ then
+ Decl := Parent (Entity (Prefix (Expr)));
+
+ if Present (Decl)
+ and then Nkind (Decl) = N_Object_Declaration
+ and then not Comes_From_Source (Decl)
+ and then Constant_Present (Decl)
+ and then Present (Sinfo.Expression (Decl))
+ and then Nkind (Sinfo.Expression (Decl)) =
+ N_Reference
+ then
+ return "";
+ end if;
+ end if;
+
+ -- The default case
+
+ return ".all";
+ end Deref_Suffix;
+
+ -- Start of processing for Explicit_Dereference
+
+ begin
+ if Hide_Parameter_Blocks
+ and then Nkind (Prefix (Expr)) = N_Selected_Component
+ and then Present (Etype (Prefix (Expr)))
+ and then Is_Access_Type (Etype (Prefix (Expr)))
+ and then Is_Param_Block_Component_Type
+ (Etype (Prefix (Expr)))
+ then
+ -- Return "Foo" instead of "Parameter_Block.Foo.all"
+
+ return Expr_Name (Selector_Name (Prefix (Expr)));
+
+ elsif Take_Prefix then
+ return Expr_Name (Prefix (Expr)) & Deref_Suffix;
+ else
+ return Deref_Suffix;
+ end if;
+ end Explicit_Dereference;
when N_Expanded_Name
| N_Selected_Component