Skip to content

Commit

Permalink
Fix #11986 debug: Executable scope 'x' with unknown function. (danmar…
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Sep 20, 2023
1 parent dc19916 commit 57bbb17
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 10 additions & 0 deletions test/testsimplifytypedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3377,6 +3377,16 @@ class TestSimplifyTypedef : public TestFixture {
"}\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() {
Expand Down

0 comments on commit 57bbb17

Please sign in to comment.