Patchwork C++ PATCH for c++/52248 (ICE with -ftime-report and undefined label)

login
register
mail settings
Submitter Jason Merrill
Date Feb. 17, 2012, 8:36 a.m.
Message ID <4F3E1186.9090605@redhat.com>
Download mbox | patch
Permalink /patch/141754/
State New
Headers show

Comments

Jason Merrill - Feb. 17, 2012, 8:36 a.m.
Here we can get to define_label from within poplevel, which results in 
recursive starting of TV_NAME_LOOKUP.  The obvious solution is to just 
use cond_start/stop in define_label.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch

commit 4e0a90cdec5d3e1b29335eb8c63c6a6885e0f674
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Feb 16 13:45:29 2012 -0800

    	PR c++/52248
    	* decl.c (define_label): Use timevar_cond_start/stop.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index f0ba181..28a7277 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -2947,9 +2947,9 @@  tree
 define_label (location_t location, tree name)
 {
   tree ret;
-  timevar_start (TV_NAME_LOOKUP);
+  bool running = timevar_cond_start (TV_NAME_LOOKUP);
   ret = define_label_1 (location, name);
-  timevar_stop (TV_NAME_LOOKUP);
+  timevar_cond_stop (TV_NAME_LOOKUP, running);
   return ret;
 }
 
diff --git a/gcc/testsuite/g++.dg/ext/timevar1.C b/gcc/testsuite/g++.dg/ext/timevar1.C
new file mode 100644
index 0000000..0d2d3f5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/timevar1.C
@@ -0,0 +1,12 @@ 
+// PR c++/52248
+// { dg-options "-ftime-report" }
+// { dg-prune-output "wall" }
+// { dg-prune-output "times" }
+// { dg-prune-output "TOTAL" }
+// { dg-prune-output "checks" }
+
+void
+foo ()
+{
+  goto lab;			// { dg-error "not defined" }
+}