Hi mclow.lists,
http://llvm.org/bugs/show_bug.cgi?id=19921
This patch affects std::complexes additional overloads for arg, conj, imag,
norm, proj and real.
For overloads now only participate in overload resolution if they are called
with an arithmetic type.
Previously they could be called with types that were convertible to arithmetic
types.
The arg and proj functions had to be had to be treated differently than the
test of the overloads since the body of their function needs to differ
depending on what type was passed it.
http://reviews.llvm.org/D4447
Files:
include/complex
test/numerics/complex.number/cmplx.over/arg.convertible/double.fail.cpp
test/numerics/complex.number/cmplx.over/arg.convertible/float.fail.cpp
test/numerics/complex.number/cmplx.over/arg.convertible/int.fail.cpp
test/numerics/complex.number/cmplx.over/arg.convertible/long_double.fail.cpp
test/numerics/complex.number/cmplx.over/conj.convertible/double.fail.cpp
test/numerics/complex.number/cmplx.over/conj.convertible/float.fail.cpp
test/numerics/complex.number/cmplx.over/conj.convertible/int.fail.cpp
test/numerics/complex.number/cmplx.over/conj.convertible/long_double.fail.cpp
test/numerics/complex.number/cmplx.over/imag.convertible/double.fail.cpp
test/numerics/complex.number/cmplx.over/imag.convertible/float.fail.cpp
test/numerics/complex.number/cmplx.over/imag.convertible/int.fail.cpp
test/numerics/complex.number/cmplx.over/imag.convertible/long_double.fail.cpp
test/numerics/complex.number/cmplx.over/norm.convertible/double.fail.cpp
test/numerics/complex.number/cmplx.over/norm.convertible/float.fail.cpp
test/numerics/complex.number/cmplx.over/norm.convertible/int.fail.cpp
test/numerics/complex.number/cmplx.over/norm.convertible/long_double.fail.cpp
test/numerics/complex.number/cmplx.over/proj.convertible/double.fail.cpp
test/numerics/complex.number/cmplx.over/proj.convertible/float.fail.cpp
test/numerics/complex.number/cmplx.over/proj.convertible/int.fail.cpp
test/numerics/complex.number/cmplx.over/proj.convertible/long_double.fail.cpp
test/numerics/complex.number/cmplx.over/real.convertible/double.fail.cpp
test/numerics/complex.number/cmplx.over/real.convertible/float.fail.cpp
test/numerics/complex.number/cmplx.over/real.convertible/int.fail.cpp
test/numerics/complex.number/cmplx.over/real.convertible/long_double.fail.cpp
Index: include/complex
===================================================================
--- include/complex
+++ include/complex
@@ -789,45 +789,41 @@
// 26.3.7 values:
-// real
+template <class _Tp, bool = is_integral<_Tp>::value,
+ bool = is_floating_point<_Tp>::value
+ >
+struct __libcpp_complex_overload_traits {};
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_Tp
-real(const complex<_Tp>& __c)
+// Integral Types
+template <class _Tp>
+struct __libcpp_complex_overload_traits<_Tp, true, false>
{
- return __c.real();
-}
+ typedef double _ValueType;
+ typedef complex<double> _ComplexType;
+};
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-long double
-real(long double __re)
+// Floating point types
+template <class _Tp>
+struct __libcpp_complex_overload_traits<_Tp, false, true>
{
- return __re;
-}
+ typedef _Tp _ValueType;
+ typedef complex<_Tp> _ComplexType;
+};
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-double
-real(double __re)
-{
- return __re;
-}
+// real
template<class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-typename enable_if
-<
- is_integral<_Tp>::value,
- double
->::type
-real(_Tp __re)
+_Tp
+real(const complex<_Tp>& __c)
{
- return __re;
+ return __c.real();
}
+template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-float
-real(float __re)
+typename __libcpp_complex_overload_traits<_Tp>::_ValueType
+real(_Tp __re)
{
return __re;
}
@@ -842,35 +838,10 @@
return __c.imag();
}
+template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-long double
-imag(long double __re)
-{
- return 0;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-double
-imag(double __re)
-{
- return 0;
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-typename enable_if
-<
- is_integral<_Tp>::value,
- double
->::type
-imag(_Tp __re)
-{
- return 0;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-float
-imag(float __re)
+typename __libcpp_complex_overload_traits<_Tp>::_ValueType
+imag(_Tp __re)
{
return 0;
}
@@ -895,25 +866,22 @@
return atan2(__c.imag(), __c.real());
}
+template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
-long double
-arg(long double __re)
+typename enable_if<
+ is_same<_Tp, long double>::value,
+ long double
+>::type
+arg(_Tp __re)
{
return atan2l(0.L, __re);
}
-inline _LIBCPP_INLINE_VISIBILITY
-double
-arg(double __re)
-{
- return atan2(0., __re);
-}
-
template<class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
- is_integral<_Tp>::value,
+ is_integral<_Tp>::value || is_same<_Tp, double>::value,
double
>::type
arg(_Tp __re)
@@ -921,9 +889,13 @@
return atan2(0., __re);
}
+template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
-float
-arg(float __re)
+typename enable_if<
+ is_same<_Tp, float>::value,
+ float
+>::type
+arg(_Tp __re)
{
return atan2f(0.F, __re);
}
@@ -942,37 +914,13 @@
return __c.real() * __c.real() + __c.imag() * __c.imag();
}
+template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
-long double
-norm(long double __re)
-{
- return __re * __re;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-double
-norm(double __re)
-{
- return __re * __re;
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- is_integral<_Tp>::value,
- double
->::type
+typename __libcpp_complex_overload_traits<_Tp>::_ValueType
norm(_Tp __re)
{
- return (double)__re * __re;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-float
-norm(float __re)
-{
- return __re * __re;
+ typedef typename __libcpp_complex_overload_traits<_Tp>::_ValueType _ValueType;
+ return static_cast<_ValueType>(__re) * __re;
}
// conj
@@ -985,38 +933,16 @@
return complex<_Tp>(__c.real(), -__c.imag());
}
+template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
-complex<long double>
-conj(long double __re)
-{
- return complex<long double>(__re);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-complex<double>
-conj(double __re)
-{
- return complex<double>(__re);
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- is_integral<_Tp>::value,
- complex<double>
->::type
+typename __libcpp_complex_overload_traits<_Tp>::_ComplexType
conj(_Tp __re)
{
- return complex<double>(__re);
+ typedef typename __libcpp_complex_overload_traits<_Tp>::_ComplexType _ComplexType;
+ return _ComplexType(__re);
}
-inline _LIBCPP_INLINE_VISIBILITY
-complex<float>
-conj(float __re)
-{
- return complex<float>(__re);
-}
+
// proj
@@ -1031,44 +957,33 @@
return __r;
}
+template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
-complex<long double>
-proj(long double __re)
-{
- if (isinf(__re))
- __re = abs(__re);
- return complex<long double>(__re);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-complex<double>
-proj(double __re)
+typename enable_if
+<
+ is_floating_point<_Tp>::value,
+ typename __libcpp_complex_overload_traits<_Tp>::_ComplexType
+>::type
+proj(_Tp __re)
{
if (isinf(__re))
__re = abs(__re);
- return complex<double>(__re);
+ return complex<_Tp>(__re);
}
-template<class _Tp>
+template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value,
- complex<double>
+ typename __libcpp_complex_overload_traits<_Tp>::_ComplexType
>::type
proj(_Tp __re)
{
- return complex<double>(__re);
+ typedef typename __libcpp_complex_overload_traits<_Tp>::_ComplexType _ComplexType;
+ return _ComplexType(__re);
}
-inline _LIBCPP_INLINE_VISIBILITY
-complex<float>
-proj(float __re)
-{
- if (isinf(__re))
- __re = abs(__re);
- return complex<float>(__re);
-}
// polar
Index: test/numerics/complex.number/cmplx.over/arg.convertible/double.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/arg.convertible/double.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// arg(T x);
+
+#include <complex>
+
+struct double_type
+{
+ operator double() const { return 1; }
+};
+
+
+int main()
+{
+ double_type v;
+ std::arg(v);
+}
Index: test/numerics/complex.number/cmplx.over/arg.convertible/float.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/arg.convertible/float.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// arg(T x);
+
+#include <complex>
+
+struct float_type
+{
+ operator float() const { return 1; }
+};
+
+
+int main()
+{
+ float_type v;
+ std::arg(v);
+}
Index: test/numerics/complex.number/cmplx.over/arg.convertible/int.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/arg.convertible/int.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// arg(T x);
+
+#include <complex>
+
+struct integral_type
+{
+ operator int() const { return 1; }
+};
+
+
+int main()
+{
+ integral_type v;
+ std::arg(v);
+}
Index: test/numerics/complex.number/cmplx.over/arg.convertible/long_double.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/arg.convertible/long_double.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// arg(T x);
+
+#include <complex>
+
+struct long_double_type
+{
+ operator long double() const { return 1; }
+};
+
+
+int main()
+{
+ long_double_type v;
+ std::arg(v);
+}
Index: test/numerics/complex.number/cmplx.over/conj.convertible/double.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/conj.convertible/double.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// complex<T>
+// conj(T x);
+
+#include <complex>
+
+struct double_type
+{
+ operator double() const { return 1; }
+};
+
+
+int main()
+{
+ double_type v;
+ std::conj(v);
+}
Index: test/numerics/complex.number/cmplx.over/conj.convertible/float.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/conj.convertible/float.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// complex<T>
+// conj(T x);
+
+#include <complex>
+
+struct float_type
+{
+ operator float() const { return 1; }
+};
+
+
+int main()
+{
+ float_type v;
+ std::conj(v);
+}
Index: test/numerics/complex.number/cmplx.over/conj.convertible/int.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/conj.convertible/int.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// complex<T>
+// conj(T x);
+
+#include <complex>
+
+struct integral_type
+{
+ operator int() const { return 1; }
+};
+
+
+int main()
+{
+ integral_type v;
+ std::conj(v);
+}
Index: test/numerics/complex.number/cmplx.over/conj.convertible/long_double.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/conj.convertible/long_double.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// complex<T>
+// conj(T x);
+
+#include <complex>
+
+struct long_double_type
+{
+ operator long double() const { return 1; }
+};
+
+
+int main()
+{
+ long_double_type v;
+ std::conj(v);
+}
Index: test/numerics/complex.number/cmplx.over/imag.convertible/double.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/imag.convertible/double.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// imag(T x);
+
+#include <complex>
+
+struct double_type
+{
+ operator double() const { return 1; }
+};
+
+
+int main()
+{
+ double_type v;
+ std::imag(v);
+}
Index: test/numerics/complex.number/cmplx.over/imag.convertible/float.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/imag.convertible/float.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// imag(T x);
+
+#include <complex>
+
+struct float_type
+{
+ operator float() const { return 1; }
+};
+
+
+int main()
+{
+ float_type v;
+ std::imag(v);
+}
Index: test/numerics/complex.number/cmplx.over/imag.convertible/int.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/imag.convertible/int.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// imag(T x);
+
+#include <complex>
+
+struct integral_type
+{
+ operator int() const { return 1; }
+};
+
+
+int main()
+{
+ integral_type v;
+ std::imag(v);
+}
Index: test/numerics/complex.number/cmplx.over/imag.convertible/long_double.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/imag.convertible/long_double.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// imag(T x);
+
+#include <complex>
+
+struct long_double_type
+{
+ operator long double() const { return 1; }
+};
+
+
+int main()
+{
+ long_double_type v;
+ std::imag(v);
+}
Index: test/numerics/complex.number/cmplx.over/norm.convertible/double.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/norm.convertible/double.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// norm(T x);
+
+#include <complex>
+
+struct double_type
+{
+ operator double() const { return 1; }
+};
+
+
+int main()
+{
+ double_type v;
+ std::norm(v);
+}
Index: test/numerics/complex.number/cmplx.over/norm.convertible/float.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/norm.convertible/float.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// norm(T x);
+
+#include <complex>
+
+struct float_type
+{
+ operator float() const { return 1; }
+};
+
+
+int main()
+{
+ float_type v;
+ std::norm(v);
+}
Index: test/numerics/complex.number/cmplx.over/norm.convertible/int.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/norm.convertible/int.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// norm(T x);
+
+#include <complex>
+
+struct integral_type
+{
+ operator int() const { return 1; }
+};
+
+
+int main()
+{
+ integral_type v;
+ std::norm(v);
+}
Index: test/numerics/complex.number/cmplx.over/norm.convertible/long_double.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/norm.convertible/long_double.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// norm(T x);
+
+#include <complex>
+
+struct long_double_type
+{
+ operator long double() const { return 1; }
+};
+
+
+int main()
+{
+ long_double_type v;
+ std::norm(v);
+}
Index: test/numerics/complex.number/cmplx.over/proj.convertible/double.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/proj.convertible/double.fail.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+
+// template<Arithmetic T>
+// complex<T>
+// proj(T x);
+
+#include <complex>
+
+struct double_type
+{
+ operator double() const { return 1; }
+};
+
+
+int main()
+{
+ double_type v;
+ std::proj(v);
+}
Index: test/numerics/complex.number/cmplx.over/proj.convertible/float.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/proj.convertible/float.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// complex<T>
+// proj(T x);
+
+#include <complex>
+
+struct float_type
+{
+ operator float() const { return 1; }
+};
+
+
+int main()
+{
+ float_type v;
+ std::proj(v);
+}
Index: test/numerics/complex.number/cmplx.over/proj.convertible/int.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/proj.convertible/int.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// complex<T>
+// proj(T x);
+
+#include <complex>
+
+struct integral_type
+{
+ operator int() const { return 1; }
+};
+
+
+int main()
+{
+ integral_type v;
+ std::proj(v);
+}
Index: test/numerics/complex.number/cmplx.over/proj.convertible/long_double.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/proj.convertible/long_double.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// complex<T>
+// proj(T x);
+
+#include <complex>
+
+struct long_double_type
+{
+ operator long double() const { return 1; }
+};
+
+
+int main()
+{
+ long_double_type v;
+ std::proj(v);
+}
Index: test/numerics/complex.number/cmplx.over/real.convertible/double.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/real.convertible/double.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// real(T x);
+
+#include <complex>
+
+struct double_type
+{
+ operator double() const { return 1; }
+};
+
+
+int main()
+{
+ double_type v;
+ std::real(v);
+}
Index: test/numerics/complex.number/cmplx.over/real.convertible/float.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/real.convertible/float.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// real(T x);
+
+#include <complex>
+
+struct float_type
+{
+ operator float() const { return 1; }
+};
+
+
+int main()
+{
+ float_type v;
+ std::real(v);
+}
Index: test/numerics/complex.number/cmplx.over/real.convertible/int.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/real.convertible/int.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// real(T x);
+
+#include <complex>
+
+struct integral_type
+{
+ operator int() const { return 1; }
+};
+
+int main()
+{
+ integral_type v;
+ std::real(v);
+}
Index: test/numerics/complex.number/cmplx.over/real.convertible/long_double.fail.cpp
===================================================================
--- /dev/null
+++ test/numerics/complex.number/cmplx.over/real.convertible/long_double.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// real(T x);
+
+#include <complex>
+
+struct long_double_type
+{
+ operator long double() const { return 1; }
+};
+
+
+int main()
+{
+ long_double_type v;
+ std::real(v);
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits