[PATCH] D33214: [libcxx] [test] Workaround C1XX bug in uses_allocator_types.hpp

Casey Carter via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 15 14:28:34 PDT 2017


CaseyCarter created this revision.

Needed by IIRC allocator.adaptor\allocator.adaptor.members\construct_pair.pass.cpp.


https://reviews.llvm.org/D33214

Files:
  test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp
  test/support/test_workarounds.h
  test/support/uses_alloc_types.hpp


Index: test/support/uses_alloc_types.hpp
===================================================================
--- test/support/uses_alloc_types.hpp
+++ test/support/uses_alloc_types.hpp
@@ -15,6 +15,7 @@
 #include <cstdlib>
 
 #include "test_macros.h"
+#include "test_workarounds.h"
 #include "type_id.h"
 
 // There are two forms of uses-allocator construction:
@@ -256,6 +257,13 @@
         return alloc;
     }
 
+#ifdef TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
+    template <class ...LArgs>
+    static CtorAlloc getAllocatorFromPackImp(CtorAlloc const& alloc) {
+        return alloc;
+    }
+#endif
+
     bool has_alloc() const { return alloc_store.get_allocator() != nullptr; }
     const CtorAlloc *get_alloc() const { return alloc_store.get_allocator(); }
 public:
Index: test/support/test_workarounds.h
===================================================================
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -20,6 +20,7 @@
 #if defined(TEST_COMPILER_C1XX)
 # define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
 # define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
+# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
 # ifndef _MSC_EXTENSIONS
 #  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 # endif
Index: test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp
===================================================================
--- /dev/null
+++ test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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_EMPTY_PARAMETER_PACK_EXPANSION.
+
+#include <type_traits>
+
+#include "test_workarounds.h"
+
+template<class T>
+struct identity {
+    using type = T;
+};
+
+template<class...> struct list {};
+
+// C1XX believes this function template is not viable when LArgs is an empty
+// parameter pack.
+template <class ...LArgs>
+int f2(typename identity<LArgs>::type..., int i) {
+    return i;
+}
+
+#ifdef TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
+// C1XX believes this function template *is* viable when LArgs is an empty
+// parameter pack. Conforming compilers believe the two overloads are
+// ambiguous when LArgs is an empty pack.
+template <class ...LArgs>
+int f2(int i) {
+    return i;
+}
+#endif
+
+template <class ...LArgs, class ...Args>
+int f1(list<LArgs...>, Args&&... args) {
+    return f2<LArgs const&...>(args...);
+}
+
+int main() {
+    f1(list<>{}, 42);
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33214.99057.patch
Type: text/x-patch
Size: 2868 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170515/8a47ccb3/attachment.bin>


More information about the cfe-commits mailing list