re PR c++/49156 ([C++0x] Error reporting routines re-entered)
authorJason Merrill <jason@redhat.com>
Thu, 26 May 2011 02:22:46 +0000 (22:22 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 26 May 2011 02:22:46 +0000 (22:22 -0400)
PR c++/49156
* error.c (dump_template_bindings): Set processing_template_decl
for a partial instantiation.

From-SVN: r174256

gcc/cp/ChangeLog
gcc/cp/error.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/error4.C [new file with mode: 0644]

index 1d0aa92e81c56a6bf4fb11b89a2679ca3ea9edda..06d51594bb8f8c32cc2e9ace4569e5db76ba1292 100644 (file)
@@ -1,5 +1,10 @@
 2011-05-25  Jason Merrill  <jason@redhat.com>
 
+       PR c++/44944
+       PR c++/49156
+       * error.c (dump_template_bindings): Set processing_template_decl
+       for a partial instantiation.
+
        PR c++/45401
        * decl.c (grokdeclarator): Don't change type when adding rvalue ref
        to another reference type.
index a6648cc664761cb120d97258f15f487b2e16afbc..8d7aaa71c85a302bec338fc534d472972654fa61 100644 (file)
@@ -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.  */
index e302c74527b832b18f10e0c8a4dc682d8286b786..07f4845ee01df5a8d3b11abb33143cca200046b0 100644 (file)
@@ -1,5 +1,7 @@
 2011-05-25  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/error4.C: New.
+
        * g++.dg/cpp0x/rv-restrict.C: New.
 
        * g++.dg/cpp0x/enum15.C: New.
diff --git a/gcc/testsuite/g++.dg/cpp0x/error4.C b/gcc/testsuite/g++.dg/cpp0x/error4.C
new file mode 100644 (file)
index 0000000..29a1cdd
--- /dev/null
@@ -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" }