diff options
author | Chris Lattner <sabre@nondot.org> | 2008-09-28 06:05:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-09-28 06:05:35 +0000 |
commit | 891ed9aa87e14ce4c13155a77c09cde4555f7dd1 (patch) | |
tree | 2b639a87a9c3700380128bf66d627b9976b19d5d | |
parent | bd7eb1c3b2af5cd0a7540c79da85e2ce15a893f4 (diff) |
Fix rdar://6252231 - cannot call vsnprintf with va_list on x86_64,
by decaying __builtin_va_list's type when forming builtins. On
x86-64 (and other targets) __builtin_va_list is a typedef for
an array.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56768 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/Builtins.cpp | 3 | ||||
-rw-r--r-- | test/Sema/builtin-object-size.c | 9 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/AST/Builtins.cpp b/lib/AST/Builtins.cpp index 8249c4119d..31e099af4e 100644 --- a/lib/AST/Builtins.cpp +++ b/lib/AST/Builtins.cpp @@ -137,6 +137,9 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context, case 'a': Type = Context.getBuiltinVaListType(); assert(!Type.isNull() && "builtin va list type not initialized!"); + // Do array -> pointer decay. The builtin should use the decayed type. + if (Type->isArrayType()) + Type = Context.getArrayDecayedType(Type); break; case 'V': { char *End; diff --git a/test/Sema/builtin-object-size.c b/test/Sema/builtin-object-size.c index abc25da1a3..fc322ad4e3 100644 --- a/test/Sema/builtin-object-size.c +++ b/test/Sema/builtin-object-size.c @@ -1,4 +1,5 @@ // RUN: clang -fsyntax-only -verify %s +// RUN: clang -fsyntax-only -triple x86_64-apple-darwin9 -verify %s int a[10]; @@ -17,3 +18,11 @@ int f2() { int f3() { return __builtin_object_size(&a, 4); // expected-error {{argument should be a value from 0 to 3}} } + + +// rdar://6252231 - cannot call vsnprintf with va_list on x86_64 +void f4(const char *fmt, ...) { + __builtin_va_list args; + __builtin___vsnprintf_chk (0, 42, 0, 11, fmt, args); +} + |