1 /* Header file to the Fortran front-end and runtime library 2 Copyright (C) 2007-2024 Free Software Foundation, Inc. 3 4 This file is part of GCC. 5 6 GCC is free software; you can redistribute it and/or modify it under 7 the terms of the GNU General Public License as published by the Free 8 Software Foundation; either version 3, or (at your option) any later 9 version. 10 11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY 12 WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with GCC; see the file COPYING3. If not see 18 <http://www.gnu.org/licenses/>. */ 19 20 21 /* Flags to specify which standard/extension contains a feature. 22 Note that no features were obsoleted nor deleted in F2003 nor in F2023. 23 Nevertheless, some features available in F2018 are prohibited in F2023. 24 Please remember to keep those definitions in sync with 25 gfortran.texi. */ 26 #define GFC_STD_F2023_DEL (1<<13) /* Prohibited in F2023. */ 27 #define GFC_STD_F2023 (1<<12) /* New in F2023. */ 28 #define GFC_STD_F2018_DEL (1<<11) /* Deleted in F2018. */ 29 #define GFC_STD_F2018_OBS (1<<10) /* Obsolescent in F2018. */ 30 #define GFC_STD_F2018 (1<<9) /* New in F2018. */ 31 #define GFC_STD_F2008_OBS (1<<8) /* Obsolescent in F2008. */ 32 #define GFC_STD_F2008 (1<<7) /* New in F2008. */ 33 #define GFC_STD_LEGACY (1<<6) /* Backward compatibility. */ 34 #define GFC_STD_GNU (1<<5) /* GNU Fortran extension. */ 35 #define GFC_STD_F2003 (1<<4) /* New in F2003. */ 36 #define GFC_STD_F95 (1<<3) /* New in F95. */ 37 #define GFC_STD_F95_DEL (1<<2) /* Deleted in F95. */ 38 #define GFC_STD_F95_OBS (1<<1) /* Obsolescent in F95. */ 39 #define GFC_STD_F77 (1<<0) /* Included in F77, but not deleted or 40 obsolescent in later standards. */ 41 42 /* Combinations of the above flags that specify which classes of features 43 * are allowed with a certain -std option. */ 44 #define GFC_STD_OPT_F95 (GFC_STD_F77 | GFC_STD_F95 | GFC_STD_F95_OBS \ 45 | GFC_STD_F2008_OBS | GFC_STD_F2018_OBS \ 46 | GFC_STD_F2018_DEL | GFC_STD_F2023_DEL) 47 #define GFC_STD_OPT_F03 (GFC_STD_OPT_F95 | GFC_STD_F2003) 48 #define GFC_STD_OPT_F08 (GFC_STD_OPT_F03 | GFC_STD_F2008) 49 #define GFC_STD_OPT_F18 ((GFC_STD_OPT_F08 | GFC_STD_F2018) \ 50 & (~GFC_STD_F2018_DEL)) 51 #define GFC_STD_OPT_F23 ((GFC_STD_OPT_F18 | GFC_STD_F2023) \ 52 & (~GFC_STD_F2023_DEL)) 53 54 /* Bitmasks for the various FPE that can be enabled. These need to be straight integers 55 e.g., 8 instead of (1<<3), because they will be included in Fortran source. */ 56 #define GFC_FPE_INVALID 1 57 #define GFC_FPE_DENORMAL 2 58 #define GFC_FPE_ZERO 4 59 #define GFC_FPE_OVERFLOW 8 60 #define GFC_FPE_UNDERFLOW 16 61 #define GFC_FPE_INEXACT 32 62 63 /* Defines for floating-point rounding modes. */ 64 #define GFC_FPE_DOWNWARD 1 65 #define GFC_FPE_TONEAREST 2 66 #define GFC_FPE_TOWARDZERO 3 67 #define GFC_FPE_UPWARD 4 68 #define GFC_FPE_AWAY 5 69 70 /* Size of the buffer required to store FPU state for any target. 71 In particular, this has to be larger than fenv_t on all glibc targets. 72 Currently, the winner is x86_64 with 32 bytes. */ 73 #define GFC_FPE_STATE_BUFFER_SIZE 32 74 75 /* Bitmasks for the various runtime checks that can be enabled. */ 76 #define GFC_RTCHECK_BOUNDS (1<<0) 77 #define GFC_RTCHECK_ARRAY_TEMPS (1<<1) 78 #define GFC_RTCHECK_RECURSION (1<<2) 79 #define GFC_RTCHECK_DO (1<<3) 80 #define GFC_RTCHECK_POINTER (1<<4) 81 #define GFC_RTCHECK_MEM (1<<5) 82 #define GFC_RTCHECK_BITS (1<<6) 83 #define GFC_RTCHECK_ALL (GFC_RTCHECK_BOUNDS | GFC_RTCHECK_ARRAY_TEMPS \ 84 | GFC_RTCHECK_RECURSION | GFC_RTCHECK_DO \ 85 | GFC_RTCHECK_POINTER | GFC_RTCHECK_MEM \ 86 | GFC_RTCHECK_BITS) 87 88 /* Special unit numbers used to convey certain conditions. Numbers -4 89 thru -9 available. NEWUNIT values start at -10. */ 90 #define GFC_INTERNAL_UNIT -1 /* KIND=1 Internal Unit. */ 91 #define GFC_INTERNAL_UNIT4 -2 /* KIND=4 Internal Unit. */ 92 #define GFC_INVALID_UNIT -3 93 94 /* Possible values for the CONVERT I/O specifier. */ 95 /* Keep in sync with GFC_FLAG_CONVERT_* in gcc/flag-types.h. */ 96 typedef enum 97 { 98 GFC_CONVERT_NONE = -1, 99 GFC_CONVERT_NATIVE = 0, 100 GFC_CONVERT_SWAP, 101 GFC_CONVERT_BIG, 102 GFC_CONVERT_LITTLE, 103 GFC_CONVERT_R16_IEEE = 4, 104 GFC_CONVERT_R16_IEEE_SWAP, 105 GFC_CONVERT_R16_IEEE_BIG, 106 GFC_CONVERT_R16_IEEE_LITTLE, 107 GFC_CONVERT_R16_IBM = 8, 108 GFC_CONVERT_R16_IBM_SWAP, 109 GFC_CONVERT_R16_IBM_BIG, 110 GFC_CONVERT_R16_IBM_LITTLE, 111 } 112 unit_convert; 113 114 115 /* Runtime errors. */ 116 typedef enum 117 { 118 LIBERROR_FIRST = -3, /* Marker for the first error. */ 119 LIBERROR_EOR = -2, /* End of record, must be negative. */ 120 LIBERROR_END = -1, /* End of file, must be negative. */ 121 LIBERROR_OK = 0, /* Indicates success, must be zero. */ 122 LIBERROR_OS = 5000, /* OS error, more info in errno. */ 123 LIBERROR_OPTION_CONFLICT, 124 LIBERROR_BAD_OPTION, 125 LIBERROR_MISSING_OPTION, 126 LIBERROR_ALREADY_OPEN, 127 LIBERROR_BAD_UNIT, 128 LIBERROR_FORMAT, 129 LIBERROR_BAD_ACTION, 130 LIBERROR_ENDFILE, 131 LIBERROR_BAD_US, 132 LIBERROR_READ_VALUE, 133 LIBERROR_READ_OVERFLOW, 134 LIBERROR_INTERNAL, 135 LIBERROR_INTERNAL_UNIT, 136 LIBERROR_ALLOCATION, 137 LIBERROR_DIRECT_EOR, 138 LIBERROR_SHORT_RECORD, 139 LIBERROR_CORRUPT_FILE, 140 LIBERROR_INQUIRE_INTERNAL_UNIT, /* Must be different from STAT_STOPPED_IMAGE. */ 141 LIBERROR_BAD_WAIT_ID, 142 LIBERROR_NO_MEMORY, 143 LIBERROR_LAST /* Not a real error, the last error # + 1. */ 144 } 145 libgfortran_error_codes; 146 147 /* Must kept in sync with libgfortran/caf/libcaf.h. */ 148 typedef enum 149 { 150 GFC_STAT_UNLOCKED = 0, 151 GFC_STAT_LOCKED, 152 GFC_STAT_LOCKED_OTHER_IMAGE, 153 GFC_STAT_STOPPED_IMAGE = 6000, /* See LIBERROR_INQUIRE_INTERNAL_UNIT above. */ 154 GFC_STAT_FAILED_IMAGE = 6001 155 } 156 libgfortran_stat_codes; 157 158 typedef enum 159 { 160 GFC_CAF_ATOMIC_ADD = 1, 161 GFC_CAF_ATOMIC_AND, 162 GFC_CAF_ATOMIC_OR, 163 GFC_CAF_ATOMIC_XOR 164 } libcaf_atomic_codes; 165 166 167 /* For CO_REDUCE. */ 168 #define GFC_CAF_BYREF (1<<0) 169 #define GFC_CAF_HIDDENLEN (1<<1) 170 #define GFC_CAF_ARG_VALUE (1<<2) 171 #define GFC_CAF_ARG_DESC (1<<3) 172 173 174 /* Default unit number for preconnected standard input and output. */ 175 #define GFC_STDIN_UNIT_NUMBER 5 176 #define GFC_STDOUT_UNIT_NUMBER 6 177 #define GFC_STDERR_UNIT_NUMBER 0 178 179 /* F2003 onward. For std < F2003, error caught in array.cc(gfc_match_array_ref). */ 180 #define GFC_MAX_DIMENSIONS 15 181 182 #define GFC_DTYPE_RANK_MASK 0x0F 183 #define GFC_DTYPE_TYPE_SHIFT 4 184 #define GFC_DTYPE_TYPE_MASK 0x70 185 #define GFC_DTYPE_SIZE_SHIFT 7 186 187 /* Basic types. BT_VOID is used by ISO C Binding so funcs like c_f_pointer 188 can take any arg with the pointer attribute as a param. These are also 189 used in the run-time library for IO. */ 190 typedef enum 191 { BT_UNKNOWN = 0, BT_INTEGER, BT_LOGICAL, BT_REAL, BT_COMPLEX, 192 BT_DERIVED, BT_CHARACTER, BT_CLASS, BT_PROCEDURE, BT_HOLLERITH, BT_VOID, 193 BT_ASSUMED, BT_UNION, BT_BOZ 194 } 195 bt; 196 197 /* Enumeration of the possible floating-point types. These values 198 correspond to the hidden arguments of the IEEE_CLASS_TYPE 199 derived-type of IEEE_ARITHMETIC. */ 200 201 enum { 202 IEEE_OTHER_VALUE = 0, 203 IEEE_SIGNALING_NAN, 204 IEEE_QUIET_NAN, 205 IEEE_NEGATIVE_INF, 206 IEEE_NEGATIVE_NORMAL, 207 IEEE_NEGATIVE_DENORMAL, 208 IEEE_NEGATIVE_SUBNORMAL = IEEE_NEGATIVE_DENORMAL, 209 IEEE_NEGATIVE_ZERO, 210 IEEE_POSITIVE_ZERO, 211 IEEE_POSITIVE_DENORMAL, 212 IEEE_POSITIVE_SUBNORMAL = IEEE_POSITIVE_DENORMAL, 213 IEEE_POSITIVE_NORMAL, 214 IEEE_POSITIVE_INF 215 }; 216