Merge common pointers for redeclarations of the same template across modules.

llvm-svn: 192560
This commit is contained in:
Richard Smith 2013-10-13 23:50:45 +00:00
parent f39720b26e
commit d46d6dea68
4 changed files with 13 additions and 0 deletions

View File

@ -1429,6 +1429,11 @@ ASTDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) {
mergeRedeclarable(D, Redecl);
// If we merged the template with a prior declaration chain, merge the common
// pointer.
// FIXME: Actually merge here, don't just overwrite.
D->Common = D->getCanonicalDecl()->Common;
return Redecl;
}

View File

@ -30,3 +30,6 @@ void use_some_template_a() {
SomeTemplate<char[1]> b, c;
b = c;
}
template<int> struct MergeTemplates;
MergeTemplates<0> *merge_templates_a;

View File

@ -17,6 +17,9 @@ typedef SomeTemplate<int&> SomeTemplateIntRef;
extern DefinedInCommon &defined_in_common;
template<int> struct MergeTemplates;
MergeTemplates<0> *merge_templates_b;
@import cxx_templates_b_impl;
template<typename T, typename> struct Identity { typedef T type; };

View File

@ -69,6 +69,8 @@ void g() {
// expected-error@Inputs/cxx-templates-a.h:19 {{definition of 'DefinedInBImpl' must be imported}}
// expected-note@Inputs/cxx-templates-b-impl.h:1 {{definition is here}}
PerformDelayedLookup(defined_in_b_impl); // expected-note {{in instantiation of}}
merge_templates_a = merge_templates_b; // ok, same type
}
RedeclaredAsFriend<int> raf1;