Skip to content

Commit

Permalink
Fix #12008 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 Oct 25, 2023
1 parent 502d7ea commit 80c5cb6
Show file tree
Hide file tree
Showing 2 changed files with 13 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 @@ -1693,7 +1693,7 @@ void Tokenizer::simplifyTypedefCpp()
} else {
if (scope == 0 && !(classLevel > 1 && tok2 == spaceInfo[classLevel - 1].bodyEnd))
break;
--scope;
scope = std::max(scope - 1, 0);
}
}

Expand Down
12 changes: 12 additions & 0 deletions test/testsimplifytypedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3395,6 +3395,18 @@ class TestSimplifyTypedef : public TestFixture {
"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));

code = "namespace N {\n" // #12008
" typedef char U;\n"
" typedef int V;\n"
" struct S {\n"
" S(V* v);\n"
" };\n"
"}\n"
"void f() {}\n"
"N::S::S(V* v) {}\n"
"namespace N {}\n";
ASSERT_EQUALS("namespace N { struct S { S ( int * v ) ; } ; } void f ( ) { } N :: S :: S ( int * v ) { }", tok(code));
}

void simplifyTypedef147() {
Expand Down

0 comments on commit 80c5cb6

Please sign in to comment.