r186584 - Replacing a morally duplicate diagnostic by adding it to an existing diagnostic's select list. Updates the tests for the more consistent diagnostic.
Aaron Ballman
aaron at aaronballman.com
Thu Jul 18 07:56:42 PDT 2013
Author: aaronballman
Date: Thu Jul 18 09:56:42 2013
New Revision: 186584
URL: http://llvm.org/viewvc/llvm-project?rev=186584&view=rev
Log:
Replacing a morally duplicate diagnostic by adding it to an existing diagnostic's select list. Updates the tests for the more consistent diagnostic.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaObjC/attr-objc-exception.m
cfe/trunk/test/SemaObjC/attr-root-class.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=186584&r1=186583&r2=186584&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 18 09:56:42 2013
@@ -1805,8 +1805,6 @@ def err_attribute_argument_n_not_identif
"'%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 : War
"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 : Erro
"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>;
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=186584&r1=186583&r2=186584&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Jul 18 09:56:42 2013
@@ -52,7 +52,8 @@ enum AttributeDeclKind {
ExpectedTLSVar,
ExpectedVariableOrField,
ExpectedVariableFieldOrTag,
- ExpectedTypeOrNamespace
+ ExpectedTypeOrNamespace,
+ ExpectedObjectiveCInterface
};
//===----------------------------------------------------------------------===//
@@ -2078,7 +2079,8 @@ static void handleArcWeakrefUnavailableA
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
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;
}
Modified: cfe/trunk/test/SemaObjC/attr-objc-exception.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-objc-exception.m?rev=186584&r1=186583&r2=186584&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/attr-objc-exception.m (original)
+++ cfe/trunk/test/SemaObjC/attr-objc-exception.m Thu Jul 18 09:56:42 2013
@@ -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();
Modified: cfe/trunk/test/SemaObjC/attr-root-class.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-root-class.m?rev=186584&r1=186583&r2=186584&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/attr-root-class.m (original)
+++ cfe/trunk/test/SemaObjC/attr-root-class.m Thu Jul 18 09:56:42 2013
@@ -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}}
{
}
More information about the cfe-commits
mailing list