]> granicus.if.org Git - clang/commitdiff
Clang missing warning about conflicting declaration vs. definition
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 21 May 2010 23:28:58 +0000 (23:28 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 21 May 2010 23:28:58 +0000 (23:28 +0000)
for variable arguments list methods. (radar 8006060).

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

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDeclObjC.cpp
test/SemaObjC/method-conflict.m

index bfcf13038d7edc2b7543590613411ce8e550c40f..1b79b75a1e086f95cb32bde3955e5964d379a579 100644 (file)
@@ -293,6 +293,8 @@ def warn_conflicting_ret_types : Warning<
 
 def warn_conflicting_param_types : Warning<
   "conflicting parameter types in implementation of %0: %1 vs %2">;
+def warn_conflicting_variadic :Warning<
+  "conflicting variadic declaration of method and its implementation">;
 
 def warn_implements_nscopying : Warning<
 "default assign attribute on property %0 which implements "
index ef43c051f7bc11cefe3d02a86ee9dc12f78dfb2a..3b05f5ac28da4991616aa400e5856f3659943cde 100644 (file)
@@ -763,6 +763,10 @@ void Sema::WarnConflictingTypedMethods(ObjCMethodDecl *ImpMethodDecl,
       << (*IM)->getType();
     Diag((*IF)->getLocation(), diag::note_previous_definition);
   }
+  if (ImpMethodDecl->isVariadic() != IntfMethodDecl->isVariadic()) {
+    Diag(ImpMethodDecl->getLocation(), diag::warn_conflicting_variadic);
+    Diag(IntfMethodDecl->getLocation(), diag::note_previous_declaration);
+  }
 }
 
 /// FIXME: Type hierarchies in Objective-C can be deep. We could most likely
index 08fdfc017ccc772372fc453f8b33fa578cb27237..5dc886fb7fd245e5abacaf5239df8e42b900b269 100644 (file)
@@ -53,3 +53,14 @@ typedef NSUInteger XDSourceLanguage;
   return 0;
 }
 @end 
+
+// rdar: // 8006060
+@interface Bar
+- (void)foo:(id)format, ...;  // expected-note {{previous declaration is here}}
+- (void)foo1:(id)format;      // expected-note {{previous declaration is here}}
+@end
+@implementation Bar
+- (void)foo:(id)format {}; // expected-warning {{conflicting variadic declaration of method and its implementation}}
+- (void)foo1:(id)format, ... {}; // expected-warning {{conflicting variadic declaration of method and its implementation}}
+@end
+