]> granicus.if.org Git - icu/commitdiff
ICU-12893 U_FALLTHROUGH: separate compiler test from compiler-feature test
authorMarkus Scherer <markus.icu@gmail.com>
Tue, 28 Feb 2017 03:38:29 +0000 (03:38 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Tue, 28 Feb 2017 03:38:29 +0000 (03:38 +0000)
X-SVN-Rev: 39711

icu4c/source/common/unicode/platform.h

index 0ecdb4a0c78e2919697d65461a57204caaf0fa9e..d29ab677e568e6913d2380136cedaf1138074311 100644 (file)
  * http://clang.llvm.org/docs/AttributeReference.html#fallthrough-clang-fallthrough
  * @internal
  */
-#ifdef __cplusplus
-#   ifdef U_FALLTHROUGH
-        // Use the predefined value.
-#   elif defined(__clang__) && \
-            (__has_cpp_attribute(clang::fallthrough) || \
-            (__has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")))
+#ifndef __cplusplus
+    // Not for C.
+#elif defined(U_FALLTHROUGH)
+    // Use the predefined value.
+#elif defined(__clang__)
+    // Test for compiler vs. feature separately.
+    // Other compilers might choke on the feature test.
+#   if __has_cpp_attribute(clang::fallthrough) || \
+            (__has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough"))
 #       define U_FALLTHROUGH [[clang::fallthrough]]
-#   else
-#       define U_FALLTHROUGH
 #   endif
-#else
-#   define U_FALLTHROUGH
 #endif
 
+#ifndef U_FALLTHROUGH
+#   define U_FALLTHROUGH
+#endif
 
 /** @} */