diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 573bbffb6..74b9c3f3f 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2408,6 +2408,12 @@ bool Tokenizer::tokenize(std::istream &code, // typedef.. simplifyTypedef(); + // Fix internal error by updating links (#2376) + // TODO: Remove this "createLinks". Make sure that the testcase + // TestSimplifyTokens::simplifyTypedefFunction8 + // doesn't fail. + createLinks(); + // enum.. simplifyEnum(); diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 631c331c5..f41f58c51 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -242,6 +242,7 @@ private: TEST_CASE(simplifyTypedefFunction5); TEST_CASE(simplifyTypedefFunction6); TEST_CASE(simplifyTypedefFunction7); + TEST_CASE(simplifyTypedefFunction8); TEST_CASE(reverseArraySyntax) TEST_CASE(simplify_numeric_condition) @@ -5407,6 +5408,15 @@ private: ASSERT_EQUALS("", errout.str()); } + void simplifyTypedefFunction8() + { + // #2376 - internal error + const char code[] = "typedef int f_expand(const nrv_byte *);\n" + "void f(f_expand *(*get_fexp(int))){}\n"; + checkSimplifyTypedef(code); + ASSERT_EQUALS("", errout.str()); // make sure that there is no internal error + } + void reverseArraySyntax() { ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));