OSDN Git Service

(fold, COND_EXPR case): All simplified results
[pf3gnuchains/gcc-fork.git] / gcc / enquire.c
index 3c647ba..d9e16f1 100644 (file)
    Don't declare malloc, instead cast the value, Richard Stallman, Nov 91.
    Include sys/types.h before signal.h, Apr 92.
    Support NO_LONG_DOUBLE_IO in f_define and f_rep; new fn fake_f_rep, Apr 92.
+   Enclose -f output in #ifndef _FLOAT_H___, Richard Stallman, May 92.
+
+   Add #undef before every #define, Jim Wilson, Dec 92.
+
+   Changes by Paul Eggert, installed Feb 93:
+   (fake_f_rep): Clear all of u, initially.  Make the ints in u unsigned.
+   (f_define): Use ordinary constants for long double
+   if it's same width as double.  Make __convert_long_double_i unsigned.
+   Richard Stallman, May 93:
+   In F_check, check NO_LONG_DOUBLE_IO.
 
    COMPILING
    With luck and a following wind, just the following will work:
 #include <setjmp.h>
 #endif
 
-/* Kludge around the possiblity that <stdio.h> includes <limits.h> */
+/* Kludge around the possibility that <stdio.h> includes <limits.h> */
 #ifdef CHAR_BIT
 #undef CHAR_BIT
 #undef CHAR_MAX
@@ -682,6 +692,10 @@ int main(argc, argv) int argc; char *argv[]; {
 
        if (L) printf("%slimits.h%s\n", co, oc);
        if (F) printf("%sfloat.h%s\n", co, oc);
+       if (F) {
+               printf ("#ifndef _FLOAT_H___\n");
+               printf ("#define _FLOAT_H___\n");
+       }
 #ifdef ID
        printf("%sProduced on %s by enquire version %s, CWI, Amsterdam%s\n",
               co, ID, VERSION, oc);
@@ -751,6 +765,9 @@ int main(argc, argv) int argc; char *argv[]; {
                        co, (total+511)/512, oc);
        }
 #endif
+       if (F) {
+               printf ("#endif %s _FLOAT_H___%s\n", co, oc);
+       }
        farewell(bugs);
        return bugs; /* To keep compilers and lint happy */
 }
@@ -772,6 +789,7 @@ Procedure i_define(desc, extra, sort, name, val, lim, req, mark)
      char *desc, *extra, *sort, *name; long val, lim, req; char *mark; {
        /* Produce a #define for a signed int type */
        describe(desc, extra);
+       printf("#undef %s%s\n", sort, name);
        if (val >= 0) {
                printf("#define %s%s %ld%s\n", sort, name, val, mark);
        } else if (val + lim < 0) {
@@ -799,6 +817,7 @@ Procedure u_define(desc, extra, sort, name, val, req, mark)
      char *desc, *extra, *sort, *name; unsigned long val, req; char *mark; {
        /* Produce a #define for an unsigned value */
        describe(desc, extra);
+       printf("#undef %s%s\n", sort, name);
        printf("#define %s%s %lu%s%s\n", sort, name, val, U, mark);
        if (val != req) {
                printf("%s*** Verify failed for above #define!\n", co);
@@ -813,15 +832,17 @@ Procedure f_define(desc, extra, sort, name, precision, val, mark)
      Long_double val; char *mark; {
        /* Produce a #define for a float/double/long double */
        describe(desc, extra);
+       printf ("#undef %s%s\n", sort, name);
        if (stdc) {
 #ifdef NO_LONG_DOUBLE_IO
                static int union_defined = 0;
-               if (!strcmp(sort, "LDBL")) {
+               if (sizeof(double) != sizeof(Long_double)
+                   && !strcmp(sort, "LDBL")) {
                        if (!union_defined) {
                                printf("#ifndef __LDBL_UNION__\n");
                                printf("#define __LDBL_UNION__\n");
                                printf("union __convert_long_double {\n");
-                               printf("  int __convert_long_double_i[4];\n");
+                               printf("  unsigned __convert_long_double_i[4];\n");
                                printf("  long double __convert_long_double_d;\n");
                                printf("};\n");
                                printf("#endif\n");
@@ -892,14 +913,15 @@ int exponent(x, fract, exp) Long_double x; double *fract; int *exp; {
 
 /* Print a value of type TYPE with value VAL,
    assuming that sprintf can't handle this type properly (without truncation).
-   We create an expession that uses type casting to create the value from
+   We create an expression that uses type casting to create the value from
    a bit pattern.  */
 
 char *fake_f_rep(type, val) char *type; Long_double val; {
        static char buf[1024];
-       union { int i[4]; Long_double ld;} u;
+       union { unsigned int i[4]; Long_double ld;} u;
+       u.i[0] = u.i[1] = u.i[2] = u.i[3] = 0;
        u.ld = val;
-       sprintf(buf, "(((union __convert_long_double) {0x%x, 0x%x, 0x%x, 0x%x}).__convert_long_double_d)",
+       sprintf(buf, "(__extension__ ((union __convert_long_double) {0x%x, 0x%x, 0x%x, 0x%x}).__convert_long_double_d)",
                u.i[0], u.i[1], u.i[2], u.i[3]);
        return buf;
 }
@@ -2126,13 +2148,23 @@ Procedure F_check(precision, val1) int precision; Long_double val1; {
           that sscanf read the number back identically. Harsh yes, but
           sometimes you've got to be cruel to be kind.
        */
-       Long_double new1;
        Number val, new, diff;
        double rem;
        int e;
        char *rep;
        char *f2;
 
+#ifdef NO_LONG_DOUBLE_IO
+       double new1;
+       /* On the Sun 3, sscanf clobbers 4 words,
+          which leads to a crash when this function tries to return.  */
+       f2= "%le";   /* Input */
+       /* It is no use checking long doubles if we can't
+          read and write them.  */
+       if (sizeof (Number) > sizeof(double))
+         return;
+#else
+       Long_double new1;
        if (sizeof(double) == sizeof(Long_double)) {
                /* Assume they're the same, and use non-stdc format */
                /* This is for stdc compilers using non-stdc libraries */
@@ -2141,6 +2173,7 @@ Procedure F_check(precision, val1) int precision; Long_double val1; {
                /* It had better support Le then */
                f2= "%Le";
        }
+#endif
        val= val1;
        rep= f_rep(precision, (Long_double) val);
        if (setjmp(lab)==0) {