diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 9c531fcb1f5..b36c079b8fd 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -755,7 +755,7 @@ namespace { const bool isFunctionPointer = Token::Match(mNameToken, "%name% )"); // Special handling for T(...) when T is a pointer - if (Token::Match(tok, "%name% [({]") && !isFunctionPointer) { + if (Token::Match(tok, "%name% [({]") && !isFunctionPointer && !Token::simpleMatch(tok->linkAt(1), ") (")) { bool pointerType = false; for (const Token* type = mRangeType.first; type != mRangeType.second; type = type->next()) { if (type->str() == "*" || type->str() == "&") { diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index bab8ccc645e..400ea626936 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -3388,6 +3388,17 @@ class TestSimplifyTypedef : public TestFixture { const char code3[] = "typedef char* T;\n" "T f() { return T(\"abc\"); }\n"; ASSERT_EQUALS("char * f ( ) { return ( char * ) ( \"abc\" ) ; }", tok(code3)); + + const char code4[] = "typedef struct _a *A;\n" // #13104 + "typedef struct _b* B;\n" + "typedef A(get_t)(B);\n" + "extern get_t* get;\n" + "A f() {\n" + " return get(0);\n" + "}\n"; + ASSERT_EQUALS("extern struct _a * ( * get ) ( struct _b * ) ; " + "struct _a * f ( ) { return get ( 0 ) ; }", + tok(code4)); } void simplifyTypedef143() { // #11506