This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/47336 (ICE re-entering diagnostic routines)


In this case, we ran into an access control error trying to print the meaning of a decltype while dumping instantiation context. The simplest answer is to just disable access control during that process rather than try to push into the right context.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 8b9688d5cdf39fb306257ea0d02a7e4239179913
Author: Jason Merrill <jason@redhat.com>
Date:   Sun May 22 15:54:43 2011 -0400

    	PR c++/47336
    	* error.c (dump_template_bindings): Suppress access control.

diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index e580fd9..a6648cc 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -313,7 +313,9 @@ dump_template_bindings (tree parms, tree args, VEC(tree,gc)* typenames)
       pp_cxx_whitespace (cxx_pp);
       pp_equal (cxx_pp);
       pp_cxx_whitespace (cxx_pp);
+      push_deferring_access_checks (dk_no_check);
       t = tsubst (t, args, tf_none, NULL_TREE);
+      pop_deferring_access_checks ();
       /* Strip typedefs.  We can't just use TFF_CHASE_TYPEDEF because
 	 pp_simple_type_specifier doesn't know about it.  */
       t = strip_typedefs (t);
diff --git a/gcc/testsuite/g++.dg/cpp0x/error3.C b/gcc/testsuite/g++.dg/cpp0x/error3.C
new file mode 100644
index 0000000..e7da961
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/error3.C
@@ -0,0 +1,24 @@
+// PR c++/47336
+// { dg-options -std=c++0x }
+
+template <typename T>
+void g(T t)
+{
+  t+1;				// { dg-error "no match" }
+}
+
+template <typename S>
+class C
+{
+  struct D {} d;
+public:
+  decltype(g(d)) h()
+  {
+    return g(d);
+  }
+};
+
+int main()
+{
+  C<int>().h();
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]