From e27bded35821829745d014f53da2ab5e57fc879e Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Tue, 31 Dec 2013 03:16:55 +0000 Subject: [PATCH] Silence g++ 4.9 build issue lib/Support/ThreadLocal.cpp:53:15: error: typedef 'SIZE_TOO_BIG' locally defined but not used [-Werror=unused-local-typedefs] typedef int SIZE_TOO_BIG[sizeof(pthread_key_t) <= sizeof(data) ? 1 : -1]; Done the C++11 way, switching on and using LLVM_STATIC_ASSERT() instead of LLVM_ATTRIBUTE_UNUSED. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198255 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Compiler.h | 3 ++- lib/Support/ThreadLocal.cpp | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index aa66a4ea52a..fb6ae5dee37 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -389,7 +389,8 @@ /// \macro LLVM_STATIC_ASSERT /// \brief Expands to C/C++'s static_assert on compilers which support it. -#if __has_feature(cxx_static_assert) || LLVM_MSC_PREREQ(1600) +#if __has_feature(cxx_static_assert) || \ + defined(__GXX_EXPERIMENTAL_CXX0X__) || LLVM_MSC_PREREQ(1600) # define LLVM_STATIC_ASSERT(expr, msg) static_assert(expr, msg) #elif __has_feature(c_static_assert) # define LLVM_STATIC_ASSERT(expr, msg) _Static_assert(expr, msg) diff --git a/lib/Support/ThreadLocal.cpp b/lib/Support/ThreadLocal.cpp index 868b6ea566a..38ab29b7ffe 100644 --- a/lib/Support/ThreadLocal.cpp +++ b/lib/Support/ThreadLocal.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Config/config.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ThreadLocal.h" //===----------------------------------------------------------------------===// @@ -26,7 +27,7 @@ using namespace sys; ThreadLocalImpl::ThreadLocalImpl() : data() { } ThreadLocalImpl::~ThreadLocalImpl() { } void ThreadLocalImpl::setInstance(const void* d) { - typedef int SIZE_TOO_BIG[sizeof(d) <= sizeof(data) ? 1 : -1]; + LLVM_STATIC_ASSERT(sizeof(d) <= sizeof(data), "size too big"); void **pd = reinterpret_cast(&data); *pd = const_cast(d); } @@ -50,7 +51,7 @@ namespace llvm { using namespace sys; ThreadLocalImpl::ThreadLocalImpl() : data() { - typedef int SIZE_TOO_BIG[sizeof(pthread_key_t) <= sizeof(data) ? 1 : -1]; + LLVM_STATIC_ASSERT(sizeof(pthread_key_t) <= sizeof(data), "size too big"); pthread_key_t* key = reinterpret_cast(&data); int errorcode = pthread_key_create(key, NULL); assert(errorcode == 0); -- 2.34.1