OSDN Git Service

* common.opt (debug_struct_ordinary, debug_struct_generic): New
[pf3gnuchains/gcc-fork.git] / libgfortran / mk-kinds-h.sh
index 0b8dbc5..98a95ab 100755 (executable)
@@ -44,7 +44,14 @@ echo "#define GFC_UINTEGER_LARGEST GFC_UINTEGER_${largest}"
 echo "#define GFC_DEFAULT_CHAR ${smallest}"
 echo ""
 
-REAL_10_FOUND=
+
+# Get the kind value for long double, so we may disambiguate it
+# from __float128.
+echo "use iso_c_binding; print *, c_long_double ; end" > tmq$$.f90
+long_double_kind=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
+                       | sed 's/ *TRANSFER *//'`
+rm -f tmq$$.*
+
 
 for k in $possible_real_kinds; do
   echo "  real (kind=$k) :: x" > tmp$$.f90
@@ -52,17 +59,18 @@ for k in $possible_real_kinds; do
   echo "  end" >> tmp$$.f90
   if $compile -S tmp$$.f90 > /dev/null 2>&1; then
     case $k in
-      4) ctype="float" ; suffix="f" ;;
-      8) ctype="double" ; suffix="" ;;
-      10) ctype="long double" ; suffix="l" ; REAL_10_FOUND=1 ;;
-      16) ctype="long double"
-         suffix="l"
-         # Disable REAL(16) if it is just __float128
-         # until the library is fixed
-         if [ -n "$REAL_10_FOUND" ]; then
-           continue
-         fi
-         ;;
+      4) ctype="float" ; cplxtype="complex float" ; suffix="f" ;;
+      8) ctype="double" ; cplxtype="complex double" ; suffix="" ;;
+      10) ctype="long double" ; cplxtype="complex long double" ; suffix="l" ;;
+      16) if [ $long_double_kind -eq 10 ]; then
+           ctype="__float128"
+           cplxtype="_Complex float __attribute__((mode(TC)))"
+           suffix="q"
+         else
+           ctype="long double"
+           cplxtype="complex long double"
+           suffix="l"
+         fi ;;
       *) echo "$0: Unknown type" >&2 ; exit 1 ;;
     esac
 
@@ -86,7 +94,7 @@ for k in $possible_real_kinds; do
 
     # Output the information we've gathered
     echo "typedef ${ctype} GFC_REAL_${k};"
-    echo "typedef complex ${ctype} GFC_COMPLEX_${k};"
+    echo "typedef ${cplxtype} GFC_COMPLEX_${k};"
     echo "#define HAVE_GFC_REAL_${k}"
     echo "#define HAVE_GFC_COMPLEX_${k}"
     echo "#define GFC_REAL_${k}_HUGE ${huge}${suffix}"
@@ -103,4 +111,9 @@ for k in $possible_real_kinds; do
   rm -f tmp$$.*
 done
 
+
+# After this, we include a header that can override some of the 
+# autodetected settings.
+echo '#include "kinds-override.h"'
+
 exit 0