forked from qt-creator/qt-creator
C++: Fix variable template parsing in expression
Fix parser to not fail on TemplateId without parentheses, for example: int i = foo<int> + foo<char>; This fixes std::pair structure parsing in MSVC headers and find Usages to work with pair->first and pair->second. Change-Id: Ic300ea99d44a749705430d5eb47b2744715af995 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -173,6 +173,7 @@ private slots:
|
||||
//! "template<class ...Args> class T : Args... {};"
|
||||
void cpp11_variadic_inheritance();
|
||||
void cpp11_attributes();
|
||||
void variableTemplatesInExpression();
|
||||
|
||||
// Q_PROPERTY
|
||||
void cpp_qproperty();
|
||||
@@ -1354,6 +1355,19 @@ void tst_AST::cpp11_attributes()
|
||||
QVERIFY(attr != nullptr);
|
||||
}
|
||||
|
||||
void tst_AST::variableTemplatesInExpression()
|
||||
{
|
||||
QSharedPointer<TranslationUnit> unit(parseDeclaration("int i = t<int> + t<char>;",
|
||||
false, false, true));
|
||||
AST *ast = unit->ast();
|
||||
QVERIFY(ast != nullptr);
|
||||
|
||||
QCOMPARE(diag.errorCount, 0);
|
||||
|
||||
DeclarationAST *d = ast->asDeclaration();
|
||||
QVERIFY(d != nullptr);
|
||||
}
|
||||
|
||||
void tst_AST::if_constexpr()
|
||||
{
|
||||
QSharedPointer<TranslationUnit> unit(parseStatement("if constexpr (a) b;",true));
|
||||
|
||||
Reference in New Issue
Block a user