aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathans@fb.com>2020-01-14 11:12:40 -0800
committerNathan Sidwell <nathans@fb.com>2020-01-14 11:12:40 -0800
commita5a3c2dcf73aa245b0eb6f6cf56c4d03ab6056da (patch)
tree18e3cd58c2b67eeecbdb356a26d42d236122bab1
parent6bd65ad89c202aba3929b9a03ef7e84de873380a (diff)
downloadgcc-a5a3c2dcf73aa245b0eb6f6cf56c4d03ab6056da.zip
gcc-a5a3c2dcf73aa245b0eb6f6cf56c4d03ab6056da.tar.gz
gcc-a5a3c2dcf73aa245b0eb6f6cf56c4d03ab6056da.tar.bz2
[PR90916] ICE in retrieve specialization
https://gcc.gnu.org/ml/gcc-patches/2020-01/msg00809.html PR c++/90916 * pt.c (retrieve_specialization): Get the TI from the decl or the classtype as appropriate.
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c15
-rw-r--r--gcc/testsuite/g++.dg/template/pr90916.C8
3 files changed, 24 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 004ce0f..3cc7c48 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2020-01-14 Nathan Sidwell <nathan@acm.org>
+
+ PR c++/90916
+ * pt.c (retrieve_specialization): Get the TI from the decl or the
+ classtype as appropriate.
+
2020-01-14 David Malcolm <dmalcolm@redhat.com>
* cp-gimplify.c (source_location_table_entry_hash::empty_zero_p):
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index fa82eca..4fdc74f 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -1252,11 +1252,16 @@ retrieve_specialization (tree tmpl, tree args, hashval_t hash)
for (ovl_iterator iter (fns); iter; ++iter)
{
tree fn = *iter;
- if (DECL_TEMPLATE_INFO (fn) && DECL_TI_TEMPLATE (fn) == tmpl
- /* using-declarations can add base methods to the method vec,
- and we don't want those here. */
- && DECL_CONTEXT (fn) == class_specialization)
- return fn;
+ if (tree ti = (TREE_CODE (fn) == TYPE_DECL && !TYPE_DECL_ALIAS_P (fn)
+ ? TYPE_TEMPLATE_INFO (TREE_TYPE (fn))
+ : DECL_TEMPLATE_INFO (fn)))
+ if (TI_TEMPLATE (ti) == tmpl
+ /* using-declarations can bring in a different
+ instantiation of tmpl as a member of a different
+ instantiation of tmpl's class. We don't want those
+ here. */
+ && DECL_CONTEXT (fn) == class_specialization)
+ return fn;
}
return NULL_TREE;
}
diff --git a/gcc/testsuite/g++.dg/template/pr90916.C b/gcc/testsuite/g++.dg/template/pr90916.C
new file mode 100644
index 0000000..bdb7e7b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/pr90916.C
@@ -0,0 +1,8 @@
+// PR c++/90916 ICE in retrieve_specialization
+
+template <typename> struct S
+{
+ struct A;
+ struct f A ();
+};
+template class S <int>;