[backport from gcc-4.7/trunk ] gcc/cp/ 2011-12-20 Dodji Seketeli PR debug/49951 * decl.c (cxx_maybe_build_cleanup): Don't set location of the call to the destructor. gcc/testsuite/ 2011-12-20 Dodji Seketeli PR debug/49951 * g++.dg/gcov/gcov-2.C: Adjust. --- gcc-4.6.2/gcc/cp/decl.c.~1~ 2011-09-25 22:29:04.000000000 +0200 +++ gcc-4.6.2/gcc/cp/decl.c 2011-12-23 16:35:12.000000000 +0100 @@ -13356,8 +13356,17 @@ cxx_maybe_build_cleanup (tree decl) cleanup = call; } + /* build_delete sets the location of the destructor call to the + current location, even though the destructor is going to be + called later, at the end of the current scope. This can lead to + a "jumpy" behaviour for users of debuggers when they step around + the end of the block. So let's unset the location of the + destructor call instead. */ + if (cleanup != NULL && EXPR_P (cleanup)) + SET_EXPR_LOCATION (cleanup, UNKNOWN_LOCATION); return cleanup; } + /* When a stmt has been parsed, this function is called. */ --- gcc-4.6.2/gcc/testsuite/g++.dg/gcov/gcov-2.C.~1~ 2009-07-17 00:29:52.000000000 +0200 +++ gcc-4.6.2/gcc/testsuite/g++.dg/gcov/gcov-2.C 2011-12-23 16:35:12.000000000 +0100 @@ -20,7 +20,7 @@ private: void foo() { - C c; /* count(2) */ + C c; /* count(1) */ c.seti (1); /* count(1) */ }