Patchwork C++ PATCH for c++/49253 (v3 debug mode regression)

login
register
mail settings
Submitter Jason Merrill
Date June 1, 2011, 6:39 p.m.
Message ID <4DE68772.1080501@redhat.com>
Download mbox | patch
Permalink /patch/98234/
State New
Headers show

Comments

Jason Merrill - June 1, 2011, 6:39 p.m.
My changes to preserve reference semantics in templates broke the 
shenanigans build_x_arrow was using for non-dependent ARROW_EXPR; it 
called build_min_non_dep and then overwrote the TREE_TYPE, but that 
broke in the case of a reference to pointer because it ended up giving 
the ARROW_EXPR REFERENCE_TYPE and then changing the type of the implicit 
INDIRECT_REF.  We shouldn't be using build_min_non_dep when there's an 
additional implied operation, anyway.  So this patch fixes it to use 
build_min instead, and set TREE_SIDE_EFFECTS directly.

Tested x86_64-pc-linux-gnu, applied to trunk.

Patch

commit 99c854c1078c3fc486ecf9b336e3a274a0c46469
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jun 1 13:31:33 2011 -0400

    	PR c++/49253
    	* typeck2.c (build_x_arrow): Don't use build_min_nt.

diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 031f076..4d5c21a 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -1463,9 +1463,9 @@  build_x_arrow (tree expr)
     {
       if (processing_template_decl)
 	{
-	  expr = build_min_non_dep (ARROW_EXPR, last_rval, orig_expr);
-	  /* It will be dereferenced.  */
-	  TREE_TYPE (expr) = TREE_TYPE (TREE_TYPE (last_rval));
+	  expr = build_min (ARROW_EXPR, TREE_TYPE (TREE_TYPE (last_rval)),
+			    orig_expr);
+	  TREE_SIDE_EFFECTS (expr) = TREE_SIDE_EFFECTS (last_rval);
 	  return expr;
 	}