Set __PASS__ to 3 for preprocess only

When running the preprocessor only, set __PASS__ to 3.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin 2008-09-25 15:45:06 -07:00
parent 2c8ad285fd
commit 61f130f4e9
3 changed files with 17 additions and 9 deletions

View File

@ -3674,9 +3674,8 @@ For example, if the \c{altreg} package is included (see
The macro \c{__PASS__} is defined to be \c{1} on preparatory passes,
and \c{2} on the final pass. In preprocess-only mode, it is set to
\c{2} (there being only the final pass); when running only to generate
dependencies (due to the \c{-M} or \c{-MG} option, see \k{opt-M}) it
is set to \c{0}.
\c{3}, and when running only to generate dependencies (due to the
\c{-M} or \c{-MG} option, see \k{opt-M}) it is set to \c{0}.
\e{Avoid using this macro if at all possible. It is tremendously easy
to generate very strange errors by misusing it, and the semantics may

2
nasm.c
View File

@ -382,7 +382,7 @@ int main(int argc, char **argv)
location.known = false;
/* pass = 1; */
preproc->reset(inname, 2, report_error, evaluate, &nasmlist,
preproc->reset(inname, 3, report_error, evaluate, &nasmlist,
depend_ptr);
while ((line = preproc->getline())) {

View File

@ -4249,7 +4249,14 @@ pp_reset(char *file, int apass, efunc errfunc, evalfunc eval,
do_predef = true;
list = listgen;
evaluate = eval;
pass = apass;
/*
* 0 for dependencies, 1 for preparatory passes, 2 for final pass.
* The caller, however, will also pass in 3 for preprocess-only so
* we can set __PASS__ accordingly.
*/
pass = apass > 2 ? 2 : apass;
dephead = deptail = deplist;
if (deplist) {
StrList *sl = nasm_malloc(strlen(file)+1+sizeof sl->next);
@ -4259,12 +4266,14 @@ pp_reset(char *file, int apass, efunc errfunc, evalfunc eval,
deptail = &sl->next;
}
/* Define the __PASS__ macro. This is defined here unlike
all the other builtins, because it is special -- it varies between
passes. */
/*
* Define the __PASS__ macro. This is defined here unlike
* all the other builtins, because it is special -- it varies between
* passes.
*/
t = nasm_malloc(sizeof(*t));
t->next = NULL;
make_tok_num(t, pass);
make_tok_num(t, apass);
t->a.mac = NULL;
define_smacro(NULL, "__PASS__", true, 0, t);
}