From: Eric Fiselier Date: Fri, 5 May 2017 20:32:26 +0000 (+0000) Subject: Fix new warnings emitted by GCC 7 X-Git-Tag: llvmorg-5.0.0-rc1~5832 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=807790a09b95595378f67229a41a300617285cb5;p=platform%2Fupstream%2Fllvm.git Fix new warnings emitted by GCC 7 llvm-svn: 302280 --- diff --git a/libcxx/include/__config b/libcxx/include/__config index 05622a4..a9f9d0f 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -1089,6 +1089,13 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( # define _LIBCPP_DIAGNOSE_ERROR(...) #endif +#if __has_attribute(fallthough) || defined(_LIBCPP_COMPILER_GCC) +// Use a function like macro to imply that it must be followed by a semicolon +#define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) +#else +#define _LIBCPP_FALLTHROUGH() ((void)0) +#endif + #if defined(_LIBCPP_ABI_MICROSOFT) && \ (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases) diff --git a/libcxx/include/locale b/libcxx/include/locale index 6bce16e..d0909d5 100644 --- a/libcxx/include/locale +++ b/libcxx/include/locale @@ -2825,7 +2825,7 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e, return false; } } - // drop through + _LIBCPP_FALLTHROUGH(); case money_base::none: if (__p != 3) { diff --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp index 1460f96..1ed9b41 100644 --- a/libcxx/src/locale.cpp +++ b/libcxx/src/locale.cpp @@ -68,8 +68,8 @@ T& make(A0 a0) { static typename aligned_storage::type buf; - ::new (&buf) T(a0); - return *reinterpret_cast(&buf); + auto *obj = ::new (&buf) T(a0); + return *obj; } template @@ -88,8 +88,8 @@ T& make(A0 a0, A1 a1, A2 a2) { static typename aligned_storage::type buf; - ::new (&buf) T(a0, a1, a2); - return *reinterpret_cast(&buf); + auto *obj = ::new (&buf) T(a0, a1, a2); + return *obj; } template @@ -480,8 +480,8 @@ locale::__imp::make_global() { // only one thread can get in here and it only gets in once static aligned_storage::type buf; - ::new (&buf) locale(locale::classic()); - return *reinterpret_cast(&buf); + auto *obj = ::new (&buf) locale(locale::classic()); + return *obj; } locale&