]> granicus.if.org Git - clang/commitdiff
Objective-C. Do not warn when an instance method and
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 17 Mar 2014 17:46:10 +0000 (17:46 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 17 Mar 2014 17:46:10 +0000 (17:46 +0000)
class method with the same selctor but different argument
types having one of them in class extension.
// rdar://16312105

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204065 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclObjC.cpp
test/SemaObjC/class-extension-dup-methods.m

index 2bed6cac384451f707e638c45942e03cd134861c..8f68852aaafd10328c84633092d1de03c374cf80 100644 (file)
@@ -838,7 +838,9 @@ void Sema::DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT,
     return;
   for (const auto *Method : CAT->methods()) {
     const ObjCMethodDecl *&PrevMethod = MethodMap[Method->getSelector()];
-    if (PrevMethod && !MatchTwoMethodDeclarations(Method, PrevMethod)) {
+    if (PrevMethod &&
+        (PrevMethod->isInstanceMethod() == Method->isInstanceMethod()) &&
+        !MatchTwoMethodDeclarations(Method, PrevMethod)) {
       Diag(Method->getLocation(), diag::err_duplicate_method_decl)
             << Method->getDeclName();
       Diag(PrevMethod->getLocation(), diag::note_previous_declaration);
index 692ff8c68a0a4c414680bc40f5de4f69a52deb45..5f463aed168cba391874b5603b77ff4f78ec5f4a 100644 (file)
 + (int)  InstMeth;
 - (int) OK;
 @end
+
+// rdar://16312105
+@class NSObject;
+
+__attribute__((objc_root_class)) @interface AppDelegate
++ (void)someMethodWithArgument:(NSObject *)argument;
++ (void)someMethodWithArgument:(NSObject *)argument : (NSObject*) argument2; // expected-note {{previous declaration is here}}
+@end
+
+@interface AppDelegate ()
+- (void)someMethodWithArgument:(float)argument; // OK. No warning to be issued here.
++ (void)someMethodWithArgument:(float)argument : (float)argument2; // expected-error {{duplicate declaration of method 'someMethodWithArgument::'}}
+@end