]> granicus.if.org Git - clang/commitdiff
When instantiating a dependently-scoped friend function declaration,
authorJohn McCall <rjmccall@apple.com>
Tue, 19 Oct 2010 05:01:53 +0000 (05:01 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 19 Oct 2010 05:01:53 +0000 (05:01 +0000)
we may need to complete the type before looking into it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116795 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateInstantiateDecl.cpp
test/CXX/temp/temp.decls/temp.friend/p1.cpp

index 5636647cda50ca044591a9a3ea14c7d369bb2283..3d78f1316ad9818bc8eddf857346adf408404b40 100644 (file)
@@ -1333,6 +1333,9 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D,
       SS.setScopeRep(Qualifier);
       SS.setRange(D->getQualifierRange());
       DC = SemaRef.computeDeclContext(SS);
+
+      if (DC && SemaRef.RequireCompleteDeclContext(SS, DC))
+        return 0;
     } else {
       DC = SemaRef.FindInstantiatedContext(D->getLocation(),
                                            D->getDeclContext(),
index 073b2a1463544cb23b7a1c7cfded9447ea1e352f..5e5d7869ff79e9e7a1c27f6321b657df8a8be6fa 100644 (file)
@@ -293,3 +293,17 @@ namespace test13 {
 
   template class Foo<0>;
 }
+
+namespace test14 {
+  template <class T> class B;
+  template <class T> class A {
+    friend void B<T>::foo();
+    static void foo(); // expected-note {{declared private here}}
+  };
+
+  template <class T> class B {
+    void foo() { return A<long>::foo(); } // expected-error {{'foo' is a private member of 'test14::A<long>'}}
+  };
+
+  template class B<int>; // expected-note {{in instantiation}}
+}