aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2023-08-11 12:17:24 -0400
committerPatrick Palka <ppalka@redhat.com>2023-08-11 12:17:24 -0400
commita4238f6db879abc048282d2d26442e68dc9427ea (patch)
tree74034741cfa24973f14fde602a27d20d2107ca45
parent834d1422c2e056f483542f1aff2cfc211bfcc748 (diff)
downloadgcc-a4238f6db879abc048282d2d26442e68dc9427ea.zip
gcc-a4238f6db879abc048282d2d26442e68dc9427ea.tar.gz
gcc-a4238f6db879abc048282d2d26442e68dc9427ea.tar.bz2
tree-pretty-print: handle COMPONENT_REF with non-decl RHS
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.
-rw-r--r--gcc/tree-pretty-print.cc16
1 files changed, 9 insertions, 7 deletions
diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc
index 25d191b..51a2135 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)) /* Not always a decl in the C++ FE. */
+ 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: