[PATCH] D32778: [libcxx] [test] Conditionally workaround C1XX/EDG bugs

2017-05-10 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302707: [test] support machinery changes for EDG & C1XX /Za 
(authored by CaseyCarter).

Changed prior to commit:
  https://reviews.llvm.org/D32778?vs=97530=98503#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32778

Files:
  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.workarounds/c1xx_broken_za_ctor_check.pass.cpp
  libcxx/trunk/test/support/test_macros.h
  libcxx/trunk/test/support/test_workarounds.h

Index: libcxx/trunk/test/support/test_macros.h
===
--- libcxx/trunk/test/support/test_macros.h
+++ libcxx/trunk/test/support/test_macros.h
@@ -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
Index: libcxx/trunk/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
===
--- libcxx/trunk/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
+++ libcxx/trunk/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
@@ -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 
+
+#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
+auto test(int) -> decltype(PushFront(std::declval()), 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
+}
Index: libcxx/trunk/test/support/test_workarounds.h
===
--- libcxx/trunk/test/support/test_workarounds.h
+++ libcxx/trunk/test/support/test_workarounds.h
@@ -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
Index: libcxx/trunk/test/support/archetypes.ipp
===
--- libcxx/trunk/test/support/archetypes.ipp
+++ libcxx/trunk/test/support/archetypes.ipp
@@ -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
Index: libcxx/trunk/test/support/archetypes.hpp
===
--- libcxx/trunk/test/support/archetypes.hpp
+++ libcxx/trunk/test/support/archetypes.hpp
@@ -5,6 +5,7 @@
 #include 
 
 #include "test_macros.h"
+#include "test_workarounds.h"
 
 #if TEST_STD_VER >= 11
 
@@ -14,7 +15,9 @@
 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 @@
   ++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 @@
 }
 //~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& 

[PATCH] D32778: [libcxx] [test] Conditionally workaround C1XX/EDG bugs

2017-05-02 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added inline comments.



Comment at: test/support/archetypes.hpp:20
 protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
   NullBase() = default;

STL_MSFT wrote:
> I think that this comment doesn't match the ifndef check, but it's a style 
> question.
I know which style *I* prefer, because I wrote it, and I know which style *you* 
prefer, because you commented. I'll change this when Marshall or Eric let me 
know what they prefer here.



Comment at: test/support/archetypes.ipp:10
+#ifdef TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+#define DEFINE_CONSTEXPR
+#else // TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR

STL_MSFT wrote:
> Should you define it to be `inline` instead of nothing?
This macro is typically defined to either `constexpr` or nothing - see the 
definitions in `archetypes.hpp` above.


https://reviews.llvm.org/D32778



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32778: [libcxx] [test] Conditionally workaround C1XX/EDG bugs

2017-05-02 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT accepted this revision.
STL_MSFT added inline comments.
This revision is now accepted and ready to land.



Comment at: test/support/archetypes.hpp:20
 protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
   NullBase() = default;

I think that this comment doesn't match the ifndef check, but it's a style 
question.



Comment at: test/support/archetypes.ipp:10
+#ifdef TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+#define DEFINE_CONSTEXPR
+#else // TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR

Should you define it to be `inline` instead of nothing?


https://reviews.llvm.org/D32778



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32778: [libcxx] [test] Conditionally workaround C1XX/EDG bugs

2017-05-02 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.

Test support machinery changes needed to parse with EDG and compile with C1XX's 
/Za flag that disables MS extensions.

I try to make changes to `` and the `optional`/`variant` tests 
simultaneously in the MS STL and in libc++, which realistically requires that I 
keep the tests largely synchronized between libc++ and our internal test suite. 
As a first step toward automating that integration, I'd like to upstream this 
patch.

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.


https://reviews.llvm.org/D32778

Files:
  test/support/archetypes.hpp
  test/support/archetypes.ipp
  test/support/msvc_stdlib_force_include.hpp
  test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
  test/support/test_macros.h
  test/support/test_workarounds.h

Index: test/support/test_workarounds.h
===
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -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
Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -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
Index: test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
===
--- /dev/null
+++ test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
@@ -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 
+
+#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
+auto test(int) -> decltype(PushFront(std::declval()), 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
+}
Index: test/support/msvc_stdlib_force_include.hpp
===
--- test/support/msvc_stdlib_force_include.hpp
+++ test/support/msvc_stdlib_force_include.hpp
@@ -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
+#ifndef _LIBCXX_IN_DEVCRT
+// Silence warnings about CRT machinery.
+#define _CRT_SECURE_NO_WARNINGS
 
-// Avoid assertion dialogs.
-#define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
+// Avoid assertion dialogs.
+#define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
+#endif // _LIBCXX_IN_DEVCRT
 
 #include 
 #include 
@@ -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 @@
 };
 
 const AssertionDialogAvoider assertion_dialog_avoider{};
+#endif // _LIBCXX_IN_DEVCRT
 
 // MSVC frontend only configurations
 #if !defined(__clang__)
@@ -69,15 +73,17 @@
 // MSVC has quick_exit() and at_quick_exit().
 #define _LIBCPP_HAS_QUICK_EXIT
 
-// atomic_is_lock_free.pass.cpp needs this