[libcxx] r298554 - [libc++] Work around C1XX bug which breaks poisoned hash tests.
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 22 15:41:41 PDT 2017
Author: ericwf
Date: Wed Mar 22 17:41:41 2017
New Revision: 298554
URL: http://llvm.org/viewvc/llvm-project?rev=298554&view=rev
Log:
[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
Added:
libcxx/trunk/test/support/test.workarounds/
libcxx/trunk/test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
libcxx/trunk/test/support/test_workarounds.h
Modified:
libcxx/trunk/test/support/poisoned_hash_helper.hpp
libcxx/trunk/test/support/test_macros.h
Modified: libcxx/trunk/test/support/poisoned_hash_helper.hpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/poisoned_hash_helper.hpp?rev=298554&r1=298553&r2=298554&view=diff
==============================================================================
--- libcxx/trunk/test/support/poisoned_hash_helper.hpp (original)
+++ libcxx/trunk/test/support/poisoned_hash_helper.hpp Wed Mar 22 17:41:41 2017
@@ -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,
Added: libcxx/trunk/test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp?rev=298554&view=auto
==============================================================================
--- libcxx/trunk/test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp (added)
+++ libcxx/trunk/test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp Wed Mar 22 17:41:41 2017
@@ -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
+}
Modified: libcxx/trunk/test/support/test_macros.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test_macros.h?rev=298554&r1=298553&r2=298554&view=diff
==============================================================================
--- libcxx/trunk/test/support/test_macros.h (original)
+++ libcxx/trunk/test/support/test_macros.h Wed Mar 22 17:41:41 2017
@@ -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__)
Added: libcxx/trunk/test/support/test_workarounds.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test_workarounds.h?rev=298554&view=auto
==============================================================================
--- libcxx/trunk/test/support/test_workarounds.h (added)
+++ libcxx/trunk/test/support/test_workarounds.h Wed Mar 22 17:41:41 2017
@@ -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
More information about the cfe-commits
mailing list