[PATCH] c++/97197 - support TARGET_MEM_REF in C/C++ error pretty-printing

Richard Biener rguenther@suse.de
Fri Sep 25 11:11:37 GMT 2020


This adds rough support to avoid "'target_mem_ref' not supported by"
in diagnostics.  There were recent patches by Martin to sanitize
dumping of MEM_REF so I'm not trying to interfere with this here.

Bootstrap & regtest pending.

OK?

2020-09-25  Richard Biener  <rguenther@suse.de>

	PR c++/97197
cp/
	* error.c (dump_expr): Handle TARGET_MEM_REF as if it
	were MEM_REF.

c-family/
	* c-pretty-print.c (c_pretty_printer::postfix_expression):
	Handle TARGET_MEM_REF as expression.
	(c_pretty_printer::expression): Handle TARGET_MEM_REF as
	unary_expression.
	(c_pretty_printer::unary_expression): Handle TARGET_MEM_REF
	as if it were MEM_REF.
---
 gcc/c-family/c-pretty-print.c | 3 +++
 gcc/cp/error.c                | 1 +
 2 files changed, 4 insertions(+)

diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c
index acffd7b872c..1a0edb82312 100644
--- a/gcc/c-family/c-pretty-print.c
+++ b/gcc/c-family/c-pretty-print.c
@@ -1693,6 +1693,7 @@ c_pretty_printer::postfix_expression (tree e)
       break;
 
     case MEM_REF:
+    case TARGET_MEM_REF:
       expression (e);
       break;
 
@@ -1833,6 +1834,7 @@ c_pretty_printer::unary_expression (tree e)
       break;
 
     case MEM_REF:
+    case TARGET_MEM_REF:
       if (TREE_CODE (TREE_OPERAND (e, 0)) == ADDR_EXPR
 	  && integer_zerop (TREE_OPERAND (e, 1)))
 	expression (TREE_OPERAND (TREE_OPERAND (e, 0), 0));
@@ -2295,6 +2297,7 @@ c_pretty_printer::expression (tree e)
     case ADDR_EXPR:
     case INDIRECT_REF:
     case MEM_REF:
+    case TARGET_MEM_REF:
     case NEGATE_EXPR:
     case BIT_NOT_EXPR:
     case TRUTH_NOT_EXPR:
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index ecb41e82d8c..c9a0c1e0288 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -2372,6 +2372,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
       break;
 
     case MEM_REF:
+    case TARGET_MEM_REF:
       if (TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR
 	  && integer_zerop (TREE_OPERAND (t, 1)))
 	dump_expr (pp, TREE_OPERAND (TREE_OPERAND (t, 0), 0), flags);
-- 
2.26.2


More information about the Gcc-patches mailing list