From 9dfbd3946a30c90daa90e5751d34b20c00b4083f Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Mon, 17 May 2010 19:58:27 +0200 Subject: [PATCH] Fixed #1673 (Tokenizer::simplifyTypedef causes segfault for boost library) --- lib/tokenize.cpp | 2 +- test/testsimplifytokens.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 0a6d51e7f..541bc7f0e 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1019,7 +1019,7 @@ void Tokenizer::simplifyTypedef() } } } - else + else if (tok2->previous()->str() != ".") { simplifyType = true; } diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 769076b7a..3ee4cc7fc 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -190,6 +190,7 @@ private: TEST_CASE(simplifyTypedef45); // ticket #1613 TEST_CASE(simplifyTypedef46); // ticket #1615 TEST_CASE(simplifyTypedef47); + TEST_CASE(simplifyTypedef48); // ticket #1673 TEST_CASE(simplifyTypedefFunction); @@ -3970,6 +3971,23 @@ private: } } + void simplifyTypedef48() // ticket #1673 + { + const char code[] = "typedef struct string { } string;\n" + "void foo (LIST *module_name)\n" + "{\n" + " bar(module_name ? module_name->string : 0);\n" + "}\n"; + + // The expected result.. + const std::string expected("struct string { } ; ; " + "void foo ( LIST * module_name ) " + "{ " + "bar ( module_name ? module_name . string : 0 ) ; " + "}"); + ASSERT_EQUALS(expected, sizeof_(code)); + } + void simplifyTypedefFunction() { {