From 57bbb17f3b9498888f65f6c1ea331371af17d58c Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 20 Sep 2023 17:18:00 +0200 Subject: [PATCH] Fix #11986 debug: Executable scope 'x' with unknown function. (#5463) --- lib/tokenize.cpp | 2 +- test/testsimplifytypedef.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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() {