mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-04-18 18:50:23 +08:00
preproc.c: Context-through single macros expansion is deprecated
For now we inform users about their sources need to be updated and also since _all_ context case are legit for single macros only we split lookup into two phases: 1) Lookup in active context, which is perfectly valid 2) Lookup in external contexts, which will be deprecated soon. If (2) happens we yield warning. A typical testcase is --- %macro one 0 %push %$a: %assign %$b 12 %push mov eax, %$a mov eax, %$b ; hit -- context through %pop %pop %endmacro one --- Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
parent
404589e558
commit
d90693c79c
38
preproc.c
38
preproc.c
@ -1462,24 +1462,42 @@ static Context *get_ctx(const char *name, const char **namep,
|
||||
if (!all_contexts)
|
||||
return ctx;
|
||||
|
||||
do {
|
||||
/*
|
||||
* NOTE: In 2.10 we will not need lookup in extarnal
|
||||
* contexts, so this is a gentle way to inform users
|
||||
* about their source code need to be updated
|
||||
*/
|
||||
|
||||
/* first round -- check the current context */
|
||||
m = hash_findix(&ctx->localmac, name);
|
||||
while (m) {
|
||||
if (!mstrcmp(m->name, name, m->casesense))
|
||||
return ctx;
|
||||
m = m->next;
|
||||
}
|
||||
|
||||
/* second round - external contexts */
|
||||
while ((ctx = ctx->next)) {
|
||||
/* Search for this smacro in found context */
|
||||
m = hash_findix(&ctx->localmac, name);
|
||||
while (m) {
|
||||
if (!mstrcmp(m->name, name, m->casesense)) {
|
||||
if ((i > 0) && (all_contexts == true)) {
|
||||
error(ERR_WARNING, "context-local label expansion"
|
||||
" to outer contexts will be deprecated"
|
||||
" starting in NASM 2.10, please update your"
|
||||
" code accordingly");
|
||||
}
|
||||
/* NOTE: obsolete since 2.10 */
|
||||
static int once = 0;
|
||||
if (!once) {
|
||||
error(ERR_WARNING, "context-local macro expansion"
|
||||
" to outer contexts will be deprecated"
|
||||
" starting in NASM 2.10, please update your"
|
||||
" code accordingly");
|
||||
once = 1;
|
||||
}
|
||||
error(ERR_WARNING, "`%s': context through macro expansion", name);
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
m = m->next;
|
||||
}
|
||||
ctx = ctx->next;
|
||||
}
|
||||
while (ctx);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user