This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: __builtin_huge_val, __builtin_inf, and std::numeric_limits


On Thu, Sep 05, 2002 at 12:59:48AM +0100, Joseph S. Myers wrote:
> >         * builtin-types.def (BT_FN_FLOAT): New.
> >         (BT_FN_DOUBLE, BT_FN_LONG_DOUBLE): New.
> >         * builtins.def (BUILT_IN_INF, BUILT_IN_INFF, BUILT_IN_INFL,
> >         BUILT_IN_HUGE_VAL, BUILT_IN_HUGE_VALF, BUILT_IN_HUGE_VALL): New.
> >         * builtins.c (fold_builtin_inf): New.
> >         (fold_builtin): Call it.
> >         * real.c (ereal_inf): New.
> >         * real.h: Declare it.
> >         * doc/extend.texi: Document new builtins.
> 
> Testcases needed.

Like so.


r~



Index: gcc.c-torture/execute/ieee/inf-1.c
===================================================================
RCS file: gcc.c-torture/execute/ieee/inf-1.c
diff -N gcc.c-torture/execute/ieee/inf-1.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc.c-torture/execute/ieee/inf-1.c	8 Sep 2002 02:14:59 -0000
***************
*** 0 ****
--- 1,35 ----
+ extern void abort (void);
+ 
+ int main()
+ {
+   float fi = __builtin_inff();
+   double di = __builtin_inf();
+   long double li = __builtin_infl();
+ 
+   float fh = __builtin_huge_valf();
+   double dh = __builtin_huge_val();
+   long double lh = __builtin_huge_vall();
+ 
+   if (fi + fi != fi)
+     abort ();
+   if (di + di != di)
+     abort ();
+   if (li + li != li)
+     abort ();
+ 
+   if (fi != fh)
+     abort ();
+   if (di != dh)
+     abort ();
+   if (li != lh)
+     abort ();
+ 
+   if (fi <= 0)
+     abort ();
+   if (di <= 0)
+     abort ();
+   if (li <= 0)
+     abort ();
+ 
+   return 0;
+ }
Index: gcc.dg/builtin-inf-1.c
===================================================================
RCS file: gcc.dg/builtin-inf-1.c
diff -N gcc.dg/builtin-inf-1.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc.dg/builtin-inf-1.c	8 Sep 2002 02:14:59 -0000
***************
*** 0 ****
--- 1,13 ----
+ /* { dg-do compile } */
+ 
+ float fi = __builtin_inff();
+ double di = __builtin_inf();
+ long double li = __builtin_infl();
+ 
+ float fh = __builtin_huge_valf();
+ double dh = __builtin_huge_val();
+ long double lh = __builtin_huge_vall();
+ 
+ /* { dg-warning "does not support infinity" "INF unsupported" { target vax-*-* i370-*-* c4x-*-* } 3 } */
+ /* { dg-warning "does not support infinity" "INF unsupported" { target vax-*-* i370-*-* c4x-*-* } 4 } */
+ /* { dg-warning "does not support infinity" "INF unsupported" { target vax-*-* i370-*-* c4x-*-* } 5 } */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]