[libcxx] r302280 - Fix new warnings emitted by GCC 7

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Fri May 5 13:32:27 PDT 2017


Author: ericwf
Date: Fri May  5 15:32:26 2017
New Revision: 302280

URL: http://llvm.org/viewvc/llvm-project?rev=302280&view=rev
Log:
Fix new warnings emitted by GCC 7

Modified:
    libcxx/trunk/include/__config
    libcxx/trunk/include/locale
    libcxx/trunk/src/locale.cpp

Modified: libcxx/trunk/include/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=302280&r1=302279&r2=302280&view=diff
==============================================================================
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri May  5 15:32:26 2017
@@ -1089,6 +1089,13 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 # 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)

Modified: libcxx/trunk/include/locale
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=302280&r1=302279&r2=302280&view=diff
==============================================================================
--- libcxx/trunk/include/locale (original)
+++ libcxx/trunk/include/locale Fri May  5 15:32:26 2017
@@ -2825,7 +2825,7 @@ money_get<_CharT, _InputIterator>::__do_
                     return false;
                 }
             }
-            // drop through
+            _LIBCPP_FALLTHROUGH();
         case money_base::none:
             if (__p != 3)
             {

Modified: libcxx/trunk/src/locale.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/locale.cpp?rev=302280&r1=302279&r2=302280&view=diff
==============================================================================
--- libcxx/trunk/src/locale.cpp (original)
+++ libcxx/trunk/src/locale.cpp Fri May  5 15:32:26 2017
@@ -68,8 +68,8 @@ T&
 make(A0 a0)
 {
     static typename aligned_storage<sizeof(T)>::type buf;
-    ::new (&buf) T(a0);
-    return *reinterpret_cast<T*>(&buf);
+    auto *obj = ::new (&buf) T(a0);
+    return *obj;
 }
 
 template <class T, class A0, class A1>
@@ -88,8 +88,8 @@ T&
 make(A0 a0, A1 a1, A2 a2)
 {
     static typename aligned_storage<sizeof(T)>::type buf;
-    ::new (&buf) T(a0, a1, a2);
-    return *reinterpret_cast<T*>(&buf);
+    auto *obj = ::new (&buf) T(a0, a1, a2);
+    return *obj;
 }
 
 template <typename T, size_t N>
@@ -480,8 +480,8 @@ locale::__imp::make_global()
 {
     // only one thread can get in here and it only gets in once
     static aligned_storage<sizeof(locale)>::type buf;
-    ::new (&buf) locale(locale::classic());
-    return *reinterpret_cast<locale*>(&buf);
+    auto *obj = ::new (&buf) locale(locale::classic());
+    return *obj;
 }
 
 locale&




More information about the cfe-commits mailing list