[C++ Patch] PR 88986 ("[7/8/9 Regression] ICE: tree check: expected tree that contains 'decl minimal' structure, have 'error_mark' in member_vec_binary_search, at cp/name-lookup.c:1136")

Paolo Carlini paolo.carlini@oracle.com
Fri Feb 1 20:52:00 GMT 2019


Hi,

I think that this ICE on invalid (and valid, for c++17+) can be in fact 
avoided by accepting in make_typename_type a TYPE_PACK_EXPANSION as 
context, thus by not triggering the "‘T ...’ is not a class" error. Not 
sure if a better fix would be something more general. Note, anyway, that 
we are asserting TYPE_P (context) thus TYPE_PACK_EXPANSIONs definitely 
get through beyond MAYBE_CLASS_TYPE_P.

Tested x86_64-linux.

Thanks, Paolo.

///////////////////////////

-------------- next part --------------
/cp
2019-02-01  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/88986
	* decl.c (make_typename_type): Allow for TYPE_PACK_EXPANSION as
	context (the first argument).

/testsuite
2019-02-01  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/88986
	* g++.dg/cpp1z/using4.C: New.

-------------- next part --------------
Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 268447)
+++ cp/decl.c	(working copy)
@@ -3816,7 +3816,9 @@ make_typename_type (tree context, tree name, enum
   gcc_assert (identifier_p (name));
   gcc_assert (TYPE_P (context));
 
-  if (!MAYBE_CLASS_TYPE_P (context))
+  if (TREE_CODE (context) == TYPE_PACK_EXPANSION)
+    /* This can happen for C++17 variadic using (c++/88986).  */;
+  else if (!MAYBE_CLASS_TYPE_P (context))
     {
       if (complain & tf_error)
 	error ("%q#T is not a class", context);
Index: testsuite/g++.dg/cpp1z/using4.C
===================================================================
--- testsuite/g++.dg/cpp1z/using4.C	(nonexistent)
+++ testsuite/g++.dg/cpp1z/using4.C	(working copy)
@@ -0,0 +1,8 @@
+// PR c++/88986
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+template<typename ...T> struct C : T... {
+  using typename T::type ...;  // { dg-warning "pack expansion" "" { target c++14_down } }
+  void f() { type value; }
+};


More information about the Gcc-patches mailing list