This commit is contained in:
parent
e8233ceb67
commit
d24a1342a6
|
@ -4095,8 +4095,16 @@ static bool setVarIdParseDeclaration(Token** tok, const VariableMap& variableMap
|
|||
return false;
|
||||
}
|
||||
} else if (Token::Match(tok2, "&|&&")) {
|
||||
if (c)
|
||||
return false;
|
||||
ref = !bracket;
|
||||
} else if (singleNameCount >= 1 && Token::Match(tok2, "( [*&]") && Token::Match(tok2->link()->next(), "(|[")) {
|
||||
} else if (singleNameCount >= 1 && Token::Match(tok2, "( [*&]") && Token::Match(tok2->link(), ") (|[")) {
|
||||
for (const Token* tok3 = tok2->tokAt(2); Token::Match(tok3, "!!)"); tok3 = tok3->next()) {
|
||||
if (Token::Match(tok3, "(|["))
|
||||
tok3 = tok3->link();
|
||||
if (tok3->str() == ",")
|
||||
return false;
|
||||
}
|
||||
bracket = true; // Skip: Seems to be valid pointer to array or function pointer
|
||||
} else if (singleNameCount >= 1 && Token::Match(tok2, "( * %name% [") && Token::Match(tok2->linkAt(3), "] ) [;,]")) {
|
||||
bracket = true;
|
||||
|
|
|
@ -4778,17 +4778,6 @@ private:
|
|||
" ref[0] = 123;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
functionVariableUsage("void foo()\n"
|
||||
"{\n"
|
||||
" Foo foo;\n"
|
||||
" Foo &ref = foo;\n"
|
||||
" ref[0] = 123;\n"
|
||||
"}",
|
||||
"test.c");
|
||||
TODO_ASSERT_EQUALS("[test.c:5]: (style) Variable 'foo' is assigned a value that is never used.\n",
|
||||
"",
|
||||
errout.str());
|
||||
}
|
||||
|
||||
void localvaralias10() { // ticket 2004
|
||||
|
|
|
@ -98,6 +98,7 @@ private:
|
|||
TEST_CASE(varid64); // #9928 - extern const char (*x[256])
|
||||
TEST_CASE(varid65); // #10936
|
||||
TEST_CASE(varid66);
|
||||
TEST_CASE(varid67); // #11711 - NOT function pointer
|
||||
TEST_CASE(varid_for_1);
|
||||
TEST_CASE(varid_for_2);
|
||||
TEST_CASE(varid_cpp_keywords_in_c_code);
|
||||
|
@ -895,10 +896,14 @@ private:
|
|||
void varid41() {
|
||||
const char code1[] = "union evt; void f(const evt & event);";
|
||||
ASSERT_EQUALS("1: union evt ; void f ( const evt & event@1 ) ;\n",
|
||||
tokenize(code1));
|
||||
ASSERT_EQUALS("1: union evt ; void f ( const evt & event ) ;\n",
|
||||
tokenize(code1, "test.c"));
|
||||
|
||||
const char code2[] = "struct evt; void f(const evt & event);";
|
||||
ASSERT_EQUALS("1: struct evt ; void f ( const evt & event@1 ) ;\n",
|
||||
tokenize(code2));
|
||||
ASSERT_EQUALS("1: struct evt ; void f ( const evt & event ) ;\n",
|
||||
tokenize(code2, "test.c"));
|
||||
}
|
||||
|
||||
|
@ -1212,6 +1217,14 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void varid67() { // #11711
|
||||
const char code1[] = "int *x;\n"
|
||||
"_Generic(*x, int: foo, default: bar)();";
|
||||
const char expected1[] = "1: int * x@1 ;\n"
|
||||
"2: _Generic ( * x@1 , int : foo , default : bar ) ( ) ;\n";
|
||||
ASSERT_EQUALS(expected1, tokenize(code1, "test.c"));
|
||||
}
|
||||
|
||||
void varid_for_1() {
|
||||
const char code[] = "void foo(int a, int b) {\n"
|
||||
" for (int a=1,b=2;;) {}\n"
|
||||
|
|
Loading…
Reference in New Issue