summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libcxx/CMakeLists.txt15
-rw-r--r--libcxx/include/__config6
-rw-r--r--libcxx/include/__tuple2
-rw-r--r--libcxx/include/cstdlib6
-rw-r--r--libcxx/include/typeinfo5
-rw-r--r--libcxx/src/strstream.cpp3
6 files changed, 32 insertions, 5 deletions
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 64c6c31c48c..d0ed9df5e49 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -322,10 +322,19 @@ add_compile_flags_if_supported(-nostdinc++)
# Warning flags ===============================================================
add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
add_compile_flags_if_supported(
- -Wall -W -Wwrite-strings
- -Wno-unused-parameter -Wno-long-long -Wno-user-defined-literals
- -Wno-covered-switch-default
+ -Wall -Wextra -W -Wwrite-strings
+ -Wno-unused-parameter -Wno-long-long
-Werror=return-type)
+if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+ add_compile_flags_if_supported(
+ -Wno-user-defined-literals
+ -Wno-covered-switch-default)
+elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
+ add_compile_flags_if_supported(
+ -Wno-attributes # FIXME: Fix -Wattribute warnings.
+ -Wno-literal-suffix
+ -Wno-c++14-compat)
+endif()
if (LIBCXX_ENABLE_WERROR)
add_compile_flags_if_supported(-Werror)
add_compile_flags_if_supported(-WX)
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 353ca10e4e2..bd3f59a27c5 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -691,6 +691,12 @@ template <unsigned> struct __static_assert_check {};
#define _NOALIAS
#endif
+#ifdef __GNUC__
+#define _LIBCPP_MAY_ALIAS __attribute__((__may_alias__))
+#else
+#define _LIBCPP_MAY_ALIAS
+#endif
+
#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__)
# define _LIBCPP_EXPLICIT explicit
#else
diff --git a/libcxx/include/__tuple b/libcxx/include/__tuple
index 6d978a2dcc2..caa427aa5fe 100644
--- a/libcxx/include/__tuple
+++ b/libcxx/include/__tuple
@@ -374,7 +374,7 @@ template <bool ..._Preds>
struct __all_dummy;
template <bool ..._Pred>
-using __all = is_same<__all_dummy<_Pred...>, __all_dummy<(_Pred, true)...>>;
+using __all = is_same<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...>>;
struct __tuple_sfinae_base {
template <template <class, class...> class _Trait,
diff --git a/libcxx/include/cstdlib b/libcxx/include/cstdlib
index 10ed231078d..9a775b84484 100644
--- a/libcxx/include/cstdlib
+++ b/libcxx/include/cstdlib
@@ -89,6 +89,12 @@ void *aligned_alloc(size_t alignment, size_t size); // C11
#pragma GCC system_header
#endif
+#ifdef __GNUC__
+#define _LIBCPP_UNREACHABLE() __builtin_unreachable()
+#else
+#define _LIBCPP_UNREACHABLE() _VSTD::abort()
+#endif
+
_LIBCPP_BEGIN_NAMESPACE_STD
using ::size_t;
diff --git a/libcxx/include/typeinfo b/libcxx/include/typeinfo
index fe9123e82e6..d3155e459b9 100644
--- a/libcxx/include/typeinfo
+++ b/libcxx/include/typeinfo
@@ -73,6 +73,9 @@ class _LIBCPP_EXCEPTION_ABI type_info
{
type_info& operator=(const type_info&);
type_info(const type_info&);
+
+ typedef size_t _LIBCPP_MAY_ALIAS _ASizeT; // Avoid strict-aliasing issues.
+
protected:
#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
const char* __type_name;
@@ -113,7 +116,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_t hash_code() const _NOEXCEPT
#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
- {return *reinterpret_cast<const size_t*>(&__type_name);}
+ {return *reinterpret_cast<const _ASizeT *>(&__type_name);}
#else
{if (!(__type_name & _LIBCPP_NONUNIQUE_RTTI_BIT)) return __type_name;
const char *__ptr = name();
diff --git a/libcxx/src/strstream.cpp b/libcxx/src/strstream.cpp
index 0e2d7ff21bb..be94f9c89e8 100644
--- a/libcxx/src/strstream.cpp
+++ b/libcxx/src/strstream.cpp
@@ -11,6 +11,7 @@
#include "algorithm"
#include "climits"
#include "cstring"
+#include "cstdlib"
#include "__debug"
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -266,6 +267,8 @@ strstreambuf::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmod
case ios::end:
newoff = seekhigh - eback();
break;
+ default:
+ _LIBCPP_UNREACHABLE();
}
newoff += __off;
if (0 <= newoff && newoff <= seekhigh - eback())
OpenPOWER on IntegriCloud