[Sanitizer] Workaround for -Wunused-private-field warning - add an attribute in TSan unit test, and silence this warning as gtest has unused fields.

llvm-svn: 158449
This commit is contained in:
Alexey Samsonov 2012-06-14 14:02:32 +00:00
parent 52f946611f
commit aac5d0c831
3 changed files with 6 additions and 2 deletions

View File

@ -47,6 +47,7 @@ typedef unsigned long DWORD; // NOLINT
# define ALWAYS_INLINE __attribute__((always_inline))
# define LIKELY(x) __builtin_expect(!!(x), 1)
# define UNLIKELY(x) __builtin_expect(!!(x), 0)
# define UNUSED __attribute__((unused))
# define USED __attribute__((used))
#endif

View File

@ -1,6 +1,8 @@
DEBUG=0
LDFLAGS=-ldl -lpthread -pie
CXXFLAGS = -fPIE -g -Wall -Werror -DTSAN_DEBUG=$(DEBUG)
CXXFLAGS = -fPIE -g -Wall -Werror -DTSAN_DEBUG=$(DEBUG)
# Gtest has unused private field. GCC doesn't know -Wunused-private-field warning
CXXFLAGS += -Wno-unused-private-field -Wno-attributes
ifeq ($(DEBUG), 0)
CXXFLAGS += -O3
endif

View File

@ -10,6 +10,7 @@
// This file is a part of ThreadSanitizer (TSan), a race detector.
//
//===----------------------------------------------------------------------===//
#include "sanitizer_common/sanitizer_internal_defs.h"
#include "tsan_atomic.h"
#include "tsan_mutex.h"
#include "gtest/gtest.h"
@ -45,7 +46,7 @@ class TestData {
static const int kSize = 64;
typedef u64 T;
Mutex mtx_;
char pad_[kCacheLineSize];
char pad_[kCacheLineSize] UNUSED;
T data_[kSize];
};