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

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158449 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/sanitizer_common/sanitizer_internal_defs.h b/lib/sanitizer_common/sanitizer_internal_defs.h
index 6ed7052..07c940e 100644
--- a/lib/sanitizer_common/sanitizer_internal_defs.h
+++ b/lib/sanitizer_common/sanitizer_internal_defs.h
@@ -47,6 +47,7 @@
 # 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
 
diff --git a/lib/tsan/Makefile.old b/lib/tsan/Makefile.old
index bb48198..ea786c3 100644
--- a/lib/tsan/Makefile.old
+++ b/lib/tsan/Makefile.old
@@ -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
diff --git a/lib/tsan/unit_tests/tsan_mutex_test.cc b/lib/tsan/unit_tests/tsan_mutex_test.cc
index 6ecd320..9e0dc28 100644
--- a/lib/tsan/unit_tests/tsan_mutex_test.cc
+++ b/lib/tsan/unit_tests/tsan_mutex_test.cc
@@ -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 @@
   static const int kSize = 64;
   typedef u64 T;
   Mutex mtx_;
-  char pad_[kCacheLineSize];
+  char pad_[kCacheLineSize] UNUSED;
   T data_[kSize];
 };