diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2011-12-06 00:02:41 +0000 | 
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-12-06 00:02:41 +0000 | 
| commit | 56f326e7f20651e97152a543180b50dc9f75d5d0 (patch) | |
| tree | f62caa170f3807324a6ed9f2428756b092227150 | |
| parent | 34a7c6dfd74f85e9c53ede0b448bb35583abac6a (diff) | |
| download | bcm5719-llvm-56f326e7f20651e97152a543180b50dc9f75d5d0.tar.gz bcm5719-llvm-56f326e7f20651e97152a543180b50dc9f75d5d0.zip  | |
objc: put out more coherent warning when method definition
attributes don't match its declaration. // rdar://10529259.
llvm-svn: 145872
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 4 | ||||
| -rw-r--r-- | clang/test/SemaObjC/method-attributes.m | 30 | 
3 files changed, 30 insertions, 6 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 9a5a664d69c..4d7f60b8c9e 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -5025,7 +5025,7 @@ def error_protected_ivar_access : Error<"instance variable %0 is protected">,    AccessControl;  def warn_maynot_respond : Warning<"%0 may not respond to %1">;  def warn_attribute_method_def : Warning< -  "method attribute can only be specified on method declarations">, +  "attributes on method implementation and its declaration must match">,    InGroup<DiagGroup<"mismatched-method-attributes">>;  def ext_typecheck_base_super : Warning<    "method parameter type %0 does not match " diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 49fcfbf2f37..afcf3cc63ae 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -2712,8 +2712,10 @@ Decl *Sema::ActOnMethodDeclaration(        IMD = IDecl->lookupMethod(ObjCMethod->getSelector(),                                   ObjCMethod->isInstanceMethod());      if (ObjCMethod->hasAttrs() && -        containsInvalidMethodImplAttribute(IMD, ObjCMethod->getAttrs())) +        containsInvalidMethodImplAttribute(IMD, ObjCMethod->getAttrs())) {        Diag(EndLoc, diag::warn_attribute_method_def); +      Diag(IMD->getLocation(), diag::note_method_declared_at); +    }    } else {      cast<DeclContext>(ClassDecl)->addDecl(ObjCMethod);    } diff --git a/clang/test/SemaObjC/method-attributes.m b/clang/test/SemaObjC/method-attributes.m index a560e7432fc..9a1271dd3ce 100644 --- a/clang/test/SemaObjC/method-attributes.m +++ b/clang/test/SemaObjC/method-attributes.m @@ -13,23 +13,45 @@  @interface INTF  - (int) foo1: (int)arg1 __attribute__((deprecated)); -- (int) foo: (int)arg1;  +- (int) foo: (int)arg1;  // expected-note {{method declared here}} -- (int) foo2: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)); +- (int) foo2: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)); // expected-note {{method declared here}}  - (int) foo3: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)) __attribute__((ns_consumes_self));  @end  @implementation INTF -- (int) foo: (int)arg1  __attribute__((deprecated)){ // expected-warning {{method attribute can only be specified}} +- (int) foo: (int)arg1  __attribute__((deprecated)){ // expected-warning {{attributes on method implementation and its declaration must match}}          return 10;  }  - (int) foo1: (int)arg1 {          return 10;  } -- (int) foo2: (int)arg1 __attribute__((deprecated)) {  // expected-warning {{method attribute can only be specified}} +- (int) foo2: (int)arg1 __attribute__((deprecated)) {  // expected-warning {{attributes on method implementation and its declaration must match}}          return 10;  }  - (int) foo3: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)) __attribute__((ns_consumes_self)) {return 0; }  - (void) dep __attribute__((deprecated)) { } // OK private methodn  @end + +// rdar://10529259 +#define IBAction void)__attribute__((ibaction) + +@interface Foo  +- (void)doSomething1:(id)sender; +- (void)doSomething2:(id)sender; // expected-note {{method declared here}} +@end + +@implementation Foo +- (void)doSomething1:(id)sender{} +- (void)doSomething2:(id)sender{} +@end + +@interface Bar : Foo +- (IBAction)doSomething1:(id)sender; +@end +@implementation Bar +- (IBAction)doSomething1:(id)sender {} +- (IBAction)doSomething2:(id)sender {} // expected-warning {{attributes on method implementation and its declaration must match}} +- (IBAction)doSomething3:(id)sender {} +@end  | 

