aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/pt.cc7
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr15.C23
2 files changed, 30 insertions, 0 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 32640f8..e77c48e 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -30200,6 +30200,13 @@ maybe_aggr_guide (tree tmpl, tree init, vec<tree,va_gc> *args)
else if (TREE_CODE (init) == TREE_LIST)
{
int len = list_length (init);
+ for (tree binfo : BINFO_BASE_BINFOS (TYPE_BINFO (template_type)))
+ {
+ if (!len)
+ break;
+ parms = tree_cons (NULL_TREE, BINFO_TYPE (binfo), parms);
+ --len;
+ }
for (tree field = TYPE_FIELDS (template_type);
len;
--len, field = DECL_CHAIN (field))
diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr15.C b/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr15.C
new file mode 100644
index 0000000..16dc0f52
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr15.C
@@ -0,0 +1,23 @@
+// PR c++/115114
+// { dg-do compile { target c++20 } }
+
+struct X {} x;
+struct Y {} y;
+
+template<class T, class U>
+struct A : T {
+ U m;
+};
+
+using ty1 = decltype(A{x, 42}); // OK
+using ty1 = decltype(A(x, 42)); // OK, used to fail
+using ty1 = A<X, int>;
+
+template<class T, class U = int, class V = int>
+struct B : T, V {
+ U m = 42;
+};
+
+using ty2 = decltype(B{x, y}); // OK
+using ty2 = decltype(B(x, y)); // OK, used to fail
+using ty2 = B<X, int, Y>;