Skip to content
Snippets Groups Projects
Commit c7ac64e7 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Test typedefs and pointers to anonymous structs.

parent c7b023c0
No related branches found
No related tags found
No related merge requests found
...@@ -97,6 +97,7 @@ private slots: ...@@ -97,6 +97,7 @@ private slots:
void nested_class_1(); void nested_class_1();
void typedef_1(); void typedef_1();
void typedef_2(); void typedef_2();
void typedef_3();
}; };
void tst_Semantic::function_declaration_1() void tst_Semantic::function_declaration_1()
...@@ -295,5 +296,28 @@ void tst_Semantic::typedef_2() ...@@ -295,5 +296,28 @@ void tst_Semantic::typedef_2()
QVERIFY(mainFun); QVERIFY(mainFun);
} }
void tst_Semantic::typedef_3()
{
QSharedPointer<Document> doc = document(
"typedef struct {\n"
" int x, y;\n"
"} *PointPtr;\n"
);
QCOMPARE(doc->errorCount, 0U);
QCOMPARE(doc->globals->symbolCount(), 2U);
Class *_pointStruct= doc->globals->symbolAt(0)->asClass();
QVERIFY(_pointStruct);
QCOMPARE(_pointStruct->memberCount(), 2U);
Declaration *typedefPointDecl = doc->globals->symbolAt(1)->asDeclaration();
QVERIFY(typedefPointDecl);
QVERIFY(typedefPointDecl->isTypedef());
QVERIFY(typedefPointDecl->type()->isPointerType());
QCOMPARE(typedefPointDecl->type()->asPointerType()->elementType()->asClass(),
_pointStruct);
}
QTEST_APPLESS_MAIN(tst_Semantic) QTEST_APPLESS_MAIN(tst_Semantic)
#include "tst_semantic.moc" #include "tst_semantic.moc"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment