fix #10295 (false negatives by inconsistent 'void' in argument list (declaration vs definition)) (#3274)
Co-authored-by: Robert Reif <reif@FX6840>
This commit is contained in:
parent
d3bb84cd0e
commit
c7be967769
|
@ -2429,6 +2429,11 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
|
|||
int offset = 0;
|
||||
int openParen = 0;
|
||||
|
||||
// check for () == (void) and (void) == ()
|
||||
if ((Token::simpleMatch(first, "( )") && Token::simpleMatch(second, "( void )")) ||
|
||||
(Token::simpleMatch(first, "( void )") && Token::simpleMatch(second, "( )")))
|
||||
return true;
|
||||
|
||||
while (first->str() == second->str() &&
|
||||
first->isLong() == second->isLong() &&
|
||||
first->isUnsigned() == second->isUnsigned()) {
|
||||
|
|
|
@ -148,6 +148,7 @@ private:
|
|||
TEST_CASE(uninitVar30); // ticket #6417
|
||||
TEST_CASE(uninitVar31); // ticket #8271
|
||||
TEST_CASE(uninitVar32); // ticket #8835
|
||||
TEST_CASE(uninitVar33); // ticket #10295
|
||||
TEST_CASE(uninitVarEnum1);
|
||||
TEST_CASE(uninitVarEnum2); // ticket #8146
|
||||
TEST_CASE(uninitVarStream);
|
||||
|
@ -2524,6 +2525,18 @@ private:
|
|||
ASSERT_EQUALS("[test.cpp:5]: (warning) Member variable 'Foo::member' is not initialized in the constructor.\n", errout.str());
|
||||
}
|
||||
|
||||
void uninitVar33() { // ticket #10295
|
||||
check("namespace app {\n"
|
||||
" class B {\n"
|
||||
" public:\n"
|
||||
" B(void);\n"
|
||||
" int x;\n"
|
||||
" };\n"
|
||||
"};\n"
|
||||
"app::B::B(void){}");
|
||||
ASSERT_EQUALS("[test.cpp:8]: (warning) Member variable 'B::x' is not initialized in the constructor.\n", errout.str());
|
||||
}
|
||||
|
||||
void uninitVarArray1() {
|
||||
check("class John\n"
|
||||
"{\n"
|
||||
|
|
|
@ -347,6 +347,7 @@ private:
|
|||
TEST_CASE(symboldatabase92); // daca crash
|
||||
TEST_CASE(symboldatabase93); // alignas attribute
|
||||
TEST_CASE(symboldatabase94); // structured bindings
|
||||
TEST_CASE(symboldatabase95); // #10295
|
||||
|
||||
TEST_CASE(createSymbolDatabaseFindAllScopes1);
|
||||
|
||||
|
@ -4720,6 +4721,24 @@ private:
|
|||
ASSERT(db->getVariableFromVarId(2) != nullptr);
|
||||
}
|
||||
|
||||
void symboldatabase95() { // #10295
|
||||
GET_SYMBOL_DB("struct B {\n"
|
||||
" void foo1(void);\n"
|
||||
" void foo2();\n"
|
||||
"};\n"
|
||||
"void B::foo1() {}\n"
|
||||
"void B::foo2(void) {}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
const Token *functok = Token::findsimplematch(tokenizer.tokens(), "foo1 ( ) { }");
|
||||
ASSERT(functok);
|
||||
ASSERT(functok->function());
|
||||
ASSERT(functok->function()->name() == "foo1");
|
||||
functok = Token::findsimplematch(tokenizer.tokens(), "foo2 ( void ) { }");
|
||||
ASSERT(functok);
|
||||
ASSERT(functok->function());
|
||||
ASSERT(functok->function()->name() == "foo2");
|
||||
}
|
||||
|
||||
void createSymbolDatabaseFindAllScopes1() {
|
||||
GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }");
|
||||
ASSERT(db->scopeList.size() == 3);
|
||||
|
|
Loading…
Reference in New Issue