diff options
author | Patrick Palka <ppalka@redhat.com> | 2022-09-26 11:30:17 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2022-09-26 11:30:17 -0400 |
commit | 099a66498bf7a40764002793eba66c881a251b76 (patch) | |
tree | 4876e589390d43536b3b6e227fbb6ed9f54a18e1 /gcc/cp/module.cc | |
parent | 1b5432b401934962affe32cd7e42e864224e8062 (diff) | |
download | gcc-099a66498bf7a40764002793eba66c881a251b76.zip gcc-099a66498bf7a40764002793eba66c881a251b76.tar.gz gcc-099a66498bf7a40764002793eba66c881a251b76.tar.bz2 |
c++ modules: variable template partial spec fixes [PR107033]
In r13-2775-g32d8123cd6ce87 I missed that we need to adjust the call to
add_mergeable_specialization in the MK_partial case to correctly handle
variable template partial specializations (it currently assumes we're
always dealing with one for a class template). This fixes an ICE when
converting the testcase from that commit to use an importable header
instead of a named module.
PR c++/107033
gcc/cp/ChangeLog:
* module.cc (trees_in::decl_value): In the MK_partial case for
a variable template partial specialization, pass decl_p=true to
add_mergeable_specialization, and set spec to the VAR_DECL not
the TEMPLATE_DECL.
* pt.cc (add_mergeable_specialization): For a variable template
partial specialization, set the TREE_TYPE of the new
DECL_TEMPLATE_SPECIALIZATIONS node to the TREE_TYPE of the
VAR_DECL not the VAR_DECL itself.
gcc/testsuite/ChangeLog:
* g++.dg/modules/partial-2.cc, g++.dg/modules/partial-2.h: New
files, factored out from ...
* g++.dg/modules/partial-2_a.C, g++.dg/modules/partial-2_b.C: ...
these.
* g++.dg/modules/partial-2_c.H: New test.
* g++.dg/modules/partial-2_d.C: New test.
Diffstat (limited to 'gcc/cp/module.cc')
-rw-r--r-- | gcc/cp/module.cc | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index f23832c..7496df5 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -8185,13 +8185,18 @@ trees_in::decl_value () /* Set the TEMPLATE_DECL's type. */ TREE_TYPE (decl) = TREE_TYPE (inner); - if (mk & MK_template_mask - || mk == MK_partial) + /* Add to specialization tables now that constraints etc are + added. */ + if (mk == MK_partial) { - /* Add to specialization tables now that constraints etc are - added. */ - bool is_type = mk == MK_partial || !(mk & MK_tmpl_decl_mask); - + bool is_type = TREE_CODE (inner) == TYPE_DECL; + spec.spec = is_type ? type : inner; + add_mergeable_specialization (!is_type, false, + &spec, decl, spec_flags); + } + else if (mk & MK_template_mask) + { + bool is_type = !(mk & MK_tmpl_decl_mask); spec.spec = is_type ? type : mk & MK_tmpl_tmpl_mask ? inner : decl; add_mergeable_specialization (!is_type, !is_type && mk & MK_tmpl_alias_mask, |