Do not add AST for pointer in variable declaration (#5593)
This commit is contained in:
parent
12844703de
commit
7618e100b4
|
@ -1445,6 +1445,14 @@ static Token * findAstTop(Token *tok1, const Token *tok2)
|
||||||
static Token * createAstAtToken(Token *tok, bool cpp)
|
static Token * createAstAtToken(Token *tok, bool cpp)
|
||||||
{
|
{
|
||||||
// skip function pointer declaration
|
// skip function pointer declaration
|
||||||
|
if (Token::Match(tok, "%type% %type%") && !Token::Match(tok, "return|throw|new|delete")) {
|
||||||
|
Token* tok2 = tok->tokAt(2);
|
||||||
|
// skip type tokens and qualifiers etc
|
||||||
|
while (Token::Match(tok2, "%type%|*|&"))
|
||||||
|
tok2 = tok2->next();
|
||||||
|
if (Token::Match(tok2, "%var% [;,)]"))
|
||||||
|
return tok2;
|
||||||
|
}
|
||||||
if (Token::Match(tok, "%type%") && !Token::Match(tok, "return|throw|if|while|new|delete")) {
|
if (Token::Match(tok, "%type%") && !Token::Match(tok, "return|throw|if|while|new|delete")) {
|
||||||
Token* type = tok;
|
Token* type = tok;
|
||||||
while (Token::Match(type, "%type%|*|&|<")) {
|
while (Token::Match(type, "%type%|*|&|<")) {
|
||||||
|
|
|
@ -6474,6 +6474,9 @@ private:
|
||||||
ASSERT_EQUALS("tmpa*=a*b*=,b*tmp=,", testAst("{ ((tmp) = (*a)), ((*a) = (*b)), ((*b) = (tmp)); }"));
|
ASSERT_EQUALS("tmpa*=a*b*=,b*tmp=,", testAst("{ ((tmp) = (*a)), ((*a) = (*b)), ((*b) = (tmp)); }"));
|
||||||
ASSERT_EQUALS("a(*v=", testAst("(*(volatile unsigned int *)(a) = (v));"));
|
ASSERT_EQUALS("a(*v=", testAst("(*(volatile unsigned int *)(a) = (v));"));
|
||||||
ASSERT_EQUALS("i(j=", testAst("(int&)(i) = j;"));
|
ASSERT_EQUALS("i(j=", testAst("(int&)(i) = j;"));
|
||||||
|
|
||||||
|
ASSERT_EQUALS("", testAst("void f(enum E* var){}"));
|
||||||
|
ASSERT_EQUALS("", testAst("void f(enum E*& var){}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void astunaryop() const { // unary operators
|
void astunaryop() const { // unary operators
|
||||||
|
|
Loading…
Reference in New Issue