Fix 9766: False positive; suspicious operator is written in declaration (#3476)
This commit is contained in:
parent
f0f4ee7d91
commit
fc6a791a74
|
@ -4013,7 +4013,8 @@ void Tokenizer::setVarIdPass1()
|
||||||
if (tok && tok->str() == "<") {
|
if (tok && tok->str() == "<") {
|
||||||
const Token *end = tok->findClosingBracket();
|
const Token *end = tok->findClosingBracket();
|
||||||
while (tok != end) {
|
while (tok != end) {
|
||||||
if (tok->isName()) {
|
if (tok->isName() && !(Token::simpleMatch(tok->next(), "<") &&
|
||||||
|
Token::Match(tok->tokAt(-2), "std :: %name%"))) {
|
||||||
const std::map<std::string, int>::const_iterator it = variableMap.find(tok->str());
|
const std::map<std::string, int>::const_iterator it = variableMap.find(tok->str());
|
||||||
if (it != variableMap.end())
|
if (it != variableMap.end())
|
||||||
tok->varId(it->second);
|
tok->varId(it->second);
|
||||||
|
|
|
@ -4589,6 +4589,11 @@ private:
|
||||||
" for (p = path; *p++;) ;\n"
|
" for (p = path; *p++;) ;\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void f() {\n"
|
||||||
|
" std::array<std::array<double,3>,3> array;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void duplicateBranch() {
|
void duplicateBranch() {
|
||||||
|
|
|
@ -47,6 +47,7 @@ private:
|
||||||
TEST_CASE(template4); // #9805
|
TEST_CASE(template4); // #9805
|
||||||
TEST_CASE(template5);
|
TEST_CASE(template5);
|
||||||
TEST_CASE(template6); // #10475 crash
|
TEST_CASE(template6); // #10475 crash
|
||||||
|
TEST_CASE(template7); // #9766 crash
|
||||||
TEST_CASE(throwIsNotAFunction);
|
TEST_CASE(throwIsNotAFunction);
|
||||||
TEST_CASE(unusedError);
|
TEST_CASE(unusedError);
|
||||||
TEST_CASE(unusedMain);
|
TEST_CASE(unusedMain);
|
||||||
|
@ -268,6 +269,14 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void template7()
|
||||||
|
{ // #9766
|
||||||
|
check("void f() {\n"
|
||||||
|
" std::array<std::array<double,3>,3> array;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:1]: (style) The function 'f' is never used.\n", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void throwIsNotAFunction() {
|
void throwIsNotAFunction() {
|
||||||
check("struct A {void f() const throw () {}}; int main() {A a; a.f();}");
|
check("struct A {void f() const throw () {}}; int main() {A a; a.f();}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
Loading…
Reference in New Issue