]> granicus.if.org Git - icu/commitdiff
ICU-13812 Define U_FALLTHROUGH for GCC 7+ for ICU4C. (#100)
authorJeff Genovy <29107334+jefgen@users.noreply.github.com>
Wed, 12 Sep 2018 17:17:35 +0000 (10:17 -0700)
committerShane Carr <shane@unicode.org>
Thu, 27 Sep 2018 21:27:39 +0000 (14:27 -0700)
Currently U_FALLTHROUGH is not defined for GCC, meaning that any switch case statements with fall-throughs will generate warnings when building ICU4C.

In GCC 7, they added support for: "_attribute_((fallthrough))" which we can now use for U_FALLTHROUGH, which eliminates many warnings when building with GCC.

icu4c/source/common/unicode/platform.h

index db34613b614781e5b00fdecb709f596648168691..4c1603554fb8bfc1e1536039d21f53cf0dee35f1 100644 (file)
@@ -517,6 +517,8 @@ namespace std {
             (__has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough"))
 #       define U_FALLTHROUGH [[clang::fallthrough]]
 #   endif
+#elif defined(__GNUC__) && (__GNUC__ >= 7)
+#   define U_FALLTHROUGH __attribute__((fallthrough))
 #endif
 
 #ifndef U_FALLTHROUGH