aboutsummaryrefslogtreecommitdiff
path: root/test/Preprocessor/macro_fn.c
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-18 01:13:56 +0000
committerChris Lattner <sabre@nondot.org>2009-04-18 01:13:56 +0000
commit0a4f1b9550b81b1391d79c0dd5a416951f4df9a6 (patch)
tree39fc086df1e22a6489c9022977332065f94f2410 /test/Preprocessor/macro_fn.c
parentdf91ef3d6c55692a0236f67b6c6b134a3bf84098 (diff)
Substantially restructure function-like macro argument parsing.
Highlights: PP::isNextPPTokenLParen() no longer eats the ( when present. We now simplify slightly the logic parsing macro arguments. We now handle PR3937 and other related cases correctly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69411 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Preprocessor/macro_fn.c')
-rw-r--r--test/Preprocessor/macro_fn.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/Preprocessor/macro_fn.c b/test/Preprocessor/macro_fn.c
new file mode 100644
index 0000000000..8dc8b77d6d
--- /dev/null
+++ b/test/Preprocessor/macro_fn.c
@@ -0,0 +1,27 @@
+/* RUN: clang-cc %s -Eonly -std=c89 -pedantic -verify
+*/
+/* PR3937 */
+#define zero() 0
+#define one(x) 0
+#define two(x, y) 0
+
+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}} */