PR c++/78282 - auto template and pack expansion
authorJason Merrill <jason@redhat.com>
Mon, 20 Feb 2017 06:06:39 +0000 (01:06 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 20 Feb 2017 06:06:39 +0000 (01:06 -0500)
* pt.c (find_parameter_packs_r): Don't walk into the type of
templates other than template template-parameters.

From-SVN: r245594

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp1y/auto-fn36.C [new file with mode: 0644]

index 7258348..b5def8c 100644 (file)
@@ -1,5 +1,9 @@
 2017-02-19  Jason Merrill  <jason@redhat.com>
 
+       PR c++/78282 - auto template and pack expansion
+       * pt.c (find_parameter_packs_r): Don't walk into the type of
+       templates other than template template-parameters.
+
        PR c++/79606 - ICE with this->base_member in NSDMI
        * class.c (build_base_path): Check processing_template_decl.
 
index 0a9f5d5..2cac24f 100644 (file)
@@ -3576,8 +3576,12 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data)
       *walk_subtrees = 0;
       return NULL_TREE;
 
-    case CONSTRUCTOR:
     case TEMPLATE_DECL:
+      if (!DECL_TEMPLATE_TEMPLATE_PARM_P (t))
+       return NULL_TREE;
+      gcc_fallthrough();
+
+    case CONSTRUCTOR:
       cp_walk_tree (&TREE_TYPE (t),
                    &find_parameter_packs_r, ppd, ppd->visited);
       return NULL_TREE;
diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn36.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn36.C
new file mode 100644 (file)
index 0000000..f89c092
--- /dev/null
@@ -0,0 +1,26 @@
+// PR c++/78282
+// { dg-do compile { target c++14 } }
+
+struct null_node
+{
+  null_node(const null_node&);
+};
+
+extern null_node null;
+
+template <typename T>
+auto get() { return null; }
+
+template <typename... Ts>
+struct inheritor: Ts...
+{
+  inheritor(const inheritor& outer)
+    : Ts(get<Ts...>())...
+    { }
+};
+
+void test()
+{
+  extern inheritor<null_node> example;
+  inheritor<null_node> result(example);
+}