aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-12-07 07:02:58 -0800
committerNathan Sidwell <nathan@acm.org>2020-12-07 08:49:33 -0800
commit9d0eb0ae948f0fbee208cfb9a86133abea650f81 (patch)
tree5d307f9a0ab43a547195ce1d7f76516e402cfefd /gcc/testsuite
parent92e563d91b012f09da8fd152e934f6b964ae49cb (diff)
downloadgcc-9d0eb0ae948f0fbee208cfb9a86133abea650f81.zip
gcc-9d0eb0ae948f0fbee208cfb9a86133abea650f81.tar.gz
gcc-9d0eb0ae948f0fbee208cfb9a86133abea650f81.tar.bz2
c++: check alias match for specializations [PR98116]
This fixes the underlying problem my recent (backedout) changes to array type creation uncovered. We had paths through structural_comptypes that ignored alias templates, even when significant. This adds the necessary checks. PR c++/98116 gcc/cp/ * typeck.c (structural_comptypes): Move early outs to comptype. Always check template-alias match when comparing_specializations. (comptypes): Do early out checking here. gcc/testsuite/ * g++.dg/template/pr98116.C: Remove dg-ice. * g++.dg/template/pr98116-2.C: New.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/g++.dg/template/pr98116-2.C34
-rw-r--r--gcc/testsuite/g++.dg/template/pr98116.C5
2 files changed, 36 insertions, 3 deletions
diff --git a/gcc/testsuite/g++.dg/template/pr98116-2.C b/gcc/testsuite/g++.dg/template/pr98116-2.C
new file mode 100644
index 0000000..fd12bb1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/pr98116-2.C
@@ -0,0 +1,34 @@
+// PR 98116, ICE with stripping typedef array type
+// { dg-do compile { target c++11 } }
+// { dg-additional-options {--param=hash-table-verification-limit=10000000 -fchecking=2} }
+
+// We got confused by alias templates that alias the same type. Their
+// hashes were different (good), but they compared equal (bad)
+
+namespace std {
+typedef int 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<!!sizeof (ContainerHasConvertibleData<Array, T>)>;
+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();
+};
diff --git a/gcc/testsuite/g++.dg/template/pr98116.C b/gcc/testsuite/g++.dg/template/pr98116.C
index 874c590..7d54314 100644
--- a/gcc/testsuite/g++.dg/template/pr98116.C
+++ b/gcc/testsuite/g++.dg/template/pr98116.C
@@ -1,10 +1,9 @@
// PR 98116, ICE with stripping typedef array type
// { dg-do compile { target c++11 } }
// { dg-additional-options {--param=hash-table-verification-limit=10000000 -fchecking=2} }
-// { dg-ice "spec_hasher::equal" }
-// We get confused by alias templates that alias the same type.
-// { dg-prune-output "hash table checking failed" }
+// We got confused by alias templates that alias the same type. Their
+// hashes were different (good), but they compared equal (bad)
namespace std {
struct is_convertible;