Fixed parentheses handling when a function-like macro name itself is used as an macro argument.

This commit is contained in:
acqn
2022-08-07 12:45:48 +08:00
parent 0a051a4dee
commit 7971eec3cc

View File

@@ -1142,17 +1142,27 @@ static void MacroReplacement (StrBuf* Source, StrBuf* Target, int MultiLine)
if (Whitespace > 0) { if (Whitespace > 0) {
SB_AppendChar (Target, ' '); SB_AppendChar (Target, ' ');
} }
if (CurC == '#') {
if (OLine == 0) { /* Directives can only be found in an argument list
OLine = Target; ** that spans multiple lines.
ParseDirectives (0); */
OLine = 0; if (MultiLine) {
} else { if (CurC == '#') {
ParseDirectives (0); /* If we were going to support #pragma in
** macro argument list, it would be output
** to OLine.
*/
if (OLine == 0) {
OLine = Target;
ParseDirectives (0);
OLine = 0;
} else {
ParseDirectives (0);
}
} }
/* Add the source info to preprocessor output if needed */
AddPreLine (Target);
} }
/* Add the source info to preprocessor output if needed */
AddPreLine (Target);
} else { } else {
/* Function-like macro */ /* Function-like macro */
if (OLine == 0) { if (OLine == 0) {