diff options
| author | Steve Naroff <snaroff@apple.com> | 2007-12-18 03:41:15 +0000 |
|---|---|---|
| committer | Steve Naroff <snaroff@apple.com> | 2007-12-18 03:41:15 +0000 |
| commit | b74406ba98685696dcf53c0128a4281bdf83b0a7 (patch) | |
| tree | 58d1147b697fb9f775599f1e808b29dd7a14fede | |
| parent | aa5c91980e1ff6cb591d6f02b38f3ac526ffbc23 (diff) | |
| download | bcm5719-llvm-b74406ba98685696dcf53c0128a4281bdf83b0a7.tar.gz bcm5719-llvm-b74406ba98685696dcf53c0128a4281bdf83b0a7.zip | |
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.
llvm-svn: 45146
| -rw-r--r-- | clang/Sema/SemaChecking.cpp | 2 | ||||
| -rw-r--r-- | clang/Sema/SemaType.cpp | 2 | ||||
| -rw-r--r-- | clang/test/Sema/va-method.m | 17 |
3 files changed, 19 insertions, 2 deletions
diff --git a/clang/Sema/SemaChecking.cpp b/clang/Sema/SemaChecking.cpp index b366a2b70f9..4d2e362038c 100644 --- a/clang/Sema/SemaChecking.cpp +++ b/clang/Sema/SemaChecking.cpp @@ -62,7 +62,7 @@ Sema::CheckFunctionCall(Expr *Fn, 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())) { diff --git a/clang/Sema/SemaType.cpp b/clang/Sema/SemaType.cpp index c89018a6772..a9b8066f972 100644 --- a/clang/Sema/SemaType.cpp +++ b/clang/Sema/SemaType.cpp @@ -366,7 +366,7 @@ QualType Sema::ObjcGetTypeForMethodDefinition(DeclTy *D) { ArgTys.push_back(ArgTy); } T = Context.getFunctionType(T, &ArgTys[0], ArgTys.size(), - false); + MDecl->isVariadic()); return T; } diff --git a/clang/test/Sema/va-method.m b/clang/test/Sema/va-method.m new file mode 100644 index 00000000000..a8a70530431 --- /dev/null +++ b/clang/test/Sema/va-method.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); // expected-warning {{second parameter of 'va_start' not last named argument}} + while (*types) ; + va_end(ap); +} + +@end + |

