diff options
author | Nathan Sidwell <nathan@acm.org> | 2020-05-19 13:29:19 -0700 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2020-05-19 13:29:19 -0700 |
commit | 74744bb1f2847b5b9ce3e97e0fec9c23bb0e499f (patch) | |
tree | 00c13ee7f64a1daa18e6617328f501cc6f6f7d13 /gcc | |
parent | 7cf3f604fb102ba67ce3abe7e97440b4ed0da92e (diff) | |
download | gcc-74744bb1f2847b5b9ce3e97e0fec9c23bb0e499f.zip gcc-74744bb1f2847b5b9ce3e97e0fec9c23bb0e499f.tar.gz gcc-74744bb1f2847b5b9ce3e97e0fec9c23bb0e499f.tar.bz2 |
c++: Alias template instantiation template info
I discovered that the alias instantiation machinery would setup
template_info, and then sometime later overwrite that with equivalent
info. This broke modules, because the template info, once set, is
logically immutable. Let's just not do that.
* pt.c (lookup_template_class_1): Do not reinit template_info of an
alias here.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/pt.c | 17 |
2 files changed, 20 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 87d1ce7..a81a620 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2020-05-19 Nathan Sidwell <nathan@acm.org> + + * pt.c (lookup_template_class_1): Do not reinit template_info of an + alias here. + 2020-05-18 Martin Sebor <msebor@redhat.com> PR c++/94923 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 4d9651a..c17a038 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10062,8 +10062,21 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context, } } - // Build template info for the new specialization. - SET_TYPE_TEMPLATE_INFO (t, build_template_info (found, arglist)); + /* 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)); elt.spec = t; slot = type_specializations->find_slot_with_hash (&elt, hash, INSERT); |