diff options
author | Nathan Sidwell <nathan@acm.org> | 2020-05-27 09:50:15 -0400 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2020-05-27 09:58:48 -0400 |
commit | ac9face8d26ea4b6aa72902ecc22e89ef00763c5 (patch) | |
tree | f9b99167a3a91f8d0b0e1cbecf079a1267e37581 /gcc | |
parent | 6c8e16aea85286721eb5689f9bcae09d36003cb1 (diff) | |
download | gcc-ac9face8d26ea4b6aa72902ecc22e89ef00763c5.zip gcc-ac9face8d26ea4b6aa72902ecc22e89ef00763c5.tar.gz gcc-ac9face8d26ea4b6aa72902ecc22e89ef00763c5.tar.bz2 |
c++: Revert alias template change [pr95263]
Turns out templates are more complicated than you think, even when you
know they are more complicated than you think. Reverting this change.
PR c++/95263
* pt.c (lookup_template_class_1): Restore alias template mutation.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/pt.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/pr95263.C | 23 |
2 files changed, 25 insertions, 15 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c17a038..4d9651a 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10062,21 +10062,8 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context, } } - /* Build template info for the new specialization. This can - overwrite the existing TEMPLATE_INFO for T (that points to - its instantiated TEMPLATE_DECL), with this one that points to - the most general template, but that's what we want. */ - - if (TYPE_ALIAS_P (t)) - { - /* This should already have been constructed during - instantiation of the alias decl. */ - tree ti = DECL_TEMPLATE_INFO (TYPE_NAME (t)); - gcc_checking_assert (template_args_equal (TI_ARGS (ti), arglist) - && TI_TEMPLATE (ti) == found); - } - else - SET_TYPE_TEMPLATE_INFO (t, build_template_info (found, arglist)); + // Build template info for the new specialization. + SET_TYPE_TEMPLATE_INFO (t, build_template_info (found, arglist)); elt.spec = t; slot = type_specializations->find_slot_with_hash (&elt, hash, INSERT); diff --git a/gcc/testsuite/g++.dg/template/pr95263.C b/gcc/testsuite/g++.dg/template/pr95263.C new file mode 100644 index 0000000..08a1b87 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr95263.C @@ -0,0 +1,23 @@ +// { dg-do compile { target c++11 } } +// PR C++/95263 +// ICE on alias template instantiation + +template <typename> class TPL { + template <int> using INT = int; +}; + +template <typename T> class Klass +{ +public: + template <int I> using ALIAS = typename TPL<T>::INT<I>; + + template <int> static void FUNC (); // OK + + template <int I, typename> static ALIAS<I> FUNC (); // SFINAE ICE +}; + +void Fn () +{ + Klass<int>::FUNC<0> (); +} + |