summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan/tests/rtl/tsan_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt/lib/tsan/tests/rtl/tsan_test.cc')
-rw-r--r--compiler-rt/lib/tsan/tests/rtl/tsan_test.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler-rt/lib/tsan/tests/rtl/tsan_test.cc b/compiler-rt/lib/tsan/tests/rtl/tsan_test.cc
index 71641400efe..50fee84ace3 100644
--- a/compiler-rt/lib/tsan/tests/rtl/tsan_test.cc
+++ b/compiler-rt/lib/tsan/tests/rtl/tsan_test.cc
@@ -28,11 +28,13 @@ TEST(ThreadSanitizer, FuncCall) {
t2.Return();
}
-int main(int argc, char **argv) {
+// We use this function instead of main, as ISO C++ forbids taking the address
+// of main, which we need to pass inside __tsan_func_entry.
+int run_tests(int argc, char **argv) {
TestMutexBeforeInit(); // Mutexes must be usable before __tsan_init();
__tsan_init();
__tsan_func_entry(__builtin_return_address(0));
- __tsan_func_entry((char*)&main + 1);
+ __tsan_func_entry((void*)((uintptr_t)&run_tests + 1));
testing::GTEST_FLAG(death_test_style) = "threadsafe";
testing::InitGoogleTest(&argc, argv);
@@ -42,3 +44,7 @@ int main(int argc, char **argv) {
__tsan_func_exit();
return res;
}
+
+int main(int argc, char **argv) {
+ return run_tests(argc, argv);
+}
OpenPOWER on IntegriCloud