This commit is contained in:
parent
5574e41b86
commit
d77fa64051
|
@ -2910,7 +2910,7 @@ void Tokenizer::combineOperators()
|
||||||
const char c2 = tok->next()->str()[0];
|
const char c2 = tok->next()->str()[0];
|
||||||
|
|
||||||
// combine +-*/ and =
|
// combine +-*/ and =
|
||||||
if (c2 == '=' && (std::strchr("+-*/%|^=!<>", c1))) {
|
if (c2 == '=' && (std::strchr("+-*/%|^=!<>", c1)) && !Token::Match(tok->previous(), "%type% *")) {
|
||||||
// skip templates
|
// skip templates
|
||||||
if (cpp && (tok->str() == ">" || Token::simpleMatch(tok->previous(), "> *"))) {
|
if (cpp && (tok->str() == ">" || Token::simpleMatch(tok->previous(), "> *"))) {
|
||||||
const Token* opening =
|
const Token* opening =
|
||||||
|
|
|
@ -347,6 +347,7 @@ private:
|
||||||
TEST_CASE(simplifyOperatorName28);
|
TEST_CASE(simplifyOperatorName28);
|
||||||
TEST_CASE(simplifyOperatorName29); // spaceship operator
|
TEST_CASE(simplifyOperatorName29); // spaceship operator
|
||||||
TEST_CASE(simplifyOperatorName31); // #6342
|
TEST_CASE(simplifyOperatorName31); // #6342
|
||||||
|
TEST_CASE(simplifyOperatorName32); // #10256
|
||||||
|
|
||||||
TEST_CASE(simplifyOverloadedOperators1);
|
TEST_CASE(simplifyOverloadedOperators1);
|
||||||
TEST_CASE(simplifyOverloadedOperators2); // (*this)(123)
|
TEST_CASE(simplifyOverloadedOperators2); // (*this)(123)
|
||||||
|
@ -4909,6 +4910,12 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
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
|
void simplifyOperatorName10() { // #8746
|
||||||
const char code1[] = "using a::operator=;";
|
const char code1[] = "using a::operator=;";
|
||||||
ASSERT_EQUALS("using a :: operator= ;", tokenizeAndStringify(code1));
|
ASSERT_EQUALS("using a :: operator= ;", tokenizeAndStringify(code1));
|
||||||
|
|
Loading…
Reference in New Issue