]> granicus.if.org Git - icu/commitdiff
ICU-12893 enable U_FALLTHROUGH only for clang; fix a former .c file
authorMarkus Scherer <markus.icu@gmail.com>
Fri, 24 Feb 2017 20:49:14 +0000 (20:49 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Fri, 24 Feb 2017 20:49:14 +0000 (20:49 +0000)
X-SVN-Rev: 39702

icu4c/source/common/unicode/platform.h
icu4c/source/common/utf_impl.cpp

index d2be366e919cd45f6a8ade26e90507279d64465e..0ecdb4a0c78e2919697d65461a57204caaf0fa9e 100644 (file)
 #   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
  * @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
index 07a922c1477f592dde4e5f568540b6a1db1887da..293e6f181f3a3f9d9932392503afbd47604f6f93 100644 (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;