Fix varid 0 with function pointer and virtual methods
This commit is contained in:
parent
2d00cabee1
commit
f56aa19fac
|
@ -3373,6 +3373,9 @@ void Tokenizer::setVarId()
|
|||
if (tok->str() == "throw")
|
||||
continue;
|
||||
|
||||
if (tok->str() == "virtual")
|
||||
continue;
|
||||
|
||||
if (tok->str() == "unsigned")
|
||||
tok = tok->next();
|
||||
|
||||
|
|
|
@ -300,6 +300,7 @@ private:
|
|||
TEST_CASE(functionpointer1);
|
||||
TEST_CASE(functionpointer2);
|
||||
TEST_CASE(functionpointer3);
|
||||
TEST_CASE(functionpointer4);
|
||||
|
||||
TEST_CASE(removeRedundantAssignment);
|
||||
|
||||
|
@ -4872,6 +4873,30 @@ private:
|
|||
ASSERT_EQUALS(expected, simplifyFunctionPointers(code));
|
||||
}
|
||||
|
||||
void functionpointer4() {
|
||||
const char code[] = ""
|
||||
"struct S\n"
|
||||
"{\n"
|
||||
" typedef void (*FP)();\n"
|
||||
" virtual FP getFP();\n"
|
||||
" virtual void execute();\n"
|
||||
"};\n"
|
||||
"void f() {\n"
|
||||
" int a[9];\n"
|
||||
"}\n";
|
||||
const char expected[] = "\n\n##file 0\n"
|
||||
"1: struct S\n"
|
||||
"2: {\n"
|
||||
"3: ;\n"
|
||||
"4: virtual void ( * getFP ( ) ) ( ) ;\n"
|
||||
"5: virtual void execute ( ) ;\n"
|
||||
"6: } ;\n"
|
||||
"7: void f ( ) {\n"
|
||||
"8: int a@1 [ 9 ] ;\n"
|
||||
"9: }\n";
|
||||
ASSERT_EQUALS(expected, tokenizeDebugListing(code, false));
|
||||
}
|
||||
|
||||
void removeRedundantAssignment() {
|
||||
ASSERT_EQUALS("void f ( ) { ; int * q ; }", tokenizeAndStringify("void f() { int *p, *q; p = q; }", true));
|
||||
ASSERT_EQUALS("void f ( ) { ; int * q ; }", tokenizeAndStringify("void f() { int *p = 0, *q; p = q; }", true));
|
||||
|
|
Loading…
Reference in New Issue