On 05/11/2012 04:48 AM, Gabriel Dos Reis wrote:
On Thu, May 10, 2012 at 6:40 PM, Paolo Carlini<paolo.carl...@oracle.com>  wrote:
Hi,

an ICE on invalid (per Daniel's analysis): when r is NULL_TREE the next
DECL_CONTEXT (r) can only crash. Plus a garbled error message because
pp_cxx_simple_type_specifier doesn't handle BOUND_TEMPLATE_TEMPLATE_PARM.

Tested x86_64-linux.

Thanks,
Paolo.

///////////////////////////
Stylistically, I would write

    if (r == NULL)

or

   if (r == NULL_TREE)

Patch OK with that change.
Thanks Gaby. Then I guess I'm going to commit the variant with NULL_TREE, I like it a tad better because after all formally these functions return trees. And consistently I change another instance only a few lines above.

Thanks,
Paolo.

/////////////////////
Index: testsuite/g++.dg/cpp0x/variadic132.C
===================================================================
--- testsuite/g++.dg/cpp0x/variadic132.C        (revision 0)
+++ testsuite/g++.dg/cpp0x/variadic132.C        (revision 0)
@@ -0,0 +1,27 @@
+// PR c++/53305
+// { dg-do compile { target c++11 } }
+
+template<class... Ts> struct tuple { };
+
+struct funct
+{
+  template<class... argTs>
+  int operator()(argTs...);
+};
+
+template<class...> class test;
+
+template<template <class...> class tp,
+        class... arg1Ts, class... arg2Ts>
+class test<tp<arg1Ts...>, tp<arg2Ts...>>
+{
+  template<class func, class...arg3Ts>
+    auto test2(func fun, arg1Ts... arg1s, arg3Ts... arg3s)
+    -> decltype(fun(arg1s..., arg3s...));
+};
+
+int main()
+{
+  test<tuple<>, tuple<char,int>> t2;
+  t2.test2(funct(), 'a', 2);  // { dg-error "no matching function" }
+}
Index: cp/cxx-pretty-print.c
===================================================================
--- cp/cxx-pretty-print.c       (revision 187376)
+++ cp/cxx-pretty-print.c       (working copy)
@@ -1261,6 +1261,7 @@ pp_cxx_simple_type_specifier (cxx_pretty_printer *
     case TEMPLATE_TYPE_PARM:
     case TEMPLATE_TEMPLATE_PARM:
     case TEMPLATE_PARM_INDEX:
+    case BOUND_TEMPLATE_TEMPLATE_PARM:
       pp_cxx_unqualified_id (pp, t);
       break;
 
Index: cp/pt.c
===================================================================
--- cp/pt.c     (revision 187376)
+++ cp/pt.c     (working copy)
@@ -12066,7 +12066,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t com
     case PARM_DECL:
       r = retrieve_local_specialization (t);
 
-      if (r == NULL)
+      if (r == NULL_TREE)
        {
          tree c;
 
@@ -12084,6 +12084,8 @@ tsubst_copy (tree t, tree args, tsubst_flags_t com
             not the following PARM_DECLs that are chained to T.  */
          c = copy_node (t);
          r = tsubst_decl (c, args, complain);
+         if (r == NULL_TREE)
+           return error_mark_node;
          /* Give it the template pattern as its context; its true context
             hasn't been instantiated yet and this is good enough for
             mangling.  */

Reply via email to