From: Steven R. Loomis Date: Wed, 18 Sep 2013 20:08:25 +0000 (+0000) Subject: ICU-10376 fixup clang warnings X-Git-Tag: milestone-59-0-1~2484 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=358e1ddcd216d5525efd2d4ec0261a58bb149ae6;p=icu ICU-10376 fixup clang warnings X-SVN-Rev: 34385 --- diff --git a/icu4c/source/common/ubidi.c b/icu4c/source/common/ubidi.c index 33d9c51f987..2ba416c08d5 100644 --- a/icu4c/source/common/ubidi.c +++ b/icu4c/source/common/ubidi.c @@ -634,10 +634,10 @@ getDirProps(UBiDi *pBiDi) { /* determine the paragraph level at position index */ U_CFUNC UBiDiLevel -ubidi_getParaLevelAtIndex(const UBiDi *pBiDi, int32_t index) { +ubidi_getParaLevelAtIndex(const UBiDi *pBiDi, int32_t pindex) { int32_t i; for(i=0; iparaCount; i++) - if(indexparas[i].limit) + if(pindexparas[i].limit) break; if(i>=pBiDi->paraCount) i=pBiDi->paraCount-1; diff --git a/icu4c/source/configure b/icu4c/source/configure index 654de7d042c..340ad6fa39e 100755 --- a/icu4c/source/configure +++ b/icu4c/source/configure @@ -7443,13 +7443,13 @@ fi # for build. if test "${CC}" == "clang"; then - CLANGCFLAGS="-Qunused-arguments" + CLANGCFLAGS="-Qunused-arguments -Wno-parentheses-equality" else CLANGCFLAGS="" fi if test "${CXX}" == "clang++"; then - CLANGCXXFLAGS="-Qunused-arguments" + CLANGCXXFLAGS="-Qunused-arguments -Wno-parentheses-equality" else CLANGCXXFLAGS="" fi diff --git a/icu4c/source/configure.ac b/icu4c/source/configure.ac index f3c1e19fbfd..f56b533b453 100644 --- a/icu4c/source/configure.ac +++ b/icu4c/source/configure.ac @@ -1250,13 +1250,13 @@ fi # for build. if test "${CC}" == "clang"; then - CLANGCFLAGS="-Qunused-arguments" + CLANGCFLAGS="-Qunused-arguments -Wno-parentheses-equality" else CLANGCFLAGS="" fi if test "${CXX}" == "clang++"; then - CLANGCXXFLAGS="-Qunused-arguments" + CLANGCXXFLAGS="-Qunused-arguments -Wno-parentheses-equality" else CLANGCXXFLAGS="" fi diff --git a/icu4c/source/i18n/csrsbcs.cpp b/icu4c/source/i18n/csrsbcs.cpp index 80d21149280..d03367cc4ee 100644 --- a/icu4c/source/i18n/csrsbcs.cpp +++ b/icu4c/source/i18n/csrsbcs.cpp @@ -20,7 +20,7 @@ U_NAMESPACE_BEGIN NGramParser::NGramParser(const int32_t *theNgramList, const uint8_t *theCharMap) - :byteIndex(0), ngram(0) + : ngram(0), byteIndex(0) { ngramList = theNgramList; charMap = theCharMap; diff --git a/icu4c/source/i18n/datefmt.cpp b/icu4c/source/i18n/datefmt.cpp index bc34dae813d..1caeac907b9 100644 --- a/icu4c/source/i18n/datefmt.cpp +++ b/icu4c/source/i18n/datefmt.cpp @@ -530,7 +530,7 @@ DateFormat::setBooleanAttribute(UDateFormatBooleanAttribute attr, //---------------------------------------------------------------------- UBool -DateFormat::getBooleanAttribute(UDateFormatBooleanAttribute attr, UErrorCode &status) const { +DateFormat::getBooleanAttribute(UDateFormatBooleanAttribute attr, UErrorCode &/*status*/) const { return fBoolFlags.get(attr); } diff --git a/icu4c/source/i18n/islamcal.cpp b/icu4c/source/i18n/islamcal.cpp index 59de71335fa..c5a4838f869 100644 --- a/icu4c/source/i18n/islamcal.cpp +++ b/icu4c/source/i18n/islamcal.cpp @@ -23,6 +23,7 @@ #include "astro.h" // CalendarAstronomer #include "uhash.h" #include "ucln_in.h" +#include "uassert.h" static const UDate HIJRA_MILLIS = -42521587200000.0; // 7/16/622 AD 00:00 @@ -84,9 +85,12 @@ const char *IslamicCalendar::getType() const { return "islamic"; } else if(civil==TBLA){ return "islamic-tbla"; + } else if(civil==UMALQURA){ + return "islamic-umalqura"; } else { - return "islamic-umalqura"; - } + U_ASSERT(false); // out of range + return "islamic-unknown"; + } } Calendar* IslamicCalendar::clone() const { @@ -459,7 +463,7 @@ void IslamicCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status) year = months / 12 + 1; month = months % 12; - } else if(civil == UMALQURA){ + } else if(civil == UMALQURA) { int32_t umalquraStartdays = yearStart(UMALQURA_YEAR_START) ; if( days < umalquraStartdays){ //Use Civil calculation @@ -490,7 +494,10 @@ void IslamicCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status) year = y; month = m; } - } + } else { // invalid 'civil' + U_ASSERT(false); // should not get here, out of range + year=month=0; + } dayOfMonth = (days - monthStart(year, month)) + 1; diff --git a/icu4c/source/i18n/islamcal.h b/icu4c/source/i18n/islamcal.h index b37e8169cb2..35785606833 100644 --- a/icu4c/source/i18n/islamcal.h +++ b/icu4c/source/i18n/islamcal.h @@ -94,7 +94,7 @@ class U_I18N_API IslamicCalendar : public Calendar { enum ECivil { ASTRONOMICAL, CIVIL, - UMALQURA, + UMALQURA, TBLA }; @@ -452,7 +452,7 @@ class U_I18N_API IslamicCalendar : public Calendar { static const int32_t ASTRONOMICAL_EPOC = 1948439; - static const int getUmalqura_MonthLength(int i, int j){ + static int getUmalqura_MonthLength(int i, int j){ static const int UMALQURA_MONTHLENGTH[] = { //* 1318 -1322 */ "0101 0111 0100", "1001 0111 0110", "0100 1011 0111", "0010 0101 0111", "0101 0010 1011", diff --git a/icu4c/source/i18n/numfmt.cpp b/icu4c/source/i18n/numfmt.cpp index f1dcdb93d59..da09207e87d 100644 --- a/icu4c/source/i18n/numfmt.cpp +++ b/icu4c/source/i18n/numfmt.cpp @@ -457,7 +457,7 @@ class ArgExtractor { const Formattable* number(void) const; const UChar *iso(void) const; - const UBool wasCurrency(void) const; + UBool wasCurrency(void) const; }; inline const Formattable* @@ -465,7 +465,7 @@ ArgExtractor::number(void) const { return num; } -inline const UBool +inline UBool ArgExtractor::wasCurrency(void) const { return fWasCurrency; } @@ -475,7 +475,7 @@ ArgExtractor::iso(void) const { return save; } -ArgExtractor::ArgExtractor(const NumberFormat& nf, const Formattable& obj, UErrorCode& /*status*/) +ArgExtractor::ArgExtractor(const NumberFormat& /*nf*/, const Formattable& obj, UErrorCode& /*status*/) : num(&obj), fWasCurrency(FALSE) { const UObject* o = obj.getObject(); // most commonly o==NULL diff --git a/icu4c/source/i18n/timezone.cpp b/icu4c/source/i18n/timezone.cpp index 0e37d19b38b..e656a7a8b90 100644 --- a/icu4c/source/i18n/timezone.cpp +++ b/icu4c/source/i18n/timezone.cpp @@ -1617,7 +1617,7 @@ TimeZone::getIDForWindowsID(const UnicodeString& winid, const char* region, Unic char winidKey[MAX_WINDOWS_ID_SIZE]; int32_t winKeyLen = winid.extract(0, winid.length(), winidKey, sizeof(winidKey) - 1, US_INV); - if (winKeyLen == 0 || winKeyLen >= sizeof(winidKey)) { + if (winKeyLen == 0 || winKeyLen >= (int32_t)sizeof(winidKey)) { ures_close(zones); return id; } @@ -1634,7 +1634,6 @@ TimeZone::getIDForWindowsID(const UnicodeString& winid, const char* region, Unic int32_t len = 0; UBool gotID = FALSE; if (region) { - int32_t tzidsLen = 0; const UChar *tzids = ures_getStringByKey(zones, region, &len, &tmperr); // use tmperr, because // regional mapping is optional if (U_SUCCESS(tmperr)) { diff --git a/icu4c/source/i18n/tzfmt.cpp b/icu4c/source/i18n/tzfmt.cpp index 3b787627e33..a2e8a5936a6 100644 --- a/icu4c/source/i18n/tzfmt.cpp +++ b/icu4c/source/i18n/tzfmt.cpp @@ -743,6 +743,10 @@ TimeZoneFormat::format(UTimeZoneFormatStyle style, const TimeZone& tz, UDate dat case UTZFMT_STYLE_ISO_EXTENDED_LOCAL_FULL: formatOffsetISO8601Extended(offset, FALSE, FALSE, FALSE, name, status); break; + + default: + // UTZFMT_STYLE_ZONE_ID, UTZFMT_STYLE_ZONE_ID_SHORT, UTZFMT_STYLE_EXEMPLAR_LOCATION + break; } if (timeType) { diff --git a/icu4c/source/layout/LETypes.h b/icu4c/source/layout/LETypes.h index 7b4b162e497..21e41ddbe21 100644 --- a/icu4c/source/layout/LETypes.h +++ b/icu4c/source/layout/LETypes.h @@ -302,7 +302,7 @@ typedef struct LEPoint LEPoint; /** * Range check for overflow */ -#define LE_RANGE_CHECK(type, count, ptrfn) (( (LE_UINTPTR_MAX / sizeof(type)) < count ) ? NULL : (ptrfn)) +#define LE_RANGE_CHECK(type, count, ptrfn) (( (LE_UINTPTR_MAX / sizeof(type)) < (size_t)count ) ? NULL : (ptrfn)) /** * A convenience macro to get the length of an array. * diff --git a/icu4c/source/layout/LigatureSubstProc.cpp b/icu4c/source/layout/LigatureSubstProc.cpp index 3c7958ea831..53f6f5a34f6 100644 --- a/icu4c/source/layout/LigatureSubstProc.cpp +++ b/icu4c/source/layout/LigatureSubstProc.cpp @@ -90,7 +90,7 @@ ByteOffset LigatureSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyp LE_DEBUG_BAD_FONT("off end of ligature substitution header"); return newState; // get out! bad font } - if(componentGlyph > glyphStorage.getGlyphCount()) { + if(componentGlyph > (le_uint32)glyphStorage.getGlyphCount()) { LE_DEBUG_BAD_FONT("preposterous componentGlyph"); currGlyph++; return newState; // get out! bad font diff --git a/icu4c/source/test/cintltst/creststn.c b/icu4c/source/test/cintltst/creststn.c index 8444da45a04..26cb7567837 100644 --- a/icu4c/source/test/cintltst/creststn.c +++ b/icu4c/source/test/cintltst/creststn.c @@ -2005,7 +2005,6 @@ static void TestPreventFallback() { UResourceBundle* theBundle = NULL; const char* testdatapath; UErrorCode status = U_ZERO_ERROR; - UResourceBundle* res = NULL; int32_t unused_len = 0; testdatapath=loadTestData(&status); diff --git a/icu4c/source/test/intltest/caltest.cpp b/icu4c/source/test/intltest/caltest.cpp index 30f98e8c73d..1becfc4868c 100644 --- a/icu4c/source/test/intltest/caltest.cpp +++ b/icu4c/source/test/intltest/caltest.cpp @@ -2802,11 +2802,10 @@ void CalendarTest::Test8449() { tstCal->roll(UCAL_DAY_OF_MONTH, (UBool)TRUE, status); TEST_CHECK_STATUS; } - + if(day != (initDay + loopCnt - 1) || month != IslamicCalendar::RABI_2 || year != 1434) - errln("invalid values for RABI_2 date after roll of " + loopCnt); - - + errln("invalid values for RABI_2 date after roll of %d", loopCnt); + status = U_ZERO_ERROR; tstCal->clear(); initMonth = 2; diff --git a/icu4c/source/test/intltest/csdetest.cpp b/icu4c/source/test/intltest/csdetest.cpp index 62b4eacb2b8..9776e9b10ae 100644 --- a/icu4c/source/test/intltest/csdetest.cpp +++ b/icu4c/source/test/intltest/csdetest.cpp @@ -285,13 +285,13 @@ void CharsetDetectionTest::ConstructionTest() LocalUEnumerationPointer eActive(ucsdet_getDetectableCharsets(csd.getAlias(), status)); const char *activeName = NULL; - while (activeName = uenum_next(eActive.getAlias(), NULL, status)) { + while ((activeName = uenum_next(eActive.getAlias(), NULL, status))) { // the charset must be included in all list UBool found = FALSE; const char *name = NULL; uenum_reset(e.getAlias(), status); - while (name = uenum_next(e.getAlias(), NULL, status)) { + while ((name = uenum_next(e.getAlias(), NULL, status))) { if (strcmp(activeName, name) == 0) { found = TRUE; break; diff --git a/icu4c/source/test/intltest/dtfmttst.cpp b/icu4c/source/test/intltest/dtfmttst.cpp index 6e44fa726ef..cb63ee08518 100644 --- a/icu4c/source/test/intltest/dtfmttst.cpp +++ b/icu4c/source/test/intltest/dtfmttst.cpp @@ -4232,15 +4232,16 @@ void DateFormatTest::TestDateFormatLeniency() { SimpleDateFormat * sdmft = new SimpleDateFormat(itemPtr->pattern, locale, status); sdmft->setLenient(itemPtr->leniency); sdmft->setBooleanAttribute(UDAT_PARSE_ALLOW_WHITESPACE, itemPtr->leniency, status).setBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, itemPtr->leniency, status); - UDate d = sdmft->parse(itemPtr->parseString, pos); - + /*UDate d = */sdmft->parse(itemPtr->parseString, pos); + delete sdmft; if(pos.getErrorIndex() > -1) if(itemPtr->expectedResult.length() != 0) { - errln("error: unexpected error - " + itemPtr->parseString + " - error index " + pos.getErrorIndex() + " - leniency " + itemPtr->leniency); - continue; - } else - continue; + errln("error: unexpected error - " + itemPtr->parseString + " - error index " + pos.getErrorIndex() + " - leniency " + itemPtr->leniency); + continue; + } else { + continue; + } } } delete cal; diff --git a/icu4c/source/test/intltest/tsmthred.cpp b/icu4c/source/test/intltest/tsmthred.cpp index efd899ee047..a65e9b91437 100644 --- a/icu4c/source/test/intltest/tsmthred.cpp +++ b/icu4c/source/test/intltest/tsmthred.cpp @@ -727,7 +727,7 @@ void ThreadSafeFormat::init(UErrorCode &status) { gFormat->format(gBBDThing, gBBDStr, NULL, status); } -void ThreadSafeFormat::fini(UErrorCode &status) { +void ThreadSafeFormat::fini(UErrorCode &/*status*/) { gFormat.adoptInstead(NULL); }