From add86e09a5c4c09fbcf3088409a1eb60c47155db Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 2 Jun 2010 21:52:07 +0200 Subject: [PATCH] re PR debug/44367 (-O0 -g wrong DW_AT_location on c++ class retval) 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 | 5 +++++ gcc/cp/semantics.c | 11 ++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1dabc4ca8c7..9a031f99d67 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 * error.c (dump_type): Improve typedef handling. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index bf016f1f586..05d1cada906 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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; -- 2.30.2