Commit c24ffc4d authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

C++: Expand arguments in nested function-like macros



Task-number: QTCREATORBUG-13219
Change-Id: I319fe39d696ccc28230d421b1395faf4dd452b03
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 54602502
......@@ -905,7 +905,7 @@ void Preprocessor::skipPreprocesorDirective(PPToken *tk)
bool Preprocessor::handleIdentifier(PPToken *tk)
{
ScopedBoolSwap s(m_state.m_inPreprocessorDirective, true);
ScopedBoolSwap s(m_state.m_inPreprocessorDirective, !tk->f.expanded);
static const QByteArray ppLine("__LINE__");
static const QByteArray ppFile("__FILE__");
......
......@@ -1877,21 +1877,27 @@ void tst_Preprocessor::concat()
"#define concat(x,y) x ## y\n"
"#define xconcat(x, y) concat(x, y)\n"
"#define FOO 42\n"
"int var = xconcat(0x, FOO);\n";
"int var1 = concat(0x, FOO);\n"
"int var2 = xconcat(0x, FOO);\n";
QByteArray prep = preprocess.run(QLatin1String("<stdin>"), input);
const QByteArray output = _(
"# 1 \"<stdin>\"\n"
"\n"
"\n"
"\n"
"int var =\n"
"# expansion begin 87,7 ~1\n"
"0x42\n"
"int var1 =\n"
"# expansion begin 88,6 ~1\n"
"0xFOO\n"
"# expansion end\n"
"# 4 \"<stdin>\"\n"
" ;\n"
"int var2 =\n"
"# expansion begin 116,7 ~1\n"
"0x42\n"
"# expansion end\n"
"# 5 \"<stdin>\"\n"
" ;\n"
);
QEXPECT_FAIL(0, "QTCREATORBUG-13219", Abort);
QCOMPARE(prep.constData(), output.constData());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment