parent
30131837b5
commit
49c5a5aabd
|
@ -2683,6 +2683,18 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
|
||||||
(Token::simpleMatch(first, "( void )") && Token::simpleMatch(second, "( )")))
|
(Token::simpleMatch(first, "( void )") && Token::simpleMatch(second, "( )")))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
auto skipTopLevelConst = [](const Token* start) -> const Token* {
|
||||||
|
const Token* tok = start->next();
|
||||||
|
if (Token::simpleMatch(tok, "const")) {
|
||||||
|
tok = tok->next();
|
||||||
|
while (Token::Match(tok, "%name%|%type%|::"))
|
||||||
|
tok = tok->next();
|
||||||
|
if (Token::Match(tok, ",|)|="))
|
||||||
|
return start->next();
|
||||||
|
}
|
||||||
|
return start;
|
||||||
|
};
|
||||||
|
|
||||||
while (first->str() == second->str() &&
|
while (first->str() == second->str() &&
|
||||||
first->isLong() == second->isLong() &&
|
first->isLong() == second->isLong() &&
|
||||||
first->isUnsigned() == second->isUnsigned()) {
|
first->isUnsigned() == second->isUnsigned()) {
|
||||||
|
@ -2704,15 +2716,12 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
|
||||||
second = second->next();
|
second = second->next();
|
||||||
|
|
||||||
// skip const on type passed by value
|
// skip const on type passed by value
|
||||||
if (Token::Match(first->next(), "const %type% %name%|,|)") &&
|
const Token* const oldSecond = second;
|
||||||
!Token::Match(first->next(), "const %type% %name%| ["))
|
first = skipTopLevelConst(first);
|
||||||
first = first->next();
|
second = skipTopLevelConst(second);
|
||||||
if (Token::Match(second->next(), "const %type% %name%|,|)") &&
|
|
||||||
!Token::Match(second->next(), "const %type% %name%| ["))
|
|
||||||
second = second->next();
|
|
||||||
|
|
||||||
// skip default value assignment
|
// skip default value assignment
|
||||||
else if (first->next()->str() == "=") {
|
if (oldSecond == second && first->next()->str() == "=") {
|
||||||
first = first->nextArgument();
|
first = first->nextArgument();
|
||||||
if (first)
|
if (first)
|
||||||
first = first->tokAt(-2);
|
first = first->tokAt(-2);
|
||||||
|
@ -2726,7 +2735,7 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
|
||||||
} else if (!first) { // End of argument list (first)
|
} else if (!first) { // End of argument list (first)
|
||||||
return !second->nextArgument(); // End of argument list (second)
|
return !second->nextArgument(); // End of argument list (second)
|
||||||
}
|
}
|
||||||
} else if (second->next()->str() == "=") {
|
} else if (oldSecond == second && second->next()->str() == "=") {
|
||||||
second = second->nextArgument();
|
second = second->nextArgument();
|
||||||
if (second)
|
if (second)
|
||||||
second = second->tokAt(-2);
|
second = second->tokAt(-2);
|
||||||
|
|
|
@ -5138,23 +5138,47 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void symboldatabase104() { // #11535
|
void symboldatabase104() {
|
||||||
GET_SYMBOL_DB("struct S {\n"
|
const bool oldDebug = settings1.debugwarnings;
|
||||||
" void f1(char* const c);\n"
|
settings1.debugwarnings = true;
|
||||||
" void f2(char* const c);\n"
|
{
|
||||||
" void f3(char* const);\n"
|
GET_SYMBOL_DB("struct S {\n" // #11535
|
||||||
" void f4(char* c);\n"
|
" void f1(char* const c);\n"
|
||||||
" void f5(char* c);\n"
|
" void f2(char* const c);\n"
|
||||||
" void f6(char*);\n"
|
" void f3(char* const);\n"
|
||||||
"};\n"
|
" void f4(char* c);\n"
|
||||||
"void S::f1(char* c) {}\n"
|
" void f5(char* c);\n"
|
||||||
"void S::f2(char*) {}\n"
|
" void f6(char*);\n"
|
||||||
"void S::f3(char* c) {}\n"
|
"};\n"
|
||||||
"void S::f4(char* const c) {}\n"
|
"void S::f1(char* c) {}\n"
|
||||||
"void S::f5(char* const) {}\n"
|
"void S::f2(char*) {}\n"
|
||||||
"void S::f6(char* const c) {}\n");
|
"void S::f3(char* c) {}\n"
|
||||||
ASSERT(db != nullptr);
|
"void S::f4(char* const c) {}\n"
|
||||||
ASSERT_EQUALS("", errout.str());
|
"void S::f5(char* const) {}\n"
|
||||||
|
"void S::f6(char* const c) {}\n");
|
||||||
|
ASSERT(db != nullptr);
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
{
|
||||||
|
GET_SYMBOL_DB("struct S2 {\n" // #11602
|
||||||
|
" enum E {};\n"
|
||||||
|
"};\n"
|
||||||
|
"struct S1 {\n"
|
||||||
|
" void f(S2::E) const;\n"
|
||||||
|
"};\n"
|
||||||
|
"void S1::f(const S2::E) const {}\n");
|
||||||
|
ASSERT(db != nullptr);
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
{
|
||||||
|
GET_SYMBOL_DB("struct S {\n"
|
||||||
|
" void f(const bool b = false);\n"
|
||||||
|
"};\n"
|
||||||
|
"void S::f(const bool b) {}\n");
|
||||||
|
ASSERT(db != nullptr);
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
settings1.debugwarnings = oldDebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
void createSymbolDatabaseFindAllScopes1() {
|
void createSymbolDatabaseFindAllScopes1() {
|
||||||
|
|
Loading…
Reference in New Issue