diff mbox series

[pushed] c++: template template parm pack expansion [PR100372]

Message ID 20210519002643.1426855-1-jason@redhat.com
State New
Headers show
Series [pushed] c++: template template parm pack expansion [PR100372] | expand

Commit Message

Jason Merrill May 19, 2021, 12:26 a.m. UTC
Here we have a pack expansion of a template template parameter pack, of
which the pattern is a TEMPLATE_DECL, which strip_typedefs doesn't want to
see.

Tested x86_64-pc-linux-gnu, applying to trunk.

	PR c++/100372

gcc/cp/ChangeLog:

	* tree.c (strip_typedefs): Only look at the pattern of a
	TYPE_PACK_EXPANSION if it's a type.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/alias-decl-ttp1.C: New test.
---
 gcc/cp/tree.c                                | 19 ++++++++++++-------
 gcc/testsuite/g++.dg/cpp0x/alias-decl-ttp1.C |  6 ++++++
 2 files changed, 18 insertions(+), 7 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-ttp1.C


base-commit: a8daf9a19a5eae6b98acede14bb6c27b2e0038e0
diff mbox series

Patch

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 35faeff065a..72f498f4b3b 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1741,13 +1741,18 @@  strip_typedefs (tree t, bool *remove_attributes, unsigned int flags)
       result = finish_underlying_type (type);
       break;
     case TYPE_PACK_EXPANSION:
-      type = strip_typedefs (PACK_EXPANSION_PATTERN (t),
-			     remove_attributes, flags);
-      if (type != PACK_EXPANSION_PATTERN (t))
-	{
-	  result = copy_node (t);
-	  PACK_EXPANSION_PATTERN (result) = type;
-	}
+      {
+	tree pat = PACK_EXPANSION_PATTERN (t);
+	if (TYPE_P (pat))
+	  {
+	    type = strip_typedefs (pat, remove_attributes, flags);
+	    if (type != pat)
+	      {
+		result = copy_node (t);
+		PACK_EXPANSION_PATTERN (result) = type;
+	      }
+	  }
+      }
       break;
     default:
       break;
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-ttp1.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-ttp1.C
new file mode 100644
index 00000000000..d1af8d1bbb2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-ttp1.C
@@ -0,0 +1,6 @@ 
+// PR c++/100372
+// { dg-do compile { target c++14 } }
+
+template <bool> using enable_if_t = int;
+template <class> bool has_P_match_v;
+template <template <class> class... List> enable_if_t<has_P_match_v<List...>> a;