diff options
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 4 | ||||
-rw-r--r-- | test/SemaObjC/method-conflict.m | 11 |
3 files changed, 17 insertions, 0 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index bfcf13038d..1b79b75a1e 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -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 " diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index ef43c051f7..3b05f5ac28 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -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 diff --git a/test/SemaObjC/method-conflict.m b/test/SemaObjC/method-conflict.m index 08fdfc017c..5dc886fb7f 100644 --- a/test/SemaObjC/method-conflict.m +++ b/test/SemaObjC/method-conflict.m @@ -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 + |