commit 26ff02d15aedb16bc16fda9a2943d75a8ae95c75 Author: Roberto E. Vargas Caballero <k...@shike2.com> AuthorDate: Fri Jan 13 15:09:17 2017 +0100 Commit: Roberto E. Vargas Caballero <k...@shike2.com> CommitDate: Fri Jan 13 15:09:17 2017 +0100
[cc1] Accept variadic macro definitions This is the first patch oriented to the implementation of variadic macros, and it allows to define them and to use them, but it does not allow to call them with parameters in the variable part. diff --git a/cc1/cpp.c b/cc1/cpp.c index eb98fcc..3612589 100644 --- a/cc1/cpp.c +++ b/cc1/cpp.c @@ -295,6 +295,10 @@ getpars(Symbol *args[NR_MACROARG]) cpperror("too many parameters in macro"); return NR_MACROARG; } + if (accept(ELLIPSIS)) { + args[n++] = NULL; + break; + } if (yytoken != IDEN) { cpperror("macro arguments must be identifiers"); return NR_MACROARG; @@ -391,6 +395,8 @@ define(void) namespace = NS_IDEN; /* Avoid polution in NS_CPP */ if ((n = getpars(args)) == NR_MACROARG) goto delete; + if (n > 0 && !args[n-1]) /* it is a variadic function */ + --n; sprintf(buff, "%02d#", n); if (!getdefs(args, n, buff+3, LINESIZ-3)) goto delete;