File tree Expand file tree Collapse file tree 5 files changed +19
-4
lines changed
Inputs/merge-template-specializations Expand file tree Collapse file tree 5 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -2382,13 +2382,17 @@ ASTDeclReader::VisitVarTemplateSpecializationDeclImpl(
2382
2382
if (writtenAsCanonicalDecl) {
2383
2383
auto *CanonPattern = readDeclAs<VarTemplateDecl>();
2384
2384
if (D->isCanonicalDecl ()) { // It's kept in the folding set.
2385
- // FIXME: If it's already present, merge it.
2385
+ VarTemplateSpecializationDecl *CanonSpec;
2386
2386
if (auto *Partial = dyn_cast<VarTemplatePartialSpecializationDecl>(D)) {
2387
- CanonPattern->getCommonPtr ()-> PartialSpecializations
2388
- .GetOrInsertNode (Partial);
2387
+ CanonSpec = CanonPattern->getCommonPtr ()
2388
+ -> PartialSpecializations .GetOrInsertNode (Partial);
2389
2389
} else {
2390
- CanonPattern->getCommonPtr ()->Specializations .GetOrInsertNode (D);
2390
+ CanonSpec =
2391
+ CanonPattern->getCommonPtr ()->Specializations .GetOrInsertNode (D);
2391
2392
}
2393
+ // If we already have a matching specialization, merge it.
2394
+ if (CanonSpec != D)
2395
+ mergeRedeclarable<VarDecl>(D, CanonSpec, Redecl);
2392
2396
}
2393
2397
}
2394
2398
Original file line number Diff line number Diff line change 1
1
template <unsigned > class SmallString {};
2
+
3
+ template <int > int var_template = 0 ;
Original file line number Diff line number Diff line change 1
1
#include " a.h"
2
2
void f (SmallString<256 >&);
3
+
4
+ template <typename T> void use_var_template (decltype (T() + var_template<0>)) {}
Original file line number Diff line number Diff line change 1
1
#include " a.h"
2
2
struct X { SmallString<256 > ss; };
3
+
4
+ template <typename T> void use_var_template (decltype (T() + var_template<0>));
5
+
3
6
#include " b.h"
Original file line number Diff line number Diff line change 3
3
// expected-no-diagnostics
4
4
#include " c.h"
5
5
X x;
6
+
7
+ void test_var_template () {
8
+ use_var_template<int >(0 );
9
+ }
You can’t perform that action at this time.
0 commit comments