From ccd05bd87eb1978bae6785548d804ae717874a83 Mon Sep 17 00:00:00 2001
From: Roberto Raggi <qtc-committer@nokia.com>
Date: Mon, 29 Dec 2008 09:40:30 +0100
Subject: [PATCH] Added a simple test for anonymous structs and typedefs.

---
 .../auto/cplusplus/semantic/tst_semantic.cpp  | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/tests/auto/cplusplus/semantic/tst_semantic.cpp b/tests/auto/cplusplus/semantic/tst_semantic.cpp
index 09ed7c1c097..5a82429d54f 100644
--- a/tests/auto/cplusplus/semantic/tst_semantic.cpp
+++ b/tests/auto/cplusplus/semantic/tst_semantic.cpp
@@ -95,6 +95,7 @@ private slots:
     void function_declaration_2();
     void function_definition_1();
     void nested_class_1();
+    void typedef_1();
 };
 
 void tst_Semantic::function_declaration_1()
@@ -235,5 +236,33 @@ void tst_Semantic::nested_class_1()
     QCOMPARE(namedTy->name()->asNameId()->identifier(), objectId);
 }
 
+void tst_Semantic::typedef_1()
+{
+    QSharedPointer<Document> doc = document(
+"typedef struct {\n"
+"   int x, y;\n"
+"} Point;\n"
+"int main() {\n"
+"   Point pt;\n"
+"   pt.x = 1;\n"
+"}\n"
+    );
+
+    QCOMPARE(doc->errorCount, 0U);
+    QCOMPARE(doc->globals->symbolCount(), 3U);
+
+    Class *anonStruct = doc->globals->symbolAt(0)->asClass();
+    QVERIFY(anonStruct);
+    QCOMPARE(anonStruct->memberCount(), 2U);
+
+    Declaration *typedefPointDecl = doc->globals->symbolAt(1)->asDeclaration();
+    QVERIFY(typedefPointDecl);
+    QVERIFY(typedefPointDecl->isTypedef());
+    QCOMPARE(typedefPointDecl->type()->asClass(), anonStruct);
+
+    Function *mainFun = doc->globals->symbolAt(2)->asFunction();
+    QVERIFY(mainFun);
+}
+
 QTEST_APPLESS_MAIN(tst_Semantic)
 #include "tst_semantic.moc"
-- 
GitLab