Fix FP with unused variable (#1814)
This commit is contained in:
parent
2e694f38c8
commit
ae8a3aae8d
|
@ -483,7 +483,7 @@ static bool iscpp11init(const Token * const tok)
|
|||
endtok = nameToken->linkAt(1)->linkAt(1);
|
||||
else
|
||||
return false;
|
||||
if (Token::Match(nameToken, "else|try|do"))
|
||||
if (Token::Match(nameToken, "else|try|do|const|override|volatile|&|&&"))
|
||||
return false;
|
||||
// There is no initialisation for example here: 'class Fred {};'
|
||||
if (!Token::simpleMatch(endtok, "} ;"))
|
||||
|
|
|
@ -86,6 +86,7 @@ private:
|
|||
TEST_CASE(redundantstmts);
|
||||
TEST_CASE(vardecl);
|
||||
TEST_CASE(archive); // ar & x
|
||||
TEST_CASE(ast);
|
||||
}
|
||||
|
||||
void test1() {
|
||||
|
@ -379,6 +380,11 @@ private:
|
|||
"}", true);
|
||||
ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Found suspicious operator '&'\n", errout.str());
|
||||
}
|
||||
|
||||
void ast() {
|
||||
check("struct c { void a() const { for (int x=0; x;); } };", true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestIncompleteStatement)
|
||||
|
|
|
@ -7091,6 +7091,12 @@ private:
|
|||
|
||||
// C++17: if (expr1; expr2)
|
||||
ASSERT_EQUALS("ifx3=y;(", testAst("if (int x=3; y)"));
|
||||
|
||||
ASSERT_EQUALS("a( forx0=x;;(", testAst("struct c { void a() const { for (int x=0; x;); } };"));
|
||||
// TODO: We dont correctly parse ref qualifiers
|
||||
TODO_ASSERT_EQUALS("a( forx0=x;;(", "a({&", testAst("struct c { void a() & { for (int x=0; x;); } };"));
|
||||
TODO_ASSERT_EQUALS("a( forx0=x;;(", "a({&&", testAst("struct c { void a() && { for (int x=0; x;); } };"));
|
||||
|
||||
}
|
||||
|
||||
void astexpr2() { // limit for large expressions
|
||||
|
|
Loading…
Reference in New Issue