[llvm] r198255 - Silence g++ 4.9 build issue
Alp Toker
alp at nuanti.com
Mon Dec 30 19:16:55 PST 2013
Author: alp
Date: Mon Dec 30 21:16:55 2013
New Revision: 198255
URL: http://llvm.org/viewvc/llvm-project?rev=198255&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/Support/Compiler.h
llvm/trunk/lib/Support/ThreadLocal.cpp
Modified: llvm/trunk/include/llvm/Support/Compiler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Compiler.h?rev=198255&r1=198254&r2=198255&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Compiler.h (original)
+++ llvm/trunk/include/llvm/Support/Compiler.h Mon Dec 30 21:16:55 2013
@@ -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)
Modified: llvm/trunk/lib/Support/ThreadLocal.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ThreadLocal.cpp?rev=198255&r1=198254&r2=198255&view=diff
==============================================================================
--- llvm/trunk/lib/Support/ThreadLocal.cpp (original)
+++ llvm/trunk/lib/Support/ThreadLocal.cpp Mon Dec 30 21:16:55 2013
@@ -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<void**>(&data);
*pd = const_cast<void*>(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<pthread_key_t*>(&data);
int errorcode = pthread_key_create(key, NULL);
assert(errorcode == 0);
More information about the llvm-commits
mailing list