diff options
author | Ed Schouten <ed@FreeBSD.org> | 2009-06-02 17:58:47 +0000 |
---|---|---|
committer | Ed Schouten <ed@FreeBSD.org> | 2009-06-02 17:58:47 +0000 |
commit | ec2b103c267a06a66e926f62cd96767b280f5cf5 (patch) | |
tree | ce7d964cbb5e39695b71481698f10cb099c23d4a /test/Preprocessor/macro_fn.c | |
download | src-ec2b103c267a06a66e926f62cd96767b280f5cf5.tar.gz src-ec2b103c267a06a66e926f62cd96767b280f5cf5.zip |
Import Clang, at r72732.vendor/clang/clang-r72732
Notes
Notes:
svn path=/vendor/clang/dist/; revision=193326
svn path=/vendor/clang/clang-r72732/; revision=193327; tag=vendor/clang/clang-r72732
Diffstat (limited to 'test/Preprocessor/macro_fn.c')
-rw-r--r-- | test/Preprocessor/macro_fn.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/Preprocessor/macro_fn.c b/test/Preprocessor/macro_fn.c new file mode 100644 index 000000000000..5c55c0ceed5f --- /dev/null +++ b/test/Preprocessor/macro_fn.c @@ -0,0 +1,46 @@ +/* RUN: clang-cc %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 |