c++: Testcases [PR 98115]
authorNathan Sidwell <nathan@acm.org>
Thu, 3 Dec 2020 16:40:43 +0000 (08:40 -0800)
committerNathan Sidwell <nathan@acm.org>
Thu, 3 Dec 2020 16:43:32 +0000 (08:43 -0800)
These two testcases provide coverage for 98115, which doesn't trigger on all hosts.

PR c++/98115
PR c++/98116
gcc/testsuite/
* g++.dg/template/pr98115.C: New.
* g++.dg/template/pr98116.C: New.

gcc/testsuite/g++.dg/template/pr98115.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/pr98116.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/template/pr98115.C b/gcc/testsuite/g++.dg/template/pr98115.C
new file mode 100644 (file)
index 0000000..0bfc57a
--- /dev/null
@@ -0,0 +1,4 @@
+// PR 98115, dependent array types lead to specialization issues
+
+template <class> class Stringify;
+template <long N> class Stringify<const char[N]>;
diff --git a/gcc/testsuite/g++.dg/template/pr98116.C b/gcc/testsuite/g++.dg/template/pr98116.C
new file mode 100644 (file)
index 0000000..d3398d2
--- /dev/null
@@ -0,0 +1,29 @@
+// PR 98116, ICE with stripping typedef array type
+// { dg-do compile { target c++11 } }
+namespace std {
+struct is_convertible;
+template <typename _Tp> using remove_pointer_t = typename _Tp ::type;
+template <bool> struct enable_if;
+template <typename> void declval();
+template <bool _Cond> using enable_if_t = typename enable_if<_Cond>::type;
+template <typename, typename> class Trans_NS___cxx11_basic_string {
+  long _M_string_length;
+};
+} // namespace std
+struct string16_char_traits;
+template class std::Trans_NS___cxx11_basic_string<unsigned short,
+                                                  string16_char_traits>;
+template <typename, typename> using IsLegalDataConversion = std::is_convertible;
+template <typename Container, typename T>
+using ContainerHasConvertibleData = IsLegalDataConversion<
+    std::remove_pointer_t<decltype(std::declval<Container>)>, T>;
+template <typename Array, typename T, long>
+using EnableIfSpanCompatibleArray =
+    std::enable_if_t<ContainerHasConvertibleData<Array, T>::value>;
+template <int Extent> class span {
+  template <long N, EnableIfSpanCompatibleArray<
+                        const std::Trans_NS___cxx11_basic_string<
+                            unsigned short, string16_char_traits>[N],
+                        std::Trans_NS___cxx11_basic_string<short, int>, Extent>>
+  span();
+};