Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr1.C

raw
1 // Testcase from P1816R0
2 // { dg-do compile { target c++20 } }
3
4 template <typename T>
5 struct S {
6 T x;
7 T y;
8 };
9
10 S s = { 1, 2 };
11
12 template <typename T>
13 struct C {
14 S<T> s;
15 T t;
16 };
17 template <typename T>
18 struct D {
19 S<int> s;
20 T t;
21 };
22 C c1 = {1, 2}; // { dg-error "" "deduction failed" }
23 C c2 = {1, 2, 3}; // { dg-error "" "deduction failed" }
24 C c3 = {{1u, 2u}, 3}; // { dg-bogus "" "OK, C<int> deduced" }
25 D d1 = {1, 2}; // { dg-error "" "deduction failed" }
26 D d2 = {1, 2, 3}; // { dg-bogus "" "OK, braces elided, D<int> deduced" }
27 template <typename T>
28 struct I {
29 using type = T;
30 };
31 template <typename T>
32 struct E {
33 typename I<T>::type i;
34 T t;
35 };
36 E e1 = {1, 2}; // { dg-bogus "" "OK, E<int> deduced" }