sal/qa/rtl/strings/test_ostring_concat.cxx  |   18 ++++++++++++++----
 sal/qa/rtl/strings/test_oustring_concat.cxx |    9 +++++++--
 2 files changed, 21 insertions(+), 6 deletions(-)

New commits:
commit 8c717ea3854130067919658e9ec7433e0b5e2ba0
Author:     Stephan Bergmann <[email protected]>
AuthorDate: Wed Aug 18 12:35:21 2021 +0200
Commit:     Stephan Bergmann <[email protected]>
CommitDate: Wed Aug 18 23:01:22 2021 +0200

    GCC bug 96878 is fixed in upcoming GCC 12
    
    However, restricting the workaround to GCC <= 11 then revealed that some old
    versions of Clang apparently had a similar issue, causing "error: use of 
class
    template 'OStringLiteral' requires template arguments; argument deduction 
not
    allowed here", and thus also need the workaround.  I saw the non-workaround 
code
    fail with a build of Clang 6.0.0 and succeed with a build of Clang 7.0.0.
    
    Change-Id: I6e4cf6c8c3a11618a578401574e5679e6b65d7f4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120657
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <[email protected]>

diff --git a/sal/qa/rtl/strings/test_ostring_concat.cxx 
b/sal/qa/rtl/strings/test_ostring_concat.cxx
index f797a15660b5..af1f31dcf162 100644
--- a/sal/qa/rtl/strings/test_ostring_concat.cxx
+++ b/sal/qa/rtl/strings/test_ostring_concat.cxx
@@ -68,15 +68,25 @@ void test::ostring::StringConcat::checkConcat()
     CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OStringBuffer( "foo" ) 
+ "bar" ));
     CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OStringBuffer, const char[ 4 
] > )), typeid( OStringBuffer( "foo" ) + "bar" ));
     CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OStringLiteral( "foo" 
) + "bar" ));
+#if (defined __GNUC__ && __GNUC__ <= 11 && !defined __clang__) || (defined 
__clang__ && __clang_major__ <= 6)
     CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OStringLiteral<4>, const 
char[ 4 ] > )), typeid( OStringLiteral<4>( "foo" ) + "bar" ));
-        //TODO: the explicit OStringLiteral<4> template argument in the 
unevaluated typeid context
+        // the explicit OStringLiteral<4> template argument in the unevaluated 
typeid context
         // is needed by some GCC versions, see 
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96878>
-        // "Failed class template argument deduction in unevaluated, 
parenthesized context"
+        // "Failed class template argument deduction in unevaluated, 
parenthesized context", and by
+        // some old Clang versions
+#else
+    CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OStringLiteral<4>, const 
char[ 4 ] > )), typeid( OStringLiteral( "foo" ) + "bar" ));
+#endif
     CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OStringLiteral( "foo" 
) + static_cast<const char*>("bar") ));
+#if (defined __GNUC__ && __GNUC__ <= 11 && !defined __clang__) || (defined 
__clang__ && __clang_major__ <= 6)
     CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OStringLiteral<4>, const 
char* > )), typeid( OStringLiteral<4>( "foo" ) + static_cast<const 
char*>("bar") ));
-        //TODO: the explicit OStringLiteral<4> template argument in the 
unevaluated typeid context
+        // the explicit OStringLiteral<4> template argument in the unevaluated 
typeid context
         // is needed by some GCC versions, see 
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96878>
-        // "Failed class template argument deduction in unevaluated, 
parenthesized context"
+        // "Failed class template argument deduction in unevaluated, 
parenthesized context", and by
+        // some old Clang versions
+#else
+    CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OStringLiteral<4>, const 
char* > )), typeid( OStringLiteral( "foo" ) + static_cast<const char*>("bar") 
));
+#endif
     const char d1[] = "xyz";
     char d2[] = "abc";
     const char* d3 = d1;
diff --git a/sal/qa/rtl/strings/test_oustring_concat.cxx 
b/sal/qa/rtl/strings/test_oustring_concat.cxx
index 3a282a95c014..8e67817e1367 100644
--- a/sal/qa/rtl/strings/test_oustring_concat.cxx
+++ b/sal/qa/rtl/strings/test_oustring_concat.cxx
@@ -69,10 +69,15 @@ void test::oustring::StringConcat::checkConcat()
     CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUStringBuffer( 
"foo" ) + "bar" ));
     CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringBuffer, const char[ 
4 ] > )), typeid( OUStringBuffer( "foo" ) + "bar" ));
     CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUStringLiteral( 
u"foo" ) + "bar" ));
+#if (defined __GNUC__ && __GNUC__ <= 11 && !defined __clang__) || (defined 
__clang__ && __clang_major__ <= 6)
     CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringLiteral<4>, const 
char[ 4 ] > )), typeid( OUStringLiteral<4>( u"foo" ) + "bar" ));
-        //TODO: the explicit OUStringLiteral<4> template argument in the 
unevaluated typeid context
+        // the explicit OUStringLiteral<4> template argument in the 
unevaluated typeid context
         // is needed by some GCC versions, see 
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96878>
-        // "Failed class template argument deduction in unevaluated, 
parenthesized context"
+        // "Failed class template argument deduction in unevaluated, 
parenthesized context", and by
+        // some old Clang versions
+#else
+    CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringLiteral<4>, const 
char[ 4 ] > )), typeid( OUStringLiteral( u"foo" ) + "bar" ));
+#endif
     const char d1[] = "xyz";
     CPPUNIT_ASSERT_EQUAL( OUString( "fooxyz" ), OUString( OUString( "foo" ) + 
d1 ));
     CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, const char[ 4 ] > 
)), typeid( OUString( "foo" ) + d1 ));

Reply via email to