forked from qt-creator/qt-creator
CPlusPlus: Support requires clause in parser
Change-Id: Ice6a7a287453516a1cfc296e2c9f16160b3ea130 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -147,6 +147,7 @@ private Q_SLOTS:
|
||||
void lambdaType();
|
||||
|
||||
void concepts();
|
||||
void requiresClause();
|
||||
};
|
||||
|
||||
|
||||
@@ -318,5 +319,27 @@ void *func2(IsPointer auto p)
|
||||
QVERIFY(!hasErrors);
|
||||
}
|
||||
|
||||
void tst_cxx11::requiresClause()
|
||||
{
|
||||
LanguageFeatures features;
|
||||
features.cxxEnabled = true;
|
||||
features.cxx11Enabled = features.cxx14Enabled = features.cxx20Enabled = true;
|
||||
|
||||
const QString source = R"(
|
||||
template<class T> constexpr bool is_meowable = true;
|
||||
template<class T> constexpr bool is_purrable() { return true; }
|
||||
template<class T> void f(T) requires is_meowable<T>;
|
||||
template<class T> requires is_meowable<T> void g(T) ;
|
||||
template<class T> void h(T) requires (is_purrable<T>());
|
||||
)";
|
||||
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() << errors;
|
||||
QVERIFY(!hasErrors);
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_cxx11)
|
||||
#include "tst_cxx11.moc"
|
||||
|
||||
Reference in New Issue
Block a user