objc - fix a bug exposed by my recent decl context
changes. // rdar://10015110


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138594 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 7a9d6d5..03081be 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -540,6 +540,9 @@
     // Make sure the cached decl gets a valid start location.
     PDecl->setLocation(AtProtoInterfaceLoc);
     PDecl->setForwardDecl(false);
+    // Since this ObjCProtocolDecl was created by a forward declaration,
+    // we now add it to the DeclContext since it wasn't added before
+    PDecl->setLexicalDeclContext(CurContext);
     CurContext->addDecl(PDecl);
     // Repeat in dependent AST files.
     PDecl->setChangedSinceDeserialization(true);
diff --git a/test/SemaObjCXX/linkage-spec.mm b/test/SemaObjCXX/linkage-spec.mm
index 1454e6a..584571d 100644
--- a/test/SemaObjCXX/linkage-spec.mm
+++ b/test/SemaObjCXX/linkage-spec.mm
@@ -10,3 +10,12 @@
 
 @interface I
 @end
+
+// rdar://10015110
+@protocol VKAnnotation;
+extern "C" {
+
+@protocol VKAnnotation
+  @property (nonatomic, assign) id coordinate;
+@end
+}