aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorno-author <no-author@gcc.gnu.org>2003-04-09 19:29:57 +0000
committerno-author <no-author@gcc.gnu.org>2003-04-09 19:29:57 +0000
commit2233db991a473be23972dcb59220f7d895fce4d1 (patch)
tree3eb28905397dc86c65462094834eb4dfc5ebd35e /gcc
parentadebcbd3f3664d601412d2d5f5fe55476dc23043 (diff)
This commit was manufactured by cvs2svn to create branch
'tree-ssa-20020619-branch'. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/tree-ssa-20020619-branch@65403 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20030408-1.c69
-rw-r--r--gcc/testsuite/gcc.dg/builtins-10.c54
-rw-r--r--gcc/testsuite/gcc.dg/builtins-11.c46
-rw-r--r--gcc/testsuite/gcc.dg/builtins-9.c103
-rw-r--r--gcc/testsuite/gcc.dg/noncompile/init-4.c3
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-10.c15
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-11.c23
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-9.c15
8 files changed, 328 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/20030408-1.c b/gcc/testsuite/gcc.c-torture/execute/20030408-1.c
new file mode 100644
index 00000000000..c1d102c2650
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20030408-1.c
@@ -0,0 +1,69 @@
+/* PR optimization/8634 */
+/* Contributed by Glen Nakamura <glen at imodulo dot com> */
+
+extern void abort (void);
+
+struct foo {
+ char a, b, c, d, e, f, g, h, i, j;
+};
+
+int test1 ()
+{
+ const char X[8] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' };
+ char buffer[8];
+ __builtin_memcpy (buffer, X, 8);
+ if (buffer[0] != 'A' || buffer[1] != 'B'
+ || buffer[2] != 'C' || buffer[3] != 'D'
+ || buffer[4] != 'E' || buffer[5] != 'F'
+ || buffer[6] != 'G' || buffer[7] != 'H')
+ abort ();
+ return 0;
+}
+
+int test2 ()
+{
+ const char X[10] = { 'A', 'B', 'C', 'D', 'E' };
+ char buffer[10];
+ __builtin_memcpy (buffer, X, 10);
+ if (buffer[0] != 'A' || buffer[1] != 'B'
+ || buffer[2] != 'C' || buffer[3] != 'D'
+ || buffer[4] != 'E' || buffer[5] != '\0'
+ || buffer[6] != '\0' || buffer[7] != '\0'
+ || buffer[8] != '\0' || buffer[9] != '\0')
+ abort ();
+ return 0;
+}
+
+int test3 ()
+{
+ const struct foo X = { a : 'A', c : 'C', e : 'E', g : 'G', i : 'I' };
+ char buffer[10];
+ __builtin_memcpy (buffer, &X, 10);
+ if (buffer[0] != 'A' || buffer[1] != '\0'
+ || buffer[2] != 'C' || buffer[3] != '\0'
+ || buffer[4] != 'E' || buffer[5] != '\0'
+ || buffer[6] != 'G' || buffer[7] != '\0'
+ || buffer[8] != 'I' || buffer[9] != '\0')
+ abort ();
+ return 0;
+}
+
+int test4 ()
+{
+ const struct foo X = { .b = 'B', .d = 'D', .f = 'F', .h = 'H' , .j = 'J' };
+ char buffer[10];
+ __builtin_memcpy (buffer, &X, 10);
+ if (buffer[0] != '\0' || buffer[1] != 'B'
+ || buffer[2] != '\0' || buffer[3] != 'D'
+ || buffer[4] != '\0' || buffer[5] != 'F'
+ || buffer[6] != '\0' || buffer[7] != 'H'
+ || buffer[8] != '\0' || buffer[9] != 'J')
+ abort ();
+ return 0;
+}
+
+int main ()
+{
+ test1 (); test2 (); test3 (); test4 ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/builtins-10.c b/gcc/testsuite/gcc.dg/builtins-10.c
new file mode 100644
index 00000000000..9e5a4583fc3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/builtins-10.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 2003 Free Software Foundation.
+
+ Check that constant folding of built-in math functions doesn't
+ break anything and produces the expected results.
+
+ Written by Roger Sayle, 2nd April 2003. */
+
+/* { dg-do link } */
+/* { dg-options "-O2 -ffast-math" } */
+
+extern void link_error(void);
+
+extern double exp(double);
+extern double log(double);
+extern double sqrt(double);
+extern double pow(double,double);
+
+void test(double x)
+{
+ if (sqrt(pow(x,4.0)) != x*x)
+ link_error ();
+
+ if (pow(sqrt(x),4.0) != x*x)
+ link_error ();
+
+ if (pow(pow(x,4.0),0.25) != x)
+ link_error ();
+}
+
+void test2(double x, double y, double z)
+{
+ if (sqrt(pow(x,y)) != pow(x,y*0.5))
+ link_error ();
+
+ if (log(pow(x,y)) != y*log(x))
+ link_error ();
+
+ if (pow(exp(x),y) != exp(x*y))
+ link_error ();
+
+ if (pow(sqrt(x),y) != pow(x,y*0.5))
+ link_error ();
+
+ if (pow(pow(x,y),z) != pow(x,y*z))
+ link_error ();
+}
+
+int main()
+{
+ test (2.0);
+ test2 (2.0, 3.0, 4.0);
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/builtins-11.c b/gcc/testsuite/gcc.dg/builtins-11.c
new file mode 100644
index 00000000000..a2ff257b9ee
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/builtins-11.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 2003 Free Software Foundation.
+
+ Check that constant folding of built-in math functions doesn't
+ break anything and produces the expected results.
+
+ Written by Roger Sayle, 5th April 2003. */
+
+/* { dg-do link } */
+/* { dg-options "-O2 -ffast-math" } */
+
+extern void link_error(void);
+
+extern double exp(double);
+extern double sqrt(double);
+extern double pow(double,double);
+
+void test(double x, double y, double z)
+{
+ if (sqrt(x)*sqrt(x) != x)
+ link_error ();
+
+ if (sqrt(x)*sqrt(y) != sqrt(x*y))
+ link_error ();
+
+ if (exp(x)*exp(y) != exp(x+y))
+ link_error ();
+
+ if (pow(x,y)*pow(z,y) != pow(z*x,y))
+ link_error ();
+
+ if (pow(x,y)*pow(x,z) != pow(x,y+z))
+ link_error ();
+
+ if (x/exp(y) != x*exp(-y))
+ link_error ();
+
+ if (x/pow(y,z) != x*pow(y,-z))
+ link_error ();
+}
+
+int main()
+{
+ test (2.0, 3.0, 4.0);
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/builtins-9.c b/gcc/testsuite/gcc.dg/builtins-9.c
new file mode 100644
index 00000000000..108e0d2f11e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/builtins-9.c
@@ -0,0 +1,103 @@
+/* Copyright (C) 2003 Free Software Foundation.
+
+ Check that constant folding of built-in math functions doesn't
+ break anything.
+
+ Written by Roger Sayle, 2nd April 2003. */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math" } */
+
+extern double log(double);
+extern double exp(double);
+extern double sqrt(double);
+extern double pow(double,double);
+
+extern float logf(float);
+extern float expf(float);
+extern float sqrtf(float);
+extern float powf(float,float);
+
+extern long double logl(long double);
+extern long double expl(long double);
+extern long double sqrtl(long double);
+extern long double powl(long double,long double);
+
+
+double test1(double x, double y)
+{
+ return log(pow(x,y));
+}
+
+double test2(double x, double y)
+{
+ return sqrt(pow(x,y));
+}
+
+double test3(double x, double y)
+{
+ return pow(exp(x),y);
+}
+
+double test4(double x, double y)
+{
+ return pow(sqrt(x),y);
+}
+
+double test5(double x, double y, double z)
+{
+ return pow(pow(x,y),z);
+}
+
+
+float test1f(float x, float y)
+{
+ return logf(powf(x,y));
+}
+
+float test2f(float x, float y)
+{
+ return sqrtf(powf(x,y));
+}
+
+float test3f(float x, float y)
+{
+ return powf(expf(x),y);
+}
+
+float test4f(float x, float y)
+{
+ return powf(sqrtf(x),y);
+}
+
+float test5f(float x, float y, float z)
+{
+ return powf(powf(x,y),z);
+}
+
+
+long double test1l(long double x, long double y)
+{
+ return logl(powl(x,y));
+}
+
+long double test2l(long double x, long double y)
+{
+ return sqrtl(powl(x,y));
+}
+
+long double test3l(long double x, long double y)
+{
+ return powl(expl(x),y);
+}
+
+long double test4l(long double x, long double y)
+{
+ return powl(sqrtl(x),y);
+}
+
+long double test5l(long double x, long double y, long double z)
+{
+ return powl(powl(x,y),z);
+}
+
diff --git a/gcc/testsuite/gcc.dg/noncompile/init-4.c b/gcc/testsuite/gcc.dg/noncompile/init-4.c
new file mode 100644
index 00000000000..906c115b8cc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/noncompile/init-4.c
@@ -0,0 +1,3 @@
+struct a { char *b; } c[D] /* { dg-error "undeclared" } */
+ = /* { dg-error "storage size" } */
+ { { "" } } ; /* { dg-warning "braces around scalar initializer|near" } */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-10.c b/gcc/testsuite/gcc.misc-tests/gcov-10.c
new file mode 100644
index 00000000000..bd1d418f378
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-10.c
@@ -0,0 +1,15 @@
+/* Test gcov block mode. */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+int main ()
+{
+ unsigned ix, jx = 0;
+
+ for (ix = 10; ix--;) if (ix & 1) jx++; /* count(11) */
+
+ return jx != 5;
+}
+
+/* { dg-final { run-gcov { -a gcov-10.c } } } */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-11.c b/gcc/testsuite/gcc.misc-tests/gcov-11.c
new file mode 100644
index 00000000000..a1037a552a9
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-11.c
@@ -0,0 +1,23 @@
+/* Test gcov block mode. */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+int one = 1; /* subvert constant folder. */
+int zero = 0;
+
+int foo (int ix)
+{
+ return ix & 1 ? one : zero; /* count(10) */
+}
+
+int main ()
+{
+ unsigned ix, jx = 0;
+
+ for (ix = 10; ix--;) jx += foo (ix); /* count(11) */
+
+ return jx != 5;
+}
+
+/* { dg-final { run-gcov { -a gcov-11.c } } } */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-9.c b/gcc/testsuite/gcc.misc-tests/gcov-9.c
new file mode 100644
index 00000000000..6e1b4a85c0c
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-9.c
@@ -0,0 +1,15 @@
+/* Test gcov block mode. */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+int main ()
+{
+ unsigned ix;
+
+ for (ix = 10; ix--;); /* count(11) */
+
+ return 0;
+}
+
+/* { dg-final { run-gcov { -a gcov-9.c } } } */