C++: Fix parsing designators vs lambdas

The introduction of C99 designators led to parsing problems with lambdas
that were passed in as a function arguments.

Fixed by prefering to parse without designators first. This will be
cleaner/clearer once the appropriate "LanguageFeatures" from the Project
Parts will be passed in.

Change-Id: Ia9cb7c4a4c9345e729cf2044e1e5411fe63e33ec
Reviewed-by: Wang Hoi <wanghoi@126.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2014-06-17 18:18:54 -04:00
parent d4c62539fd
commit 38b8940bd4
3 changed files with 65 additions and 16 deletions

View File

@@ -98,13 +98,14 @@ class tst_cxx11: public QObject
}
};
Document::Ptr document(const QString &fileName, QByteArray *errors = 0)
Document::Ptr document(const QString &fileName, QByteArray *errors = 0, bool c99Enabled = false)
{
Document::Ptr doc = Document::create(fileName);
QFile file(testdata(fileName));
if (file.open(QFile::ReadOnly)) {
LanguageFeatures features;
features.cxx11Enabled = true;
features.c99Enabled = c99Enabled;
Client client(errors);
doc->control()->setDiagnosticClient(&client);
doc->setUtf8Source(QTextStream(&file).readAll().toUtf8());
@@ -124,6 +125,9 @@ private Q_SLOTS:
void parse_data();
void parse();
void parseWithC99Enabled_data();
void parseWithC99Enabled();
//
// checks for the semantic
//
@@ -169,6 +173,29 @@ void tst_cxx11::parse()
VERIFY_ERRORS();
}
void tst_cxx11::parseWithC99Enabled_data()
{
QTest::addColumn<QString>("file");
QTest::addColumn<QString>("errorFile");
QTest::newRow("lambda.1") << "lambda.1.cpp" << "";
}
void tst_cxx11::parseWithC99Enabled()
{
QFETCH(QString, file);
QFETCH(QString, errorFile);
const bool c99Enabled = true;
QByteArray errors;
Document::Ptr doc = document(file, &errors, c99Enabled);
if (! qgetenv("DEBUG").isNull())
printf("%s\n", errors.constData());
VERIFY_ERRORS();
}
//
// check the visibility of symbols declared inside inline namespaces
//