2009-11-08 04:45:36 +03:00
|
|
|
// RUN: clang-cc -fsyntax-only -verify %s
|
2009-03-24 05:24:46 +03:00
|
|
|
// RUN: clang-cc -fsyntax-only -verify %s -triple x86_64-apple-darwin9
|
2007-10-12 21:48:41 +04:00
|
|
|
|
|
|
|
void f1(int a)
|
|
|
|
{
|
|
|
|
__builtin_va_list ap;
|
|
|
|
|
|
|
|
__builtin_va_start(ap, a, a); // expected-error {{too many arguments to function}}
|
|
|
|
__builtin_va_start(ap, a); // expected-error {{'va_start' used in function with fixed args}}
|
|
|
|
}
|
|
|
|
|
|
|
|
void f2(int a, int b, ...)
|
|
|
|
{
|
|
|
|
__builtin_va_list ap;
|
|
|
|
|
|
|
|
__builtin_va_start(ap, 10); // expected-warning {{second parameter of 'va_start' not last named argument}}
|
|
|
|
__builtin_va_start(ap, a); // expected-warning {{second parameter of 'va_start' not last named argument}}
|
|
|
|
__builtin_va_start(ap, b);
|
|
|
|
}
|
2008-02-11 07:20:54 +03:00
|
|
|
|
|
|
|
void f3(float a, ...)
|
|
|
|
{
|
|
|
|
__builtin_va_list ap;
|
|
|
|
|
|
|
|
__builtin_va_start(ap, a);
|
|
|
|
__builtin_va_start(ap, (a));
|
|
|
|
}
|
2008-11-16 21:43:46 +03:00
|
|
|
|
|
|
|
|
|
|
|
// stdarg: PR3075
|
|
|
|
void f4(const char *msg, ...) {
|
|
|
|
__builtin_va_list ap;
|
|
|
|
__builtin_stdarg_start((ap), (msg));
|
|
|
|
__builtin_va_end (ap);
|
|
|
|
}
|
|
|
|
|
2008-12-16 01:05:35 +03:00
|
|
|
void f5() {
|
|
|
|
__builtin_va_list ap;
|
|
|
|
__builtin_va_start(ap,ap); // expected-error {{'va_start' used in function with fixed args}}
|
|
|
|
}
|
|
|
|
|
|
|
|
void f6(int a, ...) {
|
|
|
|
__builtin_va_list ap;
|
|
|
|
__builtin_va_start(ap); // expected-error {{too few arguments to function}}
|
|
|
|
}
|
2009-01-20 10:46:22 +03:00
|
|
|
|
|
|
|
// PR3350
|
|
|
|
void
|
|
|
|
foo(__builtin_va_list authors, ...) {
|
|
|
|
__builtin_va_start (authors, authors);
|
|
|
|
(void)__builtin_va_arg(authors, int);
|
|
|
|
__builtin_va_end (authors);
|
|
|
|
}
|
|
|
|
|
2009-02-12 12:21:08 +03:00
|
|
|
void f7(int a, ...) {
|
|
|
|
__builtin_va_list ap;
|
|
|
|
__builtin_va_start(ap, a);
|
|
|
|
// FIXME: This error message is sub-par.
|
2009-05-04 02:36:05 +04:00
|
|
|
__builtin_va_arg(ap, int) = 1; // expected-error {{expression is not assignable}}
|
2009-02-12 12:21:08 +03:00
|
|
|
int *x = &__builtin_va_arg(ap, int); // expected-error {{address expression must be an lvalue or a function designator}}
|
|
|
|
__builtin_va_end(ap);
|
|
|
|
}
|
2009-04-05 04:52:59 +04:00
|
|
|
|