When checking a using declaration, make sure that the context we're
looking in is complete. Fixes PR8756.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122323 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index d257531..0021c79 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -4052,6 +4052,10 @@
     return true;
   }
 
+  if (!NamedContext->isDependentContext() &&
+      RequireCompleteDeclContext(const_cast<CXXScopeSpec&>(SS), NamedContext))
+    return true;
+
   if (getLangOptions().CPlusPlus0x) {
     // C++0x [namespace.udecl]p3:
     //   In a using-declaration used as a member-declaration, the
diff --git a/test/SemaCXX/using-decl-1.cpp b/test/SemaCXX/using-decl-1.cpp
index 65be0bc..ebe97f6 100644
--- a/test/SemaCXX/using-decl-1.cpp
+++ b/test/SemaCXX/using-decl-1.cpp
@@ -108,3 +108,13 @@
     template <typename T> using A::f<T>; // expected-error {{cannot template a using declaration}}
   };
 }
+
+// PR8756
+namespace foo
+{
+  class Class1; // expected-note{{forward declaration}}
+  class Class2
+  {
+    using ::foo::Class1::Function; // expected-error{{incomplete type 'foo::Class1' named in nested name specifier}}
+  };
+}