diff mbox series

[committed] c++: Add testcases from PR c++/69694

Message ID 20200320170747.637679-1-ppalka@redhat.com
State New
Headers show
Series [committed] c++: Add testcases from PR c++/69694 | expand

Commit Message

Jeff Law via Gcc-patches March 20, 2020, 5:07 p.m. UTC
These testcases are compiling successfully since 7.1.

gcc/testsuite/ChangeLog:

	PR c++/69694
	* g++.dg/cpp0x/decltype74.C: New test.
	* g++.dg/cpp0x/decltype75.C: New test.
---
 gcc/testsuite/g++.dg/cpp0x/decltype74.C | 30 +++++++++++++++++++++++++
 gcc/testsuite/g++.dg/cpp0x/decltype75.C | 24 ++++++++++++++++++++
 2 files changed, 54 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/decltype74.C
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/decltype75.C
diff mbox series

Patch

diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype74.C b/gcc/testsuite/g++.dg/cpp0x/decltype74.C
new file mode 100644
index 00000000000..9ddd1c13e4f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/decltype74.C
@@ -0,0 +1,30 @@ 
+// PR c++/69694
+// { dg-do compile { target c++11 } }
+
+// n3911: TransformationTrait Alias `void_t`
+template<typename...> struct make_void { using type = void; };
+template<typename... Ts> using void_t = typename make_void<Ts...>::type;
+
+// std::declval<void*&>
+void*& declval_void();
+
+template<typename, typename = void> struct Fun;
+template<typename R>
+  struct Fun<R(), void>
+{
+  void fun();
+};
+template<typename Desc>
+  struct Fun<Desc, void_t<decltype (declval_void() = Desc::name)>>
+    : Fun<void()>
+{
+};
+
+struct Tag { static constexpr void* name = 0; };
+
+template<typename> void a()
+{
+  Fun<Tag>{}.fun();
+}
+
+void b() { a<int>(); }
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype75.C b/gcc/testsuite/g++.dg/cpp0x/decltype75.C
new file mode 100644
index 00000000000..0e97411af8b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/decltype75.C
@@ -0,0 +1,24 @@ 
+// PR c++/69694
+// This is a reduced version of decltype74.C.
+// { dg-do compile { target c++11 } }
+
+template<typename... Ts> using void_t = void;
+
+extern void *declval_void;
+
+template<typename, typename> struct Fun { };
+
+template<typename Desc>
+struct Fun<Desc, void_t<decltype (declval_void = Desc::name)>>
+{
+  void fun();
+};
+
+struct Tag { static constexpr void* name = 0; };
+
+template<typename> void a()
+{
+  Fun<Tag, void>{}.fun();
+}
+
+void b() { a<int>(); }