aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2016-10-05 14:57:45 -0400
committerJason Merrill <jason@gcc.gnu.org>2016-10-05 14:57:45 -0400
commit8b7033e0e1d10099b5c531a9a3b960fded60e24c (patch)
tree070b20236185dd89bcc429abca5c7b25ba83990b
parent2e21fd4d98882bd7f0d35a18c49cbc62d2d73d6e (diff)
downloadgcc-8b7033e0e1d10099b5c531a9a3b960fded60e24c.zip
gcc-8b7033e0e1d10099b5c531a9a3b960fded60e24c.tar.gz
gcc-8b7033e0e1d10099b5c531a9a3b960fded60e24c.tar.bz2
* semantics.c (finish_compound_literal): Handle class placeholder.
From-SVN: r240802
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/semantics.c5
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/class-deduction18.C7
3 files changed, 16 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index dd43d98..40cbb97 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index cae5afc..1b19f60 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};
+}