]> granicus.if.org Git - clang/commitdiff
Merge common pointers for redeclarations of the same template across modules.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sun, 13 Oct 2013 23:50:45 +0000 (23:50 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sun, 13 Oct 2013 23:50:45 +0000 (23:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192560 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ASTReaderDecl.cpp
test/Modules/Inputs/cxx-templates-a.h
test/Modules/Inputs/cxx-templates-b.h
test/Modules/cxx-templates.cpp

index 341f8eb068ded3c5935a48f5bf742879b94f3e4c..2a1ac11ec04c05dd14accfd1c1ca6220fe6d4ece 100644 (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;
 }
 
index 37e3426fc0b305e522ef1e2bcf4a3a5c4b24d71c..d2261f6a291372ed23a98f931fe67896ac438ac9 100644 (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;
index c495074a93fde6711b3f941470d0d7b0ddf2f922..6cc951b0ee35ff1c72055a37cf0f28bdde3dda66 100644 (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; };
index f34a2bdaa712a8d0cca1ba5aaafeabb3cae65399..911f953a5c16d070c30d85ce0e022dbe97202c06 100644 (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;