Replacing a morally duplicate diagnostic by adding it to an existing diagnostic's select list.  Updates the tests for the more consistent diagnostic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186584 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 1f138d2..003930c 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1805,8 +1805,6 @@
   "'%0' attribute requires parameter %1 to be an identifier">;
 def err_attribute_argument_out_of_bounds : Error<
   "'%0' attribute parameter %1 is out of bounds">;
-def err_attribute_requires_objc_interface : Error<
-  "attribute may only be applied to an Objective-C interface">;
 def err_attribute_uuid_malformed_guid : Error<
   "uuid attribute contains a malformed GUID">;
 def warn_nonnull_pointers_only : Warning<
@@ -2006,7 +2004,7 @@
   "variables, functions and labels|fields and global variables|structs|"
   "variables, functions and tag types|thread-local variables|"
   "variables and fields|variables, data members and tag types|"
-  "types and namespaces}1">,
+  "types and namespaces|Objective-C interfaces}1">,
   InGroup<IgnoredAttributes>;
 def err_attribute_wrong_decl_type : Error<
   "%0 attribute only applies to %select{functions|unions|"
@@ -2016,7 +2014,7 @@
   "variables, functions and labels|fields and global variables|structs|"
   "variables, functions and tag types|thread-local variables|"
   "variables and fields|variables, data members and tag types|"
-  "types and namespaces}1">;
+  "types and namespaces|Objective-C interfaces}1">;
 def warn_function_attribute_wrong_type : Warning<
   "'%0' only applies to function types; type here is %1">,
   InGroup<IgnoredAttributes>;
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index cdc9649..9d73ca3 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -52,7 +52,8 @@
   ExpectedTLSVar,
   ExpectedVariableOrField,
   ExpectedVariableFieldOrTag,
-  ExpectedTypeOrNamespace
+  ExpectedTypeOrNamespace,
+  ExpectedObjectiveCInterface
 };
 
 //===----------------------------------------------------------------------===//
@@ -2078,7 +2079,8 @@
 static void handleObjCRootClassAttr(Sema &S, Decl *D, 
                                     const AttributeList &Attr) {
   if (!isa<ObjCInterfaceDecl>(D)) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_requires_objc_interface);
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type)
+      << Attr.getName() << ExpectedObjectiveCInterface;
     return;
   }
   
@@ -2490,7 +2492,8 @@
 
   ObjCInterfaceDecl *OCI = dyn_cast<ObjCInterfaceDecl>(D);
   if (OCI == 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_requires_objc_interface);
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type)
+      << Attr.getName() << ExpectedObjectiveCInterface;
     return;
   }
 
diff --git a/test/SemaObjC/attr-objc-exception.m b/test/SemaObjC/attr-objc-exception.m
index b497271..dd8ac57 100644
--- a/test/SemaObjC/attr-objc-exception.m
+++ b/test/SemaObjC/attr-objc-exception.m
@@ -8,9 +8,9 @@
 @end
 
 
-__attribute__((__objc_exception__)) // expected-error {{attribute may only be applied to an Objective-C interface}}
+__attribute__((__objc_exception__)) // expected-error {{'__objc_exception__' attribute only applies to Objective-C interfaces}}
 int X;
 
-__attribute__((__objc_exception__)) // expected-error {{attribute may only be applied to an Objective-C interface}}
+__attribute__((__objc_exception__)) // expected-error {{'__objc_exception__' attribute only applies to Objective-C interfaces}}
 void foo();
 
diff --git a/test/SemaObjC/attr-root-class.m b/test/SemaObjC/attr-root-class.m
index 195cd66..4f4c8b6 100644
--- a/test/SemaObjC/attr-root-class.m
+++ b/test/SemaObjC/attr-root-class.m
@@ -11,6 +11,6 @@
 @implementation NonRootClass
 @end
 
-__attribute__((objc_root_class)) static void nonClassDeclaration()  // expected-error {{attribute may only be applied to an Objective-C interface}}
+__attribute__((objc_root_class)) static void nonClassDeclaration()  // expected-error {{'objc_root_class' attribute only applies to Objective-C interfaces}}
 {
 }