From: Jeff Genovy <29107334+jefgen@users.noreply.github.com> Date: Wed, 12 Sep 2018 17:17:35 +0000 (-0700) Subject: ICU-13812 Define U_FALLTHROUGH for GCC 7+ for ICU4C. (#100) X-Git-Tag: release-63-rc~77 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ddf8ff2b7d345ad7b263d904be761670ec1c51a1;p=icu ICU-13812 Define U_FALLTHROUGH for GCC 7+ for ICU4C. (#100) 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. --- diff --git a/icu4c/source/common/unicode/platform.h b/icu4c/source/common/unicode/platform.h index db34613b614..4c1603554fb 100644 --- a/icu4c/source/common/unicode/platform.h +++ b/icu4c/source/common/unicode/platform.h @@ -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