Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Preprocessor / macro_fn.c
blob5f4ea0e26d5d8b643ec2b535489ae8f502002cc3
1 /* RUN: %clang_cc1 %s -Eonly -std=c89 -pedantic -verify
2 */
3 /* PR3937 */
4 #define zero() 0 /* expected-note 2 {{defined here}} */
5 #define one(x) 0 /* expected-note 2 {{defined here}} */
6 #define two(x, y) 0 /* expected-note 4 {{defined here}} */
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}} */
10 zero()
11 zero(1); /* expected-error {{too many arguments provided to function-like macro invocation}} */
12 zero(1, 2, 3); /* expected-error {{too many arguments provided to function-like macro invocation}} */
14 one() /* ok */
15 one(a)
16 one(a,) /* expected-error {{too many arguments provided to function-like macro invocation}} \
17 expected-warning {{empty macro arguments are a C99 feature}}*/
18 one(a, b) /* expected-error {{too many arguments provided to function-like macro invocation}} */
20 two() /* expected-error {{too few arguments provided to function-like macro invocation}} */
21 two(a) /* expected-error {{too few arguments provided to function-like macro invocation}} */
22 two(a,b)
23 two(a, ) /* expected-warning {{empty macro arguments are a C99 feature}} */
24 two(a,b,c) /* expected-error {{too many arguments provided to function-like macro invocation}} */
25 two(
26 , /* expected-warning {{empty macro arguments are a C99 feature}} */
27 , /* expected-warning {{empty macro arguments are a C99 feature}} \
28 expected-error {{too many arguments provided to function-like macro invocation}} */
29 ) /* expected-warning {{empty macro arguments are a C99 feature}} */
30 two(,) /* expected-warning 2 {{empty macro arguments are a C99 feature}} */
34 /* PR4006 */
35 #define e(...) __VA_ARGS__ /* expected-warning {{variadic macros are a C99 feature}} */
36 e(x)
37 e()
39 zero_dot()
40 one_dot(x) /* empty ... argument: expected-warning {{must specify at least one argument for '...' parameter of variadic macro}} */
41 one_dot() /* empty first argument, elided ...: expected-warning {{must specify at least one argument for '...' parameter of variadic macro}} */
44 /* Crash with function-like macro test at end of directive. */
45 #define E() (i == 0)
46 #if E
47 #endif
50 #define NSAssert(condition, desc, ...) /* expected-warning {{variadic macros are a C99 feature}} */ \
51 SomeComplicatedStuff((desc), ##__VA_ARGS__) /* expected-warning {{token pasting of ',' and __VA_ARGS__ is a GNU extension}} */
52 NSAssert(somecond, somedesc)