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
This commit is contained in:
Aaron Ballman 2013-07-18 14:56:42 +00:00
parent 5e2169f94f
commit 37a8953f71
4 changed files with 11 additions and 10 deletions

View File

@ -1805,8 +1805,6 @@ def err_attribute_argument_n_not_identifier : Error<
"'%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 @@ def warn_attribute_wrong_decl_type : Warning<
"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 @@ def err_attribute_wrong_decl_type : Error<
"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>;

View File

@ -52,7 +52,8 @@ enum AttributeDeclKind {
ExpectedTLSVar,
ExpectedVariableOrField,
ExpectedVariableFieldOrTag,
ExpectedTypeOrNamespace
ExpectedTypeOrNamespace,
ExpectedObjectiveCInterface
};
//===----------------------------------------------------------------------===//
@ -2078,7 +2079,8 @@ static void handleArcWeakrefUnavailableAttr(Sema &S, Decl *D,
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 @@ static void handleObjCExceptionAttr(Sema &S, Decl *D,
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;
}

View File

@ -8,9 +8,9 @@ __attribute__((__objc_exception__))
@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();

View File

@ -11,6 +11,6 @@ __attribute__((objc_root_class))
@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}}
{
}