From 4bb34584ad059e744cc490d04c6e6e9bcf11676e Mon Sep 17 00:00:00 2001 From: William Zhao <39807811+mingyzha@users.noreply.github.com> Date: Fri, 22 Sep 2017 18:00:51 +0000 Subject: [PATCH] ICU-13275 Merge into some W3 warning fixes into trunk X-SVN-Rev: 40446 --- icu4c/source/common/dictbe.cpp | 2 +- icu4c/source/common/locdispnames.cpp | 6 ++-- icu4c/source/common/locdspnm.cpp | 2 +- icu4c/source/i18n/collationdatawriter.cpp | 2 +- .../source/i18n/collationfastlatinbuilder.cpp | 2 +- icu4c/source/i18n/datefmt.cpp | 2 +- icu4c/source/i18n/decNumber.cpp | 28 +++++++++---------- icu4c/source/i18n/decimfmt.cpp | 4 +-- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/icu4c/source/common/dictbe.cpp b/icu4c/source/common/dictbe.cpp index dc9d348ef8f..9da0d236072 100644 --- a/icu4c/source/common/dictbe.cpp +++ b/icu4c/source/common/dictbe.cpp @@ -1088,7 +1088,7 @@ static inline uint32_t getKatakanaCost(int32_t wordLength){ return (wordLength > kMaxKatakanaLength) ? 8192 : katakanaCost[wordLength]; } -static inline bool isKatakana(uint16_t value) { +static inline bool isKatakana(UChar32 value) { return (value >= 0x30A1u && value <= 0x30FEu && value != 0x30FBu) || (value >= 0xFF66u && value <= 0xFF9fu); } diff --git a/icu4c/source/common/locdispnames.cpp b/icu4c/source/common/locdispnames.cpp index 1aa3ca70822..95750e44006 100644 --- a/icu4c/source/common/locdispnames.cpp +++ b/icu4c/source/common/locdispnames.cpp @@ -542,7 +542,7 @@ uloc_getDisplayName(const char *locale, return 0; } separator = (const UChar *)p0 + subLen; - sepLen = p1 - separator; + sepLen = static_cast(p1 - separator); } if(patLen==0 || (patLen==defaultPatLen && !u_strncmp(pattern, defaultPattern, patLen))) { @@ -558,8 +558,8 @@ uloc_getDisplayName(const char *locale, *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; } - sub0Pos=p0-pattern; - sub1Pos=p1-pattern; + sub0Pos = static_cast(p0-pattern); + sub1Pos = static_cast(p1-pattern); if (sub1Pos < sub0Pos) { /* a very odd pattern */ int32_t t=sub0Pos; sub0Pos=sub1Pos; sub1Pos=t; langi=1; diff --git a/icu4c/source/common/locdspnm.cpp b/icu4c/source/common/locdspnm.cpp index 39934dc6c33..b034a278a42 100644 --- a/icu4c/source/common/locdspnm.cpp +++ b/icu4c/source/common/locdspnm.cpp @@ -54,7 +54,7 @@ static int32_t ncat(char *buffer, uint32_t buflen, ...) { *p = 0; va_end(args); - return p - buffer; + return static_cast(p - buffer); } U_NAMESPACE_BEGIN diff --git a/icu4c/source/i18n/collationdatawriter.cpp b/icu4c/source/i18n/collationdatawriter.cpp index a91119d8dfa..823c8eb0111 100644 --- a/icu4c/source/i18n/collationdatawriter.cpp +++ b/icu4c/source/i18n/collationdatawriter.cpp @@ -224,7 +224,7 @@ CollationDataWriter::write(UBool isBase, const UVersionInfo dataVersion, int32_t totalSize = indexesLength * 4; if(hasMappings && (isBase || data.jamoCE32s != baseData->jamoCE32s)) { - indexes[CollationDataReader::IX_JAMO_CE32S_START] = data.jamoCE32s - data.ce32s; + indexes[CollationDataReader::IX_JAMO_CE32S_START] = static_cast(data.jamoCE32s - data.ce32s); } else { indexes[CollationDataReader::IX_JAMO_CE32S_START] = -1; } diff --git a/icu4c/source/i18n/collationfastlatinbuilder.cpp b/icu4c/source/i18n/collationfastlatinbuilder.cpp index e889697d8a5..e5ba2f0e21d 100644 --- a/icu4c/source/i18n/collationfastlatinbuilder.cpp +++ b/icu4c/source/i18n/collationfastlatinbuilder.cpp @@ -607,7 +607,7 @@ CollationFastLatinBuilder::encodeContractions(UErrorCode &errorCode) { } UBool firstTriple = TRUE; for(int32_t index = (int32_t)ce & 0x7fffffff;; index += 3) { - int32_t x = contractionCEs.elementAti(index); + int32_t x = static_cast(contractionCEs.elementAti(index)); if((uint32_t)x == CollationFastLatin::CONTR_CHAR_MASK && !firstTriple) { break; } int64_t cce0 = contractionCEs.elementAti(index + 1); int64_t cce1 = contractionCEs.elementAti(index + 2); diff --git a/icu4c/source/i18n/datefmt.cpp b/icu4c/source/i18n/datefmt.cpp index f6a0d892388..e8641f43200 100644 --- a/icu4c/source/i18n/datefmt.cpp +++ b/icu4c/source/i18n/datefmt.cpp @@ -739,7 +739,7 @@ DateFormat::setBooleanAttribute(UDateFormatBooleanAttribute attr, UBool DateFormat::getBooleanAttribute(UDateFormatBooleanAttribute attr, UErrorCode &/*status*/) const { - return fBoolFlags.get(attr); + return static_cast(fBoolFlags.get(attr)); } U_NAMESPACE_END diff --git a/icu4c/source/i18n/decNumber.cpp b/icu4c/source/i18n/decNumber.cpp index 969ea8f709f..149062e0921 100644 --- a/icu4c/source/i18n/decNumber.cpp +++ b/icu4c/source/i18n/decNumber.cpp @@ -386,7 +386,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFromUInt32(decNumber *dn, uInt uin) { *up=(Unit)(uin%(DECDPUNMAX+1)); uin=uin/(DECDPUNMAX+1); } - dn->digits=decGetDigits(dn->lsu, up-dn->lsu); + dn->digits=decGetDigits(dn->lsu, static_cast(up - dn->lsu)); return dn; } /* decNumberFromUInt32 */ @@ -666,7 +666,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFromString(decNumber *dn, const char /* Handle decimal point... */ if (dotchar!=NULL && dotchar(last-dotchar); /* adjust exponent */ /* [we can now ignore the .] */ /* OK, the digits string is good. Assemble in the decNumber, or in */ @@ -866,7 +866,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberAnd(decNumber *res, const decNumber * } /* both OK */ } /* each unit */ /* [here uc-1 is the msu of the result] */ - res->digits=decGetDigits(res->lsu, uc-res->lsu); + res->digits=decGetDigits(res->lsu, static_cast(uc - res->lsu)); res->exponent=0; /* integer */ res->bits=0; /* sign=0 */ return res; /* [no status to set] */ @@ -1253,7 +1253,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberInvert(decNumber *res, const decNumbe } /* each digit */ } /* each unit */ /* [here uc-1 is the msu of the result] */ - res->digits=decGetDigits(res->lsu, uc-res->lsu); + res->digits=decGetDigits(res->lsu, static_cast(uc - res->lsu)); res->exponent=0; /* integer */ res->bits=0; /* sign=0 */ return res; /* [no status to set] */ @@ -1880,7 +1880,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberOr(decNumber *res, const decNumber *l } /* non-zero */ } /* each unit */ /* [here uc-1 is the msu of the result] */ - res->digits=decGetDigits(res->lsu, uc-res->lsu); + res->digits=decGetDigits(res->lsu, static_cast(uc-res->lsu)); res->exponent=0; /* integer */ res->bits=0; /* sign=0 */ return res; /* [no status to set] */ @@ -2586,7 +2586,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberRotate(decNumber *res, const decNumbe } /* whole units to rotate */ /* the rotation may have left an undetermined number of zeros */ /* on the left, so true length needs to be calculated */ - res->digits=decGetDigits(res->lsu, msumax-res->lsu+1); + res->digits=decGetDigits(res->lsu, static_cast(msumax-res->lsu+1)); } /* rotate needed */ } /* rhs OK */ } /* numerics */ @@ -3310,7 +3310,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberXor(decNumber *res, const decNumber * } /* non-zero */ } /* each unit */ /* [here uc-1 is the msu of the result] */ - res->digits=decGetDigits(res->lsu, uc-res->lsu); + res->digits=decGetDigits(res->lsu, static_cast(uc-res->lsu)); res->exponent=0; /* integer */ res->bits=0; /* sign=0 */ return res; /* [no status to set] */ @@ -5101,7 +5101,7 @@ static decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs, } /* p */ *up=(Unit)item; up++; /* [final needs no division] */ } /* lp */ - accunits=up-acc; /* count of units */ + accunits = static_cast(up-acc); /* count of units */ } else { /* here to use units directly, without chunking ['old code'] */ #endif @@ -6587,11 +6587,11 @@ static Int decUnitAddSub(const Unit *a, Int alength, /* OK, all A and B processed; might still have carry or borrow */ /* return number of Units in the result, negated if a borrow */ - if (carry==0) return c-clsu; /* no carry, so no more to do */ + if (carry==0) return static_cast(c-clsu); /* no carry, so no more to do */ if (carry>0) { /* positive carry */ *c=(Unit)carry; /* place as new unit */ c++; /* .. */ - return c-clsu; + return static_cast(c-clsu); } /* -ve carry: it's a borrow; complement needed */ add=1; /* temporary carry... */ @@ -6614,7 +6614,7 @@ static Int decUnitAddSub(const Unit *a, Int alength, *c=(Unit)(add-carry-1); c++; /* interesting, include it */ } - return clsu-c; /* -ve result indicates borrowed */ + return static_cast(clsu-c); /* -ve result indicates borrowed */ } /* decUnitAddSub */ /* ------------------------------------------------------------------ */ @@ -6798,7 +6798,7 @@ static Int decShiftToLeast(Unit *uar, Int units, Int shift) { if (cut==DECDPUN) { /* unit-boundary case; easy */ up=uar+D2U(shift); for (; up(target-uar); } /* messier */ @@ -6826,7 +6826,7 @@ static Int decShiftToLeast(Unit *uar, Int units, Int shift) { count-=cut; if (count<=0) break; } - return target-uar+1; + return static_cast(target-uar+1); } /* decShiftToLeast */ #if DECSUBSET @@ -7690,7 +7690,7 @@ static decNumber *decDecap(decNumber *dn, Int drop) { cut=MSUDIGITS(dn->digits-drop); /* digits to be in use in msu */ if (cut!=DECDPUN) *msu%=powers[cut]; /* clear left digits */ /* that may have left leading zero digits, so do a proper count... */ - dn->digits=decGetDigits(dn->lsu, msu-dn->lsu+1); + dn->digits=decGetDigits(dn->lsu, static_cast(msu-dn->lsu+1)); return dn; } /* decDecap */ diff --git a/icu4c/source/i18n/decimfmt.cpp b/icu4c/source/i18n/decimfmt.cpp index 613c2ddf567..2a8a226c77e 100644 --- a/icu4c/source/i18n/decimfmt.cpp +++ b/icu4c/source/i18n/decimfmt.cpp @@ -2543,7 +2543,7 @@ UnicodeString DecimalFormat::getPadCharacterString() const { } void DecimalFormat::setPadCharacter(const UnicodeString &padChar) { - UChar pad; + UChar32 pad; if (padChar.length() > 0) { pad = padChar.char32At(0); } @@ -2792,7 +2792,7 @@ DecimalFormat::setDecimalSeparatorAlwaysShown(UBool newValue) UBool DecimalFormat::isDecimalPatternMatchRequired(void) const { - return fBoolFlags.contains(UNUM_PARSE_DECIMAL_MARK_REQUIRED); + return static_cast(fBoolFlags.contains(UNUM_PARSE_DECIMAL_MARK_REQUIRED)); } //------------------------------------------------------------------------------