1/* RUN: %clang_cc1 %s -Eonly -std=c89 -pedantic -verify
2*/
3/* PR3937 */
4#define zero() 0
5#define one(x) 0
6#define two(x, y) 0
7#define zero_dot(...) 0   /* expected-warning {{variadic macros are a C99 feature}} */
8#define one_dot(x, ...) 0 /* expected-warning {{variadic macros are a C99 feature}} expected-note 2{{macro 'one_dot' defined here}} */
9
10zero()
11zero(1);          /* expected-error {{too many arguments provided to function-like macro invocation}} */
12zero(1, 2, 3);    /* expected-error {{too many arguments provided to function-like macro invocation}} */
13
14one()   /* ok */
15one(a)
16one(a,)           /* expected-error {{too many arguments provided to function-like macro invocation}} */
17one(a, b)         /* expected-error {{too many arguments provided to function-like macro invocation}} */
18
19two()       /* expected-error {{too few arguments provided to function-like macro invocation}} */
20two(a)      /* expected-error {{too few arguments provided to function-like macro invocation}} */
21two(a,b)
22two(a, )    /* expected-warning {{empty macro arguments are a C99 feature}} */
23two(a,b,c)  /* expected-error {{too many arguments provided to function-like macro invocation}} */
24two(
25    ,     /* expected-warning {{empty macro arguments are a C99 feature}} */
26    ,     /* expected-warning {{empty macro arguments are a C99 feature}}  \
27             expected-error {{too many arguments provided to function-like macro invocation}} */
28    )
29two(,)      /* expected-warning 2 {{empty macro arguments are a C99 feature}} */
30
31
32
33/* PR4006 & rdar://6807000 */
34#define e(...) __VA_ARGS__  /* expected-warning {{variadic macros are a C99 feature}} */
35e(x)
36e()
37
38zero_dot()
39one_dot(x)  /* empty ... argument: expected-warning {{must specify at least one argument for '...' parameter of variadic macro}}  */
40one_dot()   /* empty first argument, elided ...: expected-warning {{must specify at least one argument for '...' parameter of variadic macro}} */
41
42
43/* rdar://6816766 - Crash with function-like macro test at end of directive. */
44#define E() (i == 0)
45#if E
46#endif
47