Author: ericwf Date: Sun May 7 16:15:28 2017 New Revision: 302380 URL: http://llvm.org/viewvc/llvm-project?rev=302380&view=rev Log: Fix two test failures caused by Windows mangling of function types.
On Windows the function template `template <class T> void test()` has the same mangled name when instantiated with the distinct types `void()` and `void() noexcept`. When this occurs Clang emits an error. This error was causing two type-traits tests to fail. However this can be worked around by using class templates instead of function templates, which is what this patch does to fix the errors. Modified: libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp Modified: libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp?rev=302380&r1=302379&r2=302380&view=diff ============================================================================== --- libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp Sun May 7 16:15:28 2017 @@ -16,9 +16,13 @@ #include "test_macros.h" +// NOTE: On Windows the function `test_is_function<void()>` and +// `test_is_function<void() noexcept> has the same mangled despite being +// a distinct instantiation. This causes Clang to emit an error. However +// structs do not have this problem. + template <class T> -void test_is_function() -{ +struct test_is_function { static_assert( std::is_function<T>::value, ""); static_assert( std::is_function<const T>::value, ""); static_assert( std::is_function<volatile T>::value, ""); @@ -29,11 +33,10 @@ void test_is_function() static_assert( std::is_function_v<volatile T>, ""); static_assert( std::is_function_v<const volatile T>, ""); #endif -} +}; template <class T> -void test_is_not_function() -{ +struct test_is_not_function { static_assert(!std::is_function<T>::value, ""); static_assert(!std::is_function<const T>::value, ""); static_assert(!std::is_function<volatile T>::value, ""); @@ -44,7 +47,7 @@ void test_is_not_function() static_assert(!std::is_function_v<volatile T>, ""); static_assert(!std::is_function_v<const volatile T>, ""); #endif -} +}; class Empty { Modified: libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp?rev=302380&r1=302379&r2=302380&view=diff ============================================================================== --- libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp Sun May 7 16:15:28 2017 @@ -14,9 +14,12 @@ #include <type_traits> #include "test_macros.h" +// NOTE: On Windows the function `test_is_member_function<void()>` and +// `test_is_member_function<void() noexcept> has the same mangled despite being +// a distinct instantiation. This causes Clang to emit an error. However +// structs do not have this problem. template <class T> -void test_member_function_pointer_imp() -{ +struct test_member_function_pointer_imp { static_assert(!std::is_void<T>::value, ""); #if TEST_STD_VER > 11 static_assert(!std::is_null_pointer<T>::value, ""); @@ -33,16 +36,16 @@ void test_member_function_pointer_imp() static_assert(!std::is_union<T>::value, ""); static_assert(!std::is_class<T>::value, ""); static_assert(!std::is_function<T>::value, ""); -} +}; template <class T> -void test_member_function_pointer() +struct test_member_function_pointer : + test_member_function_pointer_imp<T>, + test_member_function_pointer_imp<const T>, + test_member_function_pointer_imp<volatile T>, + test_member_function_pointer_imp<const volatile T> { - test_member_function_pointer_imp<T>(); - test_member_function_pointer_imp<const T>(); - test_member_function_pointer_imp<volatile T>(); - test_member_function_pointer_imp<const volatile T>(); -} +}; class Class { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits