diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.dg/torture/builtin-convert-3.c | |
download | cbb-gcc-4.6.4-upstream.tar.bz2 cbb-gcc-4.6.4-upstream.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.dg/torture/builtin-convert-3.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/builtin-convert-3.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-convert-3.c b/gcc/testsuite/gcc.dg/torture/builtin-convert-3.c new file mode 100644 index 000000000..2034b4190 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/builtin-convert-3.c @@ -0,0 +1,61 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Verify that builtin math functions (with fixed point return types) + are converted to smaller FP types correctly by the compiler. + + Written by Kaveh Ghazi, 2004-05-01. */ + +/* { dg-do link } */ +/* { dg-options "-ffast-math" } */ +/* { dg-add-options c99_runtime } */ + +#include "../builtins-config.h" + +#define PROTOTYPE1_RET(FN, RET) \ + extern RET FN(double); \ + extern RET FN##f(float); \ + extern RET FN##l(long double); + +/* Test converting math builtins to narrower FP types based on if the + argument is a narrower type (perhaps implicitly) cast to a wider + one. */ +#define INNER_CAST1(MATHFN, RET) \ + PROTOTYPE1_RET (MATHFN, RET); \ + extern void link_failure_inner_##MATHFN##l_##MATHFN(void); \ + extern void link_failure_inner_##MATHFN##l_##MATHFN##f(void); \ + extern void link_failure_inner_##MATHFN##_##MATHFN##f(void); \ + if (sizeof (long double) > sizeof (double) \ + && MATHFN##l(d1) != MATHFN(d1)) \ + link_failure_inner_##MATHFN##l_##MATHFN(); \ + if (sizeof (long double) > sizeof (float) \ + && MATHFN##l(f1) != MATHFN##f(f1)) \ + link_failure_inner_##MATHFN##l_##MATHFN##f(); \ + if (sizeof (long double) > sizeof (float) \ + && MATHFN##l((double)f1) != MATHFN##f(f1)) \ + link_failure_inner_##MATHFN##l_##MATHFN##f(); \ + if (sizeof (double) > sizeof (float) \ + && MATHFN(f1) != MATHFN##f(f1)) \ + link_failure_inner_##MATHFN##_##MATHFN##f() + +void __attribute__ ((__noinline__)) test (double d1, float f1) +{ +#ifdef __OPTIMIZE__ +#ifdef HAVE_C99_RUNTIME + /* We're converting to implicitly generated C99 functions. */ + INNER_CAST1 (__builtin_lceil, long); + INNER_CAST1 (__builtin_llceil, long long); + INNER_CAST1 (__builtin_lfloor, long); + INNER_CAST1 (__builtin_llfloor, long long); + INNER_CAST1 (lround, long); + INNER_CAST1 (llround, long long); + INNER_CAST1 (lrint, long); + INNER_CAST1 (llrint, long long); +#endif /* HAVE_C99_RUNTIME */ +#endif /* __OPTIMIZE__ */ +} + +int main (void) +{ + test (1, 2); + return 0; +} |