blob: e928997dd8babba6e2e98ea8e9602ac0eb39eec9 [file] [log] [blame]
Daniel Dunbar4fcfde42009-11-08 01:45:36 +00001// RUN: clang-cc -fsyntax-only -verify %s
Daniel Dunbard7d5f022009-03-24 02:24:46 +00002// RUN: clang-cc -fsyntax-only -verify %s -triple x86_64-apple-darwin9
Anders Carlsson6eda8c92007-10-12 17:48:41 +00003
4void f1(int a)
5{
6 __builtin_va_list ap;
7
8 __builtin_va_start(ap, a, a); // expected-error {{too many arguments to function}}
9 __builtin_va_start(ap, a); // expected-error {{'va_start' used in function with fixed args}}
10}
11
12void f2(int a, int b, ...)
13{
14 __builtin_va_list ap;
15
16 __builtin_va_start(ap, 10); // expected-warning {{second parameter of 'va_start' not last named argument}}
17 __builtin_va_start(ap, a); // expected-warning {{second parameter of 'va_start' not last named argument}}
18 __builtin_va_start(ap, b);
19}
Anders Carlsson88cf2262008-02-11 04:20:54 +000020
21void f3(float a, ...)
22{
23 __builtin_va_list ap;
24
25 __builtin_va_start(ap, a);
26 __builtin_va_start(ap, (a));
27}
Chris Lattner58ace882008-11-16 18:43:46 +000028
29
30// stdarg: PR3075
31void f4(const char *msg, ...) {
32 __builtin_va_list ap;
33 __builtin_stdarg_start((ap), (msg));
34 __builtin_va_end (ap);
35}
36
Eli Friedman56f20ae2008-12-15 22:05:35 +000037void f5() {
38 __builtin_va_list ap;
39 __builtin_va_start(ap,ap); // expected-error {{'va_start' used in function with fixed args}}
40}
41
42void f6(int a, ...) {
43 __builtin_va_list ap;
44 __builtin_va_start(ap); // expected-error {{too few arguments to function}}
45}
Eli Friedman6597f982009-01-20 07:46:22 +000046
47// PR3350
48void
49foo(__builtin_va_list authors, ...) {
50 __builtin_va_start (authors, authors);
51 (void)__builtin_va_arg(authors, int);
52 __builtin_va_end (authors);
53}
54
Daniel Dunbaradadd8d2009-02-12 09:21:08 +000055void f7(int a, ...) {
56 __builtin_va_list ap;
57 __builtin_va_start(ap, a);
58 // FIXME: This error message is sub-par.
Eli Friedman53202852009-05-03 22:36:05 +000059 __builtin_va_arg(ap, int) = 1; // expected-error {{expression is not assignable}}
Daniel Dunbaradadd8d2009-02-12 09:21:08 +000060 int *x = &__builtin_va_arg(ap, int); // expected-error {{address expression must be an lvalue or a function designator}}
61 __builtin_va_end(ap);
62}
Chris Lattnerf5026912009-04-05 00:52:59 +000063