Preserve varId in simplifyArrayAccessSyntax (#6523)

This commit is contained in:
PKEuS 2015-09-05 13:13:34 +02:00
parent 8a7d62cec8
commit 5c348890b2
2 changed files with 5 additions and 3 deletions

View File

@ -2054,6 +2054,7 @@ void Tokenizer::simplifyArrayAccessSyntax()
if (Token::Match(tok, "%num% [ %name% ]")) {
std::string temp = tok->str();
tok->str(tok->strAt(2));
tok->varId(tok->tokAt(2)->varId());
tok->tokAt(2)->str(temp);
}
}

View File

@ -132,7 +132,7 @@ private:
TEST_CASE(simplifyOperator1);
TEST_CASE(simplifyOperator2);
TEST_CASE(reverseArraySyntax)
TEST_CASE(simplifyArrayAccessSyntax)
TEST_CASE(simplify_numeric_condition)
TEST_CASE(simplify_condition);
@ -2523,8 +2523,9 @@ private:
"}"));
}
void reverseArraySyntax() {
ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));
void simplifyArrayAccessSyntax() {
ASSERT_EQUALS("\n\n##file 0\n"
"1: int a@1 ; a@1 [ 13 ] ;\n", tokenizeDebugListing("int a; 13[a];"));
}
void simplify_numeric_condition() {