forked from qt-creator/qt-creator
CPlusPlus: Handle C++20 concepts in parser
Change-Id: I8c6b8b1ba3f36b83cd1d667bec9830271147b1ac 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:
@@ -145,6 +145,8 @@ private Q_SLOTS:
|
||||
|
||||
void lambdaType_data();
|
||||
void lambdaType();
|
||||
|
||||
void concepts();
|
||||
};
|
||||
|
||||
|
||||
@@ -293,5 +295,28 @@ void tst_cxx11::lambdaType()
|
||||
QCOMPARE(oo.prettyType(function->type()), expectedType);
|
||||
}
|
||||
|
||||
void tst_cxx11::concepts()
|
||||
{
|
||||
LanguageFeatures features;
|
||||
features.cxxEnabled = true;
|
||||
features.cxx11Enabled = features.cxx14Enabled = features.cxx20Enabled = true;
|
||||
|
||||
const QString source = R"(
|
||||
template<typename T> concept IsPointer = requires(T p) { *p; };
|
||||
template<IsPointer T> void* func(T p) { return p; }
|
||||
void *func2(IsPointer auto p)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
)";
|
||||
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