aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbellard <bellard>2003-05-18 18:48:33 +0000
committerbellard <bellard>2003-05-18 18:48:33 +0000
commit638e666c42bcc3f65499baa0660d558a2b40ad8f (patch)
treeaecee10fcd007e7613e8698595278c776f601fbb
parente58bda52cd4a12b6b2fae30588d19bd1528c70d8 (diff)
downloadtinycc-638e666c42bcc3f65499baa0660d558a2b40ad8f.tar.gz
tinycc-638e666c42bcc3f65499baa0660d558a2b40ad8f.tar.bz2
fixed zero arg macro parse
-rw-r--r--tcc.c2
-rw-r--r--tcctest.c6
2 files changed, 7 insertions, 1 deletions
diff --git a/tcc.c b/tcc.c
index 6ef7e85..7c24ce6 100644
--- a/tcc.c
+++ b/tcc.c
@@ -3812,7 +3812,7 @@ static int macro_subst_tok(TokenString *tok_str,
/* NOTE: empty args are allowed, except if no args */
for(;;) {
/* handle '()' case */
- if (!args && tok == ')')
+ if (!args && !sa && tok == ')')
break;
if (!sa)
error("macro '%s' used with too many args",
diff --git a/tcctest.c b/tcctest.c
index 695ddfa..494b4db 100644
--- a/tcctest.c
+++ b/tcctest.c
@@ -253,6 +253,12 @@ void macro_test(void)
/* test macro substituion inside args (should not eat stream) */
printf("qq=%d\n", qq(qq)(2));
+ /* test zero argument case. NOTE: gcc 2.95.x does not accept a
+ null argument without a space. gcc 3.2 fixes that. */
+
+#define qq1(x) 1
+ printf("qq1=%d\n", qq1( ));
+
/* comment with stray handling *\
/
/* this is a valid *\/ comment */