c++: Add testcases from PR c++/69694
authorPatrick Palka <ppalka@redhat.com>
Fri, 20 Mar 2020 17:06:21 +0000 (13:06 -0400)
committerPatrick Palka <ppalka@redhat.com>
Fri, 20 Mar 2020 17:06:21 +0000 (13:06 -0400)
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/ChangeLog
gcc/testsuite/g++.dg/cpp0x/decltype74.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/decltype75.C [new file with mode: 0644]

index c9fff884146bb2fd1dbe91c979fad1b206c2fbc2..76b93b570bb184491c09f5e7ee7c1169f67ab094 100644 (file)
@@ -1,3 +1,9 @@
+2020-03-20  Patrick Palka  <ppalka@redhat.com>
+
+       PR c++/69694
+       * g++.dg/cpp0x/decltype74.C: New test.
+       * g++.dg/cpp0x/decltype75.C: New test.
+
 2020-03-20  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>
             Andre Vieira  <andre.simoesdiasvieira@arm.com>
             Mihail Ionescu  <mihail.ionescu@arm.com>
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype74.C b/gcc/testsuite/g++.dg/cpp0x/decltype74.C
new file mode 100644 (file)
index 0000000..9ddd1c1
--- /dev/null
@@ -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 (file)
index 0000000..0e97411
--- /dev/null
@@ -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>(); }