re PR c++/85883 (class template argument deduction fails in new-expression)
PR c++/85883 * init.c (build_new): Handle deducing a class with new with more than one argument. * g++.dg/cpp1z/class-deduction55.C: New test. * g++.dg/cpp1z/class-deduction56.C: New test. * g++.dg/cpp1z/class-deduction57.C: New test. From-SVN: r260901
This commit is contained in:
parent
5baa6f8ebd
commit
009bb506b1
@ -1,3 +1,9 @@
|
||||
2018-05-29 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR c++/85883
|
||||
* init.c (build_new): Handle deducing a class with new
|
||||
with more than one argument.
|
||||
|
||||
2018-05-29 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/85952
|
||||
|
@ -3586,11 +3586,27 @@ build_new (vec<tree, va_gc> **placement, tree type, tree nelts,
|
||||
if (auto_node)
|
||||
{
|
||||
tree d_init = NULL_TREE;
|
||||
if (vec_safe_length (*init) == 1)
|
||||
const size_t len = vec_safe_length (*init);
|
||||
/* E.g. new auto(x) must have exactly one element, or
|
||||
a {} initializer will have one element. */
|
||||
if (len == 1)
|
||||
{
|
||||
d_init = (**init)[0];
|
||||
d_init = resolve_nondeduced_context (d_init, complain);
|
||||
}
|
||||
/* For the rest, e.g. new A(1, 2, 3), create a list. */
|
||||
else if (len > 1)
|
||||
{
|
||||
unsigned int n;
|
||||
tree t;
|
||||
tree *pp = &d_init;
|
||||
FOR_EACH_VEC_ELT (**init, n, t)
|
||||
{
|
||||
t = resolve_nondeduced_context (t, complain);
|
||||
*pp = build_tree_list (NULL_TREE, t);
|
||||
pp = &TREE_CHAIN (*pp);
|
||||
}
|
||||
}
|
||||
type = do_auto_deduction (type, d_init, auto_node, complain);
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,10 @@
|
||||
2018-05-29 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR c++/85883
|
||||
* g++.dg/cpp1z/class-deduction55.C: New test.
|
||||
* g++.dg/cpp1z/class-deduction56.C: New test.
|
||||
* g++.dg/cpp1z/class-deduction57.C: New test.
|
||||
|
||||
2018-05-29 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/85952
|
||||
|
15
gcc/testsuite/g++.dg/cpp1z/class-deduction55.C
Normal file
15
gcc/testsuite/g++.dg/cpp1z/class-deduction55.C
Normal file
@ -0,0 +1,15 @@
|
||||
// PR c++/85883
|
||||
// { dg-options -std=c++17 }
|
||||
|
||||
template <typename T>
|
||||
struct Bar
|
||||
{
|
||||
Bar(T) { }
|
||||
};
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
auto x = Bar(1);
|
||||
auto y = new Bar(3);
|
||||
}
|
15
gcc/testsuite/g++.dg/cpp1z/class-deduction56.C
Normal file
15
gcc/testsuite/g++.dg/cpp1z/class-deduction56.C
Normal file
@ -0,0 +1,15 @@
|
||||
// PR c++/85883
|
||||
// { dg-options -std=c++17 }
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct Bar
|
||||
{
|
||||
Bar(T1, T2) { }
|
||||
};
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
auto x = Bar(1, 2);
|
||||
auto y = new Bar(3, 4);
|
||||
}
|
15
gcc/testsuite/g++.dg/cpp1z/class-deduction57.C
Normal file
15
gcc/testsuite/g++.dg/cpp1z/class-deduction57.C
Normal file
@ -0,0 +1,15 @@
|
||||
// PR c++/85883
|
||||
// { dg-options -std=c++17 }
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
struct Bar
|
||||
{
|
||||
Bar(T1, T2, T3) { }
|
||||
};
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
auto x = Bar(1, 2, 3);
|
||||
auto y = new Bar(3, 4, 5);
|
||||
}
|
Loading…
Reference in New Issue
Block a user