summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2017-03-22 22:41:41 +0000
committerEric Fiselier <eric@efcs.ca>2017-03-22 22:41:41 +0000
commit9506f141bd3e1f61b4cdbec9ec9d8b7da9f21484 (patch)
tree66cb64e4bc339e7f9559d1f0bc22ed66457bfed2
parent51e077924dbc8663bc3c2d9d292f4d2db5450f0b (diff)
downloadbcm5719-llvm-9506f141bd3e1f61b4cdbec9ec9d8b7da9f21484.tar.gz
bcm5719-llvm-9506f141bd3e1f61b4cdbec9ec9d8b7da9f21484.zip
[libc++] Work around C1XX bug which breaks poisoned hash tests.
Summary: This is my attempt to work around the C1XX bug described to me by @BillyONeal. Reviewers: BillyONeal, STL_MSFT, CaseyCarter Reviewed By: BillyONeal Subscribers: cfe-commits, BillyONeal Differential Revision: https://reviews.llvm.org/D31260 llvm-svn: 298554
-rw-r--r--libcxx/test/support/poisoned_hash_helper.hpp3
-rw-r--r--libcxx/test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp29
-rw-r--r--libcxx/test/support/test_macros.h11
-rw-r--r--libcxx/test/support/test_workarounds.h20
4 files changed, 63 insertions, 0 deletions
diff --git a/libcxx/test/support/poisoned_hash_helper.hpp b/libcxx/test/support/poisoned_hash_helper.hpp
index e8a2d8c3a59..824c35837b2 100644
--- a/libcxx/test/support/poisoned_hash_helper.hpp
+++ b/libcxx/test/support/poisoned_hash_helper.hpp
@@ -14,6 +14,7 @@
#include <cassert>
#include "test_macros.h"
+#include "test_workarounds.h"
#if TEST_STD_VER < 11
#error this header may only be used in C++11 or newer
@@ -49,9 +50,11 @@ namespace PoisonedHashDetail {
// specializations of hash for nullptr t and all cv-unqualified
// arithmetic, enumeration, and pointer types.
using LibraryHashTypes = TypeList<
+#if !defined(TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR)
#if TEST_STD_VER > 14
decltype(nullptr),
#endif
+#endif
bool,
char,
signed char,
diff --git a/libcxx/test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp b/libcxx/test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
new file mode 100644
index 00000000000..ade241f0db7
--- /dev/null
+++ b/libcxx/test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// Verify TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR.
+
+#include "test_workarounds.h"
+
+#include <type_traits>
+
+struct ConvertsToNullptr {
+ using DestType = decltype(nullptr);
+ operator DestType() const { return nullptr; }
+};
+
+int main() {
+#if defined(TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR)
+ static_assert(!std::is_convertible<ConvertsToNullptr, decltype(nullptr)>::value, "");
+#else
+ static_assert(std::is_convertible<ConvertsToNullptr, decltype(nullptr)>::value, "");
+#endif
+}
diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h
index 75b7885f8f6..1db3f7f8fa1 100644
--- a/libcxx/test/support/test_macros.h
+++ b/libcxx/test/support/test_macros.h
@@ -52,6 +52,17 @@
#define TEST_HAS_BUILTIN_IDENTIFIER(X) 0
#endif
+#if defined(__clang__)
+#define TEST_COMPILER_CLANG
+# if defined(__apple_build_version__)
+# define TEST_COMPILER_APPLE_CLANG
+# endif
+#elif defined(_MSC_VER)
+# define TEST_COMPILER_C1XX
+#elif defined(__GNUC__)
+# define TEST_COMPILER_GCC
+#endif
+
#if defined(__apple_build_version__)
#define TEST_APPLE_CLANG_VER (__clang_major__ * 100) + __clang_minor__
#elif defined(__clang_major__)
diff --git a/libcxx/test/support/test_workarounds.h b/libcxx/test/support/test_workarounds.h
new file mode 100644
index 00000000000..ec77a142f4f
--- /dev/null
+++ b/libcxx/test/support/test_workarounds.h
@@ -0,0 +1,20 @@
+// -*- C++ -*-
+//===---------------------------- test_macros.h ---------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SUPPORT_TEST_WORKAROUNDS_H
+#define SUPPORT_TEST_WORKAROUNDS_H
+
+#include "test_macros.h"
+
+#if defined(TEST_COMPILER_C1XX)
+# define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
+#endif
+
+#endif // SUPPORT_TEST_WORKAROUNDS_H
OpenPOWER on IntegriCloud