diff mbox

C++ PATCH for C++17 class template placeholders

Message ID CADzB+2n2p=_cq5nXfqSEQmarVN-5Rh3p=RBCkVk2jGFEtzyrug@mail.gmail.com
State New
Headers show

Commit Message

Jason Merrill Oct. 5, 2016, 6:58 p.m. UTC
On Tue, Oct 4, 2016 at 11:11 PM, Jason Merrill <jason@redhat.com> wrote:
> On Tue, Oct 4, 2016 at 4:42 PM, Jason Merrill <jason@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 <jason@redhat.com>
Date:   Wed Oct 5 14:32:16 2016 -0400

            * semantics.c (finish_compound_literal): Handle class placeholder.
diff mbox

Patch

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};
+}