diff mbox series

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

Message ID nycvar.YFH.7.76.2009251311080.5031@elmra.sevgm.obk
State New
Headers show
Series c++/97197 - support TARGET_MEM_REF in C/C++ error pretty-printing | expand

Commit Message

Richard Biener Sept. 25, 2020, 11:11 a.m. UTC
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(+)

Comments

Jakub Jelinek Sept. 25, 2020, 11:20 a.m. UTC | #1
On Fri, Sep 25, 2020 at 01:11:37PM +0200, Richard Biener wrote:
> 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.

Is that correct?
I mean, TARGET_MEM_REF encodes more than what MEM_REF encodes,
so printing it like MEM_REF will ignore many things from there.
I'd say we should print it like:
*(type *)(BASE + STEP * INDEX + INDEX2 + OFFSET)
rather than how we print MEM_REFs as
*(type *)(BASE + OFFSET)
(with skipping whatever is NULL in there).
So instead of adding case MEM_REF: in the second and last hunk
copy and edit it (perhaps kill the probably unnecessary
part that checks for *&foo and prints it as foo, because who would
create TARGET_MEM_REF when MEM_REF could have been used in that case).
> 
> 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.

	Jakub
Richard Biener Sept. 25, 2020, 11:37 a.m. UTC | #2
On Fri, 25 Sep 2020, Jakub Jelinek wrote:

> On Fri, Sep 25, 2020 at 01:11:37PM +0200, Richard Biener wrote:
> > 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.
> 
> Is that correct?
> I mean, TARGET_MEM_REF encodes more than what MEM_REF encodes,
> so printing it like MEM_REF will ignore many things from there.
> I'd say we should print it like:
> *(type *)(BASE + STEP * INDEX + INDEX2 + OFFSET)
> rather than how we print MEM_REFs as
> *(type *)(BASE + OFFSET)
> (with skipping whatever is NULL in there).
> So instead of adding case MEM_REF: in the second and last hunk
> copy and edit it (perhaps kill the probably unnecessary
> part that checks for *&foo and prints it as foo, because who would
> create TARGET_MEM_REF when MEM_REF could have been used in that case).

See my comment above for Martins attempts to improve things.  I don't
really want to try decide what to do with those late diagnostic IL
printing but my commit was blamed for showing target-mem-ref unsupported.

I don't have much time to spend to think what to best print and what not,
but yes, printing only the MEM_REF part is certainly imprecise.

I'll leave the PR to FE folks.

Thanks,
Richard.

> > 
> > 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.
> 
> 	Jakub
> 
>
diff mbox series

Patch

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);