[qfcc] Save force-expanding function-type arg macros

The expansion is necessary for the final test in preproc-2.r, but breaks
preproc-1.r because the closing ')' is *not* visible to collect_args
(its assumption is incorrect). This needs reworking (and probably
rethinking) of the entire macro argument collection, but I need a little
break from the preprocessor (and it's good enough for *most* uses), so
I'm adding the code (disabled) in order to avoid losing it and my notes
about the problem.
This commit is contained in:
Bill Currie 2023-11-23 13:28:48 +09:00
parent 4480453861
commit 5e02716a01

View file

@ -1723,6 +1723,29 @@ rescan:
} }
queue_macro (extra, m); queue_macro (extra, m);
goto rescan; goto rescan;
#if 0 // causes preproc-1.r to fail (see XXX below)
} else if (token == -rua_id && !macro->name // in an arg
&& (sym = symtab_lookup (extra->macro_tab, e.text))
&& !sym->s.macro->next
&& sym->s.macro->params) {
// force function-type macros in macro arguments to be expanded
auto m = sym->s.macro;
auto c = macro->cursor;
// XXX breakage for preproc-1.r: collect_args assumes the macro
// is complete, but in the case of preproc-1.r, it is not. In fact,
// with the final ) removed from the F macro, tokens are consumed
// to the end of the file. Thus, nt x = F(LPAREN(), 0, <:-);
// expands to int x = 42 ); instead of int x = 42;
// However, this block is needed for the H5C(H5A()) test
collect_args (m, macro, scanner);
if (macro->cursor != c) {
if (m->update) {
m->update (m, scanner);
}
queue_macro (extra, m);
goto rescan;
}
#endif
} }
*tok = e; *tok = e;
} }