OSDN Git Service

Document LTO behavior with incompatible declarations.
[pf3gnuchains/gcc-fork.git] / libgfortran / mk-kinds-h.sh
1 #!/bin/sh
2 LC_ALL=C
3 export LC_ALL
4
5 compile="$1"
6
7 # Possible types must be listed in ascending order
8 possible_integer_kinds="1 2 4 8 16"
9 possible_real_kinds="4 8 10 16"
10
11
12 largest=""
13 smallest=""
14 for k in $possible_integer_kinds; do
15   echo "  integer (kind=$k) :: i" > tmp$$.f90
16   echo "  i = 1_$k" >> tmp$$.f90
17   echo "  end" >> tmp$$.f90
18   if $compile -S tmp$$.f90 > /dev/null 2>&1; then
19     s=`expr 8 \* $k`
20     largest="$k"
21
22     if [ $s -eq 128 ]; then
23       prefix="__"
24     else
25       prefix=""
26     fi
27
28     if [ "$smallest" = "" ]; then
29         smallest="$k"
30     fi
31
32     echo "typedef ${prefix}int${s}_t GFC_INTEGER_${k};"
33     echo "typedef ${prefix}uint${s}_t GFC_UINTEGER_${k};"
34     echo "typedef GFC_INTEGER_${k} GFC_LOGICAL_${k};"
35     echo "#define HAVE_GFC_LOGICAL_${k}"
36     echo "#define HAVE_GFC_INTEGER_${k}"
37     echo ""
38   fi
39   rm -f tmp$$.*
40 done
41
42 echo "#define GFC_INTEGER_LARGEST GFC_INTEGER_${largest}"
43 echo "#define GFC_UINTEGER_LARGEST GFC_UINTEGER_${largest}"
44 echo "#define GFC_DEFAULT_CHAR ${smallest}"
45 echo ""
46
47
48 for k in $possible_real_kinds; do
49   echo "  real (kind=$k) :: x" > tmp$$.f90
50   echo "  x = 1.0_$k" >> tmp$$.f90
51   echo "  end" >> tmp$$.f90
52   if $compile -S tmp$$.f90 > /dev/null 2>&1; then
53     case $k in
54       4) ctype="float" ; suffix="f" ;;
55       8) ctype="double" ; suffix="" ;;
56       10) ctype="long double" ; suffix="l" ;;
57       16) ctype="long double" ; suffix="l" ;;
58       *) echo "$0: Unknown type" >&2 ; exit 1 ;;
59     esac
60
61     # Check for the value of HUGE
62     echo "print *, huge(0._$k) ; end" > tmq$$.f90
63     huge=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
64                 | sed 's/ *TRANSFER *//' | sed 's/_.*//'`
65     rm -f tmq$$.*
66
67     # Check for the value of DIGITS
68     echo "print *, digits(0._$k) ; end" > tmq$$.f90
69     digits=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
70                 | sed 's/ *TRANSFER *//'`
71     rm -f tmq$$.*
72
73     # Check for the value of RADIX
74     echo "print *, radix(0._$k) ; end" > tmq$$.f90
75     radix=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
76                 | sed 's/ *TRANSFER *//'`
77     rm -f tmq$$.*
78
79     # Output the information we've gathered
80     echo "typedef ${ctype} GFC_REAL_${k};"
81     echo "typedef complex ${ctype} GFC_COMPLEX_${k};"
82     echo "#define HAVE_GFC_REAL_${k}"
83     echo "#define HAVE_GFC_COMPLEX_${k}"
84     echo "#define GFC_REAL_${k}_HUGE ${huge}${suffix}"
85     echo "#define GFC_REAL_${k}_DIGITS ${digits}"
86     echo "#define GFC_REAL_${k}_RADIX ${radix}"
87     echo ""
88   fi
89   rm -f tmp$$.*
90 done
91
92 exit 0