From 92c7bc2abc9f7e1753f520b83fa857675388cbf8 Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Fri, 23 Jan 2004 18:37:16 +0000 Subject: [PATCH] * gcc.dg/builtins-29.c: New test case. From-SVN: r76444 --- gcc/ChangeLog | 2 - gcc/testsuite/ChangeLog | 4 ++ gcc/testsuite/gcc.dg/builtins-29.c | 96 ++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/builtins-29.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 94a3436da3e..84fa8aa9098 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -36,8 +36,6 @@ round, roundf and roundl. (fold_builtin): Call fold_builtin_round for BUILT_IN_ROUND{,F,L}. - * gcc.dg/builtins-29.c: New test case. - 2004-01-23 Alexandre Oliva PR optimization/13819 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 848ca88e605..0e37a5880c6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2004-01-23 Roger Sayle + + * gcc.dg/builtins-29.c: New test case. + 2004-01-23 Zack Weinberg PR 18314 diff --git a/gcc/testsuite/gcc.dg/builtins-29.c b/gcc/testsuite/gcc.dg/builtins-29.c new file mode 100644 index 00000000000..30f9bad4ef7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtins-29.c @@ -0,0 +1,96 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Check that constant folding of round, roundf and roundl math functions + doesn't break anything and produces the expected results. + + Written by Roger Sayle, 22nd January 2004. */ + +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +extern void link_error(void); + +extern double round(double); +extern float roundf(float); +extern long double roundl(long double); + +void test() +{ + if (round (0.0) != 0.0) + link_error (); + if (round (6.0) != 6.0) + link_error (); + if (round (-8.0) != -8.0) + link_error (); + + if (round (3.2) != 3.0) + link_error (); + if (round (-2.8) != -3.0) + link_error (); + if (round (0.01) != 0.0) + link_error (); + if (round (-0.7) != -1.0) + link_error (); + + if (round (2.5) != 3.0) + link_error (); + if (round (-1.5) != -2.0) + link_error (); +} + +void testf() +{ + if (roundf (0.0f) != 0.0f) + link_error (); + if (roundf (6.0f) != 6.0f) + link_error (); + if (roundf (-8.0f) != -8.0f) + link_error (); + + if (roundf (3.2f) != 3.0f) + link_error (); + if (roundf (-2.8f) != -3.0f) + link_error (); + if (roundf (0.01f) != 0.0f) + link_error (); + if (roundf (-0.7f) != -1.0f) + link_error (); + + if (roundf (2.5f) != 3.0f) + link_error (); + if (roundf (-1.5f) != -2.0f) + link_error (); +} + +void testl() +{ + if (roundl (0.0l) != 0.0l) + link_error (); + if (roundl (6.0l) != 6.0l) + link_error (); + if (roundl (-8.0l) != -8.0l) + link_error (); + + if (roundl (3.2l) != 3.0l) + link_error (); + if (roundl (-2.8l) != -3.0l) + link_error (); + if (roundl (0.01l) != 0.0l) + link_error (); + if (roundl (-0.7l) != -1.0l) + link_error (); + + if (roundl (2.5l) != 3.0l) + link_error (); + if (roundl (-1.5l) != -2.0l) + link_error (); +} + +int main() +{ + test (); + testf (); + testl (); + return 0; +} +