Patchwork C++ PATCH for c++/44944 and c++/49156 (ICE re-entering error reporting routines)

login
register
mail settings
Submitter Jason Merrill
Date May 26, 2011, 12:18 a.m.
Message ID <4DDD9C55.5060409@redhat.com>
Download mbox | patch
Permalink /patch/97476/
State New
Headers show

Comments

Jason Merrill - May 26, 2011, 12:18 a.m.
Another case where we were hitting errors while trying to print template 
argument/typename bindings.  In this case, the problem was that we were 
printing a partially instantiated template and processing_template_decl 
wasn't set.

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

Patch

commit b01a76f5f664101d5dce453bf42fdd74aa5ed207
Author: Jason Merrill <jason@redhat.com>
Date:   Wed May 25 16:40:19 2011 -0400

    	PR c++/49156
    	* error.c (dump_template_bindings): Set processing_template_decl
    	for a partial instantiation.

diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index a6648cc..8d7aaa7 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -307,6 +307,7 @@  dump_template_bindings (tree parms, tree args, VEC(tree,gc)* typenames)
 
   FOR_EACH_VEC_ELT (tree, typenames, i, t)
     {
+      bool dependent = uses_template_parms (args);
       if (need_comma)
 	pp_separate_with_comma (cxx_pp);
       dump_type (t, TFF_PLAIN_IDENTIFIER);
@@ -314,7 +315,11 @@  dump_template_bindings (tree parms, tree args, VEC(tree,gc)* typenames)
       pp_equal (cxx_pp);
       pp_cxx_whitespace (cxx_pp);
       push_deferring_access_checks (dk_no_check);
+      if (dependent)
+	++processing_template_decl;
       t = tsubst (t, args, tf_none, NULL_TREE);
+      if (dependent)
+	--processing_template_decl;
       pop_deferring_access_checks ();
       /* Strip typedefs.  We can't just use TFF_CHASE_TYPEDEF because
 	 pp_simple_type_specifier doesn't know about it.  */
diff --git a/gcc/testsuite/g++.dg/cpp0x/error4.C b/gcc/testsuite/g++.dg/cpp0x/error4.C
new file mode 100644
index 0000000..29a1cdd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/error4.C
@@ -0,0 +1,22 @@ 
+// PR c++/49156
+// { dg-options -std=c++0x }
+
+template<typename T> T declval();
+
+template<typename T>
+struct S {
+
+  template<typename U>
+    static U get(const volatile T&);
+
+  template<typename U>
+    static decltype(*declval<U>()) get(...);
+
+  typedef decltype(get<T>(declval<T>())) type; // { dg-error "no match" }
+};
+
+struct X { };
+
+S<X>::type x;
+
+// { dg-prune-output "note" }