re PR debug/58123 (debug line not tracked for last autovariable dtor)
authorAldy Hernandez <aldyh@redhat.com>
Sat, 21 Feb 2015 00:27:05 +0000 (00:27 +0000)
committerAldy Hernandez <aldyh@gcc.gnu.org>
Sat, 21 Feb 2015 00:27:05 +0000 (00:27 +0000)
PR debug/58123
* gimplify.c (gimplify_expr): Prefer location of TRY_FINALLY_EXPR
over input_location.

From-SVN: r220886

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C
gcc/testsuite/g++.dg/gcov/gcov-2.C
gcc/testsuite/g++.dg/pr58123.C [new file with mode: 0644]

index 9febcbd5ffdee82c36f50d4dcc4f0233b5f69e75..ca429c08d63c87c7b2ec15384fa6897b27233864 100644 (file)
@@ -1,3 +1,9 @@
+2015-02-20  Aldy Hernandez  <aldyh@redhat.com>
+
+       PR debug/58123
+       * gimplify.c (gimplify_expr): Prefer location of TRY_FINALLY_EXPR
+       over input_location.
+
 2015-02-20  Bernd Schmidt  <bernds@codesourcery.com>
 
        * tree-streamer-in.c (unpack_ts_decl_common_value_fields,
index 1353ada2f857970470f6adbd36fcdc26c45867af..d822913accea99a07d137242b7e1a0b5099825e2 100644 (file)
@@ -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));
index 1efc08dcbc5eb283e28aa1c81a3ce8ed1435bb20..011e1a3def3d93a1b3a764dbbebb0dade4aeb199 100644 (file)
@@ -1,3 +1,10 @@
+2015-02-20  Aldy Hernandez  <aldyh@redhat.com>
+
+       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  <rguenther@suse.de>
 
        PR tree-optimization/65136
index 405739311a91c754b5c06eaf49901da827c804cd..0fcd08ea6f90464ae04aebc6e518350436b4e390 100644 (file)
@@ -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" } }
index 66d8af39bce402032b6e5d60929e5980d34a272e..6d002f5d2cd01d7818d14c45ae7092924d2fa8d8 100644 (file)
@@ -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 (file)
index 0000000..7fe1a27
--- /dev/null
@@ -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" } }