From a9c247a3cb3ba86c12c7bad0fae1db8c9a5df13f Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Tue, 1 Mar 2016 07:44:57 +0000 Subject: [PATCH] ICU-12166 annotate intended switch case fallthroughs X-SVN-Rev: 38447 --- icu4c/source/common/locdispnames.cpp | 4 +- icu4c/source/common/ucnv2022.cpp | 12 ++--- icu4c/source/common/ucnv_ext.cpp | 9 ++-- icu4c/source/common/ucnv_lmb.c | 12 +++-- icu4c/source/common/ucnv_u8.c | 14 ++++-- icu4c/source/common/ucnvbocu.cpp | 41 ++++++++++----- icu4c/source/common/ucnvisci.c | 4 +- icu4c/source/common/ucnvmbcs.cpp | 43 +++++++++++----- icu4c/source/common/ucnvscsu.c | 66 +++++++++++++++++-------- icu4c/source/common/unicode/platform.h | 23 ++++++++- icu4c/source/common/unistr.cpp | 4 +- icu4c/source/common/uresbund.cpp | 5 +- icu4c/source/common/uresdata.cpp | 3 +- icu4c/source/common/ustrtrns.cpp | 14 ++++-- icu4c/source/common/util_props.cpp | 3 +- icu4c/source/i18n/calendar.cpp | 4 +- icu4c/source/i18n/fmtable.cpp | 13 +++-- icu4c/source/i18n/gregocal.cpp | 3 +- icu4c/source/i18n/plurrule.cpp | 1 + icu4c/source/i18n/regexcmp.cpp | 2 + icu4c/source/i18n/smpdtfmt.cpp | 10 ++-- icu4c/source/i18n/ucoleitr.cpp | 6 +-- icu4c/source/io/uprntf_p.c | 2 + icu4c/source/io/uscanf_p.c | 2 +- icu4c/source/test/intltest/colldata.cpp | 6 +-- icu4c/source/test/intltest/intltest.cpp | 7 +++ icu4c/source/test/intltest/ssearch.cpp | 6 +-- icu4c/source/test/intltest/transrt.cpp | 3 +- icu4c/source/tools/genrb/derb.cpp | 4 +- icu4c/source/tools/makeconv/genmbcs.cpp | 6 ++- 30 files changed, 226 insertions(+), 106 deletions(-) diff --git a/icu4c/source/common/locdispnames.cpp b/icu4c/source/common/locdispnames.cpp index 3ea9602d055..ff52b10b292 100644 --- a/icu4c/source/common/locdispnames.cpp +++ b/icu4c/source/common/locdispnames.cpp @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 1997-2013, International Business Machines +* Copyright (C) 1997-2016, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -638,7 +638,7 @@ uloc_getDisplayName(const char *locale, break; case 3: kenum = uloc_openKeywords(locale, pErrorCode); - /* fall through */ + U_FALLTHROUGH; default: { const char* kw=uenum_next(kenum, &len, pErrorCode); if (kw == NULL) { diff --git a/icu4c/source/common/ucnv2022.cpp b/icu4c/source/common/ucnv2022.cpp index 6d50ae8f083..7d4815dcb21 100644 --- a/icu4c/source/common/ucnv2022.cpp +++ b/icu4c/source/common/ucnv2022.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 2000-2015, International Business Machines +* Copyright (C) 2000-2016, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * file name: ucnv2022.cpp @@ -971,9 +971,9 @@ DONE: *err = U_UNSUPPORTED_ESCAPE_SEQUENCE; break; } - /*fall through*/ + U_FALLTHROUGH; case GB2312_1: - /*fall through*/ + U_FALLTHROUGH; case CNS_11643_1: myData2022->toU2022State.cs[1]=(int8_t)tempState; break; @@ -2160,7 +2160,6 @@ escape: /* ISO-2022-JP does not use single-byte (C1) SS2 and SS3 */ case CR: - /*falls through*/ case LF: /* automatically reset to single-byte mode */ if((StateEnum)pToU2022State->cs[0] != ASCII && (StateEnum)pToU2022State->cs[0] != JISX201) { @@ -2168,7 +2167,7 @@ escape: } pToU2022State->cs[2] = 0; pToU2022State->g = 0; - /* falls through */ + U_FALLTHROUGH; default: /* convert one or two bytes */ myData->isEmptySegment = FALSE; @@ -3343,10 +3342,9 @@ escape: /* ISO-2022-CN does not use single-byte (C1) SS2 and SS3 */ case CR: - /*falls through*/ case LF: uprv_memset(pToU2022State, 0, sizeof(ISO2022State)); - /* falls through */ + U_FALLTHROUGH; default: /* convert one or two bytes */ myData->isEmptySegment = FALSE; diff --git a/icu4c/source/common/ucnv_ext.cpp b/icu4c/source/common/ucnv_ext.cpp index 5cd1ab61747..0c43693b357 100644 --- a/icu4c/source/common/ucnv_ext.cpp +++ b/icu4c/source/common/ucnv_ext.cpp @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 2003-2013, International Business Machines +* Copyright (C) 2003-2016, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -690,10 +690,13 @@ ucnv_extWriteFromU(UConverter *cnv, const int32_t *cx, switch(length) { case 3: *p++=(uint8_t)(value>>16); - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: *p++=(uint8_t)(value>>8); - case 1: /*fall through*/ + U_FALLTHROUGH; + case 1: *p++=(uint8_t)value; + U_FALLTHROUGH; default: break; /* will never occur */ } diff --git a/icu4c/source/common/ucnv_lmb.c b/icu4c/source/common/ucnv_lmb.c index 01d0aa15469..aa88488dfb8 100644 --- a/icu4c/source/common/ucnv_lmb.c +++ b/icu4c/source/common/ucnv_lmb.c @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 2000-2015, International Business Machines +* Copyright (C) 2000-2016, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * file name: ucnv_lmb.cpp @@ -793,12 +793,16 @@ LMBCSConversionWorker ( { case 4: *pLMBCS++ = (ulmbcs_byte_t)(value >> 24); - case 3: /*fall through*/ + U_FALLTHROUGH; + case 3: *pLMBCS++ = (ulmbcs_byte_t)(value >> 16); - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: *pLMBCS++ = (ulmbcs_byte_t)(value >> 8); - case 1: /*fall through*/ + U_FALLTHROUGH; + case 1: *pLMBCS++ = (ulmbcs_byte_t)value; + U_FALLTHROUGH; default: /* will never occur */ break; diff --git a/icu4c/source/common/ucnv_u8.c b/icu4c/source/common/ucnv_u8.c index b78587339a3..499288c2edf 100644 --- a/icu4c/source/common/ucnv_u8.c +++ b/icu4c/source/common/ucnv_u8.c @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 2002-2015, International Business Machines +* Copyright (C) 2002-2016, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * file name: ucnv_u8.c @@ -680,7 +680,8 @@ static UChar32 ucnv_getNextUChar_UTF8(UConverterToUnicodeArgs *args, break; } ++source; - case 5: /*fall through*/ + U_FALLTHROUGH; + case 5: ch += (myByte = *source); ch <<= 6; if (!U8_IS_TRAIL(myByte)) @@ -689,7 +690,8 @@ static UChar32 ucnv_getNextUChar_UTF8(UConverterToUnicodeArgs *args, break; } ++source; - case 4: /*fall through*/ + U_FALLTHROUGH; + case 4: ch += (myByte = *source); ch <<= 6; if (!U8_IS_TRAIL(myByte)) @@ -698,7 +700,8 @@ static UChar32 ucnv_getNextUChar_UTF8(UConverterToUnicodeArgs *args, break; } ++source; - case 3: /*fall through*/ + U_FALLTHROUGH; + case 3: ch += (myByte = *source); ch <<= 6; if (!U8_IS_TRAIL(myByte)) @@ -707,7 +710,8 @@ static UChar32 ucnv_getNextUChar_UTF8(UConverterToUnicodeArgs *args, break; } ++source; - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: ch += (myByte = *source); if (!U8_IS_TRAIL(myByte)) { diff --git a/icu4c/source/common/ucnvbocu.cpp b/icu4c/source/common/ucnvbocu.cpp index 6b0552e5f85..2b97c02c318 100644 --- a/icu4c/source/common/ucnvbocu.cpp +++ b/icu4c/source/common/ucnvbocu.cpp @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 2002-2015, International Business Machines +* Copyright (C) 2002-2016, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -549,15 +549,18 @@ getTrail: case 4: *target++=(uint8_t)(diff>>24); *offsets++=sourceIndex; - case 3: /*fall through*/ + U_FALLTHROUGH; + case 3: *target++=(uint8_t)(diff>>16); *offsets++=sourceIndex; - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: *target++=(uint8_t)(diff>>8); *offsets++=sourceIndex; /* case 1: handled above */ *target++=(uint8_t)diff; *offsets++=sourceIndex; + U_FALLTHROUGH; default: /* will never occur */ break; @@ -580,10 +583,13 @@ getTrail: /* each branch falls through to the next one */ case 3: *charErrorBuffer++=(uint8_t)(diff>>16); - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: *charErrorBuffer++=(uint8_t)(diff>>8); - case 1: /*fall through*/ + U_FALLTHROUGH; + case 1: *charErrorBuffer=(uint8_t)diff; + U_FALLTHROUGH; default: /* will never occur */ break; @@ -597,12 +603,15 @@ getTrail: case 3: *target++=(uint8_t)(diff>>16); *offsets++=sourceIndex; - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: *target++=(uint8_t)(diff>>8); *offsets++=sourceIndex; - case 1: /*fall through*/ + U_FALLTHROUGH; + case 1: *target++=(uint8_t)diff; *offsets++=sourceIndex; + U_FALLTHROUGH; default: /* will never occur */ break; @@ -777,12 +786,14 @@ getTrail: /* each branch falls through to the next one */ case 4: *target++=(uint8_t)(diff>>24); - case 3: /*fall through*/ + U_FALLTHROUGH; + case 3: *target++=(uint8_t)(diff>>16); /* case 2: handled above */ *target++=(uint8_t)(diff>>8); /* case 1: handled above */ *target++=(uint8_t)diff; + U_FALLTHROUGH; default: /* will never occur */ break; @@ -804,10 +815,13 @@ getTrail: /* each branch falls through to the next one */ case 3: *charErrorBuffer++=(uint8_t)(diff>>16); - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: *charErrorBuffer++=(uint8_t)(diff>>8); - case 1: /*fall through*/ + U_FALLTHROUGH; + case 1: *charErrorBuffer=(uint8_t)diff; + U_FALLTHROUGH; default: /* will never occur */ break; @@ -820,10 +834,13 @@ getTrail: /* each branch falls through to the next one */ case 3: *target++=(uint8_t)(diff>>16); - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: *target++=(uint8_t)(diff>>8); - case 1: /*fall through*/ + U_FALLTHROUGH; + case 1: *target++=(uint8_t)diff; + U_FALLTHROUGH; default: /* will never occur */ break; diff --git a/icu4c/source/common/ucnvisci.c b/icu4c/source/common/ucnvisci.c index 855a0abf32d..9b44ecf9cf3 100644 --- a/icu4c/source/common/ucnvisci.c +++ b/icu4c/source/common/ucnvisci.c @@ -1284,7 +1284,7 @@ static void UConverter_toUnicode_ISCII_OFFSETS_LOGIC(UConverterToUnicodeArgs *ar /* look at the pre-context and perform special processing */ switch (sourceChar) { case ISCII_INV: - case EXT: /*falls through*/ + case EXT: case ATR: *contextCharToUnicode = (UChar)sourceChar; @@ -1322,7 +1322,6 @@ static void UConverter_toUnicode_ISCII_OFFSETS_LOGIC(UConverterToUnicodeArgs *ar } break; case 0x0A: - /* fall through */ case 0x0D: data->resetToDefaultToUnicode = TRUE; GET_MAPPING(sourceChar,targetUniChar,data) @@ -1420,6 +1419,7 @@ static void UConverter_toUnicode_ISCII_OFFSETS_LOGIC(UConverterToUnicodeArgs *ar /* else fall through to default */ } /* else fall through to default */ + U_FALLTHROUGH; } default:GET_MAPPING(sourceChar,targetUniChar,data) ; diff --git a/icu4c/source/common/ucnvmbcs.cpp b/icu4c/source/common/ucnvmbcs.cpp index 4e4de8d2e9f..010b086e826 100644 --- a/icu4c/source/common/ucnvmbcs.cpp +++ b/icu4c/source/common/ucnvmbcs.cpp @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 2000-2015, International Business Machines +* Copyright (C) 2000-2016, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -963,11 +963,14 @@ ucnv_MBCSGetFilteredUnicodeSetForUnicode(const UConverterSharedData *sharedData, switch(st3Multiplier) { case 4: b|=*stage3++; - case 3: /*fall through*/ + U_FALLTHROUGH; + case 3: b|=*stage3++; - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: b|=stage3[0]|stage3[1]; stage3+=2; + U_FALLTHROUGH; default: break; } @@ -4634,12 +4637,16 @@ unassigned: /* each branch falls through to the next one */ case 4: *target++=(uint8_t)(value>>24); - case 3: /*fall through*/ + U_FALLTHROUGH; + case 3: *target++=(uint8_t)(value>>16); - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: *target++=(uint8_t)(value>>8); - case 1: /*fall through*/ + U_FALLTHROUGH; + case 1: *target++=(uint8_t)value; + U_FALLTHROUGH; default: /* will never occur */ break; @@ -4650,15 +4657,19 @@ unassigned: case 4: *target++=(uint8_t)(value>>24); *offsets++=sourceIndex; - case 3: /*fall through*/ + U_FALLTHROUGH; + case 3: *target++=(uint8_t)(value>>16); *offsets++=sourceIndex; - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: *target++=(uint8_t)(value>>8); *offsets++=sourceIndex; - case 1: /*fall through*/ + U_FALLTHROUGH; + case 1: *target++=(uint8_t)value; *offsets++=sourceIndex; + U_FALLTHROUGH; default: /* will never occur */ break; @@ -4681,10 +4692,13 @@ unassigned: /* each branch falls through to the next one */ case 3: *charErrorBuffer++=(uint8_t)(value>>16); - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: *charErrorBuffer++=(uint8_t)(value>>8); - case 1: /*fall through*/ + U_FALLTHROUGH; + case 1: *charErrorBuffer=(uint8_t)value; + U_FALLTHROUGH; default: /* will never occur */ break; @@ -4700,16 +4714,19 @@ unassigned: if(offsets!=NULL) { *offsets++=sourceIndex; } - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: *target++=(uint8_t)(value>>8); if(offsets!=NULL) { *offsets++=sourceIndex; } - case 1: /*fall through*/ + U_FALLTHROUGH; + case 1: *target++=(uint8_t)value; if(offsets!=NULL) { *offsets++=sourceIndex; } + U_FALLTHROUGH; default: /* will never occur */ break; diff --git a/icu4c/source/common/ucnvscsu.c b/icu4c/source/common/ucnvscsu.c index 1aacd810d76..15ed9c496ef 100644 --- a/icu4c/source/common/ucnvscsu.c +++ b/icu4c/source/common/ucnvscsu.c @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 2000-2015, International Business Machines +* Copyright (C) 2000-2016, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -1395,12 +1395,16 @@ outputBytes: /* each branch falls through to the next one */ case 4: *target++=(uint8_t)(c>>24); - case 3: /*fall through*/ + U_FALLTHROUGH; + case 3: *target++=(uint8_t)(c>>16); - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: *target++=(uint8_t)(c>>8); - case 1: /*fall through*/ + U_FALLTHROUGH; + case 1: *target++=(uint8_t)c; + U_FALLTHROUGH; default: /* will never occur */ break; @@ -1411,15 +1415,19 @@ outputBytes: case 4: *target++=(uint8_t)(c>>24); *offsets++=sourceIndex; - case 3: /*fall through*/ + U_FALLTHROUGH; + case 3: *target++=(uint8_t)(c>>16); *offsets++=sourceIndex; - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: *target++=(uint8_t)(c>>8); *offsets++=sourceIndex; - case 1: /*fall through*/ + U_FALLTHROUGH; + case 1: *target++=(uint8_t)c; *offsets++=sourceIndex; + U_FALLTHROUGH; default: /* will never occur */ break; @@ -1448,12 +1456,16 @@ outputBytes: /* each branch falls through to the next one */ case 4: *p++=(uint8_t)(c>>24); - case 3: /*fall through*/ + U_FALLTHROUGH; + case 3: *p++=(uint8_t)(c>>16); - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: *p++=(uint8_t)(c>>8); - case 1: /*fall through*/ + U_FALLTHROUGH; + case 1: *p=(uint8_t)c; + U_FALLTHROUGH; default: /* will never occur */ break; @@ -1469,16 +1481,19 @@ outputBytes: if(offsets!=NULL) { *offsets++=sourceIndex; } - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: *target++=(uint8_t)(c>>8); if(offsets!=NULL) { *offsets++=sourceIndex; } - case 1: /*fall through*/ + U_FALLTHROUGH; + case 1: *target++=(uint8_t)c; if(offsets!=NULL) { *offsets++=sourceIndex; } + U_FALLTHROUGH; default: break; } @@ -1853,12 +1868,16 @@ outputBytes: /* each branch falls through to the next one */ case 4: *target++=(uint8_t)(c>>24); - case 3: /*fall through*/ + U_FALLTHROUGH; + case 3: *target++=(uint8_t)(c>>16); - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: *target++=(uint8_t)(c>>8); - case 1: /*fall through*/ + U_FALLTHROUGH; + case 1: *target++=(uint8_t)c; + U_FALLTHROUGH; default: /* will never occur */ break; @@ -1885,12 +1904,16 @@ outputBytes: /* each branch falls through to the next one */ case 4: *p++=(uint8_t)(c>>24); - case 3: /*fall through*/ + U_FALLTHROUGH; + case 3: *p++=(uint8_t)(c>>16); - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: *p++=(uint8_t)(c>>8); - case 1: /*fall through*/ + U_FALLTHROUGH; + case 1: *p=(uint8_t)c; + U_FALLTHROUGH; default: /* will never occur */ break; @@ -1903,10 +1926,13 @@ outputBytes: /* each branch falls through to the next one */ case 3: *target++=(uint8_t)(c>>16); - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: *target++=(uint8_t)(c>>8); - case 1: /*fall through*/ + U_FALLTHROUGH; + case 1: *target++=(uint8_t)c; + U_FALLTHROUGH; default: break; } diff --git a/icu4c/source/common/unicode/platform.h b/icu4c/source/common/unicode/platform.h index 8eed735ac8f..5c3221d85e8 100644 --- a/icu4c/source/common/unicode/platform.h +++ b/icu4c/source/common/unicode/platform.h @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 1997-2015, International Business Machines +* Copyright (C) 1997-2016, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -428,10 +428,13 @@ # define U_HAVE_DEBUG_LOCATION_NEW 0 #endif -/* Compatibility with non clang compilers */ +/* Compatibility with non clang compilers: http://clang.llvm.org/docs/LanguageExtensions.html */ #ifndef __has_attribute # define __has_attribute(x) 0 #endif +#ifndef __has_cpp_attribute +# define __has_cpp_attribute(x) 0 +#endif #ifndef __has_builtin # define __has_builtin(x) 0 #endif @@ -441,6 +444,9 @@ #ifndef __has_extension # define __has_extension(x) 0 #endif +#ifndef __has_warning +# define __has_warning(x) 0 +#endif /** * \def U_MALLOC_ATTR @@ -521,6 +527,19 @@ # define U_NOEXCEPT #endif +/** + * \def U_FALLTHROUGH + * Annotate intentional fall-through between switch labels. + * http://clang.llvm.org/docs/AttributeReference.html#fallthrough-clang-fallthrough + * @internal + */ +#if __has_cpp_attribute(clang::fallthrough) || \ + (__has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")) +# define U_FALLTHROUGH [[clang::fallthrough]] +#else +# define U_FALLTHROUGH +#endif + /** @} */ /*===========================================================================*/ diff --git a/icu4c/source/common/unistr.cpp b/icu4c/source/common/unistr.cpp index f957c536e18..61b54fe06bc 100644 --- a/icu4c/source/common/unistr.cpp +++ b/icu4c/source/common/unistr.cpp @@ -1,6 +1,6 @@ /* ****************************************************************************** -* Copyright (C) 1999-2015, International Business Machines Corporation and +* Copyright (C) 1999-2016, International Business Machines Corporation and * others. All Rights Reserved. ****************************************************************************** * @@ -521,6 +521,7 @@ UnicodeString::copyFrom(const UnicodeString &src, UBool fastCopy) { } // else if(!fastCopy) fall through to case kWritableAlias // -> allocate a new buffer and copy the contents + U_FALLTHROUGH; case kWritableAlias: { // src is a writable alias; we make a copy of that instead int32_t srcLength = src.length(); @@ -530,6 +531,7 @@ UnicodeString::copyFrom(const UnicodeString &src, UBool fastCopy) { break; } // if there is not enough memory, then fall through to setting to bogus + U_FALLTHROUGH; } default: // if src is bogus, set ourselves to bogus diff --git a/icu4c/source/common/uresbund.cpp b/icu4c/source/common/uresbund.cpp index b2d071a09f9..62460f8e20d 100644 --- a/icu4c/source/common/uresbund.cpp +++ b/icu4c/source/common/uresbund.cpp @@ -1,6 +1,6 @@ /* ****************************************************************************** -* Copyright (C) 1997-2015, International Business Machines Corporation and +* Copyright (C) 1997-2016, International Business Machines Corporation and * others. All Rights Reserved. ****************************************************************************** * @@ -1485,7 +1485,8 @@ U_CAPI const UChar* U_EXPORT2 ures_getNextString(UResourceBundle *resB, int32_t* case URES_BINARY: case URES_INT_VECTOR: *status = U_RESOURCE_TYPE_MISMATCH; - default: /*fall through*/ + U_FALLTHROUGH; + default: return NULL; } } diff --git a/icu4c/source/common/uresdata.cpp b/icu4c/source/common/uresdata.cpp index fbfb56de6b5..d88053bd611 100644 --- a/icu4c/source/common/uresdata.cpp +++ b/icu4c/source/common/uresdata.cpp @@ -1,6 +1,6 @@ /* ******************************************************************************* -* Copyright (C) 1999-2015, International Business Machines Corporation +* Copyright (C) 1999-2016, International Business Machines Corporation * and others. All Rights Reserved. ******************************************************************************* * file name: uresdata.cpp @@ -1050,6 +1050,7 @@ ures_swapResource(const UDataSwapper *ds, switch(RES_GET_TYPE(res)) { case URES_ALIAS: /* physically same value layout as string, fall through */ + U_FALLTHROUGH; case URES_STRING: count=udata_readInt32(ds, (int32_t)*p); /* swap length */ diff --git a/icu4c/source/common/ustrtrns.cpp b/icu4c/source/common/ustrtrns.cpp index 5ec22f7a8aa..00a0bfd5eef 100644 --- a/icu4c/source/common/ustrtrns.cpp +++ b/icu4c/source/common/ustrtrns.cpp @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 2001-2014, International Business Machines +* Copyright (C) 2001-2016, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -291,7 +291,8 @@ utf8_nextCharSafeBodyTerminated(const uint8_t **ps, UChar32 c) { illegal=1; break; } - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: trail=(uint8_t)(*s++ - 0x80); if(trail>0x3f) { /* not a trail byte */ @@ -299,7 +300,8 @@ utf8_nextCharSafeBodyTerminated(const uint8_t **ps, UChar32 c) { break; } c=(c<<6)|trail; - case 1: /*fall through*/ + U_FALLTHROUGH; + case 1: trail=(uint8_t)(*s++ - 0x80); if(trail>0x3f) { /* not a trail byte */ @@ -362,11 +364,13 @@ utf8_nextCharSafeBodyPointer(const uint8_t **ps, const uint8_t *limit, UChar32 c illegal=1; break; } - case 2: /*fall through*/ + U_FALLTHROUGH; + case 2: trail=*s++; c=(c<<6)|(trail&0x3f); illegal|=(trail&0xc0)^0x80; - case 1: /*fall through*/ + U_FALLTHROUGH; + case 1: trail=*s++; c=(c<<6)|(trail&0x3f); illegal|=(trail&0xc0)^0x80; diff --git a/icu4c/source/common/util_props.cpp b/icu4c/source/common/util_props.cpp index 1bdaaddb71a..25a241825ad 100644 --- a/icu4c/source/common/util_props.cpp +++ b/icu4c/source/common/util_props.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (c) 2001-2011, International Business Machines +* Copyright (c) 2001-2016, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * Date Name Description @@ -101,6 +101,7 @@ int32_t ICU_Utility::parsePattern(const UnicodeString& rule, int32_t pos, int32_ return -1; } // FALL THROUGH to skipWhitespace + U_FALLTHROUGH; case 126 /*'~'*/: pos = skipWhitespace(rule, pos); break; diff --git a/icu4c/source/i18n/calendar.cpp b/icu4c/source/i18n/calendar.cpp index 1cd18d3a4fa..799b08186d0 100644 --- a/icu4c/source/i18n/calendar.cpp +++ b/icu4c/source/i18n/calendar.cpp @@ -2125,6 +2125,7 @@ void Calendar::add(UCalendarDateFields field, int32_t amount, UErrorCode& status } } // Fall through into normal handling + U_FALLTHROUGH; case UCAL_EXTENDED_YEAR: case UCAL_MONTH: { @@ -2601,6 +2602,7 @@ Calendar::isWeekend(void) const (millisInDay < transitionMillis); } // else fall through, return FALSE + U_FALLTHROUGH; } default: break; @@ -3639,7 +3641,7 @@ void Calendar::prepareGetActual(UCalendarDateFields field, UBool isMinimum, UErr case UCAL_YEAR_WOY: set(UCAL_WEEK_OF_YEAR, getGreatestMinimum(UCAL_WEEK_OF_YEAR)); - + U_FALLTHROUGH; case UCAL_MONTH: set(UCAL_DATE, getGreatestMinimum(UCAL_DATE)); break; diff --git a/icu4c/source/i18n/fmtable.cpp b/icu4c/source/i18n/fmtable.cpp index a2fa4095f26..9fdef20c3ae 100644 --- a/icu4c/source/i18n/fmtable.cpp +++ b/icu4c/source/i18n/fmtable.cpp @@ -1,7 +1,7 @@ /* ******************************************************************************* -* Copyright (C) 1997-2014, International Business Machines Corporation and * -* others. All Rights Reserved. * +* Copyright (C) 1997-2016, International Business Machines Corporation and +* others. All Rights Reserved. ******************************************************************************* * * File FMTABLE.CPP @@ -431,7 +431,8 @@ Formattable::getLong(UErrorCode& status) const return ((const Measure*) fValue.fObject)-> getNumber().getLong(status); } - default: + U_FALLTHROUGH; + default: status = U_INVALID_FORMAT_ERROR; return 0; } @@ -482,7 +483,8 @@ Formattable::getInt64(UErrorCode& status) const return ((const Measure*) fValue.fObject)-> getNumber().getInt64(status); } - default: + U_FALLTHROUGH; + default: status = U_INVALID_FORMAT_ERROR; return 0; } @@ -512,7 +514,8 @@ Formattable::getDouble(UErrorCode& status) const return ((const Measure*) fValue.fObject)-> getNumber().getDouble(status); } - default: + U_FALLTHROUGH; + default: status = U_INVALID_FORMAT_ERROR; return 0; } diff --git a/icu4c/source/i18n/gregocal.cpp b/icu4c/source/i18n/gregocal.cpp index 5e98605bf92..3dcd9083115 100644 --- a/icu4c/source/i18n/gregocal.cpp +++ b/icu4c/source/i18n/gregocal.cpp @@ -1,6 +1,6 @@ /* ******************************************************************************* -* Copyright (C) 1997-2015, International Business Machines Corporation and +* Copyright (C) 1997-2016, International Business Machines Corporation and * others. All Rights Reserved. ******************************************************************************* * @@ -850,6 +850,7 @@ GregorianCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& s inCutoverMonth = TRUE; } } + break; default: ; } diff --git a/icu4c/source/i18n/plurrule.cpp b/icu4c/source/i18n/plurrule.cpp index 6f064fb1553..525bf56969d 100644 --- a/icu4c/source/i18n/plurrule.cpp +++ b/icu4c/source/i18n/plurrule.cpp @@ -492,6 +492,7 @@ PluralRuleParser::parse(const UnicodeString& ruleData, PluralRules *prules, UErr case tNotEqual: curAndConstraint->negated=TRUE; + U_FALLTHROUGH; case tIn: case tWithin: case tEqual: diff --git a/icu4c/source/i18n/regexcmp.cpp b/icu4c/source/i18n/regexcmp.cpp index d1b5bba4cbb..be8323371a9 100644 --- a/icu4c/source/i18n/regexcmp.cpp +++ b/icu4c/source/i18n/regexcmp.cpp @@ -2896,6 +2896,7 @@ void RegexCompile::matchStartType() { case URX_JMPX: loc++; // Except for extra operand on URX_JMPX, same as URX_JMP. + U_FALLTHROUGH; case URX_JMP: { int32_t jmpDest = URX_VAL(op); @@ -3258,6 +3259,7 @@ int32_t RegexCompile::minMatchLength(int32_t start, int32_t end) { case URX_JMPX: loc++; // URX_JMPX has an extra operand, ignored here, // otherwise processed identically to URX_JMP. + U_FALLTHROUGH; case URX_JMP: { int32_t jmpDest = URX_VAL(op); diff --git a/icu4c/source/i18n/smpdtfmt.cpp b/icu4c/source/i18n/smpdtfmt.cpp index 1ec37319a93..14e93e4810b 100644 --- a/icu4c/source/i18n/smpdtfmt.cpp +++ b/icu4c/source/i18n/smpdtfmt.cpp @@ -1347,6 +1347,7 @@ SimpleDateFormat::processOverrideString(const Locale &locale, const UnicodeStrin if (type==kOvrStrDate) { break; } + U_FALLTHROUGH; } case kOvrStrTime : { for ( int8_t i=0 ; ifNarrowWeekdays, @@ -2974,7 +2977,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC } // fall through to gotNumber check - + U_FALLTHROUGH; case UDAT_YEAR_FIELD: case UDAT_YEAR_WOY_FIELD: case UDAT_FRACTIONAL_SECOND_FIELD: @@ -3165,7 +3168,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC value = 0; // fall through to set field - + U_FALLTHROUGH; case UDAT_HOUR_OF_DAY0_FIELD: cal.set(UCAL_HOUR_OF_DAY, value); return pos.getIndex(); @@ -3198,6 +3201,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC } // else for eee-eeeee fall through to handling of EEE-EEEEE // fall through, do not break here + U_FALLTHROUGH; case UDAT_DAY_OF_WEEK_FIELD: { // Want to be able to parse both short and long forms. @@ -3290,7 +3294,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC value = 0; // fall through to set field - + U_FALLTHROUGH; case UDAT_HOUR0_FIELD: cal.set(UCAL_HOUR, value); return pos.getIndex(); diff --git a/icu4c/source/i18n/ucoleitr.cpp b/icu4c/source/i18n/ucoleitr.cpp index 66b01727e7e..91e892d65ee 100644 --- a/icu4c/source/i18n/ucoleitr.cpp +++ b/icu4c/source/i18n/ucoleitr.cpp @@ -1,6 +1,6 @@ /* ****************************************************************************** -* Copyright (C) 2001-2015, International Business Machines +* Copyright (C) 2001-2016, International Business Machines * Corporation and others. All Rights Reserved. ****************************************************************************** * @@ -222,11 +222,11 @@ uint64_t UCollationPCE::processCE(uint32_t ce) switch(strength) { default: tertiary = ucol_tertiaryOrder(ce); - /* note fall-through */ + U_FALLTHROUGH; case UCOL_SECONDARY: secondary = ucol_secondaryOrder(ce); - /* note fall-through */ + U_FALLTHROUGH; case UCOL_PRIMARY: primary = ucol_primaryOrder(ce); diff --git a/icu4c/source/io/uprntf_p.c b/icu4c/source/io/uprntf_p.c index a3dd75be508..fcb6ff8016e 100644 --- a/icu4c/source/io/uprntf_p.c +++ b/icu4c/source/io/uprntf_p.c @@ -1508,6 +1508,7 @@ u_printf_parse(const u_printf_stream_handler *streamHandler, /* set the spec's width to the # of chars written */ info->fWidth = *written; /* fall through to set the pointer */ + U_FALLTHROUGH; case ufmt_string: case ufmt_ustring: case ufmt_pointer: @@ -1535,6 +1536,7 @@ u_printf_parse(const u_printf_stream_handler *streamHandler, /* set the spec's width to the # of chars written */ info->fWidth = *written; /* fall through to set the pointer */ + U_FALLTHROUGH; case ufmt_string: case ufmt_ustring: case ufmt_pointer: diff --git a/icu4c/source/io/uscanf_p.c b/icu4c/source/io/uscanf_p.c index db11cc19253..716885d4957 100644 --- a/icu4c/source/io/uscanf_p.c +++ b/icu4c/source/io/uscanf_p.c @@ -1352,7 +1352,7 @@ u_scanf_parse(UFILE *f, case ufmt_count: /* set the spec's width to the # of items converted */ spec.fInfo.fWidth = cpConsumed; - /* fall through to next case */ + U_FALLTHROUGH; case ufmt_char: case ufmt_uchar: case ufmt_int: diff --git a/icu4c/source/test/intltest/colldata.cpp b/icu4c/source/test/intltest/colldata.cpp index b36bc63c51b..79d93654926 100644 --- a/icu4c/source/test/intltest/colldata.cpp +++ b/icu4c/source/test/intltest/colldata.cpp @@ -57,12 +57,10 @@ CEList::CEList(UCollator *coll, const UnicodeString &string, UErrorCode &status) { default: strengthMask |= UCOL_TERTIARYORDERMASK; - /* fall through */ - + U_FALLTHROUGH; case UCOL_SECONDARY: strengthMask |= UCOL_SECONDARYORDERMASK; - /* fall through */ - + U_FALLTHROUGH; case UCOL_PRIMARY: strengthMask |= UCOL_PRIMARYORDERMASK; } diff --git a/icu4c/source/test/intltest/intltest.cpp b/icu4c/source/test/intltest/intltest.cpp index 4a0a3e31972..98827b9f9a8 100644 --- a/icu4c/source/test/intltest/intltest.cpp +++ b/icu4c/source/test/intltest/intltest.cpp @@ -263,18 +263,25 @@ IntlTest::appendHex(uint32_t number, { case 8: target += digitString[(number >> 28) & 0xF]; + U_FALLTHROUGH; case 7: target += digitString[(number >> 24) & 0xF]; + U_FALLTHROUGH; case 6: target += digitString[(number >> 20) & 0xF]; + U_FALLTHROUGH; case 5: target += digitString[(number >> 16) & 0xF]; + U_FALLTHROUGH; case 4: target += digitString[(number >> 12) & 0xF]; + U_FALLTHROUGH; case 3: target += digitString[(number >> 8) & 0xF]; + U_FALLTHROUGH; case 2: target += digitString[(number >> 4) & 0xF]; + U_FALLTHROUGH; case 1: target += digitString[(number >> 0) & 0xF]; break; diff --git a/icu4c/source/test/intltest/ssearch.cpp b/icu4c/source/test/intltest/ssearch.cpp index a1d1d07a6ed..bea90a1d124 100644 --- a/icu4c/source/test/intltest/ssearch.cpp +++ b/icu4c/source/test/intltest/ssearch.cpp @@ -367,12 +367,10 @@ OrderList::OrderList(UCollator *coll, const UnicodeString &string, int32_t strin { default: strengthMask |= UCOL_TERTIARYORDERMASK; - /* fall through */ - + U_FALLTHROUGH; case UCOL_SECONDARY: strengthMask |= UCOL_SECONDARYORDERMASK; - /* fall through */ - + U_FALLTHROUGH; case UCOL_PRIMARY: strengthMask |= UCOL_PRIMARYORDERMASK; } diff --git a/icu4c/source/test/intltest/transrt.cpp b/icu4c/source/test/intltest/transrt.cpp index b3f952e4f32..91b6b442a27 100644 --- a/icu4c/source/test/intltest/transrt.cpp +++ b/icu4c/source/test/intltest/transrt.cpp @@ -449,7 +449,8 @@ UBool RTTest::isCamel(const UnicodeString& a) { break; case U_TITLECASE_LETTER: if (haveLower) return TRUE; - // drop through, since second letter is lower. + // fall through, since second letter is lower. + U_FALLTHROUGH; case U_LOWERCASE_LETTER: haveLower = TRUE; break; diff --git a/icu4c/source/tools/genrb/derb.cpp b/icu4c/source/tools/genrb/derb.cpp index 1f6a2dee293..3d2507bc14e 100644 --- a/icu4c/source/tools/genrb/derb.cpp +++ b/icu4c/source/tools/genrb/derb.cpp @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 1999-2015, International Business Machines +* Copyright (C) 1999-2016, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -342,7 +342,7 @@ static UChar *quotedString(const UChar *string) { case 0x0022: *np++ = 0x005C; - + U_FALLTHROUGH; default: *np++ = *sp; break; diff --git a/icu4c/source/tools/makeconv/genmbcs.cpp b/icu4c/source/tools/makeconv/genmbcs.cpp index e3c78dec494..61a346e1a4b 100644 --- a/icu4c/source/tools/makeconv/genmbcs.cpp +++ b/icu4c/source/tools/makeconv/genmbcs.cpp @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 2000-2013, International Business Machines +* Copyright (C) 2000-2016, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -831,10 +831,13 @@ MBCSAddFromUnicode(MBCSData *mbcsData, switch(length) { case 4: b=*pb++; + U_FALLTHROUGH; case 3: b=(b<<8)|*pb++; + U_FALLTHROUGH; case 2: b=(b<<8)|*pb++; + U_FALLTHROUGH; case 1: default: b=(b<<8)|*pb++; @@ -1011,6 +1014,7 @@ MBCSAddTable(NewConverter *cnvData, UCMTable *table, UConverterStaticData *stati case -1: /* there was no precision/fallback indicator */ /* fall through to set the mappings */ + U_FALLTHROUGH; case 0: /* set roundtrip mappings */ isOK&=MBCSAddToUnicode(mbcsData, m->b.bytes, m->bLen, c, f);