ref: c43561c89b53aa1ccd0d98acd400ad059ab99fb0
parent: 98fca36162887f14d76aa2a8746cec529826c079
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Nov 13 03:17:23 EST 2021
cc1: Expand macro parameters Macro parameters must be expanded before the macro itself is expanded.
--- a/src/cmd/cc/cc1/cpp.c
+++ b/src/cmd/cc/cc1/cpp.c
@@ -154,7 +154,6 @@
if (ahead() != '(' && nargs > 0)
return 0;
- disexpand = 1;
next();
n = 0;
argp = buffer;
@@ -257,7 +256,13 @@
size_t elen;
int n, i;
char *s = sym->u.s;
- char *arglist[NR_MACROARG], arguments[INPUTSIZ], buffer[INPUTSIZ];
+ char *arglist[NR_MACROARG];
+ char arguments[INPUTSIZ], buffer[INPUTSIZ];
+
+ DBG("MACRO '%s' detected %d %d", sym->name, disexpand, sym->hide);
+
+ if (disexpand || sym->hide)
+ return 0;
macroname = sym->name;
if (sym == symfile) {
--- a/src/cmd/cc/cc1/lex.c
+++ b/src/cmd/cc/cc1/lex.c
@@ -614,7 +614,7 @@
input->p = p;
tok2str();
if ((sym = lookup(NS_CPP, yytext, NOALLOC)) != NULL) {
- if (!disexpand && !sym->hide && expand(begin, sym))
+ if (expand(sym))
return next();
}
sym = lookup(namespace, yytext, ALLOC);