Chris Lattner | 0a4f1b9 | 2009-04-18 01:13:56 +0000 | [diff] [blame] | 1 | /* RUN: clang-cc %s -Eonly -std=c89 -pedantic -verify |
| 2 | */ |
| 3 | /* PR3937 */ |
| 4 | #define zero() 0 |
| 5 | #define one(x) 0 |
| 6 | #define two(x, y) 0 |
Chris Lattner | 97e2de1 | 2009-04-20 21:08:10 +0000 | [diff] [blame] | 7 | #define zero_dot(...) 0 /* expected-warning {{variadic macros were introduced in C99}} */ |
| 8 | #define one_dot(x, ...) 0 /* expected-warning {{variadic macros were introduced in C99}} */ |
Chris Lattner | 0a4f1b9 | 2009-04-18 01:13:56 +0000 | [diff] [blame] | 9 | |
| 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}} */ |
| 13 | |
| 14 | one() /* ok */ |
| 15 | one(a) |
| 16 | one(a,) /* expected-error {{too many arguments provided to function-like macro invocation}} */ |
| 17 | one(a, b) /* expected-error {{too many arguments provided to function-like macro invocation}} */ |
| 18 | |
| 19 | two() /* expected-error {{too few arguments provided to function-like macro invocation}} */ |
| 20 | two(a) /* expected-error {{too few arguments provided to function-like macro invocation}} */ |
| 21 | two(a,b) |
| 22 | two(a, ) /* expected-warning {{empty macro arguments were standardized in C99}} */ |
| 23 | two(a,b,c) /* expected-error {{too many arguments provided to function-like macro invocation}} */ |
| 24 | two( |
| 25 | , /* expected-warning {{empty macro arguments were standardized in C99}} */ |
| 26 | , /* expected-warning {{empty macro arguments were standardized in C99}} \ |
| 27 | expected-error {{too many arguments provided to function-like macro invocation}} */ |
| 28 | ) |
| 29 | two(,) /* expected-warning 2 {{empty macro arguments were standardized in C99}} */ |
Chris Lattner | 8fde597 | 2009-04-19 18:26:34 +0000 | [diff] [blame] | 30 | |
| 31 | |
| 32 | |
Chris Lattner | 97e2de1 | 2009-04-20 21:08:10 +0000 | [diff] [blame] | 33 | /* PR4006 & rdar://6807000 */ |
Chris Lattner | 8fde597 | 2009-04-19 18:26:34 +0000 | [diff] [blame] | 34 | #define e(...) __VA_ARGS__ /* expected-warning {{variadic macros were introduced in C99}} */ |
| 35 | e(x) |
Chris Lattner | 97e2de1 | 2009-04-20 21:08:10 +0000 | [diff] [blame] | 36 | e() |
| 37 | |
| 38 | zero_dot() |
| 39 | one_dot(x) /* empty ... argument: expected-warning {{varargs argument missing, but tolerated as an extension}} */ |
| 40 | one_dot() /* empty first argument, elided ...: expected-warning {{varargs argument missing, but tolerated as an extension}} */ |
Chris Lattner | a864cf7 | 2009-04-24 07:15:46 +0000 | [diff] [blame] | 41 | |
| 42 | |
| 43 | /* rdar://6816766 - Crash with function-like macro test at end of directive. */ |
| 44 | #define E() (i == 0) |
| 45 | #if E |
| 46 | #endif |