]> granicus.if.org Git - clang/commitdiff
Elimate bogus warning when va_start is correctly used in
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 21 Jan 2008 22:59:53 +0000 (22:59 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 21 Jan 2008 22:59:53 +0000 (22:59 +0000)
a method.

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

Sema/SemaDeclObjC.cpp
include/clang/AST/DeclObjC.h
test/Sema/va-method-1.m [new file with mode: 0644]
test/Sema/va-method.m

index 5e15753af6f526c31f9819b3d8924b4c6b1e02dc..60d8ce42e3000d20f8131c263085a932b6ff65b5 100644 (file)
@@ -64,7 +64,7 @@ void Sema::ObjCActOnStartOfMethodDef(Scope *FnBodyScope, DeclTy *D) {
     PI.Ident = PDecl->getIdentifier();
     PI.IdentLoc = PDecl->getLocation(); // user vars have a real location.
     PI.TypeInfo = PDecl->getType().getAsOpaquePtr();
-    ActOnParamDeclarator(PI, FnBodyScope);
+    MDecl->setParamDecl(i, ActOnParamDeclarator(PI, FnBodyScope));
   }
 }
 
index fb8143777269a6637fa8d5141a2da03984bf8ec3..c2048115c3bd6a52394e50378044eb3330b4ded8 100644 (file)
@@ -135,6 +135,9 @@ public:
     assert(i < getNumParams() && "Illegal param #");
     return ParamInfo[i];
   }  
+  void setParamDecl(int i, ParmVarDecl *pDecl) {
+    ParamInfo[i] = pDecl;
+  }  
   void setMethodParams(ParmVarDecl **NewParamInfo, unsigned NumParams);
   
   AttributeList *getMethodAttrs() const {return MethodAttrs;}
diff --git a/test/Sema/va-method-1.m b/test/Sema/va-method-1.m
new file mode 100644 (file)
index 0000000..077982a
--- /dev/null
@@ -0,0 +1,17 @@
+// RUN: clang -fsyntax-only -verify %s
+
+#include <stdarg.h>
+
+@interface NSObject @end
+@interface XX : NSObject @end
+
+@implementation XX
+- (void)encodeValuesOfObjCTypes:(const char *)types, ... {
+   va_list ap;
+   va_start(ap, types); 
+   while (*types) ;
+   va_end(ap);
+}
+
+@end
+
index 1393af1eb262dbe2e9bfc2234752b90e17738b97..258286937fffedacb5e52ed6a4c0334d132a81c1 100644 (file)
@@ -8,7 +8,7 @@
 @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}}
+   va_start(ap, types); 
    while (*types) ;
    va_end(ap);
 }