Fixed #3316 (Cppcheck reporting internal errors - code compiles cleanly)
This commit is contained in:
parent
a32b05197d
commit
097637a66c
|
@ -3409,12 +3409,17 @@ void Tokenizer::setVarId()
|
|||
if (tok->str() == "virtual")
|
||||
continue;
|
||||
|
||||
if (tok->str() == "unsigned")
|
||||
tok = tok->next();
|
||||
|
||||
if (Token::Match(tok, "class|struct|union %type% :|{|;"))
|
||||
continue;
|
||||
|
||||
while (Token::Match(tok, "public:|private:|protected:"))
|
||||
tok = tok->next();
|
||||
if (!tok)
|
||||
break;
|
||||
|
||||
if (tok->str() == "unsigned")
|
||||
tok = tok->next();
|
||||
|
||||
if (Token::Match(tok, "using namespace %type% ;")) {
|
||||
tok = tok->next();
|
||||
continue;
|
||||
|
@ -3426,12 +3431,15 @@ void Tokenizer::setVarId()
|
|||
if (Token::Match(tok, "else|return|typedef|delete|sizeof"))
|
||||
continue;
|
||||
|
||||
while (Token::Match(tok, "const|static|extern|public:|private:|protected:|;|mutable"))
|
||||
while (Token::Match(tok, "const|static|extern|;|mutable"))
|
||||
tok = tok->next();
|
||||
|
||||
if (tok && tok->str() == "friend")
|
||||
continue;
|
||||
|
||||
if (Token::Match(tok, "struct %type%"))
|
||||
tok = tok->next();
|
||||
|
||||
// skip global namespace prefix
|
||||
if (Token::simpleMatch(tok, "::"))
|
||||
tok = tok->next();
|
||||
|
|
|
@ -190,6 +190,7 @@ private:
|
|||
TEST_CASE(varid39); // ticket #3279 (varid for 'FOO::BAR const')
|
||||
TEST_CASE(varid40); // ticket #3279
|
||||
TEST_CASE(varid41); // ticket #3340 (varid for union type)
|
||||
TEST_CASE(varid42); // ticket #3316 (varid for array)
|
||||
TEST_CASE(varidFunctionCall1);
|
||||
TEST_CASE(varidFunctionCall2);
|
||||
TEST_CASE(varidFunctionCall3);
|
||||
|
@ -3030,6 +3031,21 @@ private:
|
|||
tokenizeDebugListing(code2));
|
||||
}
|
||||
|
||||
void varid42() {
|
||||
const std::string code("namespace fruit { struct banana {}; };\n"
|
||||
"class Fred {\n"
|
||||
"public:\n"
|
||||
" struct fruit::banana Bananas[25];\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("\n\n##file 0\n"
|
||||
"1: namespace fruit { struct banana { } ; } ;\n"
|
||||
"2: class Fred {\n"
|
||||
"3: public:\n"
|
||||
"4: struct fruit :: banana Bananas@1 [ 25 ] ;\n"
|
||||
"5: } ;\n",
|
||||
tokenizeDebugListing(code));
|
||||
}
|
||||
|
||||
void varidFunctionCall1() {
|
||||
const std::string code("void f() {\n"
|
||||
" int x;\n"
|
||||
|
|
Loading…
Reference in New Issue