diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-10-22 09:19:17 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-10-22 12:13:34 +0200 |
commit | cde9b22a9225801d58ed0ab56fbd065f4e51eb92 (patch) | |
tree | 7a542c1180c29d2967e15a637183b9e150612cd3 /external | |
parent | 3e9ee3803535cde4c6f5de4fb7edf36e5ed6fac4 (diff) |
exernal/icu: Various C++20 comparison operator fixes
There are three patterns here:
* Missing const (source/common/uvector.cpp, source/common/uvector.h): Overload
resolution ambiguities when a synthesized canditate of operator == for a
reversed-argument rewrite conflicts with the actual operator ==, due to the
asymmetric const-ness of the implicit object parameter and the RHS parameter:
> uniset.cpp:360:18: error: use of overloaded operator '!=' is ambiguous (with operand types 'icu_63::UVector' and 'icu_63::UVector')
> if (*strings != *o.strings) return FALSE;
> ~~~~~~~~ ^ ~~~~~~~~~~
> ./uvector.h:385:23: note: candidate function
> inline UBool UVector::operator!=(const UVector& other) {
> ^
> ./uvector.h:116:11: note: candidate function
> UBool operator==(const UVector& other);
> ^
> ./uvector.h:116:11: note: candidate function (with reversed parameter order)
* UBool -> bool (source/i18n/tzrule.cpp, source/i18n/unicode/tzrule.h):
[over.match.oper]/9 (of the current C++20 draft) states: "If a rewritten
operator== candidate is selected [...], its return type shall be cv bool":
> basictz.cpp:411:37: error: return type 'UBool' (aka 'signed char') of selected 'operator==' function for rewritten '==' comparison is not 'bool'
> if (*(tzt0.getTo()) == *tar) {
> ~~~~~~~~~~~~~~~ ^ ~~~~
> ./unicode/tzrule.h:675:19: note: declared here
> virtual UBool operator==(const TimeZoneRule& that) const;
> ^
* Additional operator != (source/i18n/unicode/rbtz.h,
source/i18n/unicode/simpletz.h, source/i18n/unicode/smpdtfmt.h,
source/i18n/unicode/stsearch.h, source/i18n/unicode/tzrule.h,
source/i18n/unicode/vtzone.h): Similar to the previous pattern, but here the
original operator used was !=, so an alternative fix (that reqires fewer
changes to the code overall) is to add specific operator != overloads:
> rbtz.cpp:79:15: error: use of overloaded operator '!=' is ambiguous (with operand types 'icu_63::RuleBasedTimeZone' and 'const icu_63::RuleBasedTimeZone')
> if (*this != right) {
> ~~~~~ ^ ~~~~~
> ./unicode/rbtz.h:87:19: note: candidate function
> virtual UBool operator!=(const TimeZone& that) const;
> ^
> ./unicode/rbtz.h:77:19: note: candidate function
> virtual UBool operator==(const TimeZone& that) const;
> ^
> ./unicode/rbtz.h:77:19: note: candidate function (with reversed parameter order)
> rbtz.cpp:101:23: error: use of overloaded operator '!=' is ambiguous (with operand types 'icu_63::InitialTimeZoneRule' and 'icu_63::InitialTimeZoneRule')
> if (*fInitialRule != *(rbtz->fInitialRule)) {
> ~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~
> ./unicode/tzrule.h:257:19: note: candidate function
> virtual UBool operator!=(const TimeZoneRule& that) const;
> ^
> ./unicode/tzrule.h:248:18: note: candidate function
> virtual bool operator==(const TimeZoneRule& that) const;
> ^
> ./unicode/tzrule.h:248:18: note: candidate function (with reversed parameter order)
> rbtz.cpp:535:23: error: use of overloaded operator '!=' is ambiguous (with operand types 'icu_63::InitialTimeZoneRule' and 'icu_63::InitialTimeZoneRule')
> if (*fInitialRule != *(that.fInitialRule)) {
> ~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~
> ./unicode/tzrule.h:257:19: note: candidate function
> virtual UBool operator!=(const TimeZoneRule& that) const;
> ^
> ./unicode/tzrule.h:248:18: note: candidate function
> virtual bool operator==(const TimeZoneRule& that) const;
> ^
> ./unicode/tzrule.h:248:18: note: candidate function (with reversed parameter order)
>
> olsontz.cpp:630:69: error: return type 'UBool' (aka 'signed char') of selected 'operator==' function for rewritten '!=' comparison is not 'bool'
> || (finalZone != NULL && z->finalZone != NULL && *finalZone != *z->finalZone)) {
> ~~~~~~~~~~ ^ ~~~~~~~~~~~~~
> ./unicode/simpletz.h:112:19: note: declared here
> virtual UBool operator==(const TimeZone& that) const;
> ^
> dtitvfmt.cpp:223:62: error: return type 'UBool' (aka 'signed char') of selected 'operator==' function for rewritten '!=' comparison is not 'bool'
> if (fDateFormat && fmt->fDateFormat && (*fDateFormat != *fmt->fDateFormat)) {return FALSE;}
> ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~
> ./unicode/smpdtfmt.h:876:19: note: declared here
> virtual UBool operator==(const Format& other) const;
> ^
> stsearch.cpp:187:17: error: return type 'UBool' (aka 'signed char') of selected 'operator==' function for rewritten '!=' comparison is not 'bool'
> if ((*this) != that) {
> ~~~~~~~ ^ ~~~~
> ./unicode/stsearch.h:299:19: note: declared here
> virtual UBool operator==(const SearchIterator &that) const;
> ^
> vtzone.cpp:1003:15: error: use of overloaded operator '!=' is ambiguous (with operand types 'icu_63::VTimeZone' and 'const icu_63::VTimeZone')
> if (*this != right) {
> ~~~~~ ^ ~~~~~
> ./unicode/vtzone.h:83:19: note: candidate function
> virtual UBool operator!=(const TimeZone& that) const;
> ^
> ./unicode/vtzone.h:73:19: note: candidate function
> virtual UBool operator==(const TimeZone& that) const;
> ^
> ./unicode/vtzone.h:73:19: note: candidate function (with reversed parameter order)
Change-Id: I38e01143d1ea0df3f43de53303fd710e41bae027
Reviewed-on: https://gerrit.libreoffice.org/81306
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'external')
-rw-r--r-- | external/icu/UnpackedTarball_icu.mk | 1 | ||||
-rw-r--r-- | external/icu/c++20-comparison.patch | 171 |
2 files changed, 172 insertions, 0 deletions
diff --git a/external/icu/UnpackedTarball_icu.mk b/external/icu/UnpackedTarball_icu.mk index d8a16e0e3777..4d45f2108f99 100644 --- a/external/icu/UnpackedTarball_icu.mk +++ b/external/icu/UnpackedTarball_icu.mk @@ -43,6 +43,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,icu,\ external/icu/char8_t.patch \ external/icu/CVE-2018-18928.patch.2 \ external/icu/clang-cl.patch \ + external/icu/c++20-comparison.patch \ )) $(eval $(call gb_UnpackedTarball_add_file,icu,source/data/brkitr/khmerdict.dict,external/icu/khmerdict.dict)) diff --git a/external/icu/c++20-comparison.patch b/external/icu/c++20-comparison.patch new file mode 100644 index 000000000000..44053e6719ca --- /dev/null +++ b/external/icu/c++20-comparison.patch @@ -0,0 +1,171 @@ +--- source/common/uvector.cpp ++++ source/common/uvector.cpp +@@ -110,7 +110,7 @@ + } + + // This only does something sensible if this object has a non-null comparer +-UBool UVector::operator==(const UVector& other) { ++UBool UVector::operator==(const UVector& other) const { + int32_t i; + if (count != other.count) return FALSE; + if (comparer != NULL) { +--- source/common/uvector.h ++++ source/common/uvector.h +@@ -113,12 +113,12 @@ + * equal if they are of the same size and all elements are equal, + * as compared using this object's comparer. + */ +- UBool operator==(const UVector& other); ++ UBool operator==(const UVector& other) const; + + /** + * Equivalent to !operator==() + */ +- inline UBool operator!=(const UVector& other); ++ inline UBool operator!=(const UVector& other) const; + + //------------------------------------------------------------ + // java.util.Vector API +@@ -382,7 +382,7 @@ + return elementAt(index); + } + +-inline UBool UVector::operator!=(const UVector& other) { ++inline UBool UVector::operator!=(const UVector& other) const { + return !operator==(other); + } + +--- source/i18n/tzrule.cpp ++++ source/i18n/tzrule.cpp +@@ -53,7 +53,7 @@ + return *this; + } + +-UBool ++bool + TimeZoneRule::operator==(const TimeZoneRule& that) const { + return ((this == &that) || + (typeid(*this) == typeid(that) && +@@ -120,7 +120,7 @@ + return *this; + } + +-UBool ++bool + InitialTimeZoneRule::operator==(const TimeZoneRule& that) const { + return ((this == &that) || + (typeid(*this) == typeid(that) && +@@ -226,7 +226,7 @@ + return *this; + } + +-UBool ++bool + AnnualTimeZoneRule::operator==(const TimeZoneRule& that) const { + if (this == &that) { + return TRUE; +@@ -445,7 +445,7 @@ + return *this; + } + +-UBool ++bool + TimeArrayTimeZoneRule::operator==(const TimeZoneRule& that) const { + if (this == &that) { + return TRUE; +--- source/i18n/unicode/rbtz.h ++++ source/i18n/unicode/rbtz.h +@@ -85,6 +85,7 @@ + * @stable ICU 3.8 + */ + virtual UBool operator!=(const TimeZone& that) const; ++ UBool operator!=(const RuleBasedTimeZone& that) const {return !operator==(that);} + + /** + * Adds the <code>TimeZoneRule</code> which represents time transitions. +--- source/i18n/unicode/simpletz.h ++++ source/i18n/unicode/simpletz.h +@@ -110,6 +110,7 @@ + * @stable ICU 2.0 + */ + virtual UBool operator==(const TimeZone& that) const; ++ UBool operator!=(const SimpleTimeZone& that) const {return !operator==(that);} + + /** + * Constructs a SimpleTimeZone with the given raw GMT offset and time zone ID, +--- source/i18n/unicode/smpdtfmt.h ++++ source/i18n/unicode/smpdtfmt.h +@@ -874,6 +874,7 @@ + * @stable ICU 2.0 + */ + virtual UBool operator==(const Format& other) const; ++ UBool operator!=(const SimpleDateFormat& that) const {return !operator==(that);} + + + using DateFormat::format; +--- source/i18n/unicode/stsearch.h ++++ source/i18n/unicode/stsearch.h +@@ -297,6 +297,7 @@ + * @stable ICU 2.0 + */ + virtual UBool operator==(const SearchIterator &that) const; ++ UBool operator!=(const StringSearch &that) const {return !operator==(that);} + + // public get and set methods ---------------------------------------- + +--- source/i18n/unicode/tzrule.h ++++ source/i18n/unicode/tzrule.h +@@ -54,7 +54,7 @@ + * @return true if the given <code>TimeZoneRule</code> objects are semantically equal. + * @stable ICU 3.8 + */ +- virtual UBool operator==(const TimeZoneRule& that) const; ++ virtual bool operator==(const TimeZoneRule& that) const; + + /** + * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects +@@ -245,7 +245,7 @@ + * @return true if the given <code>TimeZoneRule</code> objects are semantically equal. + * @stable ICU 3.8 + */ +- virtual UBool operator==(const TimeZoneRule& that) const; ++ virtual bool operator==(const TimeZoneRule& that) const; + + /** + * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects +@@ -255,6 +255,7 @@ + * @stable ICU 3.8 + */ + virtual UBool operator!=(const TimeZoneRule& that) const; ++ UBool operator!=(const InitialTimeZoneRule& that) const {return !operator==(that);} + + /** + * Gets the time when this rule takes effect in the given year. +@@ -456,7 +457,7 @@ + * @return true if the given <code>TimeZoneRule</code> objects are semantically equal. + * @stable ICU 3.8 + */ +- virtual UBool operator==(const TimeZoneRule& that) const; ++ virtual bool operator==(const TimeZoneRule& that) const; + + /** + * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects +@@ -672,7 +673,7 @@ + * @return true if the given <code>TimeZoneRule</code> objects are semantically equal. + * @stable ICU 3.8 + */ +- virtual UBool operator==(const TimeZoneRule& that) const; ++ virtual bool operator==(const TimeZoneRule& that) const; + + /** + * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects +--- source/i18n/unicode/vtzone.h ++++ source/i18n/unicode/vtzone.h +@@ -81,6 +81,7 @@ + * @stable ICU 3.8 + */ + virtual UBool operator!=(const TimeZone& that) const; ++ UBool operator!=(const VTimeZone& that) const {return !operator==(that);} + + /** + * Create a <code>VTimeZone</code> instance by the time zone ID. |