fix: Paste tokens in arguments of nested macros (#1062)

This commit is contained in:
wroy authored and GitHub committed 2026-10-31 09:54:46 +01:00
1 parent c266c160a8
commit 4271677e15
2 files changed
+39 -1

No files matched your search

+19 -1
View File
@@ -7,6 +7,7 @@
#include "Parsing/Simple/SimpleExpressionInterpreter.h"
#include "Utils/StringUtils.h"
#include <algorithm>
#include <regex>
#include <sstream>
#include <utility>
@@ -879,8 +880,25 @@ void DefinesStreamProxy::ExpandMacro(ParserLine& line,
const Define* macro,
const std::vector<std::string>& parameterValues)
{
std::vector<std::string> pastedValues;
const auto* values = &parameterValues;
if (std::ranges::any_of(parameterValues,
[](const std::string& value)
{
return value.find("##") != std::string::npos;
}))
{
pastedValues = parameterValues;
for (auto& value : pastedValues)
{
if (value.find("##") != std::string::npos)
ProcessTokenPastingOperators(line, linePos, value);
}
values = &pastedValues;
}
std::ostringstream rawOutput;
InsertMacroParameters(rawOutput, macro, parameterValues);
InsertMacroParameters(rawOutput, macro, *values);
std::string str = rawOutput.str();
ProcessNestedMacros(line, linePos, callstack, str);