[libcxx] r302707 - [test] support machinery changes for EDG & C1XX /Za

Casey Carter via cfe-commits cfe-commits at lists.llvm.org
Wed May 10 12:10:50 PDT 2017


Author: caseycarter
Date: Wed May 10 14:10:49 2017
New Revision: 302707

URL: http://llvm.org/viewvc/llvm-project?rev=302707&view=rev
Log:
[test] support machinery changes for EDG & C1XX /Za

This change works around a couple of bugs:

1. EDG doesn't like explicit constexpr in a derived class. This program:

  struct Base {};
  struct Derived : Base {
      constexpr Derived() = default;
  };

  triggers "error: defaulted default constructor cannot be constexpr."

2. C1XX with /Za has no idea which constructor needs to be valid for copy elision.

The change also conditionally disables parts of the msvc_stdlib_force_include.hpp header that conflict with external configuration when _LIBCXX_IN_DEVCRT is defined.

Differential Revision: https://reviews.llvm.org/D32778

Added:
    libcxx/trunk/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
Modified:
    libcxx/trunk/test/support/archetypes.hpp
    libcxx/trunk/test/support/archetypes.ipp
    libcxx/trunk/test/support/msvc_stdlib_force_include.hpp
    libcxx/trunk/test/support/test_macros.h
    libcxx/trunk/test/support/test_workarounds.h

Modified: libcxx/trunk/test/support/archetypes.hpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/archetypes.hpp?rev=302707&r1=302706&r2=302707&view=diff
==============================================================================
--- libcxx/trunk/test/support/archetypes.hpp (original)
+++ libcxx/trunk/test/support/archetypes.hpp Wed May 10 14:10:49 2017
@@ -5,6 +5,7 @@
 #include <cassert>
 
 #include "test_macros.h"
+#include "test_workarounds.h"
 
 #if TEST_STD_VER >= 11
 
@@ -14,7 +15,9 @@ template <bool, class T>
 struct DepType : T {};
 
 struct NullBase {
+#ifndef TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
   NullBase() = default;
   NullBase(NullBase const&) = default;
   NullBase& operator=(NullBase const&) = default;
@@ -81,7 +84,9 @@ struct TestBase {
       ++assigned; ++value_assigned;
       return *this;
     }
+#ifndef TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
     ~TestBase() {
       assert(value != -999); assert(alive > 0);
       --alive; ++destroyed; value = -999;
@@ -144,7 +149,9 @@ struct ValueBase {
     }
     //~ValueBase() { assert(value != -999); value = -999; }
     int value;
+#ifndef TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
     constexpr static int check_value(int const& val) {
 #if TEST_STD_VER < 14
       return val == -1 || val == 999 ? (TEST_THROW(42), 0) : val;
@@ -197,7 +204,9 @@ struct TrivialValueBase {
     template <bool Dummy = true, typename std::enable_if<Dummy && !Explicit, bool>::type = true>
     constexpr TrivialValueBase(std::initializer_list<int>& il, int = 0) : value(static_cast<int>(il.size())) {}
     int value;
+#ifndef TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
     constexpr TrivialValueBase() noexcept : value(0) {}
 };
 

Modified: libcxx/trunk/test/support/archetypes.ipp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/archetypes.ipp?rev=302707&r1=302706&r2=302707&view=diff
==============================================================================
--- libcxx/trunk/test/support/archetypes.ipp (original)
+++ libcxx/trunk/test/support/archetypes.ipp Wed May 10 14:10:49 2017
@@ -6,7 +6,11 @@
 #define DEFINE_EXPLICIT
 #endif
 #ifndef DEFINE_CONSTEXPR
+#ifdef TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+#define DEFINE_CONSTEXPR
+#else // TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
 #define DEFINE_CONSTEXPR constexpr
+#endif // TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
 #endif
 #ifndef DEFINE_ASSIGN_CONSTEXPR
 #if TEST_STD_VER >= 14

Modified: libcxx/trunk/test/support/msvc_stdlib_force_include.hpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/msvc_stdlib_force_include.hpp?rev=302707&r1=302706&r2=302707&view=diff
==============================================================================
--- libcxx/trunk/test/support/msvc_stdlib_force_include.hpp (original)
+++ libcxx/trunk/test/support/msvc_stdlib_force_include.hpp Wed May 10 14:10:49 2017
@@ -13,11 +13,13 @@
 // This header is force-included when running the libc++ tests against the
 // MSVC standard library.
 
-// Silence warnings about CRT machinery.
-#define _CRT_SECURE_NO_WARNINGS
-
-// Avoid assertion dialogs.
-#define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
+#ifndef _LIBCXX_IN_DEVCRT
+    // Silence warnings about CRT machinery.
+    #define _CRT_SECURE_NO_WARNINGS
+
+    // Avoid assertion dialogs.
+    #define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
+#endif // _LIBCXX_IN_DEVCRT
 
 #include <crtdbg.h>
 #include <stdlib.h>
@@ -31,6 +33,7 @@
     #define _MSVC_STL_VER 42
 #endif
 
+#ifndef _LIBCXX_IN_DEVCRT
 struct AssertionDialogAvoider {
     AssertionDialogAvoider() {
         _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
@@ -42,6 +45,7 @@ struct AssertionDialogAvoider {
 };
 
 const AssertionDialogAvoider assertion_dialog_avoider{};
+#endif // _LIBCXX_IN_DEVCRT
 
 // MSVC frontend only configurations
 #if !defined(__clang__)
@@ -74,8 +78,9 @@ const AssertionDialogAvoider assertion_d
 #define _HAS_FUNCTION_ASSIGN       1
 #define _HAS_OLD_IOSTREAMS_MEMBERS 1
 
-// Silence warnings about raw pointers and other unchecked iterators.
-#define _SCL_SECURE_NO_WARNINGS
+    // Silence warnings about raw pointers and other unchecked iterators.
+    #define _SCL_SECURE_NO_WARNINGS
+#endif // _LIBCXX_IN_DEVCRT
 
 #include <ciso646>
 

Added: libcxx/trunk/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp?rev=302707&view=auto
==============================================================================
--- libcxx/trunk/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp (added)
+++ libcxx/trunk/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp Wed May 10 14:10:49 2017
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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_ZA_CTOR_CHECK.
+
+#include <type_traits>
+
+#include "test_workarounds.h"
+
+struct X {
+    X(int) {}
+
+    X(X&&) = default;
+    X& operator=(X&&) = default;
+
+private:
+    X(const X&) = default;
+    X& operator=(const X&) = default;
+};
+
+void PushFront(X&&) {}
+
+template<class T = int>
+auto test(int) -> decltype(PushFront(std::declval<T>()), std::true_type{});
+auto test(long) -> std::false_type;
+
+int main() {
+#if defined(TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK)
+    static_assert(!decltype(test(0))::value, "");
+#else
+    static_assert(decltype(test(0))::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=302707&r1=302706&r2=302707&view=diff
==============================================================================
--- libcxx/trunk/test/support/test_macros.h (original)
+++ libcxx/trunk/test/support/test_macros.h Wed May 10 14:10:49 2017
@@ -52,10 +52,12 @@
 #define TEST_HAS_BUILTIN_IDENTIFIER(X) 0
 #endif
 
-#if defined(__clang__)
-#define TEST_COMPILER_CLANG
+#if defined(__EDG__)
+# define TEST_COMPILER_EDG
+#elif defined(__clang__)
+# define TEST_COMPILER_CLANG
 # if defined(__apple_build_version__)
-#   define TEST_COMPILER_APPLE_CLANG
+#  define TEST_COMPILER_APPLE_CLANG
 # endif
 #elif defined(_MSC_VER)
 # define TEST_COMPILER_C1XX

Modified: libcxx/trunk/test/support/test_workarounds.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test_workarounds.h?rev=302707&r1=302706&r2=302707&view=diff
==============================================================================
--- libcxx/trunk/test/support/test_workarounds.h (original)
+++ libcxx/trunk/test/support/test_workarounds.h Wed May 10 14:10:49 2017
@@ -13,9 +13,16 @@
 
 #include "test_macros.h"
 
+#if defined(TEST_COMPILER_EDG)
+# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+#endif
+
 #if defined(TEST_COMPILER_C1XX)
 # define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
 # define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
+# ifndef _MSC_EXTENSIONS
+#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
+# endif
 #endif
 
 #endif // SUPPORT_TEST_WORKAROUNDS_H




More information about the cfe-commits mailing list