Fix #11004 FP AssignmentIntegerToAddress with volatile (#4046)

This commit is contained in:
chrchr-github 2022-04-25 22:00:37 +02:00 committed by GitHub
parent 81f9b9b2b7
commit b4df064875
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View File

@ -7516,7 +7516,7 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, const Token * const tokEnd, co
}
while (Token::Match(varName, "%type% %type%")) {
if (varName->str() != "const") {
if (varName->str() != "const" && varName->str() != "volatile") {
++typelen;
}
varName = varName->next();

View File

@ -2526,13 +2526,22 @@ private:
}
void volatile_variables() {
const char code[] = "volatile int a=0;\n"
"volatile int b=0;\n"
"volatile int c=0;\n";
{
const char code[] = "volatile int a=0;\n"
"volatile int b=0;\n"
"volatile int c=0;\n";
const std::string actual(tokenizeAndStringify(code));
const std::string actual(tokenizeAndStringify(code));
ASSERT_EQUALS("volatile int a ; a = 0 ;\nvolatile int b ; b = 0 ;\nvolatile int c ; c = 0 ;", actual);
ASSERT_EQUALS("volatile int a ; a = 0 ;\nvolatile int b ; b = 0 ;\nvolatile int c ; c = 0 ;", actual);
}
{
const char code[] = "char *volatile s1, *volatile s2;\n"; // #11004
const std::string actual(tokenizeAndStringify(code));
ASSERT_EQUALS("char * volatile s1 ; char * volatile s2 ;", actual);
}
}