From: Richard Smith Date: Wed, 8 Jul 2015 02:22:15 +0000 (+0000) Subject: [modules] When determining the visible module set during template X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fa1f36419e0b95b451521803ac43341ab7ddd41e;p=clang [modules] When determining the visible module set during template instantiation, use the set of modules visible from the template definition, not from whichever declaration the specialization was instantiated from. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241662 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index b00b8a0ea9..d905fcf13a 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -1272,7 +1272,7 @@ const CXXRecordDecl *CXXRecordDecl::getTemplateInstantiationPattern() const { break; CTD = NewCTD; } - return CTD->getTemplatedDecl(); + return CTD->getTemplatedDecl()->getDefinition(); } if (auto *CTPSD = From.dyn_cast()) { @@ -1281,7 +1281,7 @@ const CXXRecordDecl *CXXRecordDecl::getTemplateInstantiationPattern() const { break; CTPSD = NewCTPSD; } - return CTPSD; + return CTPSD->getDefinition(); } } @@ -1290,7 +1290,7 @@ const CXXRecordDecl *CXXRecordDecl::getTemplateInstantiationPattern() const { const CXXRecordDecl *RD = this; while (auto *NewRD = RD->getInstantiatedFromMemberClass()) RD = NewRD; - return RD; + return RD->getDefinition(); } } diff --git a/test/Modules/Inputs/merge-template-pattern-visibility/a.h b/test/Modules/Inputs/merge-template-pattern-visibility/a.h new file mode 100644 index 0000000000..7f9b6497e7 --- /dev/null +++ b/test/Modules/Inputs/merge-template-pattern-visibility/a.h @@ -0,0 +1,5 @@ +template struct A; +template struct B; + +template struct A {}; +template struct B : A {}; diff --git a/test/Modules/Inputs/merge-template-pattern-visibility/b.h b/test/Modules/Inputs/merge-template-pattern-visibility/b.h new file mode 100644 index 0000000000..5ed18e7e7c --- /dev/null +++ b/test/Modules/Inputs/merge-template-pattern-visibility/b.h @@ -0,0 +1,9 @@ +template struct A; +template struct B; + +template struct A {}; +template struct B : A {}; + +inline void f() { + B bi; +} diff --git a/test/Modules/Inputs/merge-template-pattern-visibility/module.modulemap b/test/Modules/Inputs/merge-template-pattern-visibility/module.modulemap new file mode 100644 index 0000000000..ba97abbaa8 --- /dev/null +++ b/test/Modules/Inputs/merge-template-pattern-visibility/module.modulemap @@ -0,0 +1,4 @@ +module X { + module A { header "a.h" } + module B { header "b.h" } +} diff --git a/test/Modules/merge-template-pattern-visibility.cpp b/test/Modules/merge-template-pattern-visibility.cpp new file mode 100644 index 0000000000..db759b5a46 --- /dev/null +++ b/test/Modules/merge-template-pattern-visibility.cpp @@ -0,0 +1,4 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fno-modules-error-recovery \ +// RUN: -fmodule-name=X -emit-module %S/Inputs/merge-template-pattern-visibility/module.modulemap -x c++ \ +// RUN: -fmodules-local-submodule-visibility