Fix preprocessor to respect strings in joins (#5007)

This adheres more to the wording used in IEEE 1800-2017 22.5.1,
specifying the join operator to be more of a delimiter than join:

> A `` delimits lexical tokens without introducing white space,
> allowing identifiers to be constructed from arguments.

Before, string RHS arguments to the join operator were silently dropped.

Signed-off-by: Arkadiusz Kozdra <[email protected]>
This commit is contained in:
Arkadiusz Kozdra
2024-03-20 08:54:23 -04:00
committed by GitHub
parent 26f15e11c4
commit 88831ca21b
4 changed files with 18 additions and 4 deletions
+2 -2
View File
@@ -1411,7 +1411,7 @@ int V3PreProcImp::getStateToken() {
}
}
case ps_JOIN: {
if (tok == VP_SYMBOL || tok == VP_TEXT) {
if (tok == VP_SYMBOL || tok == VP_TEXT || tok == VP_STRING) {
UASSERT(!m_joinStack.empty(), "`` join stack empty, but in a ``");
const string lhs = m_joinStack.top();
m_joinStack.pop();
@@ -1423,7 +1423,7 @@ int V3PreProcImp::getStateToken() {
unputString(out);
statePop();
goto next_tok;
} else if (tok == VP_EOF || tok == VP_WHITE || tok == VP_COMMENT || tok == VP_STRING) {
} else if (tok == VP_EOF || tok == VP_WHITE || tok == VP_COMMENT) {
// Other compilers just ignore this, so no warning
// "Expecting symbol to terminate ``; whitespace etc cannot
// follow ``. Found: "+tokenName(tok)+"\n"