Commit feba990f authored by hjk's avatar hjk Committed by hjk
Browse files

preprocessor: swallow ) after defined(...



Task-number: QTCREATORBUG-7256
Change-Id: I6149e56e5f50f75c9e039be9c162036a3890e2d7
Reviewed-by: default avatarDavid Schulz <david.schulz@nokia.com>
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 75ca41be
......@@ -652,7 +652,13 @@ void Preprocessor::handleDefined(PPToken *tk)
else
break;
} while (isValidToken(*tk));
pushToken(tk);
if (lparenSeen) {
while (tk->isNot(T_RPAREN))
lex(tk);
} else {
pushToken(tk);
}
QByteArray result(1, '0');
if (m_env->resolve(idToken.asByteArrayRef()))
result[0] = '1';
......
......@@ -819,6 +819,27 @@ void tst_Preprocessor::defined_data()
"#if !defined X \n#define Y\n#endif";
QTest::newRow("4c") << false << true <<
"#ifndef X \n#define Y\n#endif";
QTest::newRow("5a") << false << false <<
"#if !defined(X) && (defined(Y))\n"
"#define X\n"
"#endif\n";
QTest::newRow("5b") << false << false <<
"#if !defined(X) && defined(Y)\n"
"#define X\n"
"#endif\n";
QTest::newRow("5c") << false << false <<
"#if !defined(X) && 0"
"#define X\n"
"#endif\n";
QTest::newRow("5d") << false << false <<
"#if (!defined(X)) && defined(Y)\n"
"#define X\n"
"#endif\n";
QTest::newRow("5d") << false << false <<
"#if (define(Y))\n"
"#define X\n"
"#endif\n";
}
QTEST_APPLESS_MAIN(tst_Preprocessor)
......
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