Patchwork [committed] Don't SET_DECL_DEBUG_EXPR on decls other than VAR_DECL (PR c++/44808)

login
register
mail settings
Submitter Jakub Jelinek
Date July 5, 2010, 2:46 p.m.
Message ID <20100705144621.GB28610@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/57915/
State New
Headers show

Comments

Jakub Jelinek - July 5, 2010, 2:46 p.m.
Hi!

While DECL_DEBUG_EXPR_IS_FROM is accepted on all all decls (with
decl_common), {,SET_}_DECL_DEBUG_EXPR only for VAR_DECLs.
While that limitation is only in the use of VAR_DECL_CHECK macros in tree.h,
var-tracking won't use it for non-VAR_DECLs anyway, so fixed by making sure
we do this only for VAR_DECLs.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.

2010-07-05  Jakub Jelinek  <jakub@redhat.com>

	PR c++/44808
	* gimplify.c (gimplify_modify_expr): Only SET_DECL_DEBUG_EXPR if
	*from_p is VAR_DECL.

	* g++.dg/opt/nrv16.C: New test.


	Jakub

Patch

--- gcc/gimplify.c.jj	2010-07-05 12:37:02.000000000 +0200
+++ gcc/gimplify.c	2010-07-05 12:51:50.000000000 +0200
@@ -4559,7 +4559,7 @@  gimplify_modify_expr (tree *expr_p, gimp
   /* Try to alleviate the effects of the gimplification creating artificial
      temporaries (see for example is_gimple_reg_rhs) on the debug info.  */
   if (!gimplify_ctxp->into_ssa
-      && DECL_P (*from_p)
+      && TREE_CODE (*from_p) == VAR_DECL
       && DECL_IGNORED_P (*from_p)
       && DECL_P (*to_p)
       && !DECL_IGNORED_P (*to_p))
--- gcc/testsuite/g++.dg/opt/nrv16.C.jj	2010-07-05 13:01:44.000000000 +0200
+++ gcc/testsuite/g++.dg/opt/nrv16.C	2010-07-05 13:00:31.000000000 +0200
@@ -0,0 +1,16 @@ 
+// PR c++/44808
+// { dg-do compile }
+
+struct S
+{
+  void *a, *b;
+  int c;
+};
+
+S
+foo ()
+{
+  S x;
+  S y = x;
+  return x;
+}