From 220d905f7c53b81c4572450f9caf6197b2cc6c02 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Sat, 21 Feb 2015 00:27:05 +0000 Subject: [PATCH] re PR debug/58123 (debug line not tracked for last autovariable dtor) PR debug/58123 * gimplify.c (gimplify_expr): Prefer location of TRY_FINALLY_EXPR over input_location. From-SVN: r220886 --- gcc/ChangeLog | 6 ++++++ gcc/gimplify.c | 6 +++--- gcc/testsuite/ChangeLog | 7 +++++++ .../g++.dg/debug/dwarf2/deallocator.C | 6 +++--- gcc/testsuite/g++.dg/gcov/gcov-2.C | 2 +- gcc/testsuite/g++.dg/pr58123.C | 18 ++++++++++++++++++ 6 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr58123.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9febcbd5ffd..ca429c08d63 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-02-20 Aldy Hernandez + + PR debug/58123 + * gimplify.c (gimplify_expr): Prefer location of TRY_FINALLY_EXPR + over input_location. + 2015-02-20 Bernd Schmidt * tree-streamer-in.c (unpack_ts_decl_common_value_fields, diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 1353ada2f85..d822913acce 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -8244,10 +8244,10 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, TREE_CODE (*expr_p) == TRY_FINALLY_EXPR ? GIMPLE_TRY_FINALLY : GIMPLE_TRY_CATCH); - if (LOCATION_LOCUS (saved_location) != UNKNOWN_LOCATION) - gimple_set_location (try_, saved_location); - else + if (EXPR_HAS_LOCATION (save_expr)) gimple_set_location (try_, EXPR_LOCATION (save_expr)); + else if (LOCATION_LOCUS (saved_location) != UNKNOWN_LOCATION) + gimple_set_location (try_, saved_location); if (TREE_CODE (*expr_p) == TRY_CATCH_EXPR) gimple_try_set_catch_is_cleanup (try_, TRY_CATCH_IS_CLEANUP (*expr_p)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1efc08dcbc5..011e1a3def3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2015-02-20 Aldy Hernandez + + PR debug/58123 + * g++.dg/debug/dwarf2/deallocator.C: Adjust for correct try + location. + * g++.dg/gcov/gcov-2.C: Likewise. + 2015-02-20 Richard Biener PR tree-optimization/65136 diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C b/gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C index 405739311a9..0fcd08ea6f9 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C @@ -41,6 +41,6 @@ void foo(int i) return; } // { dg-final { scan-assembler "deallocator.C:29" } } -// { dg-final { scan-assembler "deallocator.C:31" } } -// { dg-final { scan-assembler "deallocator.C:38" } } -// { dg-final { scan-assembler "deallocator.C:41" } } +// { dg-final { scan-assembler "deallocator.C:24" } } +// { dg-final { scan-assembler "deallocator.C:34" } } +// { dg-final { scan-assembler "deallocator.C:21" } } diff --git a/gcc/testsuite/g++.dg/gcov/gcov-2.C b/gcc/testsuite/g++.dg/gcov/gcov-2.C index 66d8af39bce..6d002f5d2cd 100644 --- a/gcc/testsuite/g++.dg/gcov/gcov-2.C +++ b/gcc/testsuite/g++.dg/gcov/gcov-2.C @@ -20,7 +20,7 @@ private: void foo() { - C c; /* count(1) */ + C c; /* count(2) */ c.seti (1); /* count(1) */ } diff --git a/gcc/testsuite/g++.dg/pr58123.C b/gcc/testsuite/g++.dg/pr58123.C new file mode 100644 index 00000000000..7fe1a276518 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr58123.C @@ -0,0 +1,18 @@ +// { dg-do compile } +// { dg-options "-fdump-tree-gimple-lineno" } + +// Test that the TRY block's location is the definition of "C a". + +class C { +public: + C() {} + ~C() {} + int m() { return 0; } +}; +int main() { + C a; + return a.m(); +} + +// { dg-final { scan-tree-dump-times "pr58123.C:13\.6\] try" 1 "gimple" } } +// { dg-final { cleanup-tree-dump "gimple" } } -- 2.30.2