SH (and I'm sure others) has some multilibs (like -m2a-single-only)
where sizeof(double) is 4, which breaks some testcases.  Here's a
patch which adds checks for small doubles (and small long doubles),
and adjusts some of the tests which depend on large doubles.
Comments?  Ok to apply?


        * lib/target-supports.exp (check_effective_target_double64): New.
        (check_effective_target_double64plus): New.
        (check_effective_target_large_double): New.
        * gcc.dg/Wconversion-real-integer.c: Require double64plus.
        * gcc.dg/div-double-1.c: Likewise.
        * gcc.dg/Wconversion-real.c: Require large_double.
        * gcc.dg/cdce1.c: Require large_double instead of checking targets.

        * gcc.c-torture/execute/ieee/unsafe-fp-assoc-1.c: Skip if
        doubles are too small.

        * gcc.c-torture/execute/ieee/20010226-1.c: Mark all floating point
        constants as long.

        * gcc.dg/torture/fp-int-convert-long-double.c (main): Check
        long double vs long long sizes.


Index: gcc.c-torture/execute/ieee/unsafe-fp-assoc-1.c
===================================================================
--- gcc.c-torture/execute/ieee/unsafe-fp-assoc-1.c      (revision 146652)
+++ gcc.c-torture/execute/ieee/unsafe-fp-assoc-1.c      (working copy)
@@ -29,9 +29,11 @@ void func ( double x )
        }
      return;
 }
 
 int main()
 {
+       if (sizeof (double) == 4)
+               return 0;
        func((double)1.00);
        return 0;
 }
Index: gcc.c-torture/execute/ieee/20010226-1.c
===================================================================
--- gcc.c-torture/execute/ieee/20010226-1.c     (revision 146652)
+++ gcc.c-torture/execute/ieee/20010226-1.c     (working copy)
@@ -1,23 +1,23 @@
 #include <float.h>
 
-long double dfrom = 1.1;
+long double dfrom = 1.1L;
 long double m1;
 long double m2;
 unsigned long mant_long;
 
 int main()
 {
   /* Some targets don't support a conforming long double type.  This is
      common with very small parts which set long double == float.   Look
      to see if the type has at least 32 bits of precision.  */
   if (LDBL_EPSILON > 0x1p-31L)
     return 0;
 
-  m1 = dfrom / 2.0;
-  m2 = m1 * 4294967296.0;
+  m1 = dfrom / 2.0L;
+  m2 = m1 * 4294967296.0L;
   mant_long = ((unsigned long) m2) & 0xffffffff;
 
   if (mant_long == 0x8ccccccc)
     return 0;
   else
     abort();
Index: gcc.dg/Wconversion-real.c
===================================================================
--- gcc.dg/Wconversion-real.c   (revision 146652)
+++ gcc.dg/Wconversion-real.c   (working copy)
@@ -1,11 +1,12 @@
 /* Test for diagnostics for Wconversion for floating-point.  */
 
 /* { dg-do compile } */
 /* { dg-skip-if "doubles are floats" { "avr-*-*" } { "*" } { "" } } */
 /* { dg-options "-std=c99 -Wconversion" } */
+/* { dg-require-effective-target large_double } */
 
 float  vfloat;
 double vdouble;
 long double vlongdouble;
 
 void ffloat (float f);
Index: gcc.dg/cdce1.c
===================================================================
--- gcc.dg/cdce1.c      (revision 146652)
+++ gcc.dg/cdce1.c      (working copy)
@@ -1,11 +1,11 @@
 /* { dg-do  run  } */
-/* { dg-skip-if "doubles are floats" { "avr-*-*" "m32c-*-*" } { "*" } { "" } } 
*/
 /* { dg-options "-O2 -fmath-errno -fdump-tree-cdce-details  -lm" } */
 /* { dg-final { scan-tree-dump  "cdce1.c:16: note: function call is 
shrink-wrapped into error conditions\."  "cdce" } } */
 /* { dg-final { cleanup-tree-dump "cdce" } } */
+/* { dg-require-effective-target large_double } */
 
 #include <stdlib.h>
 #include <math.h>
 #include <errno.h>
 int total_err_count = 0;
 double foo_opt (int x, double y) __attribute__((noinline));
Index: gcc.dg/torture/fp-int-convert-long-double.c
===================================================================
--- gcc.dg/torture/fp-int-convert-long-double.c (revision 146652)
+++ gcc.dg/torture/fp-int-convert-long-double.c (working copy)
@@ -10,9 +10,12 @@ int
 main (void)
 {
   TEST_I_F(signed char, unsigned char, long double, LDBL_MANT_DIG);
   TEST_I_F(signed short, unsigned short, long double, LDBL_MANT_DIG);
   TEST_I_F(signed int, unsigned int, long double, LDBL_MANT_DIG);
   TEST_I_F(signed long, unsigned long, long double, LDBL_MANT_DIG);
-  TEST_I_F(signed long long, unsigned long long, long double, LDBL_MANT_DIG);
+  if (sizeof(long double) > sizeof(long long))
+    {
+      TEST_I_F(signed long long, unsigned long long, long double, 
LDBL_MANT_DIG);
+    }
   exit (0);
 }
Index: gcc.dg/Wconversion-real-integer.c
===================================================================
--- gcc.dg/Wconversion-real-integer.c   (revision 146652)
+++ gcc.dg/Wconversion-real-integer.c   (working copy)
@@ -2,12 +2,13 @@
    integers.  */
 
 /* { dg-do compile }
 /* { dg-skip-if "doubles are floats,ints are 16bits" { "avr-*-*" } { "*" } { 
"" } } */
 /* { dg-options "-std=c99 -Wconversion" } */
 /* { dg-require-effective-target int32plus } */
+/* { dg-require-effective-target double64plus } */
 #include <limits.h>
 
 void fsi (signed int x);
 void fui (unsigned int x);
 void ffloat (float x);
 void fdouble (double x);
Index: gcc.dg/div-double-1.c
===================================================================
--- gcc.dg/div-double-1.c       (revision 146652)
+++ gcc.dg/div-double-1.c       (working copy)
@@ -1,8 +1,9 @@
 /* { dg-do run } */
 /* { dg-options "-O2 -ffinite-math-only" } */
+/* { dg-require-effective-target double64plus } */
 
 extern void abort (void);
 
 volatile double a = 2.002083e-146;
 volatile double b;
 
Index: lib/target-supports.exp
===================================================================
--- lib/target-supports.exp     (revision 146652)
+++ lib/target-supports.exp     (working copy)
@@ -1191,12 +1191,39 @@ proc check_effective_target_llp64 { } {
 proc check_effective_target_large_long_double { } {
     return [check_no_compiler_messages large_long_double object {
        int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
     }]
 }
 
+# Return 1 if the target supports double larger than float,
+# 0 otherwise.
+
+proc check_effective_target_large_double { } {
+    return [check_no_compiler_messages large_double object {
+       int dummy[sizeof(double) < sizeof(float) ? 1 : -1];
+    }]
+}
+
+# Return 1 if the target supports double of 64 bits,
+# 0 otherwise.
+
+proc check_effective_target_double64 { } {
+    return [check_no_compiler_messages double64 object {
+       int dummy[sizeof(double) == 8 ? 1 : -1];
+    }]
+}
+
+# Return 1 if the target supports double of at least 64 bits,
+# 0 otherwise.
+
+proc check_effective_target_double64plus { } {
+    return [check_no_compiler_messages double64plus object {
+       int dummy[sizeof(double) >= 8 ? 1 : -1];
+    }]
+}
+
 # Return 1 if the target supports compiling fixed-point,
 # 0 otherwise.
 
 proc check_effective_target_fixed_point { } {
     return [check_no_compiler_messages fixed_point object {
         _Sat _Fract x; _Sat _Accum y;

Reply via email to