On Tue, Oct 4, 2016 at 11:11 PM, Jason Merrill <ja...@redhat.com> wrote: > On Tue, Oct 4, 2016 at 4:42 PM, Jason Merrill <ja...@redhat.com> wrote: >> C++17 adds the ability to omit the template arguments for a class >> template when declaring a variable with an initializer, much like auto >> but supporting a wider variety of initialization. This is intended to >> replace functions like make_tuple. >> >> Tested x86_64-pc-linux-gnu, applying to trunk. > > A few tweaks...
And another.
commit 38f26c12a24dae80a51daeb6f9401e99ce5920b7 Author: Jason Merrill <ja...@redhat.com> Date: Wed Oct 5 14:32:16 2016 -0400 * semantics.c (finish_compound_literal): Handle class placeholder. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 1d8f336..2467a3d 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2671,6 +2671,11 @@ finish_compound_literal (tree type, tree compound_literal, return error_mark_node; } + if (tree anode = type_uses_auto (type)) + if (CLASS_PLACEHOLDER_TEMPLATE (anode)) + type = do_auto_deduction (type, compound_literal, anode, complain, + adc_variable_type); + if (processing_template_decl) { TREE_TYPE (compound_literal) = type; diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction18.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction18.C new file mode 100644 index 0000000..ab2126e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction18.C @@ -0,0 +1,7 @@ +// { dg-options -std=c++1z } + +template<class T> struct S{S(T){}}; + +int main() { + S{1}; +}