[cfe-commits] r45146 - in /cfe/trunk: Sema/SemaChecking.cpp Sema/SemaType.cpp test/Sema/va-method.m

Steve Naroff snaroff at apple.com
Mon Dec 17 19:41:21 PST 2007


Author: snaroff
Date: Mon Dec 17 21:41:15 2007
New Revision: 45146

URL: http://llvm.org/viewvc/llvm-project?rev=45146&view=rev
Log:

Fixe bogus error for variable argument methods. Sema::ObjcGetTypeForMethodDefinition() wasn't preserving the isVariadic boolean. Another fix is to avoid synthsizing the function decl entirely, however this is a separate issue that I don't want to deal with now. Also added a FIXME to Sema::CheckFunctionCall(), which is currently emitting a bogus warning.

Added:
    cfe/trunk/test/Sema/va-method.m
Modified:
    cfe/trunk/Sema/SemaChecking.cpp
    cfe/trunk/Sema/SemaType.cpp

Modified: cfe/trunk/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaChecking.cpp?rev=45146&r1=45145&r2=45146&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/Sema/SemaChecking.cpp Mon Dec 17 21:41:15 2007
@@ -62,7 +62,7 @@
            diag::err_va_start_used_in_non_variadic_function);
       return true;
     }
-      
+    // FIXME: This isn't correct for methods (results in bogus warning).
     bool SecondArgIsLastNamedArgument = false;
     if (DeclRefExpr *DR = dyn_cast<DeclRefExpr>(Args[1])) {
       if (ParmVarDecl *PV = dyn_cast<ParmVarDecl>(DR->getDecl())) {

Modified: cfe/trunk/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaType.cpp?rev=45146&r1=45145&r2=45146&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaType.cpp (original)
+++ cfe/trunk/Sema/SemaType.cpp Mon Dec 17 21:41:15 2007
@@ -366,7 +366,7 @@
     ArgTys.push_back(ArgTy);
   }
   T = Context.getFunctionType(T, &ArgTys[0], ArgTys.size(),
-                              false);
+                              MDecl->isVariadic());
   return T;
 }
 

Added: cfe/trunk/test/Sema/va-method.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/va-method.m?rev=45146&view=auto

==============================================================================
--- cfe/trunk/test/Sema/va-method.m (added)
+++ cfe/trunk/test/Sema/va-method.m Mon Dec 17 21:41:15 2007
@@ -0,0 +1,17 @@
+// RUN: clang -fsyntax-only -verify %s
+
+#include <stdarg.h>
+
+ at interface NSObject @end
+ at interface XX : NSObject @end
+
+ at implementation XX
+- (void)encodeValuesOfObjCTypes:(const char *)types, ... {
+   va_list ap;
+   va_start(ap, types); // expected-warning {{second parameter of 'va_start' not last named argument}}
+   while (*types) ;
+   va_end(ap);
+}
+
+ at end
+





More information about the cfe-commits mailing list