diff mbox

c-common PATCH to pretty-printing of INDIRECT_REF of reference

Message ID 55BA7754.3050202@redhat.com
State New
Headers show

Commit Message

Jason Merrill July 30, 2015, 7:13 p.m. UTC
I noticed that on the concepts branch we were printing an extra '*' when 
dumping an expression involving references, but haven't been able to 
come up with a testcase for the trunk.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit c81115210bdc4dbc5614a1fea4dca59fa9f42af9
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jul 29 10:45:02 2015 -0400

    	* c-pretty-print.c (unary_expression) [INDIRECT_REF]: Don't print
    	'*' for reference decay.

diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c
index d1a0e12..90f8c3d 100644
--- a/gcc/c-family/c-pretty-print.c
+++ b/gcc/c-family/c-pretty-print.c
@@ -1774,7 +1774,13 @@  c_pretty_printer::unary_expression (tree e)
       if (code == ADDR_EXPR && TREE_CODE (TREE_OPERAND (e, 0)) != STRING_CST)
 	pp_ampersand (this);
       else if (code == INDIRECT_REF)
-	pp_c_star (this);
+	{
+	  tree type = TREE_TYPE (TREE_OPERAND (e, 0));
+	  if (type && TREE_CODE (type) == REFERENCE_TYPE)
+	    /* Reference decay is implicit, don't print anything.  */;
+	  else
+	    pp_c_star (this);
+	}
       else if (code == NEGATE_EXPR)
 	pp_minus (this);
       else if (code == BIT_NOT_EXPR || code == CONJ_EXPR)