]> granicus.if.org Git - clang/commitdiff
[modules] When determining the visible module set during template
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 8 Jul 2015 02:22:15 +0000 (02:22 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 8 Jul 2015 02:22:15 +0000 (02:22 +0000)
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

lib/AST/DeclCXX.cpp
test/Modules/Inputs/merge-template-pattern-visibility/a.h [new file with mode: 0644]
test/Modules/Inputs/merge-template-pattern-visibility/b.h [new file with mode: 0644]
test/Modules/Inputs/merge-template-pattern-visibility/module.modulemap [new file with mode: 0644]
test/Modules/merge-template-pattern-visibility.cpp [new file with mode: 0644]

index b00b8a0ea9ccc8a7f2fb4ee25ca36bdf9a5176b8..d905fcf13a45aebf934fb206ac955a0d97379bf5 100644 (file)
@@ -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<ClassTemplatePartialSpecializationDecl *>()) {
@@ -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 (file)
index 0000000..7f9b649
--- /dev/null
@@ -0,0 +1,5 @@
+template<typename, typename = int> struct A;
+template<typename T> struct B;
+
+template<typename, typename> struct A {};
+template<typename T> struct B : A<T> {};
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 (file)
index 0000000..5ed18e7
--- /dev/null
@@ -0,0 +1,9 @@
+template<typename, typename = int> struct A;
+template<typename T> struct B;
+
+template<typename, typename> struct A {};
+template<typename T> struct B : A<T> {};
+
+inline void f() {
+  B<int> 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 (file)
index 0000000..ba97abb
--- /dev/null
@@ -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 (file)
index 0000000..db759b5
--- /dev/null
@@ -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