Skip to content

Commit 5368e45

Browse files
author
H. Peter Anvin (Intel)
committed
preproc: fix pasting of TOKEN_HERE, TOKEN_BASE and TOKEN_QMARK
Make the pasting behavior of TOKEN_QMARK, TOKEN_HERE and TOKEN_BASE match the NASM 2.15 behavior: ? is a keyword and pastes as an ID, $ and $$ are treated as operators (which doesn't seem to make much sense, but it is the current legacy behavior.) Reported-by: C. Masloch <pushbx@ulukai.org> Bugzilla: https://bugzilla.nasm.us/show_bug.cgi?id=3392733 Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
1 parent 6d95cc8 commit 5368e45

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

asm/preproc.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* ----------------------------------------------------------------------- *
22
*
3-
* Copyright 1996-2020 The NASM Authors - All Rights Reserved
3+
* Copyright 1996-2021 The NASM Authors - All Rights Reserved
44
* See the file AUTHORS included with the NASM distribution for
55
* the specific copyright holders.
66
*
@@ -1478,7 +1478,7 @@ static Token *tokenize(const char *line)
14781478
p++;
14791479
} else if (nasm_isidstart(*p) || (*p == '$' && nasm_isidstart(p[1]))) {
14801480
/*
1481-
* A regular identifier. This includes keywords, which are not
1481+
* A regular identifier. This includes keywords which are not
14821482
* special to the preprocessor.
14831483
*/
14841484
type = TOKEN_ID;
@@ -4907,7 +4907,8 @@ static inline bool pp_concat_match(const Token *t, enum concat_flags mask)
49074907

49084908
switch (t->type) {
49094909
case TOKEN_ID:
4910-
ctype = CONCAT_ID; /* Ought this include $ and $$? */
4910+
case TOKEN_QMARK: /* Keyword, treated as ID for pasting */
4911+
ctype = CONCAT_ID;
49114912
break;
49124913
case TOKEN_LOCAL_MACRO:
49134914
ctype = CONCAT_LOCAL_MACRO;
@@ -4922,6 +4923,11 @@ static inline bool pp_concat_match(const Token *t, enum concat_flags mask)
49224923
case TOKEN_FLOAT:
49234924
ctype = CONCAT_NUM;
49244925
break;
4926+
case TOKEN_HERE:
4927+
case TOKEN_BASE:
4928+
/* NASM 2.15 treats these as operators, but is that sane? */
4929+
ctype = CONCAT_OP;
4930+
break;
49254931
case TOKEN_OTHER:
49264932
ctype = CONCAT_OP; /* For historical reasons */
49274933
break;

0 commit comments

Comments
 (0)