When name lookup comes across a declaration that is in a module that
is not visible, look for any previous declarations of that entity that
might be visible.

llvm-svn: 146563
diff --git a/clang/test/Modules/Inputs/decl.h b/clang/test/Modules/Inputs/decl.h
new file mode 100644
index 0000000..8dbe11e
--- /dev/null
+++ b/clang/test/Modules/Inputs/decl.h
@@ -0,0 +1,2 @@
+@class A;
+typedef struct B B;
diff --git a/clang/test/Modules/Inputs/def.h b/clang/test/Modules/Inputs/def.h
new file mode 100644
index 0000000..c9bc36d
--- /dev/null
+++ b/clang/test/Modules/Inputs/def.h
@@ -0,0 +1,7 @@
+@interface A
+@end
+
+struct B {
+  int b1;
+};
+
diff --git a/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map
index f25a36e..6b93a6a 100644
--- a/clang/test/Modules/Inputs/module.map
+++ b/clang/test/Modules/Inputs/module.map
@@ -36,3 +36,8 @@
 module redeclarations_left { header "redeclarations_left.h" }
 module redeclarations_right { header "redeclarations_right.h" }
 module load_failure { header "load_failure.h" }
+
+module decldef {
+  explicit module Decl { header "decl.h" }
+  explicit module Def { header "def.h" }
+}
\ No newline at end of file
diff --git a/clang/test/Modules/decldef.mm b/clang/test/Modules/decldef.mm
new file mode 100644
index 0000000..bbdcd9c
--- /dev/null
+++ b/clang/test/Modules/decldef.mm
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -I %S/Inputs -fmodule-cache-path %t %s -verify
+
+__import_module__ decldef;
+A *a1; // expected-error{{unknown type name 'A'}}
+B *b1; // expected-error{{unknown type name 'B'}}
+
+__import_module__ decldef.Decl;
+
+// FIXME: No link between @interface (which we can't see) and @class
+// (which we can).
+// A *a2;
+B *b;
+
+void testB() {
+  B b; // FIXME: Should error, because we can't see the definition.
+}