forked from OSchip/llvm-project
[modules] Merge variable template specializations.
This commit is contained in:
parent
954ba6045d
commit
63814be4fa
|
@ -2382,13 +2382,17 @@ ASTDeclReader::VisitVarTemplateSpecializationDeclImpl(
|
||||||
if (writtenAsCanonicalDecl) {
|
if (writtenAsCanonicalDecl) {
|
||||||
auto *CanonPattern = readDeclAs<VarTemplateDecl>();
|
auto *CanonPattern = readDeclAs<VarTemplateDecl>();
|
||||||
if (D->isCanonicalDecl()) { // It's kept in the folding set.
|
if (D->isCanonicalDecl()) { // It's kept in the folding set.
|
||||||
// FIXME: If it's already present, merge it.
|
VarTemplateSpecializationDecl *CanonSpec;
|
||||||
if (auto *Partial = dyn_cast<VarTemplatePartialSpecializationDecl>(D)) {
|
if (auto *Partial = dyn_cast<VarTemplatePartialSpecializationDecl>(D)) {
|
||||||
CanonPattern->getCommonPtr()->PartialSpecializations
|
CanonSpec = CanonPattern->getCommonPtr()
|
||||||
.GetOrInsertNode(Partial);
|
->PartialSpecializations.GetOrInsertNode(Partial);
|
||||||
} else {
|
} else {
|
||||||
|
CanonSpec =
|
||||||
CanonPattern->getCommonPtr()->Specializations.GetOrInsertNode(D);
|
CanonPattern->getCommonPtr()->Specializations.GetOrInsertNode(D);
|
||||||
}
|
}
|
||||||
|
// If we already have a matching specialization, merge it.
|
||||||
|
if (CanonSpec != D)
|
||||||
|
mergeRedeclarable<VarDecl>(D, CanonSpec, Redecl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
template<unsigned> class SmallString {};
|
template<unsigned> class SmallString {};
|
||||||
|
|
||||||
|
template<int> int var_template = 0;
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
#include "a.h"
|
#include "a.h"
|
||||||
void f(SmallString<256>&);
|
void f(SmallString<256>&);
|
||||||
|
|
||||||
|
template<typename T> void use_var_template(decltype(T() + var_template<0>)) {}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
#include "a.h"
|
#include "a.h"
|
||||||
struct X { SmallString<256> ss; };
|
struct X { SmallString<256> ss; };
|
||||||
|
|
||||||
|
template<typename T> void use_var_template(decltype(T() + var_template<0>));
|
||||||
|
|
||||||
#include "b.h"
|
#include "b.h"
|
||||||
|
|
|
@ -3,3 +3,7 @@
|
||||||
// expected-no-diagnostics
|
// expected-no-diagnostics
|
||||||
#include "c.h"
|
#include "c.h"
|
||||||
X x;
|
X x;
|
||||||
|
|
||||||
|
void test_var_template() {
|
||||||
|
use_var_template<int>(0);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue