ICU-12893 enable U_FALLTHROUGH only for clang; fix a former .c file

X-SVN-Rev: 39702
This commit is contained in:
Markus Scherer 2017-02-24 20:49:14 +00:00
parent 8c61bdb545
commit 1d5d552ae1
2 changed files with 8 additions and 3 deletions

View File

@ -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

View File

@ -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;