* semantics.c (finish_compound_literal): Handle class placeholder.
authorJason Merrill <jason@redhat.com>
Wed, 5 Oct 2016 18:57:45 +0000 (14:57 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 5 Oct 2016 18:57:45 +0000 (14:57 -0400)
From-SVN: r240802

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

index dd43d9880a90b55521fe9ecc20474dbdecc59663..40cbb97a6c287cda4e86a2eb29e218d22707c709 100644 (file)
@@ -1,3 +1,7 @@
+2016-10-05  Jason Merrill  <jason@redhat.com>
+
+       * semantics.c (finish_compound_literal): Handle class placeholder.
+
 2016-10-05  Marek Polacek  <polacek@redhat.com>
 
        Implement P0305R1, Selection statements with initializer.
index cae5afc0d4be747f605e9a726b4513c8be10b221..1b19f600cb7e23d7dcbf9579dc105d205cb9673d 100644 (file)
@@ -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 (file)
index 0000000..ab2126e
--- /dev/null
@@ -0,0 +1,7 @@
+// { dg-options -std=c++1z }
+
+template<class T> struct S{S(T){}};
+
+int main() {
+  S{1};
+}