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) {
|
||||
auto *CanonPattern = readDeclAs<VarTemplateDecl>();
|
||||
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)) {
|
||||
CanonPattern->getCommonPtr()->PartialSpecializations
|
||||
.GetOrInsertNode(Partial);
|
||||
CanonSpec = CanonPattern->getCommonPtr()
|
||||
->PartialSpecializations.GetOrInsertNode(Partial);
|
||||
} else {
|
||||
CanonSpec =
|
||||
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<int> int var_template = 0;
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
#include "a.h"
|
||||
void f(SmallString<256>&);
|
||||
|
||||
template<typename T> void use_var_template(decltype(T() + var_template<0>)) {}
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#include "a.h"
|
||||
struct X { SmallString<256> ss; };
|
||||
|
||||
template<typename T> void use_var_template(decltype(T() + var_template<0>));
|
||||
|
||||
#include "b.h"
|
||||
|
|
|
@ -3,3 +3,7 @@
|
|||
// expected-no-diagnostics
|
||||
#include "c.h"
|
||||
X x;
|
||||
|
||||
void test_var_template() {
|
||||
use_var_template<int>(0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue