Skip to content

Commit 80c5cb6

Browse files
Fix #12008 debug: Executable scope 'x' with unknown function. (#5588)
1 parent 502d7ea commit 80c5cb6

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ void Tokenizer::simplifyTypedefCpp()
16931693
} else {
16941694
if (scope == 0 && !(classLevel > 1 && tok2 == spaceInfo[classLevel - 1].bodyEnd))
16951695
break;
1696-
--scope;
1696+
scope = std::max(scope - 1, 0);
16971697
}
16981698
}
16991699

test/testsimplifytypedef.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3395,6 +3395,18 @@ class TestSimplifyTypedef : public TestFixture {
33953395
"void N::T::f(V*) {}\n"
33963396
"namespace N {}\n";
33973397
ASSERT_EQUALS("namespace N { struct S { } ; struct T { void f ( int * ) ; } ; } void N :: T :: f ( int * ) { }", tok(code));
3398+
3399+
code = "namespace N {\n" // #12008
3400+
" typedef char U;\n"
3401+
" typedef int V;\n"
3402+
" struct S {\n"
3403+
" S(V* v);\n"
3404+
" };\n"
3405+
"}\n"
3406+
"void f() {}\n"
3407+
"N::S::S(V* v) {}\n"
3408+
"namespace N {}\n";
3409+
ASSERT_EQUALS("namespace N { struct S { S ( int * v ) ; } ; } void f ( ) { } N :: S :: S ( int * v ) { }", tok(code));
33983410
}
33993411

34003412
void simplifyTypedef147() {

0 commit comments

Comments
 (0)