Add test for #6342 (#3569)

* Add test for #6342

* Format
This commit is contained in:
chrchr-github 2021-11-18 20:25:21 +01:00 committed by GitHub
parent 80578c3504
commit 22eeeed17a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -341,6 +341,7 @@ private:
TEST_CASE(simplifyOperatorName27); TEST_CASE(simplifyOperatorName27);
TEST_CASE(simplifyOperatorName28); TEST_CASE(simplifyOperatorName28);
TEST_CASE(simplifyOperatorName29); // spaceship operator TEST_CASE(simplifyOperatorName29); // spaceship operator
TEST_CASE(simplifyOperatorName31); // #6342
TEST_CASE(simplifyOverloadedOperators1); TEST_CASE(simplifyOverloadedOperators1);
TEST_CASE(simplifyOverloadedOperators2); // (*this)(123) TEST_CASE(simplifyOverloadedOperators2); // (*this)(123)
@ -4834,6 +4835,17 @@ private:
ASSERT_EQUALS(code, tokenizeAndStringify(code)); ASSERT_EQUALS(code, tokenizeAndStringify(code));
} }
void simplifyOperatorName31() { // #6342
const char code[] = "template <typename T>\n"
"struct B {\n"
" typedef T A[3];\n"
" operator A& () { return x_; }\n"
" A x_;\n"
"};";
ASSERT_EQUALS("template < typename T >\nstruct B {\n\noperatorT ( & ( ) ) [ 3 ] { return x_ ; }\nT x_ [ 3 ] ;\n} ;", 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));