diff options
author | Marek Polacek <polacek@redhat.com> | 2019-01-02 22:20:45 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2019-01-02 22:20:45 +0000 |
commit | 29bb9224fcd5aaf7a126f49d2004858a9ba620d5 (patch) | |
tree | ee9f340d1450633b685ddf07e5e9c0177a1e23a4 /gcc/cp | |
parent | 5b81a980e6949bfb826bf5f0da7180f1f8e559d4 (diff) | |
download | gcc-29bb9224fcd5aaf7a126f49d2004858a9ba620d5.zip gcc-29bb9224fcd5aaf7a126f49d2004858a9ba620d5.tar.gz gcc-29bb9224fcd5aaf7a126f49d2004858a9ba620d5.tar.bz2 |
PR c++/88631 - CTAD failing for value-initialization.
* typeck2.c (build_functional_cast): Try deducing the template
arguments even if there are no arguments to deduce from.
* g++.dg/cpp1z/class-deduction59.C: New test.
From-SVN: r267533
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 15 |
2 files changed, 16 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fa03419..1ac5832 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -4,6 +4,10 @@ * call.c (convert_for_arg_passing): Only give warnings with tf_warning. * typeck.c (convert_for_assignment): Likewise. + PR c++/88631 - CTAD failing for value-initialization. + * typeck2.c (build_functional_cast): Try deducing the template + arguments even if there are no arguments to deduce from. + 2019-01-01 Jakub Jelinek <jakub@redhat.com> Update copyright years. diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 5dec117..03b24a9 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -2147,9 +2147,18 @@ build_functional_cast (tree exp, tree parms, tsubst_flags_t complain) } else if (!parms) { - if (complain & tf_error) - error ("cannot deduce template arguments for %qT from ()", anode); - return error_mark_node; + /* Even if there are no parameters, we might be able to deduce from + default template arguments. Pass TF_NONE so that we don't + generate redundant diagnostics. */ + type = do_auto_deduction (type, parms, anode, tf_none, + adc_variable_type); + if (type == error_mark_node) + { + if (complain & tf_error) + error ("cannot deduce template arguments for %qT from ()", + anode); + return error_mark_node; + } } else type = do_auto_deduction (type, parms, anode, complain, |