diff mbox series

[COMMITTED] c++: Add testcase for [PR81339]

Message ID 20200724184400.3928062-1-ppalka@redhat.com
State New
Headers show
Series [COMMITTED] c++: Add testcase for [PR81339] | expand

Commit Message

Patrick Palka July 24, 2020, 6:44 p.m. UTC
We correctly reject this testcase since r11-434, i.e. since the fix for
PR c++/57943.

gcc/testsuite/ChangeLog:

	PR c++/81339
	* g++.dg/cpp0x/decltype78.C: New test.
---
 gcc/testsuite/g++.dg/cpp0x/decltype78.C | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/decltype78.C
diff mbox series

Patch

diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype78.C b/gcc/testsuite/g++.dg/cpp0x/decltype78.C
new file mode 100644
index 00000000000..6f4e5b4ad3b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/decltype78.C
@@ -0,0 +1,24 @@ 
+// PR c++/81339
+// { dg-do compile { target c++11 } }
+
+struct true_type { static const bool value = true; };
+struct false_type { static const bool value = false; };
+
+template <typename T>
+struct IsDefaultConstructibleT
+{
+    // using T here (instead of U) should be an error
+    template <typename U, typename = decltype(T())> // { dg-error "deleted" }
+      static true_type test(void*);
+
+    template <typename U>
+      static false_type test(...);
+
+    static constexpr bool value = decltype(test<T>(nullptr))::value;
+};
+
+struct S {
+  S() = delete;
+};
+
+static_assert( IsDefaultConstructibleT<S>::value, "" ); // { dg-error "assertion failed" }