public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-6346] [Ada] treepr: Print value of static expression
@ 2022-01-07 16:27 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-01-07 16:27 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:5e5030df8f223fb800d5ad7735c419a16b37dfaf
commit r12-6346-g5e5030df8f223fb800d5ad7735c419a16b37dfaf
Author: Bob Duff <duff@adacore.com>
Date: Fri Dec 10 15:53:04 2021 -0500
[Ada] treepr: Print value of static expression
gcc/ada/
* treepr.adb (Print_Node_Ref): Print the value if available.
Diff:
---
gcc/ada/treepr.adb | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/gcc/ada/treepr.adb b/gcc/ada/treepr.adb
index c1e71b18b44..ad2bbf07df8 100644
--- a/gcc/ada/treepr.adb
+++ b/gcc/ada/treepr.adb
@@ -37,6 +37,7 @@ with Namet; use Namet;
with Nlists; use Nlists;
with Output; use Output;
with Seinfo; use Seinfo;
+with Sem_Eval; use Sem_Eval;
with Sinfo; use Sinfo;
with Sinfo.Nodes; use Sinfo.Nodes;
with Sinfo.Utils; use Sinfo.Utils;
@@ -1642,6 +1643,24 @@ package body Treepr is
end if;
end if;
+ -- If this is an integer-like expression whose value is known, print
+ -- that value.
+
+ if Nkind (N) in N_Subexpr
+ and then Compile_Time_Known_Value (N)
+ and then Present (Etype (N))
+ and then not Is_Array_Type (Etype (N))
+ then
+ if Is_Entity_Name (N) -- e.g. enumeration literal
+ or else Nkind (N) in N_Integer_Literal
+ | N_Character_Literal
+ | N_Unchecked_Type_Conversion
+ then
+ Print_Str (" val = ");
+ UI_Write (Expr_Value (N));
+ end if;
+ end if;
+
if Nkind (N) in N_Entity then
Write_Str (" (Entity_Id=");
else
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-07 16:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-07 16:27 [gcc r12-6346] [Ada] treepr: Print value of static expression Pierre-Marie de Rodat
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).