[cfe-commits] r104407 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDeclObjC.cpp test/SemaObjC/method-conflict.m

Fariborz Jahanian fjahanian at apple.com
Fri May 21 16:28:58 PDT 2010


Author: fjahanian
Date: Fri May 21 18:28:58 2010
New Revision: 104407

URL: http://llvm.org/viewvc/llvm-project?rev=104407&view=rev
Log:
Clang missing warning about conflicting declaration vs. definition 
for variable arguments list methods. (radar 8006060).

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

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=104407&r1=104406&r2=104407&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri May 21 18:28:58 2010
@@ -293,6 +293,8 @@
 
 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 "

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=104407&r1=104406&r2=104407&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri May 21 18:28:58 2010
@@ -763,6 +763,10 @@
       << (*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

Modified: cfe/trunk/test/SemaObjC/method-conflict.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/method-conflict.m?rev=104407&r1=104406&r2=104407&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/method-conflict.m (original)
+++ cfe/trunk/test/SemaObjC/method-conflict.m Fri May 21 18:28:58 2010
@@ -53,3 +53,14 @@
   return 0;
 }
 @end 
+
+// rdar: // 8006060
+ at interface Bar
+- (void)foo:(id)format, ...;  // expected-note {{previous declaration is here}}
+- (void)foo1:(id)format;      // expected-note {{previous declaration is here}}
+ at end
+ at 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}}
+ at end
+





More information about the cfe-commits mailing list