diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 018fbda1f..749710867 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1666,7 +1666,7 @@ void Tokenizer::simplifyTypedefCpp() pattern += typeName->str(); } else { - if (scope == 0) + if (scope == 0 && !(classLevel > 1 && tok2 == spaceInfo[classLevel - 1].bodyEnd)) break; --scope; } diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index 401266212..2b4080eed 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -3377,6 +3377,16 @@ private: "}\n" "N::C::C(T*) : p(nullptr) {}\n"; ASSERT_EQUALS("namespace N { struct C { C ( int * ) ; void * p ; } ; } N :: C :: C ( int * ) : p ( nullptr ) { }", tok(code)); + + code = "namespace N {\n" // #11986 + " typedef char U;\n" + " typedef int V;\n" + " struct S {};\n" + " struct T { void f(V*); };\n" + "}\n" + "void N::T::f(V*) {}\n" + "namespace N {}\n"; + ASSERT_EQUALS("namespace N { struct S { } ; struct T { void f ( int * ) ; } ; } void N :: T :: f ( int * ) { }", tok(code)); } void simplifyTypedefFunction1() {