From 22eeeed17a7e696452d5bc69905e495ba651010b Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 18 Nov 2021 20:25:21 +0100 Subject: [PATCH] Add test for #6342 (#3569) * Add test for #6342 * Format --- test/testtokenize.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index ae501af78..41a6af326 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -341,6 +341,7 @@ private: TEST_CASE(simplifyOperatorName27); TEST_CASE(simplifyOperatorName28); TEST_CASE(simplifyOperatorName29); // spaceship operator + TEST_CASE(simplifyOperatorName31); // #6342 TEST_CASE(simplifyOverloadedOperators1); TEST_CASE(simplifyOverloadedOperators2); // (*this)(123) @@ -4834,6 +4835,17 @@ private: ASSERT_EQUALS(code, tokenizeAndStringify(code)); } + void simplifyOperatorName31() { // #6342 + const char code[] = "template \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 const char code1[] = "using a::operator=;"; ASSERT_EQUALS("using a :: operator= ;", tokenizeAndStringify(code1));