re PR debug/44367 (-O0 -g wrong DW_AT_location on c++ class retval)
authorJakub Jelinek <jakub@redhat.com>
Wed, 2 Jun 2010 19:52:07 +0000 (21:52 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 2 Jun 2010 19:52:07 +0000 (21:52 +0200)
PR debug/44367
* semantics.c (finalize_nrv): Don't copy DECL_ARTIFICIAL, DECL_IGNORED_P,
DECL_SOURCE_LOCATION and DECL_ABSTRACT_ORIGIN from var to result.
Set DECL_VALUE_EXPR on var.

From-SVN: r160186

gcc/cp/ChangeLog
gcc/cp/semantics.c

index 1dabc4ca8c70f3b3e3a20099117ea62b18dd6441..9a031f99d672da7eb3320d32f2ae2bfff928c3e0 100644 (file)
@@ -5,6 +5,11 @@
        (decl_shadowed_for_var_lookup, decl_shadowed_for_var_insert): Adjust.
        (init_shadowed_var_for_decl): Adjust initialization.
 
+       PR debug/44367
+       * semantics.c (finalize_nrv): Don't copy DECL_ARTIFICIAL, DECL_IGNORED_P,
+       DECL_SOURCE_LOCATION and DECL_ABSTRACT_ORIGIN from var to result.
+       Set DECL_VALUE_EXPR on var.
+
 2010-06-02  Jason Merrill  <jason@redhat.com>
 
        * error.c (dump_type): Improve typedef handling.
index bf016f1f58633fec375a3806dca66fe6e7f271f5..05d1cada90684837c0484276d2af557dd96650f8 100644 (file)
@@ -3504,14 +3504,15 @@ finalize_nrv (tree *tp, tree var, tree result)
 {
   struct nrv_data data;
 
-  /* Copy debugging information from VAR to RESULT.  */
+  /* Copy name from VAR to RESULT.  */
   DECL_NAME (result) = DECL_NAME (var);
-  DECL_ARTIFICIAL (result) = DECL_ARTIFICIAL (var);
-  DECL_IGNORED_P (result) = DECL_IGNORED_P (var);
-  DECL_SOURCE_LOCATION (result) = DECL_SOURCE_LOCATION (var);
-  DECL_ABSTRACT_ORIGIN (result) = DECL_ABSTRACT_ORIGIN (var);
   /* Don't forget that we take its address.  */
   TREE_ADDRESSABLE (result) = TREE_ADDRESSABLE (var);
+  /* Finally set DECL_VALUE_EXPR to avoid assigning
+     a stack slot at -O0 for the original var and debug info
+     uses RESULT location for VAR.  */
+  SET_DECL_VALUE_EXPR (var, result);
+  DECL_HAS_VALUE_EXPR_P (var) = 1;
 
   data.var = var;
   data.result = result;