Add requirement that attribute 'objc_protocol_requires_explicit_implementation' can only be applied to protocol definitions.

llvm-svn: 201899
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 19b7955..88cdc75 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1643,8 +1643,14 @@
                                       Attr.getAttributeSpellingListIndex()));
 }
 
-static void handleObjCSuppresProtocolAttr(Sema &S, Decl *D,
+static void handleObjCSuppresProtocolAttr(Sema &S, ObjCProtocolDecl *D,
                                           const AttributeList &Attr) {
+  if (!D->isThisDeclarationADefinition()) {
+    S.Diag(Attr.getLoc(), diag::err_objc_attr_protocol_requires_definition)
+      << Attr.getName() << Attr.getRange();
+    return;
+  }
+
   D->addAttr(::new (S.Context)
           ObjCExplicitProtocolImplAttr(Attr.getRange(), S.Context,
                                        Attr.getAttributeSpellingListIndex()));
@@ -4191,7 +4197,7 @@
   case AttributeList::AT_ObjCRootClass:
     handleSimpleAttribute<ObjCRootClassAttr>(S, D, Attr); break;
   case AttributeList::AT_ObjCExplicitProtocolImpl:
-    handleObjCSuppresProtocolAttr(S, D, Attr);
+    handleObjCSuppresProtocolAttr(S, cast<ObjCProtocolDecl>(D), Attr);
     break;
   case AttributeList::AT_ObjCRequiresPropertyDefs:
     handleSimpleAttribute<ObjCRequiresPropertyDefsAttr>(S, D, Attr); break;