2009-12-16 04:14:24 +08:00
|
|
|
/* RUN: %clang_cc1 %s -Eonly -std=c89 -pedantic -verify
|
2009-04-18 09:13:56 +08:00
|
|
|
*/
|
|
|
|
/* PR3937 */
|
|
|
|
#define zero() 0
|
|
|
|
#define one(x) 0
|
|
|
|
#define two(x, y) 0
|
2012-06-23 07:59:08 +08:00
|
|
|
#define zero_dot(...) 0 /* expected-warning {{variadic macros are a C99 feature}} */
|
|
|
|
#define one_dot(x, ...) 0 /* expected-warning {{variadic macros are a C99 feature}} expected-note 2{{macro 'one_dot' defined here}} */
|
2009-04-18 09:13:56 +08:00
|
|
|
|
|
|
|
zero()
|
|
|
|
zero(1); /* expected-error {{too many arguments provided to function-like macro invocation}} */
|
|
|
|
zero(1, 2, 3); /* expected-error {{too many arguments provided to function-like macro invocation}} */
|
|
|
|
|
|
|
|
one() /* ok */
|
|
|
|
one(a)
|
|
|
|
one(a,) /* expected-error {{too many arguments provided to function-like macro invocation}} */
|
|
|
|
one(a, b) /* expected-error {{too many arguments provided to function-like macro invocation}} */
|
|
|
|
|
|
|
|
two() /* expected-error {{too few arguments provided to function-like macro invocation}} */
|
|
|
|
two(a) /* expected-error {{too few arguments provided to function-like macro invocation}} */
|
|
|
|
two(a,b)
|
2012-06-23 07:59:08 +08:00
|
|
|
two(a, ) /* expected-warning {{empty macro arguments are a C99 feature}} */
|
2009-04-18 09:13:56 +08:00
|
|
|
two(a,b,c) /* expected-error {{too many arguments provided to function-like macro invocation}} */
|
|
|
|
two(
|
2012-06-23 07:59:08 +08:00
|
|
|
, /* expected-warning {{empty macro arguments are a C99 feature}} */
|
|
|
|
, /* expected-warning {{empty macro arguments are a C99 feature}} \
|
2009-04-18 09:13:56 +08:00
|
|
|
expected-error {{too many arguments provided to function-like macro invocation}} */
|
|
|
|
)
|
2012-06-23 07:59:08 +08:00
|
|
|
two(,) /* expected-warning 2 {{empty macro arguments are a C99 feature}} */
|
2009-04-20 02:26:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-21 05:08:10 +08:00
|
|
|
/* PR4006 & rdar://6807000 */
|
2012-06-23 07:59:08 +08:00
|
|
|
#define e(...) __VA_ARGS__ /* expected-warning {{variadic macros are a C99 feature}} */
|
2009-04-20 02:26:34 +08:00
|
|
|
e(x)
|
2009-04-21 05:08:10 +08:00
|
|
|
e()
|
|
|
|
|
|
|
|
zero_dot()
|
2012-06-23 07:59:08 +08:00
|
|
|
one_dot(x) /* empty ... argument: expected-warning {{must specify at least one argument for '...' parameter of variadic macro}} */
|
|
|
|
one_dot() /* empty first argument, elided ...: expected-warning {{must specify at least one argument for '...' parameter of variadic macro}} */
|
2009-04-24 15:15:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* rdar://6816766 - Crash with function-like macro test at end of directive. */
|
|
|
|
#define E() (i == 0)
|
|
|
|
#if E
|
|
|
|
#endif
|