From 1d5d552ae1943b5983df8d8f943edd04f28e2357 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Fri, 24 Feb 2017 20:49:14 +0000 Subject: [PATCH] ICU-12893 enable U_FALLTHROUGH only for clang; fix a former .c file X-SVN-Rev: 39702 --- icu4c/source/common/unicode/platform.h | 9 ++++++--- icu4c/source/common/utf_impl.cpp | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/icu4c/source/common/unicode/platform.h b/icu4c/source/common/unicode/platform.h index d2be366e919..0ecdb4a0c78 100644 --- a/icu4c/source/common/unicode/platform.h +++ b/icu4c/source/common/unicode/platform.h @@ -430,7 +430,7 @@ # define U_HAVE_DEBUG_LOCATION_NEW 0 #endif -/* Compatibility with non clang compilers: http://clang.llvm.org/docs/LanguageExtensions.html */ +/* Compatibility with compilers other than clang: http://clang.llvm.org/docs/LanguageExtensions.html */ #ifndef __has_attribute # define __has_attribute(x) 0 #endif @@ -538,8 +538,11 @@ * @internal */ #ifdef __cplusplus -# if __has_cpp_attribute(clang::fallthrough) || \ - (__has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")) +# ifdef U_FALLTHROUGH + // Use the predefined value. +# elif defined(__clang__) && \ + (__has_cpp_attribute(clang::fallthrough) || \ + (__has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough"))) # define U_FALLTHROUGH [[clang::fallthrough]] # else # define U_FALLTHROUGH diff --git a/icu4c/source/common/utf_impl.cpp b/icu4c/source/common/utf_impl.cpp index 07a922c1477..293e6f181f3 100644 --- a/icu4c/source/common/utf_impl.cpp +++ b/icu4c/source/common/utf_impl.cpp @@ -155,6 +155,7 @@ utf8_nextCharSafeBody(const uint8_t *s, int32_t *pi, int32_t length, UChar32 c, c=(c<<6)|trail; /* c>=0x110 would result in code point>0x10ffff, outside Unicode */ if(c>=0x110 || trail>0x3f) { break; } + U_FALLTHROUGH; case 2: trail=s[i++]-0x80; c=(c<<6)|trail; @@ -163,6 +164,7 @@ utf8_nextCharSafeBody(const uint8_t *s, int32_t *pi, int32_t length, UChar32 c, * before the last (c<<6), a surrogate is c=360..37f */ if(((c&0xffe0)==0x360 && strict!=-2) || trail>0x3f) { break; } + U_FALLTHROUGH; case 1: trail=s[i++]-0x80; c=(c<<6)|trail; -- 2.40.0