diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
commit | be1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch) | |
tree | 1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/Preprocessor/macro_fn.c | |
parent | c4626a62754862d20b41e8a46a3574264ea80e6d (diff) | |
parent | f1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff) |
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/Preprocessor/macro_fn.c')
-rw-r--r-- | clang/test/Preprocessor/macro_fn.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/clang/test/Preprocessor/macro_fn.c b/clang/test/Preprocessor/macro_fn.c new file mode 100644 index 0000000..85733b4 --- /dev/null +++ b/clang/test/Preprocessor/macro_fn.c @@ -0,0 +1,46 @@ +/* RUN: %clang_cc1 %s -Eonly -std=c89 -pedantic -verify +*/ +/* PR3937 */ +#define zero() 0 +#define one(x) 0 +#define two(x, y) 0 +#define zero_dot(...) 0 /* expected-warning {{variadic macros were introduced in C99}} */ +#define one_dot(x, ...) 0 /* expected-warning {{variadic macros were introduced in C99}} */ + +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) +two(a, ) /* expected-warning {{empty macro arguments were standardized in C99}} */ +two(a,b,c) /* expected-error {{too many arguments provided to function-like macro invocation}} */ +two( + , /* expected-warning {{empty macro arguments were standardized in C99}} */ + , /* expected-warning {{empty macro arguments were standardized in C99}} \ + expected-error {{too many arguments provided to function-like macro invocation}} */ + ) +two(,) /* expected-warning 2 {{empty macro arguments were standardized in C99}} */ + + + +/* PR4006 & rdar://6807000 */ +#define e(...) __VA_ARGS__ /* expected-warning {{variadic macros were introduced in C99}} */ +e(x) +e() + +zero_dot() +one_dot(x) /* empty ... argument: expected-warning {{varargs argument missing, but tolerated as an extension}} */ +one_dot() /* empty first argument, elided ...: expected-warning {{varargs argument missing, but tolerated as an extension}} */ + + +/* rdar://6816766 - Crash with function-like macro test at end of directive. */ +#define E() (i == 0) +#if E +#endif |