Fix #10256 Function::addArguments found argument 'x' with varid 0 (#3845)

This commit is contained in:
chrchr-github 2022-02-21 18:06:26 +01:00 committed by GitHub
parent 5574e41b86
commit d77fa64051
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -2910,7 +2910,7 @@ void Tokenizer::combineOperators()
const char c2 = tok->next()->str()[0];
// combine +-*/ and =
if (c2 == '=' && (std::strchr("+-*/%|^=!<>", c1))) {
if (c2 == '=' && (std::strchr("+-*/%|^=!<>", c1)) && !Token::Match(tok->previous(), "%type% *")) {
// skip templates
if (cpp && (tok->str() == ">" || Token::simpleMatch(tok->previous(), "> *"))) {
const Token* opening =

View File

@ -347,6 +347,7 @@ private:
TEST_CASE(simplifyOperatorName28);
TEST_CASE(simplifyOperatorName29); // spaceship operator
TEST_CASE(simplifyOperatorName31); // #6342
TEST_CASE(simplifyOperatorName32); // #10256
TEST_CASE(simplifyOverloadedOperators1);
TEST_CASE(simplifyOverloadedOperators2); // (*this)(123)
@ -4909,6 +4910,12 @@ private:
ASSERT_EQUALS("", errout.str());
}
void simplifyOperatorName32() { // #10256
const char code[] = "void f(int* = nullptr) {}\n";
ASSERT_EQUALS("void f ( int * = nullptr ) { }", tokenizeAndStringify(code));
ASSERT_EQUALS("", errout.str());
}
void simplifyOperatorName10() { // #8746
const char code1[] = "using a::operator=;";
ASSERT_EQUALS("using a :: operator= ;", tokenizeAndStringify(code1));