* gcc.dg/builtins-29.c: New test case.
authorRoger Sayle <roger@eyesopen.com>
Fri, 23 Jan 2004 18:37:16 +0000 (18:37 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Fri, 23 Jan 2004 18:37:16 +0000 (18:37 +0000)
From-SVN: r76444

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/builtins-29.c [new file with mode: 0644]

index 94a3436..84fa8aa 100644 (file)
@@ -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  <aoliva@redhat.com>
 
        PR optimization/13819
index 848ca88..0e37a58 100644 (file)
@@ -1,3 +1,7 @@
+2004-01-23  Roger Sayle  <roger@eyesopen.com>
+
+       * gcc.dg/builtins-29.c: New test case.
+
 2004-01-23  Zack Weinberg  <zack@codesourcery.com>
 
        PR 18314
diff --git a/gcc/testsuite/gcc.dg/builtins-29.c b/gcc/testsuite/gcc.dg/builtins-29.c
new file mode 100644 (file)
index 0000000..30f9bad
--- /dev/null
@@ -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;
+}
+