From: Jonathan Roelofs Date: Tue, 28 Apr 2015 18:04:44 +0000 (+0000) Subject: Fix PR22047: ObjC: Method unavailability attribute doesn't work with overloaded methods X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=791ac8f91419f261f4ebf914eaae1df188f99727;p=clang Fix PR22047: ObjC: Method unavailability attribute doesn't work with overloaded methods http://reviews.llvm.org/D9261 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236006 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 37ef9baf11..38318791fd 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -2385,10 +2385,10 @@ bool Sema::AreMultipleMethodsInGlobalPool(Selector Sel, ObjCMethodDecl *BestMeth // Diagnose finding more than one method in global pool SmallVector Methods; Methods.push_back(BestMethod); - for (ObjCMethodList *M = &MethList; M; M = M->getNext()) - if (M->getMethod() && !M->getMethod()->isHidden() && - M->getMethod() != BestMethod) - Methods.push_back(M->getMethod()); + for (ObjCMethodList *ML = &MethList; ML; ML = ML->getNext()) + if (ObjCMethodDecl *M = ML->getMethod()) + if (!M->isHidden() && M != BestMethod && !M->hasAttr()) + Methods.push_back(M); if (Methods.size() > 1) DiagnoseMultipleMethodInGlobalPool(Methods, Sel, R, receiverIdOrClass); @@ -2420,7 +2420,7 @@ void Sema::DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl & bool receiverIdOrClass) { // We found multiple methods, so we may have to complain. bool issueDiagnostic = false, issueError = false; - + // We support a warning which complains about *any* difference in // method signature. bool strictSelectorMatch = @@ -2434,7 +2434,7 @@ void Sema::DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl & } } } - + // If we didn't see any strict differences, we won't see any loose // differences. In ARC, however, we also need to check for loose // mismatches, because most of them are errors. diff --git a/test/SemaObjC/multiple-method-names.m b/test/SemaObjC/multiple-method-names.m new file mode 100644 index 0000000000..9fd83b208a --- /dev/null +++ b/test/SemaObjC/multiple-method-names.m @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -Wobjc-multiple-method-names -x objective-c %s -verify +// PR22047 + +@interface Face0 +- (void)foo:(float)i; // expected-note {{using}} +@end + +@interface Face1 +- (void)foo:(int)i __attribute__((unavailable)); +@end + +@interface Face2 +- (void)foo:(char)i; // expected-note {{also found}} +@end + +void f(id i) { + [i foo:4.0f]; // expected-warning {{multiple methods named 'foo:' found}} +} +