67 lines · c
1/* RUN: %clang_cc1 %s -Eonly -std=c89 -pedantic -verify2*/3// RUN: %clang_cc1 %s -Eonly -std=c89 -pedantic -Wno-gnu-zero-variadic-macro-arguments -verify -DOMIT_VARIADIC_MACRO_ARGS -DVARIADIC_MACRO_ARGS_REMOVE_COMMA4// RUN: %clang_cc1 %s -Eonly -std=c89 -pedantic -Wno-variadic-macro-arguments-omitted -verify -DOMIT_VARIADIC_MACRO_ARGS5/* PR3937 */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}} */11 12#ifndef OMIT_VARIADIC_MACRO_ARGS13/* expected-note@-3 2{{macro 'one_dot' defined here}} */14#endif15 16zero()17zero(1); /* expected-error {{too many arguments provided to function-like macro invocation}} */18zero(1, 2, 3); /* expected-error {{too many arguments provided to function-like macro invocation}} */19 20one() /* ok */21one(a)22one(a,) /* expected-error {{too many arguments provided to function-like macro invocation}} \23 expected-warning {{empty macro arguments are a C99 feature}}*/24one(a, b) /* expected-error {{too many arguments provided to function-like macro invocation}} */25 26two() /* expected-error {{too few arguments provided to function-like macro invocation}} */27two(a) /* expected-error {{too few arguments provided to function-like macro invocation}} */28two(a,b)29two(a, ) /* expected-warning {{empty macro arguments are a C99 feature}} */30two(a,b,c) /* expected-error {{too many arguments provided to function-like macro invocation}} */31two(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}} */36two(,) /* expected-warning 2 {{empty macro arguments are a C99 feature}} */37 38 39 40/* PR4006 */41#define e(...) __VA_ARGS__ /* expected-warning {{variadic macros are a C99 feature}} */42e(x)43e()44 45zero_dot()46one_dot(x) /* empty ... argument */47one_dot() /* empty first argument, elided ... */48 49#ifndef OMIT_VARIADIC_MACRO_ARGS50/* 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}} */52#endif53 54/* Crash with function-like macro test at end of directive. */55#define E() (i == 0)56#if E57#endif58 59#define NSAssert(condition, desc, ...) /* expected-warning {{variadic macros are a C99 feature}} */ \60 SomeComplicatedStuff((desc), ##__VA_ARGS__)61 62#ifndef VARIADIC_MACRO_ARGS_REMOVE_COMMA63/* expected-warning@-3 {{token pasting of ',' and __VA_ARGS__ is a GNU extension}} */64#endif65 66NSAssert(somecond, somedesc)67