Preprocessor: fix handling of first empty argument.

First empty argument used to be dropped: e.g. MACRO(,test) would be
expanded with one parameter only, with value 'test'.

Change-Id: I693fbb7faf1360f62266fa04c4b39c2de0d159a7
Reviewed-by: Erik Verbruggen <erik.verbruggen@nokia.com>
This commit is contained in:
Francois Ferrand
2012-03-16 14:10:46 +01:00
committed by Erik Verbruggen
parent ffd58c577a
commit 3e9105e401
2 changed files with 19 additions and 1 deletions

View File

@@ -43,6 +43,7 @@ Q_OBJECT
private Q_SLOTS:
void va_args();
void named_va_args();
void first_empty_macro_arg();
void unfinished_function_like_macro_call();
void nasty_macro_expansion();
void tstst();
@@ -82,6 +83,23 @@ void tst_Preprocessor::named_va_args()
QVERIFY(preprocessed.contains("int f(int a,int b);"));
}
void tst_Preprocessor::first_empty_macro_arg()
{
Client *client = 0; // no client.
Environment env;
Preprocessor preprocess(client, &env);
QByteArray preprocessed = preprocess(QLatin1String("<stdin>"),
QByteArray("\n#define foo(a,b) a int b;"
"\nfoo(const,cVal)\n"
"\nfoo(,Val)\n"
"\nfoo( ,Val2)\n"));
QVERIFY(preprocessed.contains("const int cVal;"));
QVERIFY(preprocessed.contains("int Val;"));
QVERIFY(preprocessed.contains("int Val2;"));
}
void tst_Preprocessor::unfinished_function_like_macro_call()
{
Client *client = 0; // no client.