forked from qt-creator/qt-creator
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:
committed by
Erik Verbruggen
parent
ffd58c577a
commit
3e9105e401
@@ -369,7 +369,7 @@ const char *MacroExpander::expand(const char *__first, const char *__last,
|
||||
MacroExpander expand_actual (env, frame);
|
||||
|
||||
const char *arg_end = skip_argument_variadics (actuals, macro, arg_it, __last);
|
||||
if (arg_it != arg_end)
|
||||
if (arg_it != arg_end || (arg_end != __last && *arg_end == ','))
|
||||
{
|
||||
actuals_ref.append(MacroArgumentReference(start_offset + (arg_it-start), arg_end - arg_it));
|
||||
const QByteArray actual (arg_it, arg_end - arg_it);
|
||||
|
@@ -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.
|
||||
|
Reference in New Issue
Block a user