Fixed false positive #6030: inheriting classes is not a variable declaration.

This commit is contained in:
PKEuS 2014-08-06 09:03:30 +02:00
parent e7605d6f77
commit fd5ff1bb8b
2 changed files with 6 additions and 1 deletions

View File

@ -2276,7 +2276,7 @@ static bool setVarIdParseDeclaration(const Token **tok, const std::map<std::stri
bool bracket = false;
while (tok2) {
if (tok2->isName()) {
if (cpp && tok2->str() == "namespace")
if (cpp && Token::Match(tok2, "namespace|public|private|protected"))
return false;
if (tok2->str() == "struct" || tok2->str() == "union" || (cpp && (tok2->str() == "class" || tok2->str() == "typename"))) {
hasstruct = true;

View File

@ -4934,6 +4934,11 @@ private:
"std::vector<int> vec{1, 2, 3};\n"
"namespace n { int z; };\n"
"int& j{i};\n"));
// #6030
ASSERT_EQUALS("\n\n##file 0\n"
"1: struct S3 : public S1 , public S2 { } ;\n",
tokenizeDebugListing("struct S3 : public S1, public S2 { };"));
}
void varidclass1() {