[C++ Patch] PR 56060

Paolo Carlini paolo.carlini@oracle.com
Sun Oct 6 00:55:00 GMT 2013


Hi,

in this old (Jakub figured out it already existed in 2007!) ICE on 
invalid, the problem happens in type_dependent_expression_p: the code 
for unknown_type_node as TREE_TYPE of the expression doesn't handle 
EXPR_PACK_EXPANSION as TREE_CODE.

It seems to me that we simply have to look inside the expression via 
PACK_EXPANSION_PATTERN: in the testcase, for "bar<U> ..." as expression 
the _PATTERN is a TEMPLATE_ID_EXPR which then is normally handled. 
Tested x86_64-linux.

Thanks,
Paolo.

////////////////////
-------------- next part --------------
/cp
2013-10-06  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/56060
	* pt.c (type_dependent_expression_p): Handle EXPR_PACK_EXPANSION.

/testsuite
2013-10-06  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/56060
	* g++.dg/cpp0x/variadic144.C: New.
-------------- next part --------------
Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 203219)
+++ cp/pt.c	(working copy)
@@ -20405,6 +20405,8 @@ type_dependent_expression_p (tree expression)
 
       if (BASELINK_P (expression))
 	expression = BASELINK_FUNCTIONS (expression);
+      else if (TREE_CODE (expression) == EXPR_PACK_EXPANSION)
+	expression = PACK_EXPANSION_PATTERN (expression);
 
       if (TREE_CODE (expression) == TEMPLATE_ID_EXPR)
 	{
Index: testsuite/g++.dg/cpp0x/variadic144.C
===================================================================
--- testsuite/g++.dg/cpp0x/variadic144.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/variadic144.C	(working copy)
@@ -0,0 +1,15 @@
+// PR c++/56060
+// { dg-do compile { target c++11 } }
+
+template<typename T> struct baz { };
+template<typename T> T bar();
+
+template<typename T, typename ... U>
+baz<decltype(bar<T>()(bar<U> ...))>  // { dg-error "cannot be used" }
+foo();
+
+int main()
+{
+  foo<int>();     // { dg-error "no matching" }
+  return 0;
+}


More information about the Gcc-patches mailing list