summaryrefslogtreecommitdiff
path: root/test/SemaCXX/cxx0x-defaulted-functions.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-11-25 19:07:40 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-11-25 19:07:40 +0000
commit17c7957f023f02fc2c88f51f8908c19b52609275 (patch)
treec654618ff2d38e26916b49614d89fe01f4a4818d /test/SemaCXX/cxx0x-defaulted-functions.cpp
parentc477790a57f44875b9de2043f2eb47dff2d20133 (diff)
Diffstat (limited to 'test/SemaCXX/cxx0x-defaulted-functions.cpp')
-rw-r--r--test/SemaCXX/cxx0x-defaulted-functions.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/SemaCXX/cxx0x-defaulted-functions.cpp b/test/SemaCXX/cxx0x-defaulted-functions.cpp
index 16e20ff4964d..7ec9726095cb 100644
--- a/test/SemaCXX/cxx0x-defaulted-functions.cpp
+++ b/test/SemaCXX/cxx0x-defaulted-functions.cpp
@@ -208,3 +208,38 @@ int fn() {
t = true;
}
}
+
+namespace dependent_classes {
+template <bool B, typename X, typename Y>
+struct conditional;
+
+template <typename X, typename Y>
+struct conditional<true, X, Y> { typedef X type; };
+
+template <typename X, typename Y>
+struct conditional<false, X, Y> { typedef Y type; };
+
+template<bool B> struct X {
+ X();
+
+ // B == false triggers error for = default.
+ using T = typename conditional<B, const X &, int>::type;
+ X(T) = default; // expected-error {{only special member functions}}
+
+ // Either value of B creates a constructor that can be default
+ using U = typename conditional<B, X&&, const X&>::type;
+ X(U) = default;
+};
+
+X<true> x1;
+X<false> x2; // expected-note {{in instantiation}}
+
+template <typename Type>
+class E {
+ explicit E(const int &) = default;
+};
+
+template <typename Type>
+E<Type>::E(const int&) {} // expected-error {{definition of explicitly defaulted function}}
+
+}