Author: marshall Date: Mon Apr 10 17:51:07 2017 New Revision: 299894 URL: http://llvm.org/viewvc/llvm-project?rev=299894&view=rev Log: Fix PR#32606: std::decay mishandles abominable function types
Modified: libcxx/trunk/include/type_traits libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp Modified: libcxx/trunk/include/type_traits URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=299894&r1=299893&r2=299894&view=diff ============================================================================== --- libcxx/trunk/include/type_traits (original) +++ libcxx/trunk/include/type_traits Mon Apr 10 17:51:07 2017 @@ -1272,11 +1272,13 @@ template <class _Tp> using remove_all_ex // decay -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS decay -{ -private: - typedef typename remove_reference<_Tp>::type _Up; +template <class _Up, bool> +struct __decay { + typedef typename remove_cv<_Up>::type type; +}; + +template <class _Up> +struct __decay<_Up, true> { public: typedef typename conditional < @@ -1291,6 +1293,15 @@ public: >::type type; }; +template <class _Tp> +struct _LIBCPP_TEMPLATE_VIS decay +{ +private: + typedef typename remove_reference<_Tp>::type _Up; +public: + typedef typename __decay<_Up, __is_referenceable<_Up>::value>::type type; +}; + #if _LIBCPP_STD_VER > 11 template <class _Tp> using decay_t = typename decay<_Tp>::type; #endif Modified: libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp?rev=299894&r1=299893&r2=299894&view=diff ============================================================================== --- libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp Mon Apr 10 17:51:07 2017 @@ -33,4 +33,10 @@ int main() test_decay<int[3], int*>(); test_decay<const int[3], const int*>(); test_decay<void(), void (*)()>(); +#if TEST_STD_VER > 11 + test_decay<int(int) const, int(int) const>(); + test_decay<int(int) volatile, int(int) volatile>(); + test_decay<int(int) &, int(int) &>(); + test_decay<int(int) &&, int(int) &&>(); +#endif } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits