Elimate bogus warning when va_start is correctly used in
a method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46232 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaDeclObjC.cpp b/Sema/SemaDeclObjC.cpp
index 5e15753..60d8ce4 100644
--- a/Sema/SemaDeclObjC.cpp
+++ b/Sema/SemaDeclObjC.cpp
@@ -64,7 +64,7 @@
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));
}
}
diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h
index fb81437..c204811 100644
--- a/include/clang/AST/DeclObjC.h
+++ b/include/clang/AST/DeclObjC.h
@@ -135,6 +135,9 @@
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
index 0000000..077982a
--- /dev/null
+++ b/test/Sema/va-method-1.m
@@ -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
+
diff --git a/test/Sema/va-method.m b/test/Sema/va-method.m
index 1393af1..2582869 100644
--- a/test/Sema/va-method.m
+++ b/test/Sema/va-method.m
@@ -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);
}