Fix #10138 syntax error : int (operator"" _ii)(unsigned long long v) … (#4374)

* Fix #10138 syntax error : int (operator"" _ii)(unsigned long long v) { return v; }

* Format
This commit is contained in:
chrchr-github 2022-08-18 23:38:45 +02:00 committed by GitHub
parent 2fee7a6e3f
commit 1aa259569e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -9223,10 +9223,16 @@ void Tokenizer::simplifyOperatorName()
break;
}
done = false;
} else if (Token::Match(par, "\"\" %name% (|;|<")) {
} else if (Token::Match(par, "\"\" %name% )| (|;|<")) {
op += "\"\"";
op += par->strAt(1);
par = par->tokAt(2);
if (par->str() == ")") {
par->link()->deleteThis();
par = par->next();
par->deletePrevious();
tok = par->tokAt(-3);
}
done = true;
} else if (par->str() == "::") {
op += par->str();

View File

@ -350,6 +350,7 @@ private:
TEST_CASE(simplifyOperatorName29); // spaceship operator
TEST_CASE(simplifyOperatorName31); // #6342
TEST_CASE(simplifyOperatorName32); // #10256
TEST_CASE(simplifyOperatorName33); // #10138
TEST_CASE(simplifyOverloadedOperators1);
TEST_CASE(simplifyOverloadedOperators2); // (*this)(123)
@ -4987,6 +4988,12 @@ private:
ASSERT_EQUALS("", errout.str());
}
void simplifyOperatorName33() { // #10138
const char code[] = "int (operator\"\" _ii)(unsigned long long v) { return v; }\n";
ASSERT_EQUALS("int operator\"\"_ii ( unsigned long long v ) { return v ; }", tokenizeAndStringify(code));
ASSERT_EQUALS("", errout.str());
}
void simplifyOperatorName10() { // #8746
const char code1[] = "using a::operator=;";
ASSERT_EQUALS("using a :: operator= ;", tokenizeAndStringify(code1));