1 /* RUN: %clang_cc1 %s -Eonly -std=c89 -pedantic -verify
3 // RUN: %clang_cc1 %s -Eonly -std=c89 -pedantic -Wno-gnu-zero-variadic-macro-arguments -verify -DOMIT_VARIADIC_MACRO_ARGS -DVARIADIC_MACRO_ARGS_REMOVE_COMMA
4 // RUN: %clang_cc1 %s -Eonly -std=c89 -pedantic -Wno-variadic-macro-arguments-omitted -verify -DOMIT_VARIADIC_MACRO_ARGS
6 #define zero() 0 /* expected-note 2 {{defined here}} */
7 #define one(x) 0 /* expected-note 2 {{defined here}} */
8 #define two(x, y) 0 /* expected-note 4 {{defined here}} */
9 #define zero_dot(...) 0 /* expected-warning {{variadic macros are a C99 feature}} */
10 #define one_dot(x, ...) 0 /* expected-warning {{variadic macros are a C99 feature}} */
12 #ifndef OMIT_VARIADIC_MACRO_ARGS
13 /* expected-note@-3 2{{macro 'one_dot' defined here}} */
17 zero(1); /* expected-error {{too many arguments provided to function-like macro invocation}} */
18 zero(1, 2, 3); /* expected-error {{too many arguments provided to function-like macro invocation}} */
22 one(a
,) /* expected-error {{too many arguments provided to function-like macro invocation}} \
23 expected-warning {{empty macro arguments are a C99 feature}}*/
24 one(a
, b
) /* expected-error {{too many arguments provided to function-like macro invocation}} */
26 two() /* expected-error {{too few arguments provided to function-like macro invocation}} */
27 two(a
) /* expected-error {{too few arguments provided to function-like macro invocation}} */
29 two(a
, ) /* expected-warning {{empty macro arguments are a C99 feature}} */
30 two(a
,b
,c
) /* expected-error {{too many arguments provided to function-like macro invocation}} */
32 , /* expected-warning {{empty macro arguments are a C99 feature}} */
33 , /* expected-warning {{empty macro arguments are a C99 feature}} \
34 expected-error {{too many arguments provided to function-like macro invocation}} */
35 ) /* expected-warning {{empty macro arguments are a C99 feature}} */
36 two(,) /* expected-warning 2 {{empty macro arguments are a C99 feature}} */
41 #define e(...) __VA_ARGS__ /* expected-warning {{variadic macros are a C99 feature}} */
46 one_dot(x
) /* empty ... argument */
47 one_dot() /* empty first argument, elided ... */
49 #ifndef OMIT_VARIADIC_MACRO_ARGS
50 /* expected-warning@-4 {{passing no argument for the '...' parameter of a variadic macro is a C23 extension}} */
51 /* expected-warning@-4 {{passing no argument for the '...' parameter of a variadic macro is a C23 extension}} */
54 /* Crash with function-like macro test at end of directive. */
59 #define NSAssert(condition, desc, ...) /* expected-warning {{variadic macros are a C99 feature}} */ \
60 SomeComplicatedStuff((desc), ##__VA_ARGS__)
62 #ifndef VARIADIC_MACRO_ARGS_REMOVE_COMMA
63 /* expected-warning@-3 {{token pasting of ',' and __VA_ARGS__ is a GNU extension}} */
66 NSAssert(somecond
, somedesc
)