From ab6d200976199739ae44493449704475a9f1d1c9 Mon Sep 17 00:00:00 2001 From: davem Date: Fri, 10 May 2002 18:08:32 +0000 Subject: [PATCH] 2002-05-10 David S. Miller * gcc.c-torture/execute/conversion.c: Test long double too. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53368 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/ChangeLog | 4 + gcc/testsuite/gcc.c-torture/execute/conversion.c | 168 +++++++++++++++++++++++ 2 files changed, 172 insertions(+) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 371e523957e..c66c70f16b2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2002-05-10 David S. Miller + + * gcc.c-torture/execute/conversion.c: Test long double too. + 2002-05-09 Jakub Jelinek * lib/g77.exp (g77_link_flags): Append all multilib dirs containing diff --git a/gcc/testsuite/gcc.c-torture/execute/conversion.c b/gcc/testsuite/gcc.c-torture/execute/conversion.c index 79ed3c7bfe9..44c84e18083 100644 --- a/gcc/testsuite/gcc.c-torture/execute/conversion.c +++ b/gcc/testsuite/gcc.c-torture/execute/conversion.c @@ -22,6 +22,13 @@ u2d(u) return u; } +long double +u2ld(u) + unsigned int u; +{ + return u; +} + float s2f(s) int s; @@ -36,6 +43,13 @@ s2d(s) return s; } +long double +s2ld(s) + int s; +{ + return s; +} + int fnear (float x, float y) { @@ -50,6 +64,13 @@ dnear (double x, double y) return t == 0 || x / t > 100000000000000.0; } +int +ldnear (double x, double y) +{ + double t = x - y; + return t == 0 || x / t > 100000000000000000000000000000000.0; +} + test_integer_to_float() { if (u2f(0U) != (float) 0U) /* 0 */ @@ -70,6 +91,15 @@ test_integer_to_float() if (u2d(~((~0U) >> 1)) != (double) ~((~0U) >> 1)) /* 0x80000000 */ abort(); + if (u2ld(0U) != (long double) 0U) /* 0 */ + abort(); + if (!ldnear (u2ld(~0U), (long double) ~0U)) /* 0xffffffff */ + abort(); + if (!ldnear (u2ld((~0U) >> 1),(long double) ((~0U) >> 1))) /* 0x7fffffff */ + abort(); + if (u2ld(~((~0U) >> 1)) != (long double) ~((~0U) >> 1)) /* 0x80000000 */ + abort(); + if (s2f(0) != (float) 0) /* 0 */ abort(); if (!fnear (s2f(~0), (float) ~0)) /* 0xffffffff */ @@ -87,6 +117,15 @@ test_integer_to_float() abort(); if (s2d((int)~((~0U) >> 1)) != (double)(int)~((~0U) >> 1)) /* 0x80000000 */ abort(); + + if (s2ld(0) != (long double) 0) /* 0 */ + abort(); + if (!ldnear (s2ld(~0), (long double) ~0)) /* 0xffffffff */ + abort(); + if (!ldnear (s2ld((int)((~0U) >> 1)), (long double)(int)((~0U) >> 1))) /* 0x7fffffff */ + abort(); + if (s2ld((int)~((~0U) >> 1)) != (long double)(int)~((~0U) >> 1)) /* 0x80000000 */ + abort(); } #if __GNUC__ @@ -104,6 +143,13 @@ ull2d(u) return u; } +long double +ull2ld(u) + unsigned long long int u; +{ + return u; +} + float sll2f(s) long long int s; @@ -118,6 +164,13 @@ sll2d(s) return s; } +long double +sll2ld(s) + long long int s; +{ + return s; +} + test_longlong_integer_to_float() { if (ull2f(0ULL) != (float) 0ULL) /* 0 */ @@ -147,6 +200,15 @@ test_longlong_integer_to_float() if (ull2d(~((~0ULL) >> 1)) != (double) ~((~0ULL) >> 1)) /* 0x80000000 */ abort(); + if (ull2ld(0ULL) != (long double) 0ULL) /* 0 */ + abort(); + if (ull2ld(~0ULL) != (long double) ~0ULL) /* 0xffffffff */ + abort(); + if (ull2ld((~0ULL) >> 1) != (long double) ((~0ULL) >> 1)) /* 0x7fffffff */ + abort(); + if (ull2ld(~((~0ULL) >> 1)) != (long double) ~((~0ULL) >> 1)) /* 0x80000000 */ + abort(); + if (sll2f(0LL) != (float) 0LL) /* 0 */ abort(); if (sll2f(~0LL) != (float) ~0LL) /* 0xffffffff */ @@ -164,6 +226,15 @@ test_longlong_integer_to_float() abort(); if (! dnear (sll2d((long long int)~((~0ULL) >> 1)), (double)(long long int)~((~0ULL) >> 1))) /* 0x80000000 */ abort(); + + if (sll2ld(0LL) != (long double) 0LL) /* 0 */ + abort(); + if (sll2ld(~0LL) != (long double) ~0LL) /* 0xffffffff */ + abort(); + if (!ldnear (sll2ld((long long int)((~0ULL) >> 1)), (long double)(long long int)((~0ULL) >> 1))) /* 0x7fffffff */ + abort(); + if (! ldnear (sll2ld((long long int)~((~0ULL) >> 1)), (long double)(long long int)~((~0ULL) >> 1))) /* 0x80000000 */ + abort(); } #endif @@ -179,6 +250,12 @@ d2u(double d) return (unsigned) d; } +unsigned int +ld2u(long double d) +{ + return (unsigned) d; +} + int f2s(float f) { @@ -191,6 +268,12 @@ d2s(double d) return (int) d; } +int +ld2s(long double d) +{ + return (int) d; +} + test_float_to_integer() { if (f2u(0.0) != 0) @@ -226,6 +309,25 @@ test_float_to_integer() abort(); } + /* These tests require long double precision, so for hosts that don't offer + that much precision, just ignore these test. */ + if (sizeof (long double) >= 8) { + if (ld2u(0.0) != 0) + abort(); + if (ld2u(0.999) != 0) + abort(); + if (ld2u(1.0) != 1) + abort(); + if (ld2u(1.99) != 1) + abort(); + if (ld2u((long double) (~0U)) != ~0U) /* 0xffffffff */ + abort(); + if (ld2u((long double) ((~0U) >> 1)) != (~0U) >> 1) /* 0x7fffffff */ + abort(); + if (ld2u((long double) ~((~0U) >> 1)) != ~((~0U) >> 1)) /* 0x80000000 */ + abort(); + } + if (f2s(0.0) != 0) abort(); if (f2s(0.999) != 0) @@ -265,6 +367,29 @@ test_float_to_integer() if (d2s((double)(int)~((~0U) >> 1)) != (int)~((~0U) >> 1)) /* 0x80000000 */ abort(); } + + /* These tests require long double precision, so for hosts that don't offer + that much precision, just ignore these test. */ + if (sizeof (long double) >= 8) { + if (ld2s(0.0) != 0) + abort(); + if (ld2s(0.999) != 0) + abort(); + if (ld2s(1.0) != 1) + abort(); + if (ld2s(1.99) != 1) + abort(); + if (ld2s(-0.999) != 0) + abort(); + if (ld2s(-1.0) != -1) + abort(); + if (ld2s(-1.99) != -1) + abort(); + if (ld2s((long double) ((~0U) >> 1)) != (~0U) >> 1) /* 0x7fffffff */ + abort(); + if (ld2s((long double)(int)~((~0U) >> 1)) != (int)~((~0U) >> 1)) /* 0x80000000 */ + abort(); + } } #if __GNUC__ @@ -280,6 +405,12 @@ d2ull(double d) return (unsigned long long int) d; } +unsigned long long int +ld2ull(long double d) +{ + return (unsigned long long int) d; +} + long long int f2sll(float f) { @@ -292,6 +423,12 @@ d2sll(double d) return (long long int) d; } +long long int +ld2sll(long double d) +{ + return (long long int) d; +} + test_float_to_longlong_integer() { if (f2ull(0.0) != 0LL) @@ -322,6 +459,20 @@ test_float_to_longlong_integer() if (d2ull((double) ~((~0ULL) >> 1)) != ~((~0ULL) >> 1)) /* 0x80000000 */ abort(); + if (ld2ull(0.0) != 0LL) + abort(); + if (ld2ull(0.999) != 0LL) + abort(); + if (ld2ull(1.0) != 1LL) + abort(); + if (ld2ull(1.99) != 1LL) + abort(); + if (ld2ull((long double) ((~0ULL) >> 1)) != (~0ULL) >> 1 && /* 0x7fffffff */ + ld2ull((long double) ((~0ULL) >> 1)) != ((~0ULL) >> 1) + 1) + abort(); + if (ld2ull((long double) ~((~0ULL) >> 1)) != ~((~0ULL) >> 1)) /* 0x80000000 */ + abort(); + if (f2sll(0.0) != 0LL) abort(); @@ -356,6 +507,23 @@ test_float_to_longlong_integer() abort(); if (d2sll((double)(long long int)~((~0ULL) >> 1)) != (long long int)~((~0ULL) >> 1)) /* 0x80000000 */ abort(); + + if (ld2sll(0.0) != 0LL) + abort(); + if (ld2sll(0.999) != 0LL) + abort(); + if (ld2sll(1.0) != 1LL) + abort(); + if (ld2sll(1.99) != 1LL) + abort(); + if (ld2sll(-0.999) != 0LL) + abort(); + if (ld2sll(-1.0) != -1LL) + abort(); + if (ld2sll(-1.99) != -1LL) + abort(); + if (ld2sll((long double)(long long int)~((~0ULL) >> 1)) != (long long int)~((~0ULL) >> 1)) /* 0x80000000 */ + abort(); } #endif -- 2.11.4.GIT