forked from qt-creator/qt-creator
C++: fix handling of empty va_args macro arguments.
Preprocessor did not correctly handle when variadic macro arguments were not provided at all, if there were other arguments: macro was not expanded in case only the non variadic arguments were given. #define MACRO(...) used to work fine for 0 or more arguments. #define MACRO(ARG0, ...) used to work only for 2 or more arguments, now fixed. Change-Id: I64e9199ceccae05618a49931c2adad8e4f9471ba Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
committed by
Nikolai Kosjar
parent
feeff29f22
commit
4d18710f46
@@ -317,6 +317,7 @@ private:
|
||||
private slots:
|
||||
void va_args();
|
||||
void named_va_args();
|
||||
void extra_va_args();
|
||||
void defined();
|
||||
void defined_data();
|
||||
void empty_macro_args();
|
||||
@@ -413,6 +414,23 @@ void tst_Preprocessor::named_va_args()
|
||||
QCOMPARE(simplified(preprocessed), QString("int f();int f(int a);int f(int a,int b);"));
|
||||
}
|
||||
|
||||
void tst_Preprocessor::extra_va_args()
|
||||
{
|
||||
Client *client = 0; // no client.
|
||||
Environment env;
|
||||
|
||||
Preprocessor preprocess(client, &env);
|
||||
QByteArray preprocessed = preprocess.run(QLatin1String("<stdin>"),
|
||||
"#define foo(ret, ...) ret f(__VA_ARGS__);\n"
|
||||
"\nfoo(int)\n"
|
||||
"\nfoo(float,int b)\n"
|
||||
"\nfoo(long,int b,int c)\n",
|
||||
true, false);
|
||||
|
||||
preprocessed = preprocessed.simplified();
|
||||
QCOMPARE(simplified(preprocessed), QString("int f();float f(int b);long f(int b,int c);"));
|
||||
}
|
||||
|
||||
void tst_Preprocessor::empty_macro_args()
|
||||
{
|
||||
Client *client = 0; // no client.
|
||||
|
Reference in New Issue
Block a user