Tokenizer::simplifyStaticConst(): Support "struct" and operator:: (#7403)
This commit is contained in:
parent
f23668dfcc
commit
b65cacf4b1
|
@ -5805,7 +5805,7 @@ void Tokenizer::simplifyStaticConst()
|
|||
// Look backwards to find the beginning of the declaration
|
||||
Token* leftTok = tok;
|
||||
for (; leftTok; leftTok = leftTok->previous()) {
|
||||
if (!Token::Match(leftTok, "%type%|static|const|extern") ||
|
||||
if (!Token::Match(leftTok, "%type%|static|const|extern|struct|::") ||
|
||||
(isCPP() && Token::Match(leftTok, "private:|protected:|public:|operator")))
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -667,7 +667,7 @@ private:
|
|||
void isVariableDeclarationPointerConst() {
|
||||
reset();
|
||||
givenACodeSampleToTokenize var("std::string const* s;");
|
||||
bool result = si.isVariableDeclaration(var.tokens(), vartok, typetok);
|
||||
bool result = si.isVariableDeclaration(var.tokens()->next(), vartok, typetok);
|
||||
ASSERT_EQUALS(true, result);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings.library);
|
||||
ASSERT(false == v.isArray());
|
||||
|
|
|
@ -3933,7 +3933,7 @@ private:
|
|||
" a::b const *p = 0;\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS("void f ( ) {\n"
|
||||
"a :: b const * p ; p = 0 ;\n"
|
||||
"const a :: b * p ; p = 0 ;\n"
|
||||
"}"
|
||||
, tokenizeAndStringify(code1));
|
||||
|
||||
|
@ -3942,7 +3942,7 @@ private:
|
|||
" ::a::b const *p = 0;\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS("void f ( ) {\n"
|
||||
":: a :: b const * p ; p = 0 ;\n"
|
||||
"const :: a :: b * p ; p = 0 ;\n"
|
||||
"}"
|
||||
, tokenizeAndStringify(code2));
|
||||
}
|
||||
|
|
|
@ -830,7 +830,7 @@ private:
|
|||
{
|
||||
const char code[] = "void f(FOO::BAR const);\n";
|
||||
ASSERT_EQUALS("\n\n##file 0\n"
|
||||
"1: void f ( FOO :: BAR const ) ;\n",
|
||||
"1: void f ( const FOO :: BAR ) ;\n",
|
||||
tokenize(code));
|
||||
}
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue