Skip to content

Commit b4df064

Browse files
Fix #11004 FP AssignmentIntegerToAddress with volatile (#4046)
1 parent 81f9b9b commit b4df064

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7516,7 +7516,7 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, const Token * const tokEnd, co
75167516
}
75177517

75187518
while (Token::Match(varName, "%type% %type%")) {
7519-
if (varName->str() != "const") {
7519+
if (varName->str() != "const" && varName->str() != "volatile") {
75207520
++typelen;
75217521
}
75227522
varName = varName->next();

test/testtokenize.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,13 +2526,22 @@ class TestTokenizer : public TestFixture {
25262526
}
25272527

25282528
void volatile_variables() {
2529-
const char code[] = "volatile int a=0;\n"
2530-
"volatile int b=0;\n"
2531-
"volatile int c=0;\n";
2529+
{
2530+
const char code[] = "volatile int a=0;\n"
2531+
"volatile int b=0;\n"
2532+
"volatile int c=0;\n";
25322533

2533-
const std::string actual(tokenizeAndStringify(code));
2534+
const std::string actual(tokenizeAndStringify(code));
25342535

2535-
ASSERT_EQUALS("volatile int a ; a = 0 ;\nvolatile int b ; b = 0 ;\nvolatile int c ; c = 0 ;", actual);
2536+
ASSERT_EQUALS("volatile int a ; a = 0 ;\nvolatile int b ; b = 0 ;\nvolatile int c ; c = 0 ;", actual);
2537+
}
2538+
{
2539+
const char code[] = "char *volatile s1, *volatile s2;\n"; // #11004
2540+
2541+
const std::string actual(tokenizeAndStringify(code));
2542+
2543+
ASSERT_EQUALS("char * volatile s1 ; char * volatile s2 ;", actual);
2544+
}
25362545
}
25372546

25382547

0 commit comments

Comments
 (0)