forked from qt-creator/qt-creator
C++ Parser: fix infinite loop when recovering from incorrect @selector expression.
This commit is contained in:
@@ -83,6 +83,8 @@ private slots:
|
||||
void objc_protocol_forward_declaration_1();
|
||||
void objc_protocol_definition_1();
|
||||
void objc_method_attributes_1();
|
||||
void objc_selector_error_recovery_1();
|
||||
void objc_selector_error_recovery_2();
|
||||
|
||||
// expressions with (square) brackets
|
||||
void normal_array_access();
|
||||
@@ -832,6 +834,45 @@ void tst_AST::objc_method_attributes_1()
|
||||
QCOMPARE(unit->spell(unavailableAttr->identifier_token), "unavailable");
|
||||
}
|
||||
|
||||
/*
|
||||
@selector(foo)
|
||||
@selector(foo:)
|
||||
@selector(foo:bar:)
|
||||
...
|
||||
*/
|
||||
void tst_AST::objc_selector_error_recovery_1()
|
||||
{
|
||||
QSharedPointer<TranslationUnit> unit(parseDeclaration("\n"
|
||||
"void tst() {\n"
|
||||
" @selector(foo:\n"
|
||||
" int i = 1;\n"
|
||||
"}\n"
|
||||
));
|
||||
AST *ast = unit->ast();
|
||||
QVERIFY(ast);
|
||||
ObjCClassDeclarationAST *zoo = ast->asObjCClassDeclaration();
|
||||
QVERIFY(zoo);
|
||||
QVERIFY(zoo->interface_token); QVERIFY(! (zoo->implementation_token));
|
||||
QVERIFY(zoo->class_name); QVERIFY(zoo->class_name->asSimpleName());
|
||||
QCOMPARE(unit->spell(zoo->class_name->asSimpleName()->identifier_token), "Zoo");
|
||||
}
|
||||
|
||||
void tst_AST::objc_selector_error_recovery_2()
|
||||
{
|
||||
QSharedPointer<TranslationUnit> unit(parseDeclaration("\n"
|
||||
"void tst() {\n"
|
||||
" @selector(foo:bar);\n"
|
||||
"}\n"
|
||||
));
|
||||
AST *ast = unit->ast();
|
||||
QVERIFY(ast);
|
||||
ObjCClassDeclarationAST *zoo = ast->asObjCClassDeclaration();
|
||||
QVERIFY(zoo);
|
||||
QVERIFY(zoo->interface_token); QVERIFY(! (zoo->implementation_token));
|
||||
QVERIFY(zoo->class_name); QVERIFY(zoo->class_name->asSimpleName());
|
||||
QCOMPARE(unit->spell(zoo->class_name->asSimpleName()->identifier_token), "Zoo");
|
||||
}
|
||||
|
||||
void tst_AST::normal_array_access()
|
||||
{
|
||||
QSharedPointer<TranslationUnit> unit(parseDeclaration("\n"
|
||||
|
||||
Reference in New Issue
Block a user