Commit 55d0e4f8 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Improved the way we expand function-like macros when we can't collect all the arguments.

parent 656d70fa
......@@ -810,9 +810,8 @@ void Preprocessor::preprocess(const QByteArray &fileName, const QByteArray &sour
++_dot;
}
if (_dot->isNot(T_RPAREN)) {
// ### warning expected T_RPAREN
}
if (_dot->isNot(T_RPAREN))
_result->append(spell);
else
expandFunctionLikeMacro(identifierToken, m);
......
#include <QtTest>
#include <pp.h>
CPLUSPLUS_USE_NAMESPACE
using namespace CPlusPlus;
class tst_Preprocessor: public QObject
{
......@@ -9,21 +9,35 @@ Q_OBJECT
private Q_SLOTS:
void pp_with_no_client();
void unfinished_function_like_macro_call();
};
void tst_Preprocessor::pp_with_no_client()
{
using namespace CPlusPlus;
Client *client = 0; // no client.
Environment env;
Preprocessor preprocess(client, &env);
QByteArray preprocessed = preprocess("<stdin>",
"#define foo(a,b) a + b\nfoo(1, 2)\n");
"\n#define foo(a,b) a + b"
"\nfoo(1, 2)\n");
QByteArray expected = "1 + 2";
QCOMPARE(preprocessed.trimmed(), expected);
}
void tst_Preprocessor::unfinished_function_like_macro_call()
{
Client *client = 0; // no client.
Environment env;
Preprocessor preprocess(client, &env);
QByteArray preprocessed = preprocess("<stdin>",
"\n#define foo(a,b) a + b"
"\nfoo(1, 2\n");
QByteArray expected = "foo";
QCOMPARE(preprocessed.trimmed(), expected);
}
QTEST_APPLESS_MAIN(tst_Preprocessor)
#include "tst_preprocessor.moc"
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