diff options
author | Jason Merrill <jason@redhat.com> | 2023-05-02 14:54:46 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2023-05-02 18:53:06 -0400 |
commit | c912fe765a1378f1b09d1095ab4e093d5205122a (patch) | |
tree | 3a318562d74fe869684247b630226e3a16d5c51c /gcc/DATESTAMP | |
parent | 33020780a9699f1146eeed61783cec89fde337a0 (diff) | |
download | gcc-c912fe765a1378f1b09d1095ab4e093d5205122a.zip gcc-c912fe765a1378f1b09d1095ab4e093d5205122a.tar.gz gcc-c912fe765a1378f1b09d1095ab4e093d5205122a.tar.bz2 |
c++: simplify member template substitution
I noticed that for member class templates of a class template we were
unnecessarily substituting both the template and its type. Avoiding that
duplication speeds compilation of this silly testcase from ~12s to ~9s on my
laptop. It's unlikely to make a difference on any real code, but the
simplification is also nice.
We still need to clear CLASSTYPE_USE_TEMPLATE on the partial instantiation
of the template class, but it makes more sense to do that in
tsubst_template_decl anyway.
#define NC(X) \
template <class U> struct X##1; \
template <class U> struct X##2; \
template <class U> struct X##3; \
template <class U> struct X##4; \
template <class U> struct X##5; \
template <class U> struct X##6;
#define NC2(X) NC(X##a) NC(X##b) NC(X##c) NC(X##d) NC(X##e) NC(X##f)
#define NC3(X) NC2(X##A) NC2(X##B) NC2(X##C) NC2(X##D) NC2(X##E)
template <int I> struct A
{
NC3(am)
};
template <class...Ts> void sink(Ts...);
template <int...Is> void g()
{
sink(A<Is>()...);
}
template <int I> void f()
{
g<__integer_pack(I)...>();
}
int main()
{
f<1000>();
}
gcc/cp/ChangeLog:
* pt.cc (instantiate_class_template): Skip the RECORD_TYPE
of a class template.
(tsubst_template_decl): Clear CLASSTYPE_USE_TEMPLATE.
Diffstat (limited to 'gcc/DATESTAMP')
0 files changed, 0 insertions, 0 deletions