fix token.cpp:745:19: debug: Executable scope 'getStrSize' with unknown function. (#3015)

This commit is contained in:
IOBYTE 2021-01-05 16:07:53 -05:00 committed by GitHub
parent 96704c9971
commit 22b10f8987
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 4 deletions

View File

@ -2443,10 +2443,16 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
}
// const after *
else if (first->next()->str() == "*" && first->strAt(2) != "const" &&
second->next()->str() == "*" && second->strAt(2) == "const") {
first = first->next();
second = second->tokAt(2);
else if (first->next()->str() == "*" && second->next()->str() == "*" &&
((first->strAt(2) != "const" && second->strAt(2) == "const") ||
(first->strAt(2) == "const" && second->strAt(2) != "const"))) {
if (first->strAt(2) != "const") {
first = first->next();
second = second->tokAt(2);
} else {
first = first->tokAt(2);
second = second->next();
}
}
// variable names are different

View File

@ -342,6 +342,7 @@ private:
TEST_CASE(symboldatabase87); // #9922 'extern const char ( * x [ 256 ] ) ;'
TEST_CASE(symboldatabase88); // #10040 (using namespace)
TEST_CASE(symboldatabase89); // valuetype name
TEST_CASE(symboldatabase90);
TEST_CASE(createSymbolDatabaseFindAllScopes1);
@ -4645,6 +4646,18 @@ private:
ASSERT(vartok1->next()->variable()->valueType()->str() == "external::ns1::A");
}
void symboldatabase90() {
GET_SYMBOL_DB("struct Fred {\n"
" void foo(const int * const x);\n"
"};\n"
"void Fred::foo(const int * x) { }");
ASSERT_EQUALS("", errout.str());
const Token *functok = Token::findsimplematch(tokenizer.tokens(), "foo ( const int * x )");
ASSERT(functok);
ASSERT(functok->function());
ASSERT(functok->function()->name() == "foo");
}
void createSymbolDatabaseFindAllScopes1() {
GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }");
ASSERT(db->scopeList.size() == 3);