forked from qt-creator/qt-creator
CppEditor: Add support for init statements in if conditions
Fixes: QTCREATORBUG-29182 Change-Id: I9b7969da694b368236246123ad0028d8e754e903 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -150,6 +150,7 @@ private Q_SLOTS:
|
||||
void requiresClause();
|
||||
void coroutines();
|
||||
void genericLambdas();
|
||||
void ifStatementWithInitialization();
|
||||
};
|
||||
|
||||
|
||||
@@ -550,5 +551,27 @@ int main()
|
||||
QVERIFY(!hasErrors);
|
||||
}
|
||||
|
||||
void tst_cxx11::ifStatementWithInitialization()
|
||||
{
|
||||
LanguageFeatures features;
|
||||
features.cxxEnabled = true;
|
||||
features.cxx11Enabled = features.cxx14Enabled = features.cxx17Enabled = true;
|
||||
|
||||
const QString source = R"(
|
||||
int main()
|
||||
{
|
||||
if (bool b = true; b)
|
||||
b = false;
|
||||
}
|
||||
)";
|
||||
QByteArray errors;
|
||||
Document::Ptr doc = Document::create(FilePath::fromPathPart(u"testFile"));
|
||||
processDocument(doc, source.toUtf8(), features, &errors);
|
||||
const bool hasErrors = !errors.isEmpty();
|
||||
if (hasErrors)
|
||||
qDebug().noquote() << errors;
|
||||
QVERIFY(!hasErrors);
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_cxx11)
|
||||
#include "tst_cxx11.moc"
|
||||
|
||||
Reference in New Issue
Block a user