* [PATCH] tree-pretty-print: handle COMPONENT_REF with non-decl RHS
@ 2023-08-01 0:35 Patrick Palka
2023-08-02 8:07 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Patrick Palka @ 2023-08-01 0:35 UTC (permalink / raw)
To: gcc-patches; +Cc: jason, Patrick Palka
Tested on x86_64-pc-linux-gnu, does this look OK for trunk?
-- >8 --
In the C++ front end, a COMPONENT_REF's second operand isn't always a
decl (at least at template parse time). This patch makes the generic
pretty printer not ICE when printing such a COMPONENT_REF.
gcc/ChangeLog:
* tree-pretty-print.cc (dump_generic_node) <case COMPONENT_REF>:
Don't call component_ref_field_offset if the RHS isn't a decl.
---
gcc/tree-pretty-print.cc | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc
index 25d191b10fd..da8dd002a3b 100644
--- a/gcc/tree-pretty-print.cc
+++ b/gcc/tree-pretty-print.cc
@@ -2482,14 +2482,16 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
if (op_prio (op0) < op_prio (node))
pp_right_paren (pp);
pp_string (pp, str);
- dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
- op0 = component_ref_field_offset (node);
- if (op0 && TREE_CODE (op0) != INTEGER_CST)
- {
- pp_string (pp, "{off: ");
- dump_generic_node (pp, op0, spc, flags, false);
+ op1 = TREE_OPERAND (node, 1);
+ dump_generic_node (pp, op1, spc, flags, false);
+ if (DECL_P (op1))
+ if (tree off = component_ref_field_offset (node))
+ if (TREE_CODE (off) != INTEGER_CST)
+ {
+ pp_string (pp, "{off: ");
+ dump_generic_node (pp, off, spc, flags, false);
pp_right_brace (pp);
- }
+ }
break;
case BIT_FIELD_REF:
--
2.41.0.478.gee48e70a82
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] tree-pretty-print: handle COMPONENT_REF with non-decl RHS
2023-08-01 0:35 [PATCH] tree-pretty-print: handle COMPONENT_REF with non-decl RHS Patrick Palka
@ 2023-08-02 8:07 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2023-08-02 8:07 UTC (permalink / raw)
To: Patrick Palka; +Cc: gcc-patches, jason
On Tue, Aug 1, 2023 at 2:36 AM Patrick Palka via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Tested on x86_64-pc-linux-gnu, does this look OK for trunk?
>
> -- >8 --
>
> In the C++ front end, a COMPONENT_REF's second operand isn't always a
> decl (at least at template parse time). This patch makes the generic
> pretty printer not ICE when printing such a COMPONENT_REF.
>
> gcc/ChangeLog:
>
> * tree-pretty-print.cc (dump_generic_node) <case COMPONENT_REF>:
> Don't call component_ref_field_offset if the RHS isn't a decl.
> ---
> gcc/tree-pretty-print.cc | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc
> index 25d191b10fd..da8dd002a3b 100644
> --- a/gcc/tree-pretty-print.cc
> +++ b/gcc/tree-pretty-print.cc
> @@ -2482,14 +2482,16 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
> if (op_prio (op0) < op_prio (node))
> pp_right_paren (pp);
> pp_string (pp, str);
> - dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
> - op0 = component_ref_field_offset (node);
> - if (op0 && TREE_CODE (op0) != INTEGER_CST)
> - {
> - pp_string (pp, "{off: ");
> - dump_generic_node (pp, op0, spc, flags, false);
> + op1 = TREE_OPERAND (node, 1);
> + dump_generic_node (pp, op1, spc, flags, false);
> + if (DECL_P (op1))
OK if you add a comment before this test.
> + if (tree off = component_ref_field_offset (node))
> + if (TREE_CODE (off) != INTEGER_CST)
> + {
> + pp_string (pp, "{off: ");
> + dump_generic_node (pp, off, spc, flags, false);
> pp_right_brace (pp);
> - }
> + }
> break;
>
> case BIT_FIELD_REF:
> --
> 2.41.0.478.gee48e70a82
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-02 8:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-01 0:35 [PATCH] tree-pretty-print: handle COMPONENT_REF with non-decl RHS Patrick Palka
2023-08-02 8:07 ` Richard Biener
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).