From 349c635163ea53a276c755a7bbcb278e1eefef3e Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 22 Feb 2017 17:55:26 -0500 Subject: [PATCH] * pt.c (do_class_deduction): Handle 0 argument case. From-SVN: r245665 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/pt.c | 8 ++++++++ gcc/testsuite/g++.dg/cpp1z/class-deduction30.C | 6 ++++++ 3 files changed, 18 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1z/class-deduction30.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e69e2eafdf1..9d6a9a67c42 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2017-02-22 Jason Merrill + + * pt.c (do_class_deduction): Handle 0 argument case. + 2017-02-22 Jakub Jelinek PR c++/79664 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 5b0f62d3832..17175bad45e 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 index 00000000000..e182803ae79 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction30.C @@ -0,0 +1,6 @@ +// { dg-options -std=c++1z } + +template struct A { }; + +A a{}; + -- 2.30.2