Patch by Howard. First part of fix for PR18218; add type traits needed to do the right thing. Fix the problems in PR18218 for isnan and pow - they also need to be applied to the other functions in <cmath>. Also, a drive-by fix for the test - now actually calls test_abs()
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@198431 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -15,6 +15,12 @@
|
||||
|
||||
#include "hexfloat.h"
|
||||
|
||||
// convertible to int/float/double/etc
|
||||
template <class T, int N=0>
|
||||
struct Value {
|
||||
operator T () { return T(N); }
|
||||
};
|
||||
|
||||
void test_abs()
|
||||
{
|
||||
static_assert((std::is_same<decltype(std::abs((float)0)), float>::value), "");
|
||||
@@ -333,7 +339,14 @@ void test_pow()
|
||||
static_assert((std::is_same<decltype(std::powf(0,0)), float>::value), "");
|
||||
static_assert((std::is_same<decltype(std::powl(0,0)), long double>::value), "");
|
||||
static_assert((std::is_same<decltype(std::pow((int)0, (int)0)), double>::value), "");
|
||||
static_assert((std::is_same<decltype(std::pow(Value<int>(), (int)0)), double>::value), "");
|
||||
static_assert((std::is_same<decltype(std::pow(Value<long double>(), (float)0)), long double>::value), "");
|
||||
static_assert((std::is_same<decltype(std::pow((float) 0, Value<float>())), float>::value), "");
|
||||
assert(std::pow(1,1) == 1);
|
||||
assert(std::pow(Value<int,1>(), Value<float,1>()) == 1);
|
||||
assert(std::pow(1.0f, Value<double,1>()) == 1);
|
||||
assert(std::pow(1.0, Value<int,1>()) == 1);
|
||||
assert(std::pow(Value<long double,1>(), 1LL) == 1);
|
||||
}
|
||||
|
||||
void test_sin()
|
||||
@@ -1279,6 +1292,7 @@ void test_trunc()
|
||||
|
||||
int main()
|
||||
{
|
||||
test_abs();
|
||||
test_acos();
|
||||
test_asin();
|
||||
test_atan();
|
||||
|
Reference in New Issue
Block a user