Hi,

On 04/30/2013 08:57 PM, Jason Merrill wrote:
On 04/30/2013 11:59 AM, Paolo Carlini wrote:
Currently, in some cases (see, eg, template/canon-type-9.C) we have that
id is true and DECLTYPE_TYPE_EXPR (t) is a TEMPLATE_PARM_INDEX but the
tsubst_copy_and_build call returns a TEMPLATE_PARM_INDEX again, not an
ADDR_EXPR, not an expression

Good point, this can happen for partial instantiations, when processing_template_decl is still true. We want to keep the DECLTYPE_TYPE around until the expression instantiates to something non-instantiation-dependent.
I see...
Hmm. Maybe the right answer is to just add a default: case to finish_decltype_type and trust that it will be right.
Ok. Then shall we do something like the below?

Thanks,
Paolo.

//////////////////
Index: cp/semantics.c
===================================================================
--- cp/semantics.c      (revision 198469)
+++ cp/semantics.c      (working copy)
@@ -5416,8 +5416,8 @@ finish_decltype_type (tree expr, bool id_expressio
           break;
 
         default:
-         gcc_unreachable ();
-          return error_mark_node;
+          type = TREE_TYPE (expr);
+          break;
         }
     }
   else
Index: testsuite/g++.dg/cpp0x/decltype53.C
===================================================================
--- testsuite/g++.dg/cpp0x/decltype53.C (revision 0)
+++ testsuite/g++.dg/cpp0x/decltype53.C (working copy)
@@ -0,0 +1,11 @@
+// PR c++/57092
+// { dg-do compile { target c++11 } }
+
+template <void (*F)(int)>
+class B {
+  decltype(F) v;
+};
+
+void foo(int) {}
+
+B<foo> o;

Reply via email to