From: Richard Smith Date: Wed, 11 Mar 2015 18:21:02 +0000 (+0000) Subject: [modules] When merging the pattern of a class template definition into a prior X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f8f4cac855eef6c12288c63647fb2a47cc7eb8bb;p=clang [modules] When merging the pattern of a class template definition into a prior definition, be sure to update the definition data on all declarations, not just the canonical one, since the pattern might not be in the list of pending definitions (if it used to be canonical itself). One-line fix by me; reduced testcase by Daniel Jasper! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@231950 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index 565f33ecba..96c16ea10e 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -2158,6 +2158,7 @@ void ASTDeclReader::mergeTemplatePattern(RedeclarableTemplateDecl *D, DClass->IsCompleteDefinition = false; } else { ExistingClass->DefinitionData = DClass->DefinitionData; + Reader.PendingDefinitions.insert(DClass); } } DClass->DefinitionData = ExistingClass->DefinitionData; diff --git a/test/Modules/Inputs/merge-template-friend/def.h b/test/Modules/Inputs/merge-template-friend/def.h new file mode 100644 index 0000000000..c75f5f6867 --- /dev/null +++ b/test/Modules/Inputs/merge-template-friend/def.h @@ -0,0 +1,3 @@ +namespace ns { +template class C {}; +} diff --git a/test/Modules/Inputs/merge-template-friend/friend.h b/test/Modules/Inputs/merge-template-friend/friend.h new file mode 100644 index 0000000000..97fb758b43 --- /dev/null +++ b/test/Modules/Inputs/merge-template-friend/friend.h @@ -0,0 +1,4 @@ +namespace ns { template class C; }; +class A { + template friend class ::ns::C; +}; diff --git a/test/Modules/Inputs/merge-template-friend/module.modulemap b/test/Modules/Inputs/merge-template-friend/module.modulemap new file mode 100644 index 0000000000..7737ad9b0c --- /dev/null +++ b/test/Modules/Inputs/merge-template-friend/module.modulemap @@ -0,0 +1,3 @@ +module a { header "friend.h" export * } +module b { header "def.h" export * } + diff --git a/test/Modules/merge-template-friend.cpp b/test/Modules/merge-template-friend.cpp new file mode 100644 index 0000000000..8a1910dad6 --- /dev/null +++ b/test/Modules/merge-template-friend.cpp @@ -0,0 +1,22 @@ +// RUN: rm -rf %t +// +// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -emit-module -fmodule-name=a -o %t/a.pcm \ +// RUN: %S/Inputs/merge-template-friend/module.modulemap +// +// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -emit-module -fmodule-name=b -o %t/b.pcm \ +// RUN: %S/Inputs/merge-template-friend/module.modulemap +// +// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -I%S/Inputs/merge-template-friend \ +// RUN: -fmodule-file=%t/a.pcm \ +// RUN: -fmodule-file=%t/b.pcm \ +// RUN: -verify %s + +#include "friend.h" +#include "def.h" + +::ns::C c; + +// expected-no-diagnostics