aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2022-01-27 14:34:05 -0500
committerPatrick Palka <ppalka@redhat.com>2022-01-27 14:34:05 -0500
commitfd59d5d4a2ef8a97541a22399480bc1f8e82ceca (patch)
treead4d1b3788c93150f919284be6d313cdd4d5052f /gcc
parent7eb61a45a171d4f8f5bf4d4f469d42e657c69a6a (diff)
downloadgcc-fd59d5d4a2ef8a97541a22399480bc1f8e82ceca.zip
gcc-fd59d5d4a2ef8a97541a22399480bc1f8e82ceca.tar.gz
gcc-fd59d5d4a2ef8a97541a22399480bc1f8e82ceca.tar.bz2
c++: Add a couple of CTAD testcases [PR82632]
PR c++/82632 gcc/testsuite/ChangeLog: * g++.dg/cpp1z/class-deduction104.C: New test. * g++.dg/cpp1z/class-deduction105.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/class-deduction104.C17
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/class-deduction105.C17
2 files changed, 34 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction104.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction104.C
new file mode 100644
index 0000000..a34dea0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction104.C
@@ -0,0 +1,17 @@
+// PR c++/82632
+// { dg-do compile { target c++17 } }
+
+template<class T> struct Optional {
+ template<class U> Optional(U&&);
+};
+
+template<class A> Optional(A) -> Optional<A>;
+
+Optional opt(1729);
+Optional dupe(opt);
+
+using ty1 = decltype(opt);
+using ty1 = Optional<int>;
+
+using ty2 = decltype(dupe);
+using ty2 = Optional<int>;
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction105.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction105.C
new file mode 100644
index 0000000..73a9c6b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction105.C
@@ -0,0 +1,17 @@
+// PR c++/82632
+// { dg-do compile { target c++17 } }
+
+template<class T, int = 1>
+struct Foo {
+ Foo() = default;
+ Foo(const Foo&) = delete;
+
+ template<int I>
+ Foo(const Foo<T, I>&);
+};
+
+template<class T, int I>
+Foo(Foo<T,I>) -> Foo<T,I+1>;
+
+Foo<int> a;
+Foo b = a;