From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; 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. --- gcc/testsuite/gcc.dg/torture/builtin-convert-3.c | 61 ++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/torture/builtin-convert-3.c (limited to 'gcc/testsuite/gcc.dg/torture/builtin-convert-3.c') 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; +} -- cgit v1.2.3