Fixed #3700 (false positive: (style) Variable 'H' is not assigned a value)
This commit is contained in:
parent
26a9a1b571
commit
bbdeebafda
|
@ -5178,7 +5178,7 @@ void Tokenizer::simplifyVarDecl(bool only_k_r_fpar)
|
|||
unsigned int typelen = 1;
|
||||
|
||||
//check if variable is declared 'const' or 'static' or both
|
||||
while (Token::Match(tok2, "const|static")) {
|
||||
while (Token::Match(tok2, "const|static") || Token::Match(tok2, "%type% const|static")) {
|
||||
if (tok2->str() == "const")
|
||||
isconst = true;
|
||||
|
||||
|
|
|
@ -294,6 +294,7 @@ private:
|
|||
TEST_CASE(vardecl17);
|
||||
TEST_CASE(vardecl18);
|
||||
TEST_CASE(vardecl19);
|
||||
TEST_CASE(vardecl20); // #3700 - register const int H = 0;
|
||||
TEST_CASE(vardecl_stl_1);
|
||||
TEST_CASE(vardecl_stl_2);
|
||||
TEST_CASE(vardecl_template_1);
|
||||
|
@ -4788,6 +4789,18 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void vardecl20() {
|
||||
// #3700
|
||||
const char code[] = "void a::b() const\n"
|
||||
"{\n"
|
||||
" register const int X = 0;\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS("void a :: b ( ) const\n"
|
||||
"{\n"
|
||||
"const int X = 0 ;\n"
|
||||
"}", tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void volatile_variables() {
|
||||
const char code[] = "volatile int a=0;\n"
|
||||
"volatile int b=0;\n"
|
||||
|
|
Loading…
Reference in New Issue