[LV] Add test showing debug output for loops with uncountable BTCs.
[llvm-project.git] / clang / test / Preprocessor / macro_fn.c
blob2e72bd272084e149a09cf11d3aca7ab2e9352774
1 /* RUN: %clang_cc1 %s -Eonly -std=c89 -pedantic -verify
2 */
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
5 /* 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}} */
12 #ifndef OMIT_VARIADIC_MACRO_ARGS
13 /* expected-note@-3 2{{macro 'one_dot' defined here}} */
14 #endif
16 zero()
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}} */
20 one() /* ok */
21 one(a)
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}} */
28 two(a,b)
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}} */
31 two(
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}} */
40 /* PR4006 */
41 #define e(...) __VA_ARGS__ /* expected-warning {{variadic macros are a C99 feature}} */
42 e(x)
43 e()
45 zero_dot()
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}} */
52 #endif
54 /* Crash with function-like macro test at end of directive. */
55 #define E() (i == 0)
56 #if E
57 #endif
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}} */
64 #endif
66 NSAssert(somecond, somedesc)