* pt.c (do_class_deduction): Handle 0 argument case.
authorJason Merrill <jason@redhat.com>
Wed, 22 Feb 2017 22:55:26 +0000 (17:55 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 22 Feb 2017 22:55:26 +0000 (17:55 -0500)
From-SVN: r245665

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp1z/class-deduction30.C [new file with mode: 0644]

index e69e2eafdf1d3baf6d5cbbd8d9135ed28e468ecd..9d6a9a67c421ecc2a640a6c865882cdcd667c136 100644 (file)
@@ -1,3 +1,7 @@
+2017-02-22  Jason Merrill  <jason@redhat.com>
+
+       * pt.c (do_class_deduction): Handle 0 argument case.
+
 2017-02-22  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/79664
index 5b0f62d3832b014ed9520f0d41a927eb5fd348e1..17175bad45eb69ffa7bbb791c3c86f77548eb47e 100644 (file)
@@ -25126,6 +25126,14 @@ do_class_deduction (tree ptype, tree tmpl, tree init, int flags,
 
   if (cands == NULL_TREE)
     {
+      if (args->length() == 0)
+       {
+         /* Try tmpl<>.  */
+         tree t = lookup_template_class (tmpl, NULL_TREE, NULL_TREE,
+                                         NULL_TREE, false, tf_none);
+         if (t != error_mark_node)
+           return t;
+       }
       error ("cannot deduce template arguments for %qT, as it has "
             "no deduction guides or user-declared constructors", type);
       return error_mark_node;
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction30.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction30.C
new file mode 100644 (file)
index 0000000..e182803
--- /dev/null
@@ -0,0 +1,6 @@
+// { dg-options -std=c++1z }
+
+template <class T = void> struct A { };
+
+A a{};
+