compilerplugins/clang/test/getstr.cxx | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
New commits: commit cafa1fad83ba4c11f45a6ab065bb94ad7e5db225 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Wed Dec 4 14:09:09 2019 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Wed Dec 4 15:46:05 2019 +0100 Adapt compilerplugins/clang/test/getstr.cxx to C++20 deleted ostream << Change-Id: I5315a7c682774edb3d16035b6fd3361e1c2bc3f5 Reviewed-on: https://gerrit.libreoffice.org/84409 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/compilerplugins/clang/test/getstr.cxx b/compilerplugins/clang/test/getstr.cxx index 358f2e2b1e7d..59b52a390e3a 100644 --- a/compilerplugins/clang/test/getstr.cxx +++ b/compilerplugins/clang/test/getstr.cxx @@ -17,21 +17,39 @@ #include <rtl/ustring.hxx> #include <sal/log.hxx> +// Determine whether std::ostream operator << for sal_Unicode* (aka char16_t*) is deleted (see +// <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1423r3.html> "char8_t backward +// compatibility remediation", as implemented now by +// <https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=0c5b35933e5b150df0ab487efb2f11ef5685f713> +// "libstdc++: P1423R3 char8_t remediation (2/4)" for -std=c++2a; TODO: the checks here and the +// relevant code in loplugin:getstr should eventually be removed once support for the deleted +// operators is widespread): +#if __cplusplus > 201703L && defined __GLIBCXX__ +#define HAVE_DELETED_OPERATORS true +#else +#define HAVE_DELETED_OPERATORS false +#endif + using S = OString; -void f(std::ostream& st, OString const& s1, OStringBuffer const& s2, OUString const& s3, - OUStringBuffer const& s4, S const& s5, OString* p1, OStringBuffer* p2, OUString* p3, - OUStringBuffer* p4, S* p5, char const* (OString::*pf)() const) +void f(std::ostream& st, OString const& s1, OStringBuffer const& s2, + OUString const& s3[[maybe_unused]], OUStringBuffer const& s4[[maybe_unused]], S const& s5, + OString* p1, OStringBuffer* p2, OUString* p3[[maybe_unused]], + OUStringBuffer* p4[[maybe_unused]], S* p5, char const* (OString::*pf)() const) { st << s1.getStr() // expected-error {{directly use object of type 'rtl::OString' in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr]}} << s2.getStr() +#if !HAVE_DELETED_OPERATORS << s3.getStr() // expected-error {{suspicious use of 'getStr' on an object of type 'rtl::OUString'; the result is implicitly cast to a void pointer in a call of 'operator <<' [loplugin:getstr]}} << s4.getStr() // expected-error {{suspicious use of 'getStr' on an object of type 'rtl::OUStringBuffer'; the result is implicitly cast to a void pointer in a call of 'operator <<' [loplugin:getstr]}} +#endif << s5.getStr() // expected-error {{directly use object of type 'S' (aka 'rtl::OString') in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr]}} << p1->getStr() // expected-error {{directly use object of type 'rtl::OString' in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr]}} << p2->getStr() +#if !HAVE_DELETED_OPERATORS << p3->getStr() // expected-error {{suspicious use of 'getStr' on an object of type 'rtl::OUString'; the result is implicitly cast to a void pointer in a call of 'operator <<' [loplugin:getstr]}} << p4->getStr() // expected-error {{suspicious use of 'getStr' on an object of type 'rtl::OUStringBuffer'; the result is implicitly cast to a void pointer in a call of 'operator <<' [loplugin:getstr]}} +#endif << p5->getStr() // expected-error {{directly use object of type 'rtl::OString' in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr]}} << (s1.*pf)(); SAL_INFO( // expected-error 1+ {{directly use object of type 'rtl::OString' in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr]}} _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits