]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/fortran/gfortran.h
x86: Optimize aes<aeswideklvariant>u8 a bit, fix whitespace
[thirdparty/gcc.git] / gcc / fortran / gfortran.h
CommitLineData
6de9cd9a 1/* gfortran header file
8d9254fc 2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
6de9cd9a
DN
3 Contributed by Andy Vaught
4
9fc4d79b 5This file is part of GCC.
6de9cd9a 6
9fc4d79b
TS
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
d234d788 9Software Foundation; either version 3, or (at your option) any later
9fc4d79b 10version.
6de9cd9a 11
9fc4d79b
TS
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
6de9cd9a
DN
16
17You should have received a copy of the GNU General Public License
d234d788
NC
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
6de9cd9a
DN
20
21#ifndef GCC_GFORTRAN_H
22#define GCC_GFORTRAN_H
23
24/* It's probably insane to have this large of a header file, but it
25 seemed like everything had to be recompiled anyway when a change
26 was made to a header file, and there were ordering issues with
27 multiple header files. Besides, Microsoft's winnt.h was 250k last
28 time I looked, so by comparison this is perfectly reasonable. */
29
953bee7c
SB
30#ifndef GCC_CORETYPES_H
31#error "gfortran.h must be included after coretypes.h"
32#endif
33
8e54f6d3
MLI
34/* In order for the format checking to accept the Fortran front end
35 diagnostic framework extensions, you must include this file before
36 diagnostic-core.h, not after. We override the definition of GCC_DIAG_STYLE
37 in c-common.h. */
38#undef GCC_DIAG_STYLE
39#define GCC_DIAG_STYLE __gcc_gfc__
40#if defined(GCC_DIAGNOSTIC_CORE_H)
41#error \
42In order for the format checking to accept the Fortran front end diagnostic \
43framework extensions, you must include this file before diagnostic-core.h, \
44not after.
45#endif
46
d74b97cc
FXC
47/* Declarations common to the front-end and library are put in
48 libgfortran/libgfortran_frontend.h */
49#include "libgfortran.h"
50
51
31043f6c 52#include "intl.h"
5868cbf9 53#include "splay-tree.h"
6de9cd9a 54
6de9cd9a
DN
55/* Major control parameters. */
56
1dde8683 57#define GFC_MAX_SYMBOL_LEN 63 /* Must be at least 63 for F2003. */
6de9cd9a 58#define GFC_LETTERS 26 /* Number of letters in the alphabet. */
6de9cd9a 59
07b3bbf2
TK
60#define MAX_SUBRECORD_LENGTH 2147483639 /* 2**31-9 */
61
62
ef144767 63#define gfc_is_whitespace(c) ((c==' ') || (c=='\t') || (c=='\f'))
6de9cd9a 64
f6288c24
FR
65/* Macros to check for groups of structure-like types and flavors since
66 derived types, structures, maps, unions are often treated similarly. */
67#define gfc_bt_struct(t) \
68 ((t) == BT_DERIVED || (t) == BT_UNION)
69#define gfc_fl_struct(f) \
70 ((f) == FL_DERIVED || (f) == FL_UNION || (f) == FL_STRUCT)
71#define case_bt_struct case BT_DERIVED: case BT_UNION
72#define case_fl_struct case FL_DERIVED: case FL_UNION: case FL_STRUCT
73
6de9cd9a
DN
74/* Stringization. */
75#define stringize(x) expand_macro(x)
76#define expand_macro(x) # x
77
df2fba9e 78/* For the runtime library, a standard prefix is a requirement to
6de9cd9a
DN
79 avoid cluttering the namespace with things nobody asked for. It's
80 ugly to look at and a pain to type when you add the prefix by hand,
81 so we hide it behind a macro. */
82#define PREFIX(x) "_gfortran_" x
5b200ac2 83#define PREFIX_LEN 10
6de9cd9a 84
36085529
TB
85/* A prefix for internal variables, which are not user-visible. */
86#if !defined (NO_DOT_IN_LABEL)
87# define GFC_PREFIX(x) "_F." x
88#elif !defined (NO_DOLLAR_IN_LABEL)
89# define GFC_PREFIX(x) "_F$" x
90#else
91# define GFC_PREFIX(x) "_F_" x
92#endif
93
30aabb86
PT
94#define BLANK_COMMON_NAME "__BLNK__"
95
6de9cd9a
DN
96/* Macro to initialize an mstring structure. */
97#define minit(s, t) { s, NULL, t }
98
99/* Structure for storing strings to be matched by gfc_match_string. */
100typedef struct
101{
102 const char *string;
103 const char *mp;
104 int tag;
105}
106mstring;
107
108
944b8b35 109
6de9cd9a
DN
110/*************************** Enums *****************************/
111
ad7ee6f8
JD
112/* Used when matching and resolving data I/O transfer statements. */
113
a79683d5
TS
114enum io_kind
115{ M_READ, M_WRITE, M_PRINT, M_INQUIRE };
ad7ee6f8 116
6de9cd9a 117
696abb30
JD
118/* These are flags for identifying whether we are reading a character literal
119 between quotes or normal source code. */
4d382327 120
a79683d5
TS
121enum gfc_instring
122{ NONSTRING = 0, INSTRING_WARN, INSTRING_NOWARN };
696abb30 123
8f0d39a8
FXC
124/* This is returned by gfc_notification_std to know if, given the flags
125 that were given (-std=, -pedantic) we should issue an error, a warning
126 or nothing. */
127
a79683d5
TS
128enum notification
129{ SILENT, WARNING, ERROR };
8f0d39a8 130
6de9cd9a
DN
131/* Matchers return one of these three values. The difference between
132 MATCH_NO and MATCH_ERROR is that MATCH_ERROR means that a match was
133 successful, but that something non-syntactic is wrong and an error
134 has already been issued. */
135
a79683d5
TS
136enum match
137{ MATCH_NO = 1, MATCH_YES, MATCH_ERROR };
6de9cd9a 138
696abb30 139/* Used for different Fortran source forms in places like scanner.c. */
a79683d5
TS
140enum gfc_source_form
141{ FORM_FREE, FORM_FIXED, FORM_UNKNOWN };
6de9cd9a 142
6de9cd9a 143/* Expression node types. */
a79683d5 144enum expr_t
7e703f01 145 { EXPR_UNKNOWN = 0, EXPR_OP = 1, EXPR_FUNCTION, EXPR_CONSTANT, EXPR_VARIABLE,
713485cc 146 EXPR_SUBSTRING, EXPR_STRUCTURE, EXPR_ARRAY, EXPR_NULL, EXPR_COMPCALL, EXPR_PPC
a79683d5 147};
6de9cd9a
DN
148
149/* Array types. */
a79683d5 150enum array_type
6de9cd9a 151{ AS_EXPLICIT = 1, AS_ASSUMED_SHAPE, AS_DEFERRED,
c62c6622
TB
152 AS_ASSUMED_SIZE, AS_IMPLIED_SHAPE, AS_ASSUMED_RANK,
153 AS_UNKNOWN
a79683d5 154};
6de9cd9a 155
a79683d5
TS
156enum ar_type
157{ AR_FULL = 1, AR_ELEMENT, AR_SECTION, AR_UNKNOWN };
6de9cd9a 158
f3e7b9d6
TB
159/* Statement label types. ST_LABEL_DO_TARGET is used for obsolescent warnings
160 related to shared DO terminations and DO targets which are neither END DO
161 nor CONTINUE; otherwise it is identical to ST_LABEL_TARGET. */
a79683d5 162enum gfc_sl_type
f3e7b9d6 163{ ST_LABEL_UNKNOWN = 1, ST_LABEL_TARGET, ST_LABEL_DO_TARGET,
6de9cd9a 164 ST_LABEL_BAD_TARGET, ST_LABEL_FORMAT
a79683d5 165};
6de9cd9a
DN
166
167/* Intrinsic operators. */
a79683d5 168enum gfc_intrinsic_op
6de9cd9a
DN
169{ GFC_INTRINSIC_BEGIN = 0,
170 INTRINSIC_NONE = -1, INTRINSIC_UPLUS = GFC_INTRINSIC_BEGIN,
171 INTRINSIC_UMINUS, INTRINSIC_PLUS, INTRINSIC_MINUS, INTRINSIC_TIMES,
172 INTRINSIC_DIVIDE, INTRINSIC_POWER, INTRINSIC_CONCAT,
173 INTRINSIC_AND, INTRINSIC_OR, INTRINSIC_EQV, INTRINSIC_NEQV,
3bed9dd0 174 /* ==, /=, >, >=, <, <= */
6de9cd9a 175 INTRINSIC_EQ, INTRINSIC_NE, INTRINSIC_GT, INTRINSIC_GE,
4d382327 176 INTRINSIC_LT, INTRINSIC_LE,
3bed9dd0
DF
177 /* .EQ., .NE., .GT., .GE., .LT., .LE. (OS = Old-Style) */
178 INTRINSIC_EQ_OS, INTRINSIC_NE_OS, INTRINSIC_GT_OS, INTRINSIC_GE_OS,
4d382327 179 INTRINSIC_LT_OS, INTRINSIC_LE_OS,
e73d3ca6 180 INTRINSIC_NOT, INTRINSIC_USER, INTRINSIC_ASSIGN, INTRINSIC_PARENTHESES,
195d1431
PT
181 GFC_INTRINSIC_END, /* Sentinel */
182 /* User defined derived type pseudo operators. These are set beyond the
183 sentinel so that they are excluded from module_read and module_write. */
184 INTRINSIC_FORMATTED, INTRINSIC_UNFORMATTED
a79683d5 185};
6de9cd9a 186
6de9cd9a
DN
187/* This macro is the number of intrinsic operators that exist.
188 Assumptions are made about the numbering of the interface_op enums. */
189#define GFC_INTRINSIC_OPS GFC_INTRINSIC_END
190
191/* Arithmetic results. */
a79683d5 192enum arith
f8e566e5 193{ ARITH_OK = 1, ARITH_OVERFLOW, ARITH_UNDERFLOW, ARITH_NAN,
7318fdca
TK
194 ARITH_DIV0, ARITH_INCOMMENSURATE, ARITH_ASYMMETRIC, ARITH_PROHIBIT,
195 ARITH_WRONGCONCAT
a79683d5 196};
6de9cd9a
DN
197
198/* Statements. */
a79683d5 199enum gfc_statement
6de9cd9a 200{
03af1e4c
DK
201 ST_ARITHMETIC_IF, ST_ALLOCATE, ST_ATTR_DECL, ST_ASSOCIATE,
202 ST_BACKSPACE, ST_BLOCK, ST_BLOCK_DATA,
6de9cd9a
DN
203 ST_CALL, ST_CASE, ST_CLOSE, ST_COMMON, ST_CONTINUE, ST_CONTAINS, ST_CYCLE,
204 ST_DATA, ST_DATA_DECL, ST_DEALLOCATE, ST_DO, ST_ELSE, ST_ELSEIF,
03af1e4c 205 ST_ELSEWHERE, ST_END_ASSOCIATE, ST_END_BLOCK, ST_END_BLOCK_DATA,
4668d6f9
PT
206 ST_ENDDO, ST_IMPLIED_ENDDO, ST_END_FILE, ST_FINAL, ST_FLUSH, ST_END_FORALL,
207 ST_END_FUNCTION, ST_ENDIF, ST_END_INTERFACE, ST_END_MODULE, ST_END_SUBMODULE,
208 ST_END_PROGRAM, ST_END_SELECT, ST_END_SUBROUTINE, ST_END_WHERE, ST_END_TYPE,
209 ST_ENTRY, ST_EQUIVALENCE, ST_ERROR_STOP, ST_EXIT, ST_FORALL, ST_FORALL_BLOCK,
210 ST_FORMAT, ST_FUNCTION, ST_GOTO, ST_IF_BLOCK, ST_IMPLICIT, ST_IMPLICIT_NONE,
211 ST_IMPORT, ST_INQUIRE, ST_INTERFACE, ST_SYNC_ALL, ST_SYNC_MEMORY,
212 ST_SYNC_IMAGES, ST_PARAMETER, ST_MODULE, ST_SUBMODULE, ST_MODULE_PROC,
213 ST_NAMELIST, ST_NULLIFY, ST_OPEN, ST_PAUSE, ST_PRIVATE, ST_PROGRAM, ST_PUBLIC,
214 ST_READ, ST_RETURN, ST_REWIND, ST_STOP, ST_SUBROUTINE, ST_TYPE, ST_USE,
215 ST_WHERE_BLOCK, ST_WHERE, ST_WAIT, ST_WRITE, ST_ASSIGNMENT,
216 ST_POINTER_ASSIGNMENT, ST_SELECT_CASE, ST_SEQUENCE, ST_SIMPLE_IF,
217 ST_STATEMENT_FUNCTION, ST_DERIVED_DECL, ST_LABEL_ASSIGNMENT, ST_ENUM,
218 ST_ENUMERATOR, ST_END_ENUM, ST_SELECT_TYPE, ST_TYPE_IS, ST_CLASS_IS,
70570ec1 219 ST_SELECT_RANK, ST_RANK, ST_STRUCTURE_DECL, ST_END_STRUCTURE,
f6288c24 220 ST_UNION, ST_END_UNION, ST_MAP, ST_END_MAP,
41dbbb37
TS
221 ST_OACC_PARALLEL_LOOP, ST_OACC_END_PARALLEL_LOOP, ST_OACC_PARALLEL,
222 ST_OACC_END_PARALLEL, ST_OACC_KERNELS, ST_OACC_END_KERNELS, ST_OACC_DATA,
223 ST_OACC_END_DATA, ST_OACC_HOST_DATA, ST_OACC_END_HOST_DATA, ST_OACC_LOOP,
224 ST_OACC_END_LOOP, ST_OACC_DECLARE, ST_OACC_UPDATE, ST_OACC_WAIT,
225 ST_OACC_CACHE, ST_OACC_KERNELS_LOOP, ST_OACC_END_KERNELS_LOOP,
62aee289
MR
226 ST_OACC_SERIAL_LOOP, ST_OACC_END_SERIAL_LOOP, ST_OACC_SERIAL,
227 ST_OACC_END_SERIAL, ST_OACC_ENTER_DATA, ST_OACC_EXIT_DATA, ST_OACC_ROUTINE,
4bf9e5a8 228 ST_OACC_ATOMIC, ST_OACC_END_ATOMIC,
20906c66
JJ
229 ST_OMP_ATOMIC, ST_OMP_BARRIER, ST_OMP_CRITICAL, ST_OMP_END_ATOMIC,
230 ST_OMP_END_CRITICAL, ST_OMP_END_DO, ST_OMP_END_MASTER, ST_OMP_END_ORDERED,
231 ST_OMP_END_PARALLEL, ST_OMP_END_PARALLEL_DO, ST_OMP_END_PARALLEL_SECTIONS,
6c7a4dfd
JJ
232 ST_OMP_END_PARALLEL_WORKSHARE, ST_OMP_END_SECTIONS, ST_OMP_END_SINGLE,
233 ST_OMP_END_WORKSHARE, ST_OMP_DO, ST_OMP_FLUSH, ST_OMP_MASTER, ST_OMP_ORDERED,
234 ST_OMP_PARALLEL, ST_OMP_PARALLEL_DO, ST_OMP_PARALLEL_SECTIONS,
235 ST_OMP_PARALLEL_WORKSHARE, ST_OMP_SECTIONS, ST_OMP_SECTION, ST_OMP_SINGLE,
a68ab351 236 ST_OMP_THREADPRIVATE, ST_OMP_WORKSHARE, ST_OMP_TASK, ST_OMP_END_TASK,
dd2fc525
JJ
237 ST_OMP_TASKWAIT, ST_OMP_TASKYIELD, ST_OMP_CANCEL, ST_OMP_CANCELLATION_POINT,
238 ST_OMP_TASKGROUP, ST_OMP_END_TASKGROUP, ST_OMP_SIMD, ST_OMP_END_SIMD,
239 ST_OMP_DO_SIMD, ST_OMP_END_DO_SIMD, ST_OMP_PARALLEL_DO_SIMD,
5f23671d 240 ST_OMP_END_PARALLEL_DO_SIMD, ST_OMP_DECLARE_SIMD, ST_OMP_DECLARE_REDUCTION,
f014c653
JJ
241 ST_OMP_TARGET, ST_OMP_END_TARGET, ST_OMP_TARGET_DATA, ST_OMP_END_TARGET_DATA,
242 ST_OMP_TARGET_UPDATE, ST_OMP_DECLARE_TARGET,
243 ST_OMP_TEAMS, ST_OMP_END_TEAMS, ST_OMP_DISTRIBUTE, ST_OMP_END_DISTRIBUTE,
244 ST_OMP_DISTRIBUTE_SIMD, ST_OMP_END_DISTRIBUTE_SIMD,
245 ST_OMP_DISTRIBUTE_PARALLEL_DO, ST_OMP_END_DISTRIBUTE_PARALLEL_DO,
246 ST_OMP_DISTRIBUTE_PARALLEL_DO_SIMD, ST_OMP_END_DISTRIBUTE_PARALLEL_DO_SIMD,
247 ST_OMP_TARGET_TEAMS, ST_OMP_END_TARGET_TEAMS, ST_OMP_TEAMS_DISTRIBUTE,
248 ST_OMP_END_TEAMS_DISTRIBUTE, ST_OMP_TEAMS_DISTRIBUTE_SIMD,
249 ST_OMP_END_TEAMS_DISTRIBUTE_SIMD, ST_OMP_TARGET_TEAMS_DISTRIBUTE,
250 ST_OMP_END_TARGET_TEAMS_DISTRIBUTE, ST_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD,
251 ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_SIMD, ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO,
252 ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO,
253 ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO,
254 ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO,
255 ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD,
256 ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD,
257 ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD,
258 ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD,
b4c3a85b
JJ
259 ST_OMP_TARGET_PARALLEL, ST_OMP_END_TARGET_PARALLEL,
260 ST_OMP_TARGET_PARALLEL_DO, ST_OMP_END_TARGET_PARALLEL_DO,
261 ST_OMP_TARGET_PARALLEL_DO_SIMD, ST_OMP_END_TARGET_PARALLEL_DO_SIMD,
262 ST_OMP_TARGET_ENTER_DATA, ST_OMP_TARGET_EXIT_DATA,
263 ST_OMP_TARGET_SIMD, ST_OMP_END_TARGET_SIMD,
264 ST_OMP_TASKLOOP, ST_OMP_END_TASKLOOP,
265 ST_OMP_TASKLOOP_SIMD, ST_OMP_END_TASKLOOP_SIMD, ST_OMP_ORDERED_DEPEND,
269322ec 266 ST_OMP_REQUIRES, ST_PROCEDURE, ST_GENERIC, ST_CRITICAL, ST_END_CRITICAL,
5df445a2 267 ST_GET_FCN_CHARACTERISTICS, ST_LOCK, ST_UNLOCK, ST_EVENT_POST,
f8862a1b
DR
268 ST_EVENT_WAIT, ST_FAIL_IMAGE, ST_FORM_TEAM, ST_CHANGE_TEAM,
269 ST_END_TEAM, ST_SYNC_TEAM, ST_NONE
a79683d5 270};
6de9cd9a 271
6de9cd9a
DN
272/* Types of interfaces that we can have. Assignment interfaces are
273 considered to be intrinsic operators. */
a79683d5 274enum interface_type
6de9cd9a
DN
275{
276 INTERFACE_NAMELESS = 1, INTERFACE_GENERIC,
e73d3ca6
PT
277 INTERFACE_INTRINSIC_OP, INTERFACE_USER_OP, INTERFACE_ABSTRACT,
278 INTERFACE_DTIO
a79683d5 279};
6de9cd9a
DN
280
281/* Symbol flavors: these are all mutually exclusive.
f6288c24 282 12 elements = 4 bits. */
a79683d5 283enum sym_flavor
6de9cd9a
DN
284{
285 FL_UNKNOWN = 0, FL_PROGRAM, FL_BLOCK_DATA, FL_MODULE, FL_VARIABLE,
a8b3b0b6 286 FL_PARAMETER, FL_LABEL, FL_PROCEDURE, FL_DERIVED, FL_NAMELIST,
f6288c24 287 FL_UNION, FL_STRUCT, FL_VOID
a79683d5 288};
6de9cd9a
DN
289
290/* Procedure types. 7 elements = 3 bits. */
a79683d5 291enum procedure_type
6de9cd9a
DN
292{ PROC_UNKNOWN, PROC_MODULE, PROC_INTERNAL, PROC_DUMMY,
293 PROC_INTRINSIC, PROC_ST_FUNCTION, PROC_EXTERNAL
a79683d5 294};
6de9cd9a 295
ea20e8be
JW
296/* Intent types. Note that these values are also used in another enum in
297 decl.c (match_attr_spec). */
a79683d5 298enum sym_intent
6de9cd9a 299{ INTENT_UNKNOWN = 0, INTENT_IN, INTENT_OUT, INTENT_INOUT
a79683d5 300};
6de9cd9a
DN
301
302/* Access types. */
a79683d5 303enum gfc_access
5f42ddb0 304{ ACCESS_UNKNOWN = 0, ACCESS_PUBLIC, ACCESS_PRIVATE
a79683d5 305};
6de9cd9a
DN
306
307/* Flags to keep track of where an interface came from.
c73b6478 308 3 elements = 2 bits. */
a79683d5 309enum ifsrc
c73b6478
JW
310{ IFSRC_UNKNOWN = 0, /* Interface unknown, only return type may be known. */
311 IFSRC_DECL, /* FUNCTION or SUBROUTINE declaration. */
312 IFSRC_IFBODY /* INTERFACE statement or PROCEDURE statement
313 with explicit interface. */
a79683d5 314};
6de9cd9a 315
86bf520d 316/* Whether a SAVE attribute was set explicitly or implicitly. */
a79683d5 317enum save_state
5349080d 318{ SAVE_NONE = 0, SAVE_EXPLICIT, SAVE_IMPLICIT
a79683d5 319};
5349080d 320
68034b1b
TS
321/* OpenACC 'routine' directive's level of parallelism. */
322enum oacc_routine_lop
323{ OACC_ROUTINE_LOP_NONE = 0,
324 OACC_ROUTINE_LOP_GANG,
325 OACC_ROUTINE_LOP_WORKER,
326 OACC_ROUTINE_LOP_VECTOR,
e5fd6684
TS
327 OACC_ROUTINE_LOP_SEQ,
328 OACC_ROUTINE_LOP_ERROR
68034b1b
TS
329};
330
6de9cd9a
DN
331/* Strings for all symbol attributes. We use these for dumping the
332 parse tree, in error messages, and also when reading and writing
333 modules. In symbol.c. */
334extern const mstring flavors[];
335extern const mstring procedures[];
336extern const mstring intents[];
337extern const mstring access_types[];
338extern const mstring ifsrc_types[];
ef7236d2 339extern const mstring save_status[];
6de9cd9a 340
e73d3ca6
PT
341/* Strings for DTIO procedure names. In symbol.c. */
342extern const mstring dtio_procs[];
343
344enum dtio_codes
345{ DTIO_RF = 0, DTIO_WF, DTIO_RUF, DTIO_WUF };
346
6de9cd9a
DN
347/* Enumeration of all the generic intrinsic functions. Used by the
348 backend for identification of a function. */
349
cd5ecab6 350enum gfc_isym_id
6de9cd9a
DN
351{
352 /* GFC_ISYM_NONE is used for intrinsics which will never be seen by
df2fba9e 353 the backend (e.g. KIND). */
6de9cd9a 354 GFC_ISYM_NONE = 0,
cd5ecab6 355 GFC_ISYM_ABORT,
6de9cd9a 356 GFC_ISYM_ABS,
a119fc1c 357 GFC_ISYM_ACCESS,
6de9cd9a
DN
358 GFC_ISYM_ACHAR,
359 GFC_ISYM_ACOS,
57391dda 360 GFC_ISYM_ACOSD,
1e399e23 361 GFC_ISYM_ACOSH,
6de9cd9a
DN
362 GFC_ISYM_ADJUSTL,
363 GFC_ISYM_ADJUSTR,
364 GFC_ISYM_AIMAG,
365 GFC_ISYM_AINT,
cd5ecab6 366 GFC_ISYM_ALARM,
6de9cd9a
DN
367 GFC_ISYM_ALL,
368 GFC_ISYM_ALLOCATED,
5d723e54 369 GFC_ISYM_AND,
cd5ecab6 370 GFC_ISYM_ANINT,
6de9cd9a
DN
371 GFC_ISYM_ANY,
372 GFC_ISYM_ASIN,
57391dda 373 GFC_ISYM_ASIND,
1e399e23 374 GFC_ISYM_ASINH,
6de9cd9a
DN
375 GFC_ISYM_ASSOCIATED,
376 GFC_ISYM_ATAN,
377 GFC_ISYM_ATAN2,
57391dda
FR
378 GFC_ISYM_ATAN2D,
379 GFC_ISYM_ATAND,
cd5ecab6 380 GFC_ISYM_ATANH,
7f4aaf91
TB
381 GFC_ISYM_ATOMIC_ADD,
382 GFC_ISYM_ATOMIC_AND,
383 GFC_ISYM_ATOMIC_CAS,
da661a58 384 GFC_ISYM_ATOMIC_DEF,
7f4aaf91
TB
385 GFC_ISYM_ATOMIC_FETCH_ADD,
386 GFC_ISYM_ATOMIC_FETCH_AND,
387 GFC_ISYM_ATOMIC_FETCH_OR,
388 GFC_ISYM_ATOMIC_FETCH_XOR,
389 GFC_ISYM_ATOMIC_OR,
da661a58 390 GFC_ISYM_ATOMIC_REF,
7f4aaf91 391 GFC_ISYM_ATOMIC_XOR,
88a95a11
FXC
392 GFC_ISYM_BGE,
393 GFC_ISYM_BGT,
cd5ecab6 394 GFC_ISYM_BIT_SIZE,
88a95a11
FXC
395 GFC_ISYM_BLE,
396 GFC_ISYM_BLT,
6de9cd9a 397 GFC_ISYM_BTEST,
8a8d1a16
TB
398 GFC_ISYM_CAF_GET,
399 GFC_ISYM_CAF_SEND,
6de9cd9a
DN
400 GFC_ISYM_CEILING,
401 GFC_ISYM_CHAR,
f77b6ca3 402 GFC_ISYM_CHDIR,
a119fc1c 403 GFC_ISYM_CHMOD,
6de9cd9a 404 GFC_ISYM_CMPLX,
a16ee379 405 GFC_ISYM_CO_BROADCAST,
d62cf3df
TB
406 GFC_ISYM_CO_MAX,
407 GFC_ISYM_CO_MIN,
a16ee379 408 GFC_ISYM_CO_REDUCE,
d62cf3df 409 GFC_ISYM_CO_SUM,
b41b2534 410 GFC_ISYM_COMMAND_ARGUMENT_COUNT,
d000aa67
TB
411 GFC_ISYM_COMPILER_OPTIONS,
412 GFC_ISYM_COMPILER_VERSION,
5d723e54 413 GFC_ISYM_COMPLEX,
6de9cd9a 414 GFC_ISYM_CONJG,
cd5ecab6 415 GFC_ISYM_CONVERSION,
6de9cd9a 416 GFC_ISYM_COS,
57391dda 417 GFC_ISYM_COSD,
6de9cd9a 418 GFC_ISYM_COSH,
8e8c2744 419 GFC_ISYM_COTAN,
57391dda 420 GFC_ISYM_COTAND,
6de9cd9a 421 GFC_ISYM_COUNT,
cd5ecab6 422 GFC_ISYM_CPU_TIME,
6de9cd9a 423 GFC_ISYM_CSHIFT,
35059811 424 GFC_ISYM_CTIME,
cadddfdd
TB
425 GFC_ISYM_C_ASSOCIATED,
426 GFC_ISYM_C_F_POINTER,
427 GFC_ISYM_C_F_PROCPOINTER,
428 GFC_ISYM_C_FUNLOC,
429 GFC_ISYM_C_LOC,
048510c8 430 GFC_ISYM_C_SIZEOF,
cd5ecab6 431 GFC_ISYM_DATE_AND_TIME,
6de9cd9a 432 GFC_ISYM_DBLE,
878f88b7 433 GFC_ISYM_DFLOAT,
cd5ecab6 434 GFC_ISYM_DIGITS,
6de9cd9a
DN
435 GFC_ISYM_DIM,
436 GFC_ISYM_DOT_PRODUCT,
437 GFC_ISYM_DPROD,
88a95a11
FXC
438 GFC_ISYM_DSHIFTL,
439 GFC_ISYM_DSHIFTR,
cd5ecab6 440 GFC_ISYM_DTIME,
6de9cd9a 441 GFC_ISYM_EOSHIFT,
cd5ecab6 442 GFC_ISYM_EPSILON,
e8525382
SK
443 GFC_ISYM_ERF,
444 GFC_ISYM_ERFC,
f489fba1 445 GFC_ISYM_ERFC_SCALED,
2bd74949 446 GFC_ISYM_ETIME,
5df445a2 447 GFC_ISYM_EVENT_QUERY,
c14c8155 448 GFC_ISYM_EXECUTE_COMMAND_LINE,
cd5ecab6 449 GFC_ISYM_EXIT,
6de9cd9a
DN
450 GFC_ISYM_EXP,
451 GFC_ISYM_EXPONENT,
cf2b3c22 452 GFC_ISYM_EXTENDS_TYPE_OF,
ef78bc3c 453 GFC_ISYM_FAILED_IMAGES,
35059811 454 GFC_ISYM_FDATE,
f1abbf69 455 GFC_ISYM_FE_RUNTIME_ERROR,
5d723e54
FXC
456 GFC_ISYM_FGET,
457 GFC_ISYM_FGETC,
01ce9e31 458 GFC_ISYM_FINDLOC,
878f88b7 459 GFC_ISYM_FLOAT,
6de9cd9a 460 GFC_ISYM_FLOOR,
cd5ecab6 461 GFC_ISYM_FLUSH,
df65f093 462 GFC_ISYM_FNUM,
5d723e54
FXC
463 GFC_ISYM_FPUT,
464 GFC_ISYM_FPUTC,
6de9cd9a 465 GFC_ISYM_FRACTION,
cd5ecab6
DF
466 GFC_ISYM_FREE,
467 GFC_ISYM_FSEEK,
df65f093 468 GFC_ISYM_FSTAT,
5d723e54 469 GFC_ISYM_FTELL,
7bc19392 470 GFC_ISYM_TGAMMA,
cd5ecab6
DF
471 GFC_ISYM_GERROR,
472 GFC_ISYM_GETARG,
473 GFC_ISYM_GET_COMMAND,
474 GFC_ISYM_GET_COMMAND_ARGUMENT,
a8c60d7f 475 GFC_ISYM_GETCWD,
cd5ecab6
DF
476 GFC_ISYM_GETENV,
477 GFC_ISYM_GET_ENVIRONMENT_VARIABLE,
4c0c6b9f 478 GFC_ISYM_GETGID,
cd5ecab6 479 GFC_ISYM_GETLOG,
4c0c6b9f 480 GFC_ISYM_GETPID,
f8862a1b 481 GFC_ISYM_GET_TEAM,
4c0c6b9f 482 GFC_ISYM_GETUID,
cd5ecab6 483 GFC_ISYM_GMTIME,
f77b6ca3 484 GFC_ISYM_HOSTNM,
cd5ecab6 485 GFC_ISYM_HUGE,
f489fba1 486 GFC_ISYM_HYPOT,
6de9cd9a 487 GFC_ISYM_IACHAR,
195a95c4 488 GFC_ISYM_IALL,
6de9cd9a 489 GFC_ISYM_IAND,
195a95c4 490 GFC_ISYM_IANY,
b41b2534 491 GFC_ISYM_IARGC,
6de9cd9a
DN
492 GFC_ISYM_IBCLR,
493 GFC_ISYM_IBITS,
494 GFC_ISYM_IBSET,
495 GFC_ISYM_ICHAR,
cd5ecab6 496 GFC_ISYM_IDATE,
6de9cd9a 497 GFC_ISYM_IEOR,
f77b6ca3 498 GFC_ISYM_IERRNO,
64f002ed 499 GFC_ISYM_IMAGE_INDEX,
ef78bc3c 500 GFC_ISYM_IMAGE_STATUS,
6de9cd9a
DN
501 GFC_ISYM_INDEX,
502 GFC_ISYM_INT,
bf3fb7e4
FXC
503 GFC_ISYM_INT2,
504 GFC_ISYM_INT8,
6de9cd9a 505 GFC_ISYM_IOR,
195a95c4 506 GFC_ISYM_IPARITY,
2bd74949 507 GFC_ISYM_IRAND,
ae8b8789 508 GFC_ISYM_ISATTY,
419af57c 509 GFC_ISYM_IS_CONTIGUOUS,
bae89173
FXC
510 GFC_ISYM_IS_IOSTAT_END,
511 GFC_ISYM_IS_IOSTAT_EOR,
3d97b1af 512 GFC_ISYM_ISNAN,
6de9cd9a
DN
513 GFC_ISYM_ISHFT,
514 GFC_ISYM_ISHFTC,
cd5ecab6
DF
515 GFC_ISYM_ITIME,
516 GFC_ISYM_J0,
517 GFC_ISYM_J1,
518 GFC_ISYM_JN,
29698e0f 519 GFC_ISYM_JN2,
f77b6ca3 520 GFC_ISYM_KILL,
cd5ecab6 521 GFC_ISYM_KIND,
6de9cd9a 522 GFC_ISYM_LBOUND,
64f002ed 523 GFC_ISYM_LCOBOUND,
414f00e9 524 GFC_ISYM_LEADZ,
6de9cd9a
DN
525 GFC_ISYM_LEN,
526 GFC_ISYM_LEN_TRIM,
88607a9a 527 GFC_ISYM_LGAMMA,
6de9cd9a
DN
528 GFC_ISYM_LGE,
529 GFC_ISYM_LGT,
cd5ecab6 530 GFC_ISYM_LINK,
6de9cd9a
DN
531 GFC_ISYM_LLE,
532 GFC_ISYM_LLT,
83d890b9 533 GFC_ISYM_LOC,
bf3fb7e4 534 GFC_ISYM_LOG,
6de9cd9a
DN
535 GFC_ISYM_LOG10,
536 GFC_ISYM_LOGICAL,
bf3fb7e4 537 GFC_ISYM_LONG,
a119fc1c 538 GFC_ISYM_LSHIFT,
bf3fb7e4 539 GFC_ISYM_LSTAT,
cd5ecab6 540 GFC_ISYM_LTIME,
0d519038 541 GFC_ISYM_MALLOC,
88a95a11
FXC
542 GFC_ISYM_MASKL,
543 GFC_ISYM_MASKR,
6de9cd9a
DN
544 GFC_ISYM_MATMUL,
545 GFC_ISYM_MAX,
cd5ecab6 546 GFC_ISYM_MAXEXPONENT,
6de9cd9a
DN
547 GFC_ISYM_MAXLOC,
548 GFC_ISYM_MAXVAL,
bf3fb7e4
FXC
549 GFC_ISYM_MCLOCK,
550 GFC_ISYM_MCLOCK8,
6de9cd9a 551 GFC_ISYM_MERGE,
88a95a11 552 GFC_ISYM_MERGE_BITS,
6de9cd9a 553 GFC_ISYM_MIN,
cd5ecab6 554 GFC_ISYM_MINEXPONENT,
6de9cd9a
DN
555 GFC_ISYM_MINLOC,
556 GFC_ISYM_MINVAL,
557 GFC_ISYM_MOD,
558 GFC_ISYM_MODULO,
cd5ecab6
DF
559 GFC_ISYM_MOVE_ALLOC,
560 GFC_ISYM_MVBITS,
6de9cd9a 561 GFC_ISYM_NEAREST,
cd5ecab6 562 GFC_ISYM_NEW_LINE,
6de9cd9a 563 GFC_ISYM_NINT,
0cd0559e 564 GFC_ISYM_NORM2,
6de9cd9a 565 GFC_ISYM_NOT,
cd5ecab6 566 GFC_ISYM_NULL,
60386f50 567 GFC_ISYM_NUM_IMAGES,
5d723e54 568 GFC_ISYM_OR,
6de9cd9a 569 GFC_ISYM_PACK,
0cd0559e 570 GFC_ISYM_PARITY,
cd5ecab6 571 GFC_ISYM_PERROR,
ad5f4de2
FXC
572 GFC_ISYM_POPCNT,
573 GFC_ISYM_POPPAR,
cd5ecab6 574 GFC_ISYM_PRECISION,
6de9cd9a
DN
575 GFC_ISYM_PRESENT,
576 GFC_ISYM_PRODUCT,
cd5ecab6 577 GFC_ISYM_RADIX,
2bd74949 578 GFC_ISYM_RAND,
ddd3e26e 579 GFC_ISYM_RANDOM_INIT,
cd5ecab6
DF
580 GFC_ISYM_RANDOM_NUMBER,
581 GFC_ISYM_RANDOM_SEED,
582 GFC_ISYM_RANGE,
2514987f 583 GFC_ISYM_RANK,
6de9cd9a 584 GFC_ISYM_REAL,
878f88b7 585 GFC_ISYM_REALPART,
f77b6ca3 586 GFC_ISYM_RENAME,
6de9cd9a
DN
587 GFC_ISYM_REPEAT,
588 GFC_ISYM_RESHAPE,
589 GFC_ISYM_RRSPACING,
cd5ecab6 590 GFC_ISYM_RSHIFT,
cf2b3c22 591 GFC_ISYM_SAME_TYPE_AS,
a39fafac 592 GFC_ISYM_SC_KIND,
6de9cd9a
DN
593 GFC_ISYM_SCALE,
594 GFC_ISYM_SCAN,
53096259 595 GFC_ISYM_SECNDS,
cd5ecab6 596 GFC_ISYM_SECOND,
6de9cd9a
DN
597 GFC_ISYM_SET_EXPONENT,
598 GFC_ISYM_SHAPE,
88a95a11
FXC
599 GFC_ISYM_SHIFTA,
600 GFC_ISYM_SHIFTL,
601 GFC_ISYM_SHIFTR,
f0f67c96 602 GFC_ISYM_BACKTRACE,
6de9cd9a 603 GFC_ISYM_SIGN,
185d7d97 604 GFC_ISYM_SIGNAL,
cd5ecab6 605 GFC_ISYM_SI_KIND,
6de9cd9a 606 GFC_ISYM_SIN,
57391dda 607 GFC_ISYM_SIND,
6de9cd9a
DN
608 GFC_ISYM_SINH,
609 GFC_ISYM_SIZE,
cd5ecab6 610 GFC_ISYM_SLEEP,
fd2157ce 611 GFC_ISYM_SIZEOF,
878f88b7 612 GFC_ISYM_SNGL,
6de9cd9a
DN
613 GFC_ISYM_SPACING,
614 GFC_ISYM_SPREAD,
615 GFC_ISYM_SQRT,
cd5ecab6 616 GFC_ISYM_SRAND,
6de9cd9a 617 GFC_ISYM_SR_KIND,
df65f093 618 GFC_ISYM_STAT,
ef78bc3c 619 GFC_ISYM_STOPPED_IMAGES,
048510c8 620 GFC_ISYM_STORAGE_SIZE,
0881224e 621 GFC_ISYM_STRIDE,
6de9cd9a 622 GFC_ISYM_SUM,
cd5ecab6 623 GFC_ISYM_SYMLINK,
f77b6ca3 624 GFC_ISYM_SYMLNK,
5b1374e9 625 GFC_ISYM_SYSTEM,
cd5ecab6 626 GFC_ISYM_SYSTEM_CLOCK,
6de9cd9a 627 GFC_ISYM_TAN,
57391dda 628 GFC_ISYM_TAND,
6de9cd9a 629 GFC_ISYM_TANH,
f8862a1b 630 GFC_ISYM_TEAM_NUMBER,
64f002ed 631 GFC_ISYM_THIS_IMAGE,
f77b6ca3
FXC
632 GFC_ISYM_TIME,
633 GFC_ISYM_TIME8,
cd5ecab6 634 GFC_ISYM_TINY,
414f00e9 635 GFC_ISYM_TRAILZ,
6de9cd9a
DN
636 GFC_ISYM_TRANSFER,
637 GFC_ISYM_TRANSPOSE,
638 GFC_ISYM_TRIM,
25fc05eb 639 GFC_ISYM_TTYNAM,
6de9cd9a 640 GFC_ISYM_UBOUND,
64f002ed 641 GFC_ISYM_UCOBOUND,
d8fe26b2
SK
642 GFC_ISYM_UMASK,
643 GFC_ISYM_UNLINK,
6de9cd9a
DN
644 GFC_ISYM_UNPACK,
645 GFC_ISYM_VERIFY,
5d723e54 646 GFC_ISYM_XOR,
cd5ecab6
DF
647 GFC_ISYM_Y0,
648 GFC_ISYM_Y1,
29698e0f
TB
649 GFC_ISYM_YN,
650 GFC_ISYM_YN2
6de9cd9a 651};
6de9cd9a 652
a79683d5 653enum init_local_logical
51b09ce3
AL
654{
655 GFC_INIT_LOGICAL_OFF = 0,
656 GFC_INIT_LOGICAL_FALSE,
657 GFC_INIT_LOGICAL_TRUE
a79683d5 658};
51b09ce3 659
a79683d5 660enum init_local_character
51b09ce3
AL
661{
662 GFC_INIT_CHARACTER_OFF = 0,
663 GFC_INIT_CHARACTER_ON
a79683d5 664};
51b09ce3 665
a79683d5 666enum init_local_integer
51b09ce3
AL
667{
668 GFC_INIT_INTEGER_OFF = 0,
669 GFC_INIT_INTEGER_ON
a79683d5 670};
51b09ce3 671
a79683d5 672enum gfc_reverse
3d03ead0 673{
aed5574e
PT
674 GFC_ENABLE_REVERSE,
675 GFC_FORWARD_SET,
3d03ead0 676 GFC_REVERSE_SET,
aed5574e 677 GFC_INHIBIT_REVERSE
a79683d5 678};
3d03ead0 679
5bab4c96
PT
680enum gfc_param_spec_type
681{
682 SPEC_EXPLICIT,
683 SPEC_ASSUMED,
684 SPEC_DEFERRED
685};
686
6de9cd9a
DN
687/************************* Structures *****************************/
688
5cf54585
TS
689/* Used for keeping things in balanced binary trees. */
690#define BBT_HEADER(self) int priority; struct self *left, *right
691
7306b628 692#define NAMED_INTCST(a,b,c,d) a,
be1f1ed9 693#define NAMED_KINDARRAY(a,b,c,d) a,
d000aa67 694#define NAMED_FUNCTION(a,b,c,d) a,
cadddfdd 695#define NAMED_SUBROUTINE(a,b,c,d) a,
fea54935 696#define NAMED_DERIVED_TYPE(a,b,c,d) a,
a79683d5 697enum iso_fortran_env_symbol
a8b3b0b6
CR
698{
699 ISOFORTRANENV_INVALID = -1,
700#include "iso-fortran-env.def"
701 ISOFORTRANENV_LAST, ISOFORTRANENV_NUMBER = ISOFORTRANENV_LAST
a79683d5 702};
d000aa67 703#undef NAMED_INTCST
be1f1ed9 704#undef NAMED_KINDARRAY
d000aa67 705#undef NAMED_FUNCTION
cadddfdd 706#undef NAMED_SUBROUTINE
fea54935 707#undef NAMED_DERIVED_TYPE
a8b3b0b6 708
7306b628 709#define NAMED_INTCST(a,b,c,d) a,
28d0b595
TB
710#define NAMED_REALCST(a,b,c,d) a,
711#define NAMED_CMPXCST(a,b,c,d) a,
a8b3b0b6
CR
712#define NAMED_LOGCST(a,b,c) a,
713#define NAMED_CHARKNDCST(a,b,c) a,
714#define NAMED_CHARCST(a,b,c) a,
715#define DERIVED_TYPE(a,b,c) a,
d000aa67 716#define NAMED_FUNCTION(a,b,c,d) a,
cadddfdd 717#define NAMED_SUBROUTINE(a,b,c,d) a,
a79683d5 718enum iso_c_binding_symbol
a8b3b0b6 719{
4d382327 720 ISOCBINDING_INVALID = -1,
a8b3b0b6
CR
721#include "iso-c-binding.def"
722 ISOCBINDING_LAST,
723 ISOCBINDING_NUMBER = ISOCBINDING_LAST
a79683d5 724};
a8b3b0b6
CR
725#undef NAMED_INTCST
726#undef NAMED_REALCST
727#undef NAMED_CMPXCST
728#undef NAMED_LOGCST
729#undef NAMED_CHARKNDCST
730#undef NAMED_CHARCST
731#undef DERIVED_TYPE
d000aa67 732#undef NAMED_FUNCTION
cadddfdd 733#undef NAMED_SUBROUTINE
a8b3b0b6 734
a79683d5 735enum intmod_id
a8b3b0b6 736{
8b198102
FXC
737 INTMOD_NONE = 0, INTMOD_ISO_FORTRAN_ENV, INTMOD_ISO_C_BINDING,
738 INTMOD_IEEE_FEATURES, INTMOD_IEEE_EXCEPTIONS, INTMOD_IEEE_ARITHMETIC
a79683d5 739};
a8b3b0b6
CR
740
741typedef struct
742{
743 char name[GFC_MAX_SYMBOL_LEN + 1];
744 int value; /* Used for both integer and character values. */
745 bt f90_type;
746}
747CInteropKind_t;
748
749/* Array of structs, where the structs represent the C interop kinds.
750 The list will be implemented based on a hash of the kind name since
751 these could be accessed multiple times.
752 Declared in trans-types.c as a global, since it's in that file
753 that the list is initialized. */
754extern CInteropKind_t c_interop_kinds_table[];
755
d58e7173
TB
756enum gfc_omp_device_type
757{
758 OMP_DEVICE_TYPE_UNSET,
759 OMP_DEVICE_TYPE_HOST,
760 OMP_DEVICE_TYPE_NOHOST,
761 OMP_DEVICE_TYPE_ANY
762};
08a6b8e0
TB
763
764/* Structure and list of supported extension attributes. */
2b374f55 765typedef enum
08a6b8e0
TB
766{
767 EXT_ATTR_DLLIMPORT = 0,
768 EXT_ATTR_DLLEXPORT,
769 EXT_ATTR_STDCALL,
770 EXT_ATTR_CDECL,
771 EXT_ATTR_FASTCALL,
e7ac6a7c 772 EXT_ATTR_NO_ARG_CHECK,
08a6b8e0 773 EXT_ATTR_LAST, EXT_ATTR_NUM = EXT_ATTR_LAST
2b374f55
TB
774}
775ext_attr_id_t;
08a6b8e0
TB
776
777typedef struct
778{
779 const char *name;
780 unsigned id;
781 const char *middle_end_name;
782}
783ext_attr_t;
784
785extern const ext_attr_t ext_attr_list[];
786
6de9cd9a
DN
787/* Symbol attribute structure. */
788typedef struct
789{
790 /* Variable attributes. */
be59db2d 791 unsigned allocatable:1, dimension:1, codimension:1, external:1, intrinsic:1,
59e36b72 792 optional:1, pointer:1, target:1, value:1, volatile_:1, temporary:1,
e9bd9f7d 793 dummy:1, result:1, assign:1, threadprivate:1, not_always_present:1,
fe4e525c 794 implied_index:1, subref_array_pointer:1, proc_pointer:1, asynchronous:1,
34d567d1 795 contiguous:1, fe_temp: 1, automatic: 1;
6de9cd9a 796
41a394bb
DK
797 /* For CLASS containers, the pointer attribute is sometimes set internally
798 even though it was not directly specified. In this case, keep the
799 "real" (original) value here. */
800 unsigned class_pointer:1;
801
5349080d
TB
802 ENUM_BITFIELD (save_state) save:2;
803
6de9cd9a 804 unsigned data:1, /* Symbol is named in a DATA statement. */
8b11b59f 805 is_protected:1, /* Symbol has been marked as protected. */
993ef28f 806 use_assoc:1, /* Symbol has been use-associated. */
4668d6f9
PT
807 used_in_submodule:1, /* Symbol has been use-associated in a
808 submodule. Needed since these entities must
809 be set host associated to be compliant. */
5a8af0b4 810 use_only:1, /* Symbol has been use-associated, with ONLY. */
0e5a218b 811 use_rename:1, /* Symbol has been use-associated and renamed. */
022e30c0 812 imported:1, /* Symbol has been associated by IMPORT. */
4d382327 813 host_assoc:1; /* Symbol has been host associated. */
6de9cd9a 814
30aabb86 815 unsigned in_namelist:1, in_common:1, in_equivalence:1;
69773742
JW
816 unsigned function:1, subroutine:1, procedure:1;
817 unsigned generic:1, generic_copy:1;
d1303acd 818 unsigned implicit_type:1; /* Type defined via implicit rules. */
ebb479cd 819 unsigned untyped:1; /* No implicit type could be found. */
6de9cd9a 820
ebb479cd 821 unsigned is_bind_c:1; /* say if is bound to C. */
7c1dab0d 822 unsigned extension:8; /* extension level of a derived type. */
cf2b3c22 823 unsigned is_class:1; /* is a CLASS container. */
2e23972e 824 unsigned class_ok:1; /* is a CLASS object with correct attributes. */
eece1eb9
PT
825 unsigned vtab:1; /* is a derived type vtab, pointed to by CLASS objects. */
826 unsigned vtype:1; /* is a derived type of a vtab. */
a8b3b0b6
CR
827
828 /* These flags are both in the typespec and attribute. The attribute
829 list is what gets read from/written to a module file. The typespec
830 is created from a decl being processed. */
831 unsigned is_c_interop:1; /* It's c interoperable. */
832 unsigned is_iso_c:1; /* Symbol is from iso_c_binding. */
833
6de9cd9a
DN
834 /* Function/subroutine attributes */
835 unsigned sequence:1, elemental:1, pure:1, recursive:1;
9e1d712c 836 unsigned unmaskable:1, masked:1, contained:1, mod_proc:1, abstract:1;
6de9cd9a 837
4668d6f9
PT
838 /* Set if this is a module function or subroutine. Note that it is an
839 attribute because it appears as a prefix in the declaration like
840 PURE, etc.. */
841 unsigned module_procedure:1;
842
cdd244b8
TB
843 /* Set if a (public) symbol [e.g. generic name] exposes this symbol,
844 which is relevant for private module procedures. */
845 unsigned public_used:1;
846
f1f39033
PT
847 /* This is set if a contained procedure could be declared pure. This is
848 used for certain optimizations that require the result or arguments
849 cannot alias. Note that this is zero for PURE procedures. */
850 unsigned implicit_pure:1;
851
30c931de 852 /* This is set for a procedure that contains expressions referencing
e73d3ca6 853 arrays coming from outside its namespace.
30c931de
PT
854 This is used to force the creation of a temporary when the LHS of
855 an array assignment may be used by an elemental procedure appearing
856 on the RHS. */
857 unsigned array_outer_dependency:1;
858
fe58e076
TK
859 /* This is set if the subroutine doesn't return. Currently, this
860 is only possible for intrinsic subroutines. */
861 unsigned noreturn:1;
862
3d79abbd
PB
863 /* Set if this procedure is an alternate entry point. These procedures
864 don't have any code associated, and the backend will turn them into
865 thunks to the master function. */
866 unsigned entry:1;
8b67b708 867
3d79abbd
PB
868 /* Set if this is the master function for a procedure with multiple
869 entry points. */
870 unsigned entry_master:1;
8b67b708 871
d198b59a
JJ
872 /* Set if this is the master function for a function with multiple
873 entry points where characteristics of the entry points differ. */
874 unsigned mixed_entry_master:1;
3d79abbd 875
6de9cd9a
DN
876 /* Set if a function must always be referenced by an explicit interface. */
877 unsigned always_explicit:1;
878
8e54f139
TB
879 /* Set if the symbol is generated and, hence, standard violations
880 shouldn't be flaged. */
881 unsigned artificial:1;
882
6de9cd9a
DN
883 /* Set if the symbol has been referenced in an expression. No further
884 modification of type or type parameters is permitted. */
885 unsigned referenced:1;
886
ecf24057 887 /* Set if this is the symbol for the main program. */
8b67b708
FXC
888 unsigned is_main_program:1;
889
6de9cd9a 890 /* Mutually exclusive multibit attributes. */
5f42ddb0
KG
891 ENUM_BITFIELD (gfc_access) access:2;
892 ENUM_BITFIELD (sym_intent) intent:2;
893 ENUM_BITFIELD (sym_flavor) flavor:4;
894 ENUM_BITFIELD (ifsrc) if_source:2;
6de9cd9a 895
5f42ddb0 896 ENUM_BITFIELD (procedure_type) proc:3;
949446f5 897
83d890b9 898 /* Special attributes for Cray pointers, pointees. */
949446f5 899 unsigned cray_pointer:1, cray_pointee:1;
6de9cd9a 900
4d382327 901 /* The symbol is a derived type with allocatable components, pointer
713485cc
JW
902 components or private components, procedure pointer components,
903 possibly nested. zero_comp is true if the derived type has no
4d382327 904 component at all. defined_assign_comp is true if the derived
8b704316
PT
905 type or a (sub-)component has a typebound defined assignment.
906 unlimited_polymorphic flags the type of the container for these
907 entities. */
713485cc 908 unsigned alloc_comp:1, pointer_comp:1, proc_pointer_comp:1,
4d382327 909 private_comp:1, zero_comp:1, coarray_comp:1, lock_comp:1,
e73d3ca6 910 event_comp:1, defined_assign_comp:1, unlimited_polymorphic:1,
f549bfb3 911 has_dtio_procs:1, caf_token:1;
77bb16aa 912
70570ec1
PT
913 /* This is a temporary selector for SELECT TYPE/RANK or an associate
914 variable for SELECT TYPE/RANK or ASSOCIATE. */
915 unsigned select_type_temporary:1, select_rank_temporary:1, associate_var:1;
8c91ab34 916
5bab4c96
PT
917 /* These are the attributes required for parameterized derived
918 types. */
919 unsigned pdt_kind:1, pdt_len:1, pdt_type:1, pdt_template:1,
920 pdt_array:1, pdt_string:1;
921
5f23671d
JJ
922 /* This is omp_{out,in,priv,orig} artificial variable in
923 !$OMP DECLARE REDUCTION. */
924 unsigned omp_udr_artificial_var:1;
925
f014c653
JJ
926 /* Mentioned in OMP DECLARE TARGET. */
927 unsigned omp_declare_target:1;
b4c3a85b 928 unsigned omp_declare_target_link:1;
d58e7173 929 ENUM_BITFIELD (gfc_omp_device_type) omp_device_type:2;
f014c653 930
dc7a8b4b
JN
931 /* Mentioned in OACC DECLARE. */
932 unsigned oacc_declare_create:1;
933 unsigned oacc_declare_copyin:1;
934 unsigned oacc_declare_deviceptr:1;
935 unsigned oacc_declare_device_resident:1;
936 unsigned oacc_declare_link:1;
937
68034b1b
TS
938 /* OpenACC 'routine' directive's level of parallelism. */
939 ENUM_BITFIELD (oacc_routine_lop) oacc_routine_lop:3;
db941d7e 940
08a6b8e0
TB
941 /* Attributes set by compiler extensions (!GCC$ ATTRIBUTES). */
942 unsigned ext_attr:EXT_ATTR_NUM;
943
1eee5628
TB
944 /* The namespace where the attribute has been set. */
945 struct gfc_namespace *volatile_ns, *asynchronous_ns;
6de9cd9a
DN
946}
947symbol_attribute;
948
949
8fc541d3
FXC
950/* We need to store source lines as sequences of multibyte source
951 characters. We define here a type wide enough to hold any multibyte
952 source character, just like libcpp does. A 32-bit type is enough. */
953
954#if HOST_BITS_PER_INT >= 32
955typedef unsigned int gfc_char_t;
956#elif HOST_BITS_PER_LONG >= 32
957typedef unsigned long gfc_char_t;
958#elif defined(HAVE_LONG_LONG) && (HOST_BITS_PER_LONGLONG >= 32)
959typedef unsigned long long gfc_char_t;
960#else
961# error "Cannot find an integer type with at least 32 bits"
962#endif
963
964
d4fa05b9 965/* The following three structures are used to identify a location in
949446f5
BF
966 the sources.
967
d4fa05b9
TS
968 gfc_file is used to maintain a tree of the source files and how
969 they include each other
6de9cd9a 970
d4fa05b9
TS
971 gfc_linebuf holds a single line of source code and information
972 which file it resides in
6de9cd9a 973
d4fa05b9 974 locus point to the sourceline and the character in the source
949446f5 975 line.
d4fa05b9 976*/
6de9cd9a 977
949446f5 978typedef struct gfc_file
6de9cd9a 979{
1b271c9b 980 struct gfc_file *next, *up;
d4fa05b9
TS
981 int inclusion_line, line;
982 char *filename;
983} gfc_file;
984
949446f5 985typedef struct gfc_linebuf
d4fa05b9 986{
620e594b 987 location_t location;
d4fa05b9
TS
988 struct gfc_file *file;
989 struct gfc_linebuf *next;
990
ba1defa5 991 int truncated;
9e8a6720 992 bool dbg_emitted;
ba1defa5 993
8fc541d3 994 gfc_char_t line[1];
d4fa05b9 995} gfc_linebuf;
4cdf7223
PB
996
997#define gfc_linebuf_header_size (offsetof (gfc_linebuf, line))
998
5ffeb913 999#define gfc_linebuf_linenum(LBUF) (LOCATION_LINE ((LBUF)->location))
5ffeb913 1000
949446f5 1001typedef struct
d4fa05b9 1002{
8fc541d3 1003 gfc_char_t *nextc;
d4fa05b9
TS
1004 gfc_linebuf *lb;
1005} locus;
6de9cd9a 1006
0ce0154c
KG
1007/* In order for the "gfc" format checking to work correctly, you must
1008 have declared a typedef locus first. */
1009#if GCC_VERSION >= 4001
1010#define ATTRIBUTE_GCC_GFC(m, n) __attribute__ ((__format__ (__gcc_gfc__, m, n))) ATTRIBUTE_NONNULL(m)
1011#else
1012#define ATTRIBUTE_GCC_GFC(m, n) ATTRIBUTE_NONNULL(m)
1013#endif
1014
6de9cd9a 1015
a3d3c0f5
DK
1016/* Suppress error messages or re-enable them. */
1017
1018void gfc_push_suppress_errors (void);
1019void gfc_pop_suppress_errors (void);
6de9cd9a
DN
1020
1021
1022/* Character length structures hold the expression that gives the
1023 length of a character variable. We avoid putting these into
1024 gfc_typespec because doing so prevents us from doing structure
1025 copies and forces us to deallocate any typespecs we create, as well
1026 as structures that contain typespecs. They also can have multiple
1027 character typespecs pointing to them.
1028
1029 These structures form a singly linked list within the current
1030 namespace and are deallocated with the namespace. It is possible to
1031 end up with gfc_charlen structures that have nothing pointing to them. */
1032
1033typedef struct gfc_charlen
1034{
1035 struct gfc_expr *length;
1036 struct gfc_charlen *next;
c03fc95d 1037 bool length_from_typespec; /* Length from explicit array ctor typespec? */
6de9cd9a 1038 tree backend_decl;
e69afb29 1039 tree passed_length; /* Length argument explicitly passed. */
110eec24
TS
1040
1041 int resolved;
6de9cd9a
DN
1042}
1043gfc_charlen;
1044
ece3f663 1045#define gfc_get_charlen() XCNEW (gfc_charlen)
6de9cd9a 1046
bc21d315 1047/* Type specification structure. */
6de9cd9a
DN
1048typedef struct
1049{
1050 bt type;
1051 int kind;
bc21d315
JW
1052
1053 union
1054 {
1055 struct gfc_symbol *derived; /* For derived types only. */
1056 gfc_charlen *cl; /* For character types only. */
401fcd3b 1057 int pad; /* For hollerith types only. */
bc21d315
JW
1058 }
1059 u;
1060
32d99e68 1061 struct gfc_symbol *interface; /* For PROCEDURE declarations. */
a8b3b0b6
CR
1062 int is_c_interop;
1063 int is_iso_c;
e69afb29
SK
1064 bt f90_type;
1065 bool deferred;
e655a6cc 1066 gfc_symbol *interop_kind;
6de9cd9a
DN
1067}
1068gfc_typespec;
1069
1070/* Array specification. */
1071typedef struct
1072{
c62c6622 1073 int rank; /* A scalar has a rank of 0, an assumed-rank array has -1. */
be59db2d 1074 int corank;
178f9aa1 1075 array_type type, cotype;
6de9cd9a 1076 struct gfc_expr *lower[GFC_MAX_DIMENSIONS], *upper[GFC_MAX_DIMENSIONS];
83d890b9
AL
1077
1078 /* These two fields are used with the Cray Pointer extension. */
1079 bool cray_pointee; /* True iff this spec belongs to a cray pointee. */
1080 bool cp_was_assumed; /* AS_ASSUMED_SIZE cp arrays are converted to
1081 AS_EXPLICIT, but we want to remember that we
1082 did this. */
9b7df66f
TK
1083
1084 bool resolved;
6de9cd9a
DN
1085}
1086gfc_array_spec;
1087
ece3f663 1088#define gfc_get_array_spec() XCNEW (gfc_array_spec)
6de9cd9a
DN
1089
1090
1091/* Components of derived types. */
1092typedef struct gfc_component
1093{
cb9e4f55 1094 const char *name;
6de9cd9a
DN
1095 gfc_typespec ts;
1096
d4b7d0f0 1097 symbol_attribute attr;
6de9cd9a
DN
1098 gfc_array_spec *as;
1099
1100 tree backend_decl;
b3c1b8a1
MM
1101 /* Used to cache a FIELD_DECL matching this same component
1102 but applied to a different backend containing type that was
1103 generated by gfc_nonrestricted_type. */
1104 tree norestrict_decl;
6de9cd9a
DN
1105 locus loc;
1106 struct gfc_expr *initializer;
5bab4c96
PT
1107 /* Used in parameterized derived type declarations to store parameterized
1108 kind expressions. */
1109 struct gfc_expr *kind_expr;
1110 struct gfc_actual_arglist *param_list;
1111
6de9cd9a 1112 struct gfc_component *next;
713485cc 1113
90661f26 1114 /* Needed for procedure pointer components. */
90661f26 1115 struct gfc_typebound_proc *tb;
3c9f5092
AV
1116 /* When allocatable/pointer and in a coarray the associated token. */
1117 tree caf_token;
6de9cd9a
DN
1118}
1119gfc_component;
1120
ece3f663 1121#define gfc_get_component() XCNEW (gfc_component)
6de9cd9a
DN
1122
1123/* Formal argument lists are lists of symbols. */
1124typedef struct gfc_formal_arglist
1125{
4f613946 1126 /* Symbol representing the argument at this position in the arglist. */
6de9cd9a 1127 struct gfc_symbol *sym;
4f613946 1128 /* Points to the next formal argument. */
6de9cd9a
DN
1129 struct gfc_formal_arglist *next;
1130}
1131gfc_formal_arglist;
1132
ece3f663 1133#define gfc_get_formal_arglist() XCNEW (gfc_formal_arglist)
6de9cd9a
DN
1134
1135
5bab4c96
PT
1136/* The gfc_actual_arglist structure is for actual arguments and
1137 for type parameter specification lists. */
6de9cd9a
DN
1138typedef struct gfc_actual_arglist
1139{
cb9e4f55 1140 const char *name;
6de9cd9a
DN
1141 /* Alternate return label when the expr member is null. */
1142 struct gfc_st_label *label;
1143
1600fe22
TS
1144 /* This is set to the type of an eventual omitted optional
1145 argument. This is used to determine if a hidden string length
1146 argument has to be added to a function call. */
1147 bt missing_arg_type;
1148
5bab4c96
PT
1149 gfc_param_spec_type spec_type;
1150
6de9cd9a
DN
1151 struct gfc_expr *expr;
1152 struct gfc_actual_arglist *next;
1153}
1154gfc_actual_arglist;
1155
ece3f663 1156#define gfc_get_actual_arglist() XCNEW (gfc_actual_arglist)
6de9cd9a
DN
1157
1158
1159/* Because a symbol can belong to multiple namelists, they must be
1160 linked externally to the symbol itself. */
1161typedef struct gfc_namelist
1162{
1163 struct gfc_symbol *sym;
1164 struct gfc_namelist *next;
1165}
1166gfc_namelist;
1167
ece3f663 1168#define gfc_get_namelist() XCNEW (gfc_namelist)
6de9cd9a 1169
41dbbb37
TS
1170/* Likewise to gfc_namelist, but contains expressions. */
1171typedef struct gfc_expr_list
1172{
1173 struct gfc_expr *expr;
1174 struct gfc_expr_list *next;
1175}
1176gfc_expr_list;
1177
1178#define gfc_get_expr_list() XCNEW (gfc_expr_list)
1179
a79683d5 1180enum gfc_omp_reduction_op
5f23671d
JJ
1181{
1182 OMP_REDUCTION_NONE = -1,
1183 OMP_REDUCTION_PLUS = INTRINSIC_PLUS,
1184 OMP_REDUCTION_MINUS = INTRINSIC_MINUS,
1185 OMP_REDUCTION_TIMES = INTRINSIC_TIMES,
1186 OMP_REDUCTION_AND = INTRINSIC_AND,
1187 OMP_REDUCTION_OR = INTRINSIC_OR,
1188 OMP_REDUCTION_EQV = INTRINSIC_EQV,
1189 OMP_REDUCTION_NEQV = INTRINSIC_NEQV,
1190 OMP_REDUCTION_MAX = GFC_INTRINSIC_END,
1191 OMP_REDUCTION_MIN,
1192 OMP_REDUCTION_IAND,
1193 OMP_REDUCTION_IOR,
1194 OMP_REDUCTION_IEOR,
1195 OMP_REDUCTION_USER
a79683d5 1196};
5f23671d 1197
a79683d5 1198enum gfc_omp_depend_op
f014c653
JJ
1199{
1200 OMP_DEPEND_IN,
1201 OMP_DEPEND_OUT,
b4c3a85b
JJ
1202 OMP_DEPEND_INOUT,
1203 OMP_DEPEND_SINK_FIRST,
1204 OMP_DEPEND_SINK
a79683d5 1205};
f014c653 1206
a79683d5 1207enum gfc_omp_map_op
f014c653
JJ
1208{
1209 OMP_MAP_ALLOC,
a6163563 1210 OMP_MAP_IF_PRESENT,
549188ea 1211 OMP_MAP_ATTACH,
f014c653
JJ
1212 OMP_MAP_TO,
1213 OMP_MAP_FROM,
41dbbb37 1214 OMP_MAP_TOFROM,
91106e84 1215 OMP_MAP_DELETE,
549188ea 1216 OMP_MAP_DETACH,
41dbbb37 1217 OMP_MAP_FORCE_ALLOC,
41dbbb37
TS
1218 OMP_MAP_FORCE_TO,
1219 OMP_MAP_FORCE_FROM,
1220 OMP_MAP_FORCE_TOFROM,
1221 OMP_MAP_FORCE_PRESENT,
dc7a8b4b
JN
1222 OMP_MAP_FORCE_DEVICEPTR,
1223 OMP_MAP_DEVICE_RESIDENT,
b4c3a85b
JJ
1224 OMP_MAP_LINK,
1225 OMP_MAP_RELEASE,
1226 OMP_MAP_ALWAYS_TO,
1227 OMP_MAP_ALWAYS_FROM,
1228 OMP_MAP_ALWAYS_TOFROM
1229};
1230
1231enum gfc_omp_linear_op
1232{
1233 OMP_LINEAR_DEFAULT,
1234 OMP_LINEAR_REF,
1235 OMP_LINEAR_VAL,
1236 OMP_LINEAR_UVAL
a79683d5 1237};
f014c653 1238
dd2fc525
JJ
1239/* For use in OpenMP clauses in case we need extra information
1240 (aligned clause alignment, linear clause step, etc.). */
1241
1242typedef struct gfc_omp_namelist
1243{
1244 struct gfc_symbol *sym;
1245 struct gfc_expr *expr;
f014c653
JJ
1246 union
1247 {
1248 gfc_omp_reduction_op reduction_op;
1249 gfc_omp_depend_op depend_op;
1250 gfc_omp_map_op map_op;
b4c3a85b
JJ
1251 gfc_omp_linear_op linear_op;
1252 struct gfc_common_head *common;
084dc63a 1253 bool lastprivate_conditional;
f014c653 1254 } u;
b46ebd6c 1255 struct gfc_omp_namelist_udr *udr;
dd2fc525 1256 struct gfc_omp_namelist *next;
2ac33bca 1257 locus where;
dd2fc525
JJ
1258}
1259gfc_omp_namelist;
1260
1261#define gfc_get_omp_namelist() XCNEW (gfc_omp_namelist)
1262
6c7a4dfd
JJ
1263enum
1264{
41dbbb37
TS
1265 OMP_LIST_FIRST,
1266 OMP_LIST_PRIVATE = OMP_LIST_FIRST,
6c7a4dfd
JJ
1267 OMP_LIST_FIRSTPRIVATE,
1268 OMP_LIST_LASTPRIVATE,
1269 OMP_LIST_COPYPRIVATE,
1270 OMP_LIST_SHARED,
1271 OMP_LIST_COPYIN,
dd2fc525
JJ
1272 OMP_LIST_UNIFORM,
1273 OMP_LIST_ALIGNED,
1274 OMP_LIST_LINEAR,
f014c653
JJ
1275 OMP_LIST_DEPEND,
1276 OMP_LIST_MAP,
1277 OMP_LIST_TO,
1278 OMP_LIST_FROM,
5f23671d 1279 OMP_LIST_REDUCTION,
41dbbb37 1280 OMP_LIST_DEVICE_RESIDENT,
dc7a8b4b 1281 OMP_LIST_LINK,
41dbbb37
TS
1282 OMP_LIST_USE_DEVICE,
1283 OMP_LIST_CACHE,
b4c3a85b
JJ
1284 OMP_LIST_IS_DEVICE_PTR,
1285 OMP_LIST_USE_DEVICE_PTR,
ef4add8e 1286 OMP_LIST_USE_DEVICE_ADDR,
21cfe724 1287 OMP_LIST_NONTEMPORAL,
6c7a4dfd
JJ
1288 OMP_LIST_NUM
1289};
1290
1291/* Because a symbol can belong to multiple namelists, they must be
1292 linked externally to the symbol itself. */
24b97832
ILT
1293
1294enum gfc_omp_sched_kind
1295{
1296 OMP_SCHED_NONE,
1297 OMP_SCHED_STATIC,
1298 OMP_SCHED_DYNAMIC,
1299 OMP_SCHED_GUIDED,
1300 OMP_SCHED_RUNTIME,
1301 OMP_SCHED_AUTO
1302};
1303
1304enum gfc_omp_default_sharing
1305{
1306 OMP_DEFAULT_UNKNOWN,
1307 OMP_DEFAULT_NONE,
1308 OMP_DEFAULT_PRIVATE,
1309 OMP_DEFAULT_SHARED,
7fd549d2
TS
1310 OMP_DEFAULT_FIRSTPRIVATE,
1311 OMP_DEFAULT_PRESENT
24b97832
ILT
1312};
1313
dd2fc525
JJ
1314enum gfc_omp_proc_bind_kind
1315{
1316 OMP_PROC_BIND_UNKNOWN,
1317 OMP_PROC_BIND_MASTER,
1318 OMP_PROC_BIND_SPREAD,
1319 OMP_PROC_BIND_CLOSE
1320};
1321
1322enum gfc_omp_cancel_kind
1323{
1324 OMP_CANCEL_UNKNOWN,
1325 OMP_CANCEL_PARALLEL,
1326 OMP_CANCEL_SECTIONS,
1327 OMP_CANCEL_DO,
1328 OMP_CANCEL_TASKGROUP
1329};
1330
b4c3a85b
JJ
1331enum gfc_omp_if_kind
1332{
e55ba804 1333 OMP_IF_CANCEL,
b4c3a85b 1334 OMP_IF_PARALLEL,
e55ba804 1335 OMP_IF_SIMD,
b4c3a85b
JJ
1336 OMP_IF_TASK,
1337 OMP_IF_TASKLOOP,
1338 OMP_IF_TARGET,
1339 OMP_IF_TARGET_DATA,
1340 OMP_IF_TARGET_UPDATE,
1341 OMP_IF_TARGET_ENTER_DATA,
1342 OMP_IF_TARGET_EXIT_DATA,
1343 OMP_IF_LAST
1344};
1345
1fc5e7ef
TB
1346enum gfc_omp_atomic_op
1347{
1348 GFC_OMP_ATOMIC_UNSET = 0,
1349 GFC_OMP_ATOMIC_UPDATE = 1,
1350 GFC_OMP_ATOMIC_READ = 2,
1351 GFC_OMP_ATOMIC_WRITE = 3,
1352 GFC_OMP_ATOMIC_MASK = 3,
1353 GFC_OMP_ATOMIC_SWAP = 16
1354};
1355
269322ec
TB
1356enum gfc_omp_requires_kind
1357{
1358 /* Keep in sync with gfc_namespace, esp. with omp_req_mem_order. */
1359 OMP_REQ_ATOMIC_MEM_ORDER_SEQ_CST = 1, /* 01 */
1360 OMP_REQ_ATOMIC_MEM_ORDER_ACQ_REL = 2, /* 10 */
1361 OMP_REQ_ATOMIC_MEM_ORDER_RELAXED = 3, /* 11 */
1362 OMP_REQ_REVERSE_OFFLOAD = (1 << 2),
1363 OMP_REQ_UNIFIED_ADDRESS = (1 << 3),
1364 OMP_REQ_UNIFIED_SHARED_MEMORY = (1 << 4),
1365 OMP_REQ_DYNAMIC_ALLOCATORS = (1 << 5),
1366 OMP_REQ_TARGET_MASK = (OMP_REQ_REVERSE_OFFLOAD
1367 | OMP_REQ_UNIFIED_ADDRESS
1368 | OMP_REQ_UNIFIED_SHARED_MEMORY),
1369 OMP_REQ_ATOMIC_MEM_ORDER_MASK = (OMP_REQ_ATOMIC_MEM_ORDER_SEQ_CST
1370 | OMP_REQ_ATOMIC_MEM_ORDER_ACQ_REL
1371 | OMP_REQ_ATOMIC_MEM_ORDER_RELAXED)
1372};
1373
c26d7df1
TB
1374enum gfc_omp_memorder
1375{
1fc5e7ef
TB
1376 OMP_MEMORDER_UNSET,
1377 OMP_MEMORDER_SEQ_CST,
c26d7df1
TB
1378 OMP_MEMORDER_ACQ_REL,
1379 OMP_MEMORDER_RELEASE,
1380 OMP_MEMORDER_ACQUIRE,
1fc5e7ef 1381 OMP_MEMORDER_RELAXED
c26d7df1
TB
1382};
1383
6c7a4dfd
JJ
1384typedef struct gfc_omp_clauses
1385{
1386 struct gfc_expr *if_expr;
20906c66 1387 struct gfc_expr *final_expr;
6c7a4dfd 1388 struct gfc_expr *num_threads;
dd2fc525 1389 gfc_omp_namelist *lists[OMP_LIST_NUM];
24b97832 1390 enum gfc_omp_sched_kind sched_kind;
d58e7173 1391 enum gfc_omp_device_type device_type;
6c7a4dfd 1392 struct gfc_expr *chunk_size;
24b97832 1393 enum gfc_omp_default_sharing default_sharing;
b4c3a85b 1394 int collapse, orderedc;
20906c66 1395 bool nowait, ordered, untied, mergeable;
b4c3a85b
JJ
1396 bool inbranch, notinbranch, defaultmap, nogroup;
1397 bool sched_simd, sched_monotonic, sched_nonmonotonic;
1fc5e7ef
TB
1398 bool simd, threads, depend_source, order_concurrent, capture;
1399 enum gfc_omp_atomic_op atomic_op;
c26d7df1 1400 enum gfc_omp_memorder memorder;
dd2fc525
JJ
1401 enum gfc_omp_cancel_kind cancel;
1402 enum gfc_omp_proc_bind_kind proc_bind;
1403 struct gfc_expr *safelen_expr;
1404 struct gfc_expr *simdlen_expr;
f014c653
JJ
1405 struct gfc_expr *num_teams;
1406 struct gfc_expr *device;
1407 struct gfc_expr *thread_limit;
b4c3a85b
JJ
1408 struct gfc_expr *grainsize;
1409 struct gfc_expr *hint;
1410 struct gfc_expr *num_tasks;
1411 struct gfc_expr *priority;
1412 struct gfc_expr *if_exprs[OMP_IF_LAST];
f014c653
JJ
1413 enum gfc_omp_sched_kind dist_sched_kind;
1414 struct gfc_expr *dist_chunk_size;
b4c3a85b 1415 const char *critical_name;
41dbbb37
TS
1416
1417 /* OpenACC. */
1418 struct gfc_expr *async_expr;
2a70708e
CP
1419 struct gfc_expr *gang_static_expr;
1420 struct gfc_expr *gang_num_expr;
41dbbb37
TS
1421 struct gfc_expr *worker_expr;
1422 struct gfc_expr *vector_expr;
1423 struct gfc_expr *num_gangs_expr;
1424 struct gfc_expr *num_workers_expr;
1425 struct gfc_expr *vector_length_expr;
1426 gfc_expr_list *wait_list;
1427 gfc_expr_list *tile_list;
1428 unsigned async:1, gang:1, worker:1, vector:1, seq:1, independent:1;
fc2a1f2f 1429 unsigned par_auto:1, gang_static:1;
829c6349 1430 unsigned if_present:1, finalize:1;
41dbbb37
TS
1431 locus loc;
1432
6c7a4dfd
JJ
1433}
1434gfc_omp_clauses;
1435
ece3f663 1436#define gfc_get_omp_clauses() XCNEW (gfc_omp_clauses)
6c7a4dfd 1437
6de9cd9a 1438
dc7a8b4b
JN
1439/* Node in the linked list used for storing !$oacc declare constructs. */
1440
1441typedef struct gfc_oacc_declare
1442{
1443 struct gfc_oacc_declare *next;
1444 bool module_var;
1445 gfc_omp_clauses *clauses;
1446 locus loc;
1447}
1448gfc_oacc_declare;
1449
1450#define gfc_get_oacc_declare() XCNEW (gfc_oacc_declare)
1451
1452
dd2fc525
JJ
1453/* Node in the linked list used for storing !$omp declare simd constructs. */
1454
1455typedef struct gfc_omp_declare_simd
1456{
1457 struct gfc_omp_declare_simd *next;
1458 locus where; /* Where the !$omp declare simd construct occurred. */
1459
1460 gfc_symbol *proc_name;
1461
1462 gfc_omp_clauses *clauses;
1463}
1464gfc_omp_declare_simd;
1465#define gfc_get_omp_declare_simd() XCNEW (gfc_omp_declare_simd)
1466
5f23671d
JJ
1467typedef struct gfc_omp_udr
1468{
1469 struct gfc_omp_udr *next;
1470 locus where; /* Where the !$omp declare reduction construct occurred. */
1471
1472 const char *name;
1473 gfc_typespec ts;
1474 gfc_omp_reduction_op rop;
1475
1476 struct gfc_symbol *omp_out;
1477 struct gfc_symbol *omp_in;
1478 struct gfc_namespace *combiner_ns;
1479
1480 struct gfc_symbol *omp_priv;
1481 struct gfc_symbol *omp_orig;
1482 struct gfc_namespace *initializer_ns;
1483}
1484gfc_omp_udr;
1485#define gfc_get_omp_udr() XCNEW (gfc_omp_udr)
dd2fc525 1486
b46ebd6c
JJ
1487typedef struct gfc_omp_namelist_udr
1488{
1489 struct gfc_omp_udr *udr;
1490 struct gfc_code *combiner;
1491 struct gfc_code *initializer;
1492}
1493gfc_omp_namelist_udr;
1494#define gfc_get_omp_namelist_udr() XCNEW (gfc_omp_namelist_udr)
1495
d80c695f
TS
1496/* The gfc_st_label structure is a BBT attached to a namespace that
1497 records the usage of statement labels within that space. */
1498
6de9cd9a
DN
1499typedef struct gfc_st_label
1500{
5cf54585
TS
1501 BBT_HEADER(gfc_st_label);
1502
6de9cd9a
DN
1503 int value;
1504
1505 gfc_sl_type defined, referenced;
1506
1507 struct gfc_expr *format;
1508
1509 tree backend_decl;
1510
1511 locus where;
388902da
LK
1512
1513 gfc_namespace *ns;
6de9cd9a
DN
1514}
1515gfc_st_label;
1516
1517
1518/* gfc_interface()-- Interfaces are lists of symbols strung together. */
1519typedef struct gfc_interface
1520{
1521 struct gfc_symbol *sym;
1522 locus where;
1523 struct gfc_interface *next;
1524}
1525gfc_interface;
1526
ece3f663 1527#define gfc_get_interface() XCNEW (gfc_interface)
6de9cd9a 1528
6de9cd9a
DN
1529/* User operator nodes. These are like stripped down symbols. */
1530typedef struct
1531{
cb9e4f55 1532 const char *name;
6de9cd9a 1533
8b11b59f 1534 gfc_interface *op;
6de9cd9a
DN
1535 struct gfc_namespace *ns;
1536 gfc_access access;
1537}
1538gfc_user_op;
1539
30b608eb 1540
e157f736
DK
1541/* A list of specific bindings that are associated with a generic spec. */
1542typedef struct gfc_tbp_generic
1543{
1544 /* The parser sets specific_st, upon resolution we look for the corresponding
1545 gfc_typebound_proc and set specific for further use. */
1546 struct gfc_symtree* specific_st;
1547 struct gfc_typebound_proc* specific;
1548
1549 struct gfc_tbp_generic* next;
218e1228 1550 bool is_operator;
e157f736
DK
1551}
1552gfc_tbp_generic;
1553
1554#define gfc_get_tbp_generic() XCNEW (gfc_tbp_generic)
1555
1556
30b608eb 1557/* Data needed for type-bound procedures. */
e157f736 1558typedef struct gfc_typebound_proc
30b608eb 1559{
e157f736
DK
1560 locus where; /* Where the PROCEDURE/GENERIC definition was. */
1561
1562 union
1563 {
b0e5fa94 1564 struct gfc_symtree* specific; /* The interface if DEFERRED. */
e157f736
DK
1565 gfc_tbp_generic* generic;
1566 }
1567 u;
30b608eb
DK
1568
1569 gfc_access access;
90661f26 1570 const char* pass_arg; /* Argument-name for PASS. NULL if not specified. */
30b608eb 1571
e157f736
DK
1572 /* The overridden type-bound proc (or GENERIC with this name in the
1573 parent-type) or NULL if non. */
1574 struct gfc_typebound_proc* overridden;
1575
30b608eb
DK
1576 /* Once resolved, we use the position of pass_arg in the formal arglist of
1577 the binding-target procedure to identify it. The first argument has
8e1f752a 1578 number 1 here, the second 2, and so on. */
30b608eb
DK
1579 unsigned pass_arg_num;
1580
1581 unsigned nopass:1; /* Whether we have NOPASS (PASS otherwise). */
1582 unsigned non_overridable:1;
b0e5fa94 1583 unsigned deferred:1;
e157f736
DK
1584 unsigned is_generic:1;
1585 unsigned function:1, subroutine:1;
b82657f4 1586 unsigned error:1; /* Ignore it, when an error occurred during resolution. */
90661f26 1587 unsigned ppc:1;
30b608eb
DK
1588}
1589gfc_typebound_proc;
1590
1591
6de9cd9a
DN
1592/* Symbol nodes. These are important things. They are what the
1593 standard refers to as "entities". The possibly multiple names that
1594 refer to the same entity are accomplished by a binary tree of
1595 symtree structures that is balanced by the red-black method-- more
1596 than one symtree node can point to any given symbol. */
1597
1598typedef struct gfc_symbol
1599{
cb9e4f55
TS
1600 const char *name; /* Primary name, before renaming */
1601 const char *module; /* Module this symbol came from */
6de9cd9a
DN
1602 locus declared_at;
1603
1604 gfc_typespec ts;
1605 symbol_attribute attr;
1606
32d99e68 1607 /* The formal member points to the formal argument list if the
6de9cd9a
DN
1608 symbol is a function or subroutine name. If the symbol is a
1609 generic name, the generic member points to the list of
1610 interfaces. */
1611
1612 gfc_interface *generic;
1613 gfc_access component_access;
1614
1615 gfc_formal_arglist *formal;
1616 struct gfc_namespace *formal_ns;
34523524
DK
1617 struct gfc_namespace *f2k_derived;
1618
5bab4c96
PT
1619 /* List of PDT parameter expressions */
1620 struct gfc_actual_arglist *param_list;
1621
6de9cd9a
DN
1622 struct gfc_expr *value; /* Parameter/Initializer value */
1623 gfc_array_spec *as;
1624 struct gfc_symbol *result; /* function result symbol */
1625 gfc_component *components; /* Derived type components */
1626
83d890b9
AL
1627 /* Defined only for Cray pointees; points to their pointer. */
1628 struct gfc_symbol *cp_pointer;
1629
cf2b3c22
TB
1630 int entry_id; /* Used in resolve.c for entries. */
1631
7c1dab0d
JW
1632 /* CLASS hashed name for declared and dynamic types in the class. */
1633 int hash_value;
cf2b3c22 1634
9056bd70 1635 struct gfc_symbol *common_next; /* Links for COMMON syms */
30aabb86 1636
a70ba41f
MM
1637 /* This is only used for pointer comparisons to check if symbols
1638 are in the same common block.
1639 In opposition to common_block, the common_head pointer takes into account
1640 equivalences: if A is in a common block C and A and B are in equivalence,
1641 then both A and B have common_head pointing to C, while A's common_block
1642 points to C and B's is NULL. */
30aabb86
PT
1643 struct gfc_common_head* common_head;
1644
6de9cd9a
DN
1645 /* Make sure setup code for dummy arguments is generated in the correct
1646 order. */
1647 int dummy_order;
1648
1649 gfc_namelist *namelist, *namelist_tail;
1650
1651 /* Change management fields. Symbols that might be modified by the
c064374d 1652 current statement have the mark member nonzero. Of these symbols,
6de9cd9a
DN
1653 symbols with old_symbol equal to NULL are symbols created within
1654 the current statement. Otherwise, old_symbol points to a copy of
278c3214
JB
1655 the old symbol. gfc_new is used in symbol.c to flag new symbols.
1656 comp_mark is used to indicate variables which have component accesses
1657 in OpenMP/OpenACC directive clauses. */
c064374d 1658 struct gfc_symbol *old_symbol;
278c3214 1659 unsigned mark:1, comp_mark:1, gfc_new:1;
c064374d
PT
1660
1661 /* The tlink field is used in the front end to carry the module
1662 declaration of separate module procedures so that the characteristics
1663 can be compared with the corresponding declaration in a submodule. In
1664 translation this field carries a linked list of symbols that require
1665 deferred initialization. */
1666 struct gfc_symbol *tlink;
1667
5291e69a
PB
1668 /* Nonzero if all equivalences associated with this symbol have been
1669 processed. */
1670 unsigned equiv_built:1;
31708dc6
RS
1671 /* Set if this variable is used as an index name in a FORALL. */
1672 unsigned forall_index:1;
345bd7eb
PT
1673 /* Set if the symbol is used in a function result specification . */
1674 unsigned fn_result_spec:1;
4af8d042 1675 /* Used to avoid multiple resolutions of a single symbol. */
dbeaa7ab
ME
1676 /* = 2 if this has already been resolved as an intrinsic,
1677 in gfc_resolve_intrinsic,
1678 = 1 if it has been resolved in resolve_symbol. */
1679 unsigned resolve_symbol_called:2;
4668d6f9
PT
1680 /* Set if this is a module function or subroutine with the
1681 abreviated declaration in a submodule. */
1682 unsigned abr_modproc_decl:1;
e0b9e5f9
TK
1683 /* Set if a previous error or warning has occurred and no other
1684 should be reported. */
1685 unsigned error:1;
4a4fc7fe
TK
1686 /* Set if the dummy argument of a procedure could be an array despite
1687 being called with a scalar actual argument. */
1688 unsigned maybe_array:1;
47d13acb
TK
1689 /* Set if this should be passed by value, but is not a VALUE argument
1690 according to the Fortran standard. */
1691 unsigned pass_as_value:1;
4af8d042 1692
6de9cd9a
DN
1693 int refs;
1694 struct gfc_namespace *ns; /* namespace containing this symbol */
1695
1696 tree backend_decl;
4d382327 1697
a8b3b0b6
CR
1698 /* Identity of the intrinsic module the symbol comes from, or
1699 INTMOD_NONE if it's not imported from a intrinsic module. */
1700 intmod_id from_intmod;
1701 /* Identity of the symbol from intrinsic modules, from enums maintained
1702 separately by each intrinsic module. Used together with from_intmod,
1703 it uniquely identifies a symbol from an intrinsic module. */
1704 int intmod_sym_id;
1705
1706 /* This may be repetitive, since the typespec now has a binding
1707 label field. */
9975a30b 1708 const char* binding_label;
a8b3b0b6
CR
1709 /* Store a reference to the common_block, if this symbol is in one. */
1710 struct gfc_common_head *common_block;
03af1e4c
DK
1711
1712 /* Link to corresponding association-list if this is an associate name. */
1713 struct gfc_association_list *assoc;
20e8ceae
AB
1714
1715 /* Link to next entry in derived type list */
1716 struct gfc_symbol *dt_next;
6de9cd9a
DN
1717}
1718gfc_symbol;
1719
dd355a42
MM
1720
1721struct gfc_undo_change_set
1722{
1723 vec<gfc_symbol *> syms;
1724 vec<gfc_typebound_proc *> tbps;
ab68a73e 1725 gfc_undo_change_set *previous;
dd355a42
MM
1726};
1727
1728
9056bd70 1729/* This structure is used to keep track of symbols in common blocks. */
30aabb86 1730typedef struct gfc_common_head
9056bd70
TS
1731{
1732 locus where;
b4c3a85b
JJ
1733 char use_assoc, saved, threadprivate;
1734 unsigned char omp_declare_target : 1;
1735 unsigned char omp_declare_target_link : 1;
d58e7173 1736 ENUM_BITFIELD (gfc_omp_device_type) omp_device_type:2;
3345e742
HA
1737 /* Provide sufficient space to hold "symbol.symbol.eq.1234567890". */
1738 char name[2*GFC_MAX_SYMBOL_LEN + 1 + 14 + 1];
30aabb86 1739 struct gfc_symbol *head;
9975a30b 1740 const char* binding_label;
a8b3b0b6 1741 int is_bind_c;
6f79f4d1 1742 int refs;
949446f5 1743}
9056bd70
TS
1744gfc_common_head;
1745
ece3f663 1746#define gfc_get_common_head() XCNEW (gfc_common_head)
9056bd70
TS
1747
1748
3d79abbd
PB
1749/* A list of all the alternate entry points for a procedure. */
1750
1751typedef struct gfc_entry_list
1752{
1753 /* The symbol for this entry point. */
1754 gfc_symbol *sym;
1755 /* The zero-based id of this entry point. */
1756 int id;
1757 /* The LABEL_EXPR marking this entry point. */
1758 tree label;
1933ba0f 1759 /* The next item in the list. */
3d79abbd
PB
1760 struct gfc_entry_list *next;
1761}
1762gfc_entry_list;
1763
93acb62c 1764#define gfc_get_entry_list() XCNEW (gfc_entry_list)
9056bd70 1765
a64f5186
JJ
1766/* Lists of rename info for the USE statement. */
1767
1768typedef struct gfc_use_rename
1769{
1770 char local_name[GFC_MAX_SYMBOL_LEN + 1], use_name[GFC_MAX_SYMBOL_LEN + 1];
1771 struct gfc_use_rename *next;
1772 int found;
1773 gfc_intrinsic_op op;
1774 locus where;
1775}
1776gfc_use_rename;
1777
1778#define gfc_get_use_rename() XCNEW (gfc_use_rename);
1779
1780/* A list of all USE statements in a namespace. */
1781
1782typedef struct gfc_use_list
1783{
1784 const char *module_name;
3d5dc929 1785 const char *submodule_name;
e9078ebb
TB
1786 bool intrinsic;
1787 bool non_intrinsic;
1788 bool only_flag;
a64f5186 1789 struct gfc_use_rename *rename;
9268ba9a 1790 locus where;
a64f5186
JJ
1791 /* Next USE statement. */
1792 struct gfc_use_list *next;
1793}
1794gfc_use_list;
1795
93acb62c 1796#define gfc_get_use_list() XCNEW (gfc_use_list)
a64f5186 1797
6de9cd9a
DN
1798/* Within a namespace, symbols are pointed to by symtree nodes that
1799 are linked together in a balanced binary tree. There can be
1800 several symtrees pointing to the same symbol node via USE
1801 statements. */
1802
6de9cd9a
DN
1803typedef struct gfc_symtree
1804{
1805 BBT_HEADER (gfc_symtree);
cb9e4f55 1806 const char *name;
6de9cd9a
DN
1807 int ambiguous;
1808 union
1809 {
1810 gfc_symbol *sym; /* Symbol associated with this node */
1811 gfc_user_op *uop;
9056bd70 1812 gfc_common_head *common;
e34ccb4c 1813 gfc_typebound_proc *tb;
5f23671d 1814 gfc_omp_udr *omp_udr;
6de9cd9a
DN
1815 }
1816 n;
6de9cd9a
DN
1817}
1818gfc_symtree;
1819
20e8ceae
AB
1820/* A list of all derived types. */
1821extern gfc_symbol *gfc_derived_types;
6b887797 1822
db941d7e
CP
1823typedef struct gfc_oacc_routine_name
1824{
1825 struct gfc_symbol *sym;
1826 struct gfc_omp_clauses *clauses;
1827 struct gfc_oacc_routine_name *next;
f6bf4bc1 1828 locus loc;
db941d7e
CP
1829}
1830gfc_oacc_routine_name;
1831
1832#define gfc_get_oacc_routine_name() XCNEW (gfc_oacc_routine_name)
1833
1af22e45
TK
1834/* Node in linked list to see what has already been finalized
1835 earlier. */
1836
1837typedef struct gfc_was_finalized {
1838 gfc_expr *e;
1839 gfc_component *c;
1840 struct gfc_was_finalized *next;
1841}
1842gfc_was_finalized;
1843
9abe5e56
DK
1844/* A namespace describes the contents of procedure, module, interface block
1845 or BLOCK construct. */
3d79abbd
PB
1846/* ??? Anything else use these? */
1847
6de9cd9a
DN
1848typedef struct gfc_namespace
1849{
4f613946
TS
1850 /* Tree containing all the symbols in this namespace. */
1851 gfc_symtree *sym_root;
1852 /* Tree containing all the user-defined operators in the namespace. */
1853 gfc_symtree *uop_root;
1854 /* Tree containing all the common blocks. */
949446f5 1855 gfc_symtree *common_root;
5f23671d
JJ
1856 /* Tree containing all the OpenMP user defined reductions. */
1857 gfc_symtree *omp_udr_root;
e34ccb4c
DK
1858
1859 /* Tree containing type-bound procedures. */
1860 gfc_symtree *tb_sym_root;
94747289
DK
1861 /* Type-bound user operators. */
1862 gfc_symtree *tb_uop_root;
1863 /* For derived-types, store type-bound intrinsic operators here. */
1864 gfc_typebound_proc *tb_op[GFC_INTRINSIC_OPS];
34523524
DK
1865 /* Linked list of finalizer procedures. */
1866 struct gfc_finalizer *finalizers;
6de9cd9a 1867
4f613946 1868 /* If set_flag[letter] is set, an implicit type has been set for letter. */
6de9cd9a 1869 int set_flag[GFC_LETTERS];
4f613946
TS
1870 /* Keeps track of the implicit types associated with the letters. */
1871 gfc_typespec default_type[GFC_LETTERS];
52f49934
DK
1872 /* Store the positions of IMPLICIT statements. */
1873 locus implicit_loc[GFC_LETTERS];
6de9cd9a 1874
4f613946 1875 /* If this is a namespace of a procedure, this points to the procedure. */
6de9cd9a 1876 struct gfc_symbol *proc_name;
4f613946
TS
1877 /* If this is the namespace of a unit which contains executable
1878 code, this points to it. */
6de9cd9a 1879 struct gfc_code *code;
4f613946
TS
1880
1881 /* Points to the equivalences set up in this namespace. */
31fee91e 1882 struct gfc_equiv *equiv, *old_equiv;
61321991
PT
1883
1884 /* Points to the equivalence groups produced by trans_common. */
1885 struct gfc_equiv_list *equiv_lists;
1886
a1ee985f 1887 gfc_interface *op[GFC_INTRINSIC_OPS];
4f613946
TS
1888
1889 /* Points to the parent namespace, i.e. the namespace of a module or
1890 procedure in which the procedure belonging to this namespace is
1891 contained. The parent namespace points to this namespace either
1892 directly via CONTAINED, or indirectly via the chain built by
1893 SIBLING. */
1894 struct gfc_namespace *parent;
1895 /* CONTAINED points to the first contained namespace. Sibling
1896 namespaces are chained via SIBLING. */
1897 struct gfc_namespace *contained, *sibling;
1898
1899 gfc_common_head blank_common;
6de9cd9a
DN
1900 gfc_access default_access, operator_access[GFC_INTRINSIC_OPS];
1901
1902 gfc_st_label *st_labels;
294fbfc8
TS
1903 /* This list holds information about all the data initializers in
1904 this namespace. */
d5e2274d 1905 struct gfc_data *data, *old_data;
6de9cd9a 1906
dc7a8b4b
JN
1907 /* !$ACC DECLARE. */
1908 gfc_oacc_declare *oacc_declare;
41dbbb37 1909
db941d7e
CP
1910 /* !$ACC ROUTINE clauses. */
1911 gfc_omp_clauses *oacc_routine_clauses;
1912
1913 /* !$ACC ROUTINE names. */
1914 gfc_oacc_routine_name *oacc_routine_names;
1915
d0803c0c 1916 gfc_charlen *cl_list;
6de9cd9a 1917
20e8ceae 1918 gfc_symbol *derived_types;
3af8d8cb 1919
4c1f4f52 1920 int save_all, seen_save, seen_implicit_none;
3d79abbd
PB
1921
1922 /* Normally we don't need to refcount namespaces. However when we read
1923 a module containing a function with multiple entry points, this
1924 will appear as several functions with the same formal namespace. */
1925 int refs;
1926
1927 /* A list of all alternate entry points to this procedure (or NULL). */
1928 gfc_entry_list *entries;
0de4325e 1929
a64f5186
JJ
1930 /* A list of USE statements in this namespace. */
1931 gfc_use_list *use_stmts;
1932
dd2fc525
JJ
1933 /* Linked list of !$omp declare simd constructs. */
1934 struct gfc_omp_declare_simd *omp_declare_simd;
1935
1af22e45
TK
1936 /* A hash set for the the gfc expressions that have already
1937 been finalized in this namespace. */
1938
1939 gfc_was_finalized *was_finalized;
1940
0de4325e 1941 /* Set to 1 if namespace is a BLOCK DATA program unit. */
9abe5e56 1942 unsigned is_block_data:1;
8998be20
TB
1943
1944 /* Set to 1 if namespace is an interface body with "IMPORT" used. */
9abe5e56 1945 unsigned has_import_set:1;
71a7778c 1946
8b7a967e
TB
1947 /* Set to 1 if the namespace uses "IMPLICT NONE (export)". */
1948 unsigned has_implicit_none_export:1;
1949
204803dc
JR
1950 /* Set to 1 if resolved has been called for this namespace.
1951 Holds -1 during resolution. */
1952 signed resolved:2;
3af8d8cb 1953
2b91aea8
MM
1954 /* Set when resolve_types has been called for this namespace. */
1955 unsigned types_resolved:1;
1956
3af8d8cb 1957 /* Set to 1 if code has been generated for this namespace. */
9abe5e56
DK
1958 unsigned translated:1;
1959
1960 /* Set to 1 if symbols in this namespace should be 'construct entities',
1961 i.e. for BLOCK local variables. */
1962 unsigned construct_entities:1;
5f23671d
JJ
1963
1964 /* Set to 1 for !$OMP DECLARE REDUCTION namespaces. */
1965 unsigned omp_udr_ns:1;
db941d7e
CP
1966
1967 /* Set to 1 for !$ACC ROUTINE namespaces. */
1968 unsigned oacc_routine:1;
ffeebc4f
JJ
1969
1970 /* Set to 1 if there are any calls to procedures with implicit interface. */
1971 unsigned implicit_interface_calls:1;
269322ec
TB
1972
1973 /* OpenMP requires. */
1974 unsigned omp_requires:6;
1975 unsigned omp_target_seen:1;
6de9cd9a
DN
1976}
1977gfc_namespace;
1978
1979extern gfc_namespace *gfc_current_ns;
71a7778c 1980extern gfc_namespace *gfc_global_ns_list;
6de9cd9a 1981
c9543002
TS
1982/* Global symbols are symbols of global scope. Currently we only use
1983 this to detect collisions already when parsing.
1984 TODO: Extend to verify procedure calls. */
1985
32e8bb8e
ILT
1986enum gfc_symbol_type
1987{
1988 GSYM_UNKNOWN=1, GSYM_PROGRAM, GSYM_FUNCTION, GSYM_SUBROUTINE,
1989 GSYM_MODULE, GSYM_COMMON, GSYM_BLOCK_DATA
1990};
1991
c9543002
TS
1992typedef struct gfc_gsymbol
1993{
1994 BBT_HEADER(gfc_gsymbol);
1995
973a384d 1996 const char *name;
a8b3b0b6
CR
1997 const char *sym_name;
1998 const char *mod_name;
1999 const char *binding_label;
32e8bb8e 2000 enum gfc_symbol_type type;
c9543002
TS
2001
2002 int defined, used;
55b9c612 2003 bool bind_c;
c9543002 2004 locus where;
71a7778c 2005 gfc_namespace *ns;
c9543002
TS
2006}
2007gfc_gsymbol;
2008
2009extern gfc_gsymbol *gfc_gsym_root;
6de9cd9a
DN
2010
2011/* Information on interfaces being built. */
2012typedef struct
2013{
2014 interface_type type;
2015 gfc_symbol *sym;
2016 gfc_namespace *ns;
2017 gfc_user_op *uop;
2018 gfc_intrinsic_op op;
2019}
2020gfc_interface_info;
2021
2022extern gfc_interface_info current_interface;
2023
2024
2025/* Array reference. */
32e8bb8e
ILT
2026
2027enum gfc_array_ref_dimen_type
2028{
a3935ffc 2029 DIMEN_ELEMENT = 1, DIMEN_RANGE, DIMEN_VECTOR, DIMEN_STAR, DIMEN_THIS_IMAGE, DIMEN_UNKNOWN
32e8bb8e
ILT
2030};
2031
6de9cd9a
DN
2032typedef struct gfc_array_ref
2033{
2034 ar_type type;
2035 int dimen; /* # of components in the reference */
d3a9eea2
TB
2036 int codimen;
2037 bool in_allocate; /* For coarray checks. */
f8862a1b 2038 gfc_expr *team;
20d0bfce 2039 gfc_expr *stat;
6de9cd9a
DN
2040 locus where;
2041 gfc_array_spec *as;
2042
2043 locus c_where[GFC_MAX_DIMENSIONS]; /* All expressions can be NULL */
2044 struct gfc_expr *start[GFC_MAX_DIMENSIONS], *end[GFC_MAX_DIMENSIONS],
2045 *stride[GFC_MAX_DIMENSIONS];
2046
32e8bb8e 2047 enum gfc_array_ref_dimen_type dimen_type[GFC_MAX_DIMENSIONS];
6de9cd9a
DN
2048}
2049gfc_array_ref;
2050
ece3f663 2051#define gfc_get_array_ref() XCNEW (gfc_array_ref)
6de9cd9a
DN
2052
2053
2054/* Component reference nodes. A variable is stored as an expression
2055 node that points to the base symbol. After that, a singly linked
2056 list of component reference nodes gives the variable's complete
2057 resolution. The array_ref component may be present and comes
2058 before the component component. */
2059
a79683d5 2060enum ref_type
a5fbc2f3
PT
2061 { REF_ARRAY, REF_COMPONENT, REF_SUBSTRING, REF_INQUIRY };
2062
2063enum inquiry_type
2064 { INQUIRY_RE, INQUIRY_IM, INQUIRY_KIND, INQUIRY_LEN };
6de9cd9a
DN
2065
2066typedef struct gfc_ref
2067{
2068 ref_type type;
2069
2070 union
2071 {
2072 struct gfc_array_ref ar;
2073
2074 struct
2075 {
2076 gfc_component *component;
2077 gfc_symbol *sym;
2078 }
2079 c;
2080
2081 struct
2082 {
2083 struct gfc_expr *start, *end; /* Substring */
2084 gfc_charlen *length;
2085 }
2086 ss;
2087
a5fbc2f3
PT
2088 inquiry_type i;
2089
6de9cd9a
DN
2090 }
2091 u;
2092
2093 struct gfc_ref *next;
2094}
2095gfc_ref;
2096
ece3f663 2097#define gfc_get_ref() XCNEW (gfc_ref)
6de9cd9a
DN
2098
2099
2100/* Structures representing intrinsic symbols and their arguments lists. */
2101typedef struct gfc_intrinsic_arg
2102{
2103 char name[GFC_MAX_SYMBOL_LEN + 1];
2104
2105 gfc_typespec ts;
47b99694 2106 unsigned optional:1, value:1;
23e38561 2107 ENUM_BITFIELD (sym_intent) intent:2;
6de9cd9a
DN
2108 gfc_actual_arglist *actual;
2109
2110 struct gfc_intrinsic_arg *next;
2111
2112}
2113gfc_intrinsic_arg;
2114
2115
4f613946
TS
2116/* Specifies the various kinds of check functions used to verify the
2117 argument lists of intrinsic functions. fX with X an integer refer
2118 to check functions of intrinsics with X arguments. f1m is used for
2119 the MAX and MIN intrinsics which can have an arbitrary number of
9a3d38f6 2120 arguments, f4ml is used for the MINLOC and MAXLOC intrinsics as
4f613946
TS
2121 these have special semantics. */
2122
6de9cd9a
DN
2123typedef union
2124{
524af0d6
JB
2125 bool (*f0)(void);
2126 bool (*f1)(struct gfc_expr *);
2127 bool (*f1m)(gfc_actual_arglist *);
2128 bool (*f2)(struct gfc_expr *, struct gfc_expr *);
2129 bool (*f3)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *);
64b1806b 2130 bool (*f5ml)(gfc_actual_arglist *);
01ce9e31 2131 bool (*f6fl)(gfc_actual_arglist *);
524af0d6
JB
2132 bool (*f3red)(gfc_actual_arglist *);
2133 bool (*f4)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *,
6de9cd9a 2134 struct gfc_expr *);
524af0d6 2135 bool (*f5)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *,
6de9cd9a
DN
2136 struct gfc_expr *, struct gfc_expr *);
2137}
2138gfc_check_f;
2139
4f613946
TS
2140/* Like gfc_check_f, these specify the type of the simplification
2141 function associated with an intrinsic. The fX are just like in
2142 gfc_check_f. cc is used for type conversion functions. */
6de9cd9a
DN
2143
2144typedef union
2145{
4c0c6b9f 2146 struct gfc_expr *(*f0)(void);
6de9cd9a
DN
2147 struct gfc_expr *(*f1)(struct gfc_expr *);
2148 struct gfc_expr *(*f2)(struct gfc_expr *, struct gfc_expr *);
2149 struct gfc_expr *(*f3)(struct gfc_expr *, struct gfc_expr *,
2150 struct gfc_expr *);
2151 struct gfc_expr *(*f4)(struct gfc_expr *, struct gfc_expr *,
2152 struct gfc_expr *, struct gfc_expr *);
2153 struct gfc_expr *(*f5)(struct gfc_expr *, struct gfc_expr *,
2154 struct gfc_expr *, struct gfc_expr *,
2155 struct gfc_expr *);
01ce9e31
TK
2156 struct gfc_expr *(*f6)(struct gfc_expr *, struct gfc_expr *,
2157 struct gfc_expr *, struct gfc_expr *,
2158 struct gfc_expr *, struct gfc_expr *);
6de9cd9a
DN
2159 struct gfc_expr *(*cc)(struct gfc_expr *, bt, int);
2160}
2161gfc_simplify_f;
2162
4f613946 2163/* Again like gfc_check_f, these specify the type of the resolution
13795658 2164 function associated with an intrinsic. The fX are just like in
66e4ab31 2165 gfc_check_f. f1m is used for MIN and MAX, s1 is used for abort(). */
6de9cd9a
DN
2166
2167typedef union
2168{
2169 void (*f0)(struct gfc_expr *);
2170 void (*f1)(struct gfc_expr *, struct gfc_expr *);
2171 void (*f1m)(struct gfc_expr *, struct gfc_actual_arglist *);
2172 void (*f2)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *);
2173 void (*f3)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *,
2174 struct gfc_expr *);
2175 void (*f4)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *,
2176 struct gfc_expr *, struct gfc_expr *);
2177 void (*f5)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *,
2178 struct gfc_expr *, struct gfc_expr *, struct gfc_expr *);
01ce9e31
TK
2179 void (*f6)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *,
2180 struct gfc_expr *, struct gfc_expr *, struct gfc_expr *,
2181 struct gfc_expr *);
6de9cd9a
DN
2182 void (*s1)(struct gfc_code *);
2183}
2184gfc_resolve_f;
2185
2186
2187typedef struct gfc_intrinsic_sym
2188{
cb9e4f55 2189 const char *name, *lib_name;
6de9cd9a
DN
2190 gfc_intrinsic_arg *formal;
2191 gfc_typespec ts;
4d382327 2192 unsigned elemental:1, inquiry:1, transformational:1, pure:1,
d000aa67 2193 generic:1, specific:1, actual_ok:1, noreturn:1, conversion:1,
f1abbf69 2194 from_module:1, vararg:1;
e1633d82
DF
2195
2196 int standard;
6de9cd9a
DN
2197
2198 gfc_simplify_f simplify;
2199 gfc_check_f check;
2200 gfc_resolve_f resolve;
2201 struct gfc_intrinsic_sym *specific_head, *next;
cd5ecab6 2202 gfc_isym_id id;
6de9cd9a
DN
2203
2204}
2205gfc_intrinsic_sym;
2206
2207
2208/* Expression nodes. The expression node types deserve explanations,
2209 since the last couple can be easily misconstrued:
2210
2211 EXPR_OP Operator node pointing to one or two other nodes
2212 EXPR_FUNCTION Function call, symbol points to function's name
2213 EXPR_CONSTANT A scalar constant: Logical, String, Real, Int or Complex
2214 EXPR_VARIABLE An Lvalue with a root symbol and possible reference list
8e1f752a 2215 which expresses structure, array and substring refs.
6de9cd9a
DN
2216 EXPR_NULL The NULL pointer value (which also has a basic type).
2217 EXPR_SUBSTRING A substring of a constant string
2218 EXPR_STRUCTURE A structure constructor
8e1f752a
DK
2219 EXPR_ARRAY An array constructor.
2220 EXPR_COMPCALL Function (or subroutine) call of a procedure pointer
2221 component or type-bound procedure. */
6de9cd9a 2222
f8e566e5 2223#include <mpfr.h>
eb6f9a86 2224#include <mpc.h>
c9d4cc5d 2225#define GFC_RND_MODE MPFR_RNDN
f6b855df 2226#define GFC_MPC_RND_MODE MPC_RNDNN
6de9cd9a 2227
b7e75771
JD
2228typedef splay_tree gfc_constructor_base;
2229
f622221a
JB
2230
2231/* This should be an unsigned variable of type size_t. But to handle
2232 compiling to a 64-bit target from a 32-bit host, we need to use a
2233 HOST_WIDE_INT. Also, occasionally the string length field is used
2234 as a flag with values -1 and -2, see e.g. gfc_add_assign_aux_vars.
2235 So it needs to be signed. */
2236typedef HOST_WIDE_INT gfc_charlen_t;
2237
6de9cd9a
DN
2238typedef struct gfc_expr
2239{
2240 expr_t expr_type;
2241
2242 gfc_typespec ts; /* These two refer to the overall expression */
2243
c62c6622 2244 int rank; /* 0 indicates a scalar, -1 an assumed-rank array. */
6de9cd9a
DN
2245 mpz_t *shape; /* Can be NULL if shape is unknown at compile time */
2246
4a44a72d
DK
2247 /* Nonnull for functions and structure constructors, may also used to hold the
2248 base-object for component calls. */
6de9cd9a
DN
2249 gfc_symtree *symtree;
2250
6de9cd9a
DN
2251 gfc_ref *ref;
2252
6de9cd9a
DN
2253 locus where;
2254
94fae14b
PT
2255 /* Used to store the base expression in component calls, when the expression
2256 is not a variable. */
32a9b8e0 2257 struct gfc_expr *base_expr;
94fae14b 2258
8dc63166
SK
2259 /* is_snan denotes a signalling not-a-number. */
2260 unsigned int is_snan : 1;
20585ad6 2261
ebb479cd
PT
2262 /* Sometimes, when an error has been emitted, it is necessary to prevent
2263 it from recurring. */
2264 unsigned int error : 1;
4d382327 2265
94bff632 2266 /* Mark an expression where a user operator has been substituted by
a1ab6660
PT
2267 a function call in interface.c(gfc_extend_expr). */
2268 unsigned int user_operator : 1;
ebb479cd 2269
94bff632
JW
2270 /* Mark an expression as being a MOLD argument of ALLOCATE. */
2271 unsigned int mold : 1;
4d382327 2272
43a68a9d
PT
2273 /* Will require finalization after use. */
2274 unsigned int must_finalize : 1;
2275
980fa45e
TK
2276 /* Set this if no range check should be performed on this expression. */
2277
2278 unsigned int no_bounds_check : 1;
2279
998511a6
TK
2280 /* Set this if a matmul expression has already been evaluated for conversion
2281 to a BLAS call. */
2282
2283 unsigned int external_blas : 1;
2284
01ce9e31
TK
2285 /* Set this if resolution has already happened. It could be harmful
2286 if done again. */
2287
2288 unsigned int do_not_resolve_again : 1;
2289
5197d799
TK
2290 /* Set this if no warning should be given somewhere in a lower level. */
2291
2292 unsigned int do_not_warn : 1;
4a4fc7fe
TK
2293
2294 /* Set this if the expression came from expanding an array constructor. */
2295 unsigned int from_constructor : 1;
2296
20585ad6
BM
2297 /* If an expression comes from a Hollerith constant or compile-time
2298 evaluation of a transfer statement, it may have a prescribed target-
2299 memory representation, and these cannot always be backformed from
2300 the value. */
2301 struct
2302 {
f622221a 2303 gfc_charlen_t length;
20585ad6
BM
2304 char *string;
2305 }
2306 representation;
2307
8dc63166
SK
2308 struct
2309 {
2310 int len; /* Length of BOZ string without terminating NULL. */
2311 int rdx; /* Radix of BOZ. */
2312 char *str; /* BOZ string with NULL terminating character. */
2313 }
2314 boz;
2315
6de9cd9a
DN
2316 union
2317 {
6de9cd9a 2318 int logical;
20585ad6 2319
ad7ee6f8
JD
2320 io_kind iokind;
2321
f8e566e5
SK
2322 mpz_t integer;
2323
2324 mpfr_t real;
6de9cd9a 2325
d0d92baf 2326 mpc_t complex;
6de9cd9a 2327
58b03ab2
TS
2328 struct
2329 {
a1ee985f 2330 gfc_intrinsic_op op;
58b03ab2
TS
2331 gfc_user_op *uop;
2332 struct gfc_expr *op1, *op2;
2333 }
2334 op;
2335
6de9cd9a
DN
2336 struct
2337 {
2338 gfc_actual_arglist *actual;
6b25a558 2339 const char *name; /* Points to the ultimate name of the function */
6de9cd9a
DN
2340 gfc_intrinsic_sym *isym;
2341 gfc_symbol *esym;
2342 }
2343 function;
2344
8e1f752a
DK
2345 struct
2346 {
2347 gfc_actual_arglist* actual;
e157f736 2348 const char* name;
4a44a72d
DK
2349 /* Base-object, whose component was called. NULL means that it should
2350 be taken from symtree/ref. */
2351 struct gfc_expr* base_object;
2352 gfc_typebound_proc* tbp; /* Should overlap with esym. */
2353
2354 /* For type-bound operators, we want to call PASS procedures but already
2355 have the full arglist; mark this, so that it is not extended by the
2356 PASS argument. */
2357 unsigned ignore_pass:1;
2358
2359 /* Do assign-calls rather than calls, that is appropriate dependency
2360 checking. */
2361 unsigned assign:1;
8e1f752a
DK
2362 }
2363 compcall;
2364
6de9cd9a
DN
2365 struct
2366 {
f622221a 2367 gfc_charlen_t length;
00660189 2368 gfc_char_t *string;
6de9cd9a
DN
2369 }
2370 character;
2371
b7e75771 2372 gfc_constructor_base constructor;
6de9cd9a
DN
2373 }
2374 value;
2375
5bab4c96
PT
2376 /* Used to store PDT expression lists associated with expressions. */
2377 gfc_actual_arglist *param_list;
2378
6de9cd9a
DN
2379}
2380gfc_expr;
2381
2382
93acb62c 2383#define gfc_get_shape(rank) (XCNEWVEC (mpz_t, (rank)))
6de9cd9a
DN
2384
2385/* Structures for information associated with different kinds of
2386 numbers. The first set of integer parameters define all there is
2387 to know about a particular kind. The rest of the elements are
2388 computed from the first elements. */
2389
2390typedef struct
2391{
e2cad04b 2392 /* Values really representable by the target. */
7bee49dc 2393 mpz_t huge, pedantic_min_int, min_int;
e2cad04b
RH
2394
2395 int kind, radix, digits, bit_size, range;
2396
2397 /* True if the C type of the given name maps to this precision.
2398 Note that more than one bit can be set. */
2399 unsigned int c_char : 1;
2400 unsigned int c_short : 1;
2401 unsigned int c_int : 1;
2402 unsigned int c_long : 1;
2403 unsigned int c_long_long : 1;
6de9cd9a
DN
2404}
2405gfc_integer_info;
2406
2407extern gfc_integer_info gfc_integer_kinds[];
2408
2409
2410typedef struct
2411{
2412 int kind, bit_size;
2413
e2cad04b
RH
2414 /* True if the C++ type bool, C99 type _Bool, maps to this precision. */
2415 unsigned int c_bool : 1;
6de9cd9a
DN
2416}
2417gfc_logical_info;
2418
2419extern gfc_logical_info gfc_logical_kinds[];
2420
2421
2422typedef struct
2423{
2d0aa65f 2424 mpfr_t epsilon, huge, tiny, subnormal;
6de9cd9a 2425 int kind, radix, digits, min_exponent, max_exponent;
6de9cd9a 2426 int range, precision;
e2cad04b
RH
2427
2428 /* The precision of the type as reported by GET_MODE_PRECISION. */
2429 int mode_precision;
2430
2431 /* True if the C type of the given name maps to this precision.
2432 Note that more than one bit can be set. */
2433 unsigned int c_float : 1;
2434 unsigned int c_double : 1;
2435 unsigned int c_long_double : 1;
a3c85b74 2436 unsigned int c_float128 : 1;
6de9cd9a
DN
2437}
2438gfc_real_info;
2439
2440extern gfc_real_info gfc_real_kinds[];
2441
374929b2
FXC
2442typedef struct
2443{
2444 int kind, bit_size;
2445 const char *name;
2446}
2447gfc_character_info;
2448
2449extern gfc_character_info gfc_character_kinds[];
2450
6de9cd9a
DN
2451
2452/* Equivalence structures. Equivalent lvalues are linked along the
2453 *eq pointer, equivalence sets are strung along the *next node. */
2454typedef struct gfc_equiv
2455{
2456 struct gfc_equiv *next, *eq;
2457 gfc_expr *expr;
30aabb86 2458 const char *module;
6de9cd9a
DN
2459 int used;
2460}
2461gfc_equiv;
2462
ece3f663 2463#define gfc_get_equiv() XCNEW (gfc_equiv)
6de9cd9a 2464
61321991
PT
2465/* Holds a single equivalence member after processing. */
2466typedef struct gfc_equiv_info
2467{
2468 gfc_symbol *sym;
2469 HOST_WIDE_INT offset;
37311e71 2470 HOST_WIDE_INT length;
61321991
PT
2471 struct gfc_equiv_info *next;
2472} gfc_equiv_info;
2473
2474/* Holds equivalence groups, after they have been processed. */
2475typedef struct gfc_equiv_list
2476{
2477 gfc_equiv_info *equiv;
2478 struct gfc_equiv_list *next;
2479} gfc_equiv_list;
6de9cd9a
DN
2480
2481/* gfc_case stores the selector list of a case statement. The *low
2482 and *high pointers can point to the same expression in the case of
2483 a single value. If *high is NULL, the selection is from *low
2484 upwards, if *low is NULL the selection is *high downwards.
2485
410d1a45
SK
2486 This structure has separate fields to allow single and double linked
2487 lists of CASEs at the same time. The singe linked list along the NEXT
6de9cd9a
DN
2488 field is a list of cases for a single CASE label. The double linked
2489 list along the LEFT/RIGHT fields is used to detect overlap and to
2490 build a table of the cases for SELECT constructs with a CHARACTER
2491 case expression. */
2492
2493typedef struct gfc_case
2494{
2495 /* Where we saw this case. */
2496 locus where;
2497 int n;
2498
2499 /* Case range values. If (low == high), it's a single value. If one of
2500 the labels is NULL, it's an unbounded case. If both are NULL, this
2501 represents the default case. */
2502 gfc_expr *low, *high;
2503
cf2b3c22
TB
2504 /* Only used for SELECT TYPE. */
2505 gfc_typespec ts;
2506
6de9cd9a
DN
2507 /* Next case label in the list of cases for a single CASE label. */
2508 struct gfc_case *next;
2509
2510 /* Used for detecting overlap, and for code generation. */
2511 struct gfc_case *left, *right;
2512
2513 /* True if this case label can never be matched. */
2514 int unreachable;
2515}
2516gfc_case;
2517
ece3f663 2518#define gfc_get_case() XCNEW (gfc_case)
6de9cd9a
DN
2519
2520
2521typedef struct
2522{
2523 gfc_expr *var, *start, *end, *step;
170a8bd6 2524 unsigned short unroll;
2bd86b95
HA
2525 bool ivdep;
2526 bool vector;
2527 bool novector;
6de9cd9a
DN
2528}
2529gfc_iterator;
2530
ece3f663 2531#define gfc_get_iterator() XCNEW (gfc_iterator)
6de9cd9a
DN
2532
2533
f7b529fa 2534/* Allocation structure for ALLOCATE, DEALLOCATE and NULLIFY statements. */
6de9cd9a
DN
2535
2536typedef struct gfc_alloc
2537{
2538 gfc_expr *expr;
2539 struct gfc_alloc *next;
2540}
2541gfc_alloc;
2542
ece3f663 2543#define gfc_get_alloc() XCNEW (gfc_alloc)
6de9cd9a
DN
2544
2545
2546typedef struct
2547{
2548 gfc_expr *unit, *file, *status, *access, *form, *recl,
6f0f0b2e 2549 *blank, *position, *action, *delim, *pad, *iostat, *iomsg, *convert,
0ef33d44
FR
2550 *decimal, *encoding, *round, *sign, *asynchronous, *id, *newunit,
2551 *share, *cc;
2552 char readonly;
6de9cd9a
DN
2553 gfc_st_label *err;
2554}
2555gfc_open;
2556
2557
2558typedef struct
2559{
7aba8abe 2560 gfc_expr *unit, *status, *iostat, *iomsg;
6de9cd9a
DN
2561 gfc_st_label *err;
2562}
2563gfc_close;
2564
2565
2566typedef struct
2567{
7aba8abe 2568 gfc_expr *unit, *iostat, *iomsg;
6de9cd9a
DN
2569 gfc_st_label *err;
2570}
2571gfc_filepos;
2572
2573
2574typedef struct
2575{
2576 gfc_expr *unit, *file, *iostat, *exist, *opened, *number, *named,
2577 *name, *access, *sequential, *direct, *form, *formatted,
2578 *unformatted, *recl, *nextrec, *blank, *position, *action, *read,
6f0f0b2e 2579 *write, *readwrite, *delim, *pad, *iolength, *iomsg, *convert, *strm_pos,
93e8af19 2580 *asynchronous, *decimal, *encoding, *pending, *round, *sign, *size, *id,
0ef33d44 2581 *iqstream, *share, *cc;
6de9cd9a
DN
2582
2583 gfc_st_label *err;
2584
2585}
2586gfc_inquire;
2587
2588
2589typedef struct
2590{
6f0f0b2e
JD
2591 gfc_expr *unit, *iostat, *iomsg, *id;
2592 gfc_st_label *err, *end, *eor;
2593}
2594gfc_wait;
2595
2596
2597typedef struct
2598{
2599 gfc_expr *io_unit, *format_expr, *rec, *advance, *iostat, *size, *iomsg,
2600 *id, *pos, *asynchronous, *blank, *decimal, *delim, *pad, *round,
4a8d4422 2601 *sign, *extra_comma, *dt_io_kind, *udtio;
7ee4f6f3 2602 char dec_ext;
6de9cd9a
DN
2603
2604 gfc_symbol *namelist;
2605 /* A format_label of `format_asterisk' indicates the "*" format */
2606 gfc_st_label *format_label;
2607 gfc_st_label *err, *end, *eor;
2608
e0e85e06 2609 locus eor_where, end_where, err_where;
6de9cd9a
DN
2610}
2611gfc_dt;
2612
2613
2614typedef struct gfc_forall_iterator
2615{
2616 gfc_expr *var, *start, *end, *stride;
2617 struct gfc_forall_iterator *next;
2618}
2619gfc_forall_iterator;
2620
2621
03af1e4c
DK
2622/* Linked list to store associations in an ASSOCIATE statement. */
2623
2624typedef struct gfc_association_list
2625{
4d382327 2626 struct gfc_association_list *next;
03af1e4c
DK
2627
2628 /* Whether this is association to a variable that can be changed; otherwise,
2629 it's association to an expression and the name may not be used as
2630 lvalue. */
2631 unsigned variable:1;
2632
3e78238a
DK
2633 /* True if this struct is currently only linked to from a gfc_symbol rather
2634 than as part of a real list in gfc_code->ext.block.assoc. This may
2635 happen for SELECT TYPE temporaries and must be considered
2636 for memory handling. */
2637 unsigned dangling:1;
2638
76fe932b
AV
2639 /* True when the rank of the target expression is guessed during parsing. */
2640 unsigned rankguessed:1;
2641
03af1e4c
DK
2642 char name[GFC_MAX_SYMBOL_LEN + 1];
2643 gfc_symtree *st; /* Symtree corresponding to name. */
571d54de
DK
2644 locus where;
2645
03af1e4c
DK
2646 gfc_expr *target;
2647}
2648gfc_association_list;
2649#define gfc_get_association_list() XCNEW (gfc_association_list)
2650
2651
6de9cd9a 2652/* Executable statements that fill gfc_code structures. */
a79683d5 2653enum gfc_exec_op
6de9cd9a 2654{
df1a69f6
MM
2655 EXEC_NOP = 1, EXEC_END_NESTED_BLOCK, EXEC_END_BLOCK, EXEC_ASSIGN,
2656 EXEC_LABEL_ASSIGN, EXEC_POINTER_ASSIGN, EXEC_CRITICAL, EXEC_ERROR_STOP,
8e1f752a
DK
2657 EXEC_GOTO, EXEC_CALL, EXEC_COMPCALL, EXEC_ASSIGN_CALL, EXEC_RETURN,
2658 EXEC_ENTRY, EXEC_PAUSE, EXEC_STOP, EXEC_CONTINUE, EXEC_INIT_ASSIGN,
8c6a85e3
TB
2659 EXEC_IF, EXEC_ARITHMETIC_IF, EXEC_DO, EXEC_DO_CONCURRENT, EXEC_DO_WHILE,
2660 EXEC_SELECT, EXEC_BLOCK, EXEC_FORALL, EXEC_WHERE, EXEC_CYCLE, EXEC_EXIT,
2661 EXEC_CALL_PPC, EXEC_ALLOCATE, EXEC_DEALLOCATE, EXEC_END_PROCEDURE,
70570ec1
PT
2662 EXEC_SELECT_TYPE, EXEC_SELECT_RANK, EXEC_SYNC_ALL, EXEC_SYNC_MEMORY,
2663 EXEC_SYNC_IMAGES, EXEC_OPEN, EXEC_CLOSE, EXEC_WAIT,
6de9cd9a 2664 EXEC_READ, EXEC_WRITE, EXEC_IOLENGTH, EXEC_TRANSFER, EXEC_DT_END,
6c7a4dfd 2665 EXEC_BACKSPACE, EXEC_ENDFILE, EXEC_INQUIRE, EXEC_REWIND, EXEC_FLUSH,
f8862a1b 2666 EXEC_FORM_TEAM, EXEC_CHANGE_TEAM, EXEC_END_TEAM, EXEC_SYNC_TEAM,
ef78bc3c 2667 EXEC_LOCK, EXEC_UNLOCK, EXEC_EVENT_POST, EXEC_EVENT_WAIT, EXEC_FAIL_IMAGE,
62aee289
MR
2668 EXEC_OACC_KERNELS_LOOP, EXEC_OACC_PARALLEL_LOOP, EXEC_OACC_SERIAL_LOOP,
2669 EXEC_OACC_ROUTINE, EXEC_OACC_PARALLEL, EXEC_OACC_KERNELS, EXEC_OACC_SERIAL,
2670 EXEC_OACC_DATA, EXEC_OACC_HOST_DATA, EXEC_OACC_LOOP, EXEC_OACC_UPDATE,
2671 EXEC_OACC_WAIT, EXEC_OACC_CACHE, EXEC_OACC_ENTER_DATA, EXEC_OACC_EXIT_DATA,
2672 EXEC_OACC_ATOMIC, EXEC_OACC_DECLARE,
6c7a4dfd
JJ
2673 EXEC_OMP_CRITICAL, EXEC_OMP_DO, EXEC_OMP_FLUSH, EXEC_OMP_MASTER,
2674 EXEC_OMP_ORDERED, EXEC_OMP_PARALLEL, EXEC_OMP_PARALLEL_DO,
2675 EXEC_OMP_PARALLEL_SECTIONS, EXEC_OMP_PARALLEL_WORKSHARE,
2676 EXEC_OMP_SECTIONS, EXEC_OMP_SINGLE, EXEC_OMP_WORKSHARE,
2677 EXEC_OMP_ATOMIC, EXEC_OMP_BARRIER, EXEC_OMP_END_NOWAIT,
20906c66 2678 EXEC_OMP_END_SINGLE, EXEC_OMP_TASK, EXEC_OMP_TASKWAIT,
dd2fc525
JJ
2679 EXEC_OMP_TASKYIELD, EXEC_OMP_CANCEL, EXEC_OMP_CANCELLATION_POINT,
2680 EXEC_OMP_TASKGROUP, EXEC_OMP_SIMD, EXEC_OMP_DO_SIMD,
f014c653
JJ
2681 EXEC_OMP_PARALLEL_DO_SIMD, EXEC_OMP_TARGET, EXEC_OMP_TARGET_DATA,
2682 EXEC_OMP_TEAMS, EXEC_OMP_DISTRIBUTE, EXEC_OMP_DISTRIBUTE_SIMD,
2683 EXEC_OMP_DISTRIBUTE_PARALLEL_DO, EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD,
2684 EXEC_OMP_TARGET_TEAMS, EXEC_OMP_TEAMS_DISTRIBUTE,
2685 EXEC_OMP_TEAMS_DISTRIBUTE_SIMD, EXEC_OMP_TARGET_TEAMS_DISTRIBUTE,
2686 EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD,
2687 EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO,
2688 EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO,
2689 EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD,
2690 EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD,
b4c3a85b
JJ
2691 EXEC_OMP_TARGET_UPDATE, EXEC_OMP_END_CRITICAL,
2692 EXEC_OMP_TARGET_ENTER_DATA, EXEC_OMP_TARGET_EXIT_DATA,
2693 EXEC_OMP_TARGET_PARALLEL, EXEC_OMP_TARGET_PARALLEL_DO,
2694 EXEC_OMP_TARGET_PARALLEL_DO_SIMD, EXEC_OMP_TARGET_SIMD,
2695 EXEC_OMP_TASKLOOP, EXEC_OMP_TASKLOOP_SIMD
a79683d5 2696};
6de9cd9a
DN
2697
2698typedef struct gfc_code
2699{
2700 gfc_exec_op op;
2701
2702 struct gfc_code *block, *next;
2703 locus loc;
2704
79bd1948 2705 gfc_st_label *here, *label1, *label2, *label3;
6de9cd9a 2706 gfc_symtree *symtree;
5493aa17 2707 gfc_expr *expr1, *expr2, *expr3, *expr4;
6de9cd9a
DN
2708 /* A name isn't sufficient to identify a subroutine, we need the actual
2709 symbol for the interface definition.
2710 const char *sub_name; */
2711 gfc_symbol *resolved_sym;
12f681a0 2712 gfc_intrinsic_sym *resolved_isym;
6de9cd9a
DN
2713
2714 union
2715 {
2716 gfc_actual_arglist *actual;
6de9cd9a 2717 gfc_iterator *iterator;
cf2b3c22
TB
2718
2719 struct
2720 {
2721 gfc_typespec ts;
2722 gfc_alloc *list;
1792349b
AV
2723 /* Take the array specification from expr3 to allocate arrays
2724 without an explicit array specification. */
2725 unsigned arr_spec_from_expr3:1;
cf2b3c22
TB
2726 }
2727 alloc;
2728
03af1e4c
DK
2729 struct
2730 {
2731 gfc_namespace *ns;
2732 gfc_association_list *assoc;
29a63d67 2733 gfc_case *case_list;
03af1e4c
DK
2734 }
2735 block;
2736
6de9cd9a
DN
2737 gfc_open *open;
2738 gfc_close *close;
2739 gfc_filepos *filepos;
2740 gfc_inquire *inquire;
6f0f0b2e 2741 gfc_wait *wait;
6de9cd9a
DN
2742 gfc_dt *dt;
2743 gfc_forall_iterator *forall_iterator;
e5ca9693 2744 struct gfc_code *which_construct;
6de9cd9a 2745 int stop_code;
3d79abbd 2746 gfc_entry_list *entry;
dc7a8b4b 2747 gfc_oacc_declare *oacc_declare;
6c7a4dfd
JJ
2748 gfc_omp_clauses *omp_clauses;
2749 const char *omp_name;
dd2fc525 2750 gfc_omp_namelist *omp_namelist;
6c7a4dfd 2751 bool omp_bool;
6de9cd9a
DN
2752 }
2753 ext; /* Points to additional structures required by statement */
2754
e5ca9693 2755 /* Cycle and break labels in constructs. */
e7041633
NF
2756 tree cycle_label;
2757 tree exit_label;
6de9cd9a
DN
2758}
2759gfc_code;
2760
2761
2762/* Storage for DATA statements. */
2763typedef struct gfc_data_variable
2764{
2765 gfc_expr *expr;
2766 gfc_iterator iter;
2767 struct gfc_data_variable *list, *next;
2768}
2769gfc_data_variable;
2770
2771
2772typedef struct gfc_data_value
2773{
f2112868 2774 mpz_t repeat;
6de9cd9a 2775 gfc_expr *expr;
6de9cd9a
DN
2776 struct gfc_data_value *next;
2777}
2778gfc_data_value;
2779
2780
2781typedef struct gfc_data
2782{
2783 gfc_data_variable *var;
2784 gfc_data_value *value;
2785 locus where;
2786
2787 struct gfc_data *next;
2788}
2789gfc_data;
2790
6de9cd9a
DN
2791
2792/* Structure for holding compile options */
2793typedef struct
2794{
6de9cd9a
DN
2795 char *module_dir;
2796 gfc_source_form source_form;
5a06474c
JD
2797 int max_continue_fixed;
2798 int max_continue_free;
6de9cd9a 2799 int max_identifier_length;
6de9cd9a 2800
3f139fcf 2801 int max_errors;
6de9cd9a 2802
2d7c7df6 2803 int flag_preprocessed;
e0bcf78c 2804 int flag_d_lines;
51b09ce3 2805 int flag_init_integer;
66086032 2806 long flag_init_integer_value;
51b09ce3
AL
2807 int flag_init_logical;
2808 int flag_init_character;
2809 char flag_init_character_value;
6de9cd9a 2810
944b8b35 2811 int fpe;
fa86f4f9 2812 int fpe_summary;
d3d3011f 2813 int rtcheck;
944b8b35 2814
6de9cd9a
DN
2815 int warn_std;
2816 int allow_std;
2817}
2818gfc_option_t;
2819
2820extern gfc_option_t gfc_option;
2821
6de9cd9a
DN
2822/* Constructor nodes for array and structure constructors. */
2823typedef struct gfc_constructor
2824{
b7e75771
JD
2825 gfc_constructor_base base;
2826 mpz_t offset; /* Offset within a constructor, used as
2827 key within base. */
2828
6de9cd9a
DN
2829 gfc_expr *expr;
2830 gfc_iterator *iterator;
2831 locus where;
b7e75771
JD
2832
2833 union
6de9cd9a 2834 {
b7e75771 2835 gfc_component *component; /* Record the component being initialized. */
6de9cd9a
DN
2836 }
2837 n;
21ea4922
JJ
2838 mpz_t repeat; /* Record the repeat number of initial values in data
2839 statement like "data a/5*10/". */
6de9cd9a
DN
2840}
2841gfc_constructor;
2842
2843
2844typedef struct iterator_stack
2845{
2846 gfc_symtree *variable;
2847 mpz_t value;
2848 struct iterator_stack *prev;
2849}
2850iterator_stack;
2851extern iterator_stack *iter_stack;
2852
34523524 2853
7431bf06
JW
2854/* Used for (possibly nested) SELECT TYPE statements. */
2855typedef struct gfc_select_type_stack
2856{
2857 gfc_symbol *selector; /* Current selector variable. */
2858 gfc_symtree *tmp; /* Current temporary variable. */
2859 struct gfc_select_type_stack *prev; /* Previous element on stack. */
2860}
2861gfc_select_type_stack;
2862extern gfc_select_type_stack *select_type_stack;
2863#define gfc_get_select_type_stack() XCNEW (gfc_select_type_stack)
2864
2865
34523524
DK
2866/* Node in the linked list used for storing finalizer procedures. */
2867
2868typedef struct gfc_finalizer
2869{
2870 struct gfc_finalizer* next;
df2fba9e 2871 locus where; /* Where the FINAL declaration occurred. */
f6fad28e
DK
2872
2873 /* Up to resolution, we want the gfc_symbol, there we lookup the corresponding
2874 symtree and later need only that. This way, we can access and call the
2875 finalizers from every context as they should be "always accessible". I
2876 don't make this a union because we need the information whether proc_sym is
2877 still referenced or not for dereferencing it on deleting a gfc_finalizer
2878 structure. */
2879 gfc_symbol* proc_sym;
4d382327 2880 gfc_symtree* proc_tree;
34523524
DK
2881}
2882gfc_finalizer;
f6fad28e
DK
2883#define gfc_get_finalizer() XCNEW (gfc_finalizer)
2884
34523524 2885
6de9cd9a
DN
2886/************************ Function prototypes *************************/
2887
2220652d
PT
2888/* decl.c */
2889bool gfc_in_match_data (void);
8234e5e0 2890match gfc_match_char_spec (gfc_typespec *);
170a8bd6 2891extern int directive_unroll;
2bd86b95
HA
2892extern bool directive_ivdep;
2893extern bool directive_vector;
2894extern bool directive_novector;
2220652d 2895
facf0354
ML
2896/* SIMD clause enum. */
2897enum gfc_simd_clause
2898{
2899 SIMD_NONE = (1 << 0),
2900 SIMD_INBRANCH = (1 << 1),
2901 SIMD_NOTINBRANCH = (1 << 2)
2902};
2903
2904/* Tuple for parsing of vectorized built-ins. */
2905struct gfc_vect_builtin_tuple
2906{
2907 gfc_vect_builtin_tuple (const char *n, gfc_simd_clause t)
2908 : name (n), simd_type (t) {}
2909
2910 const char *name;
2911 gfc_simd_clause simd_type;
2912};
2913
2914/* Map of middle-end built-ins that should be vectorized. */
2915extern hash_map<nofree_string_hash, int> *gfc_vectorized_builtins;
2916
5bab4c96
PT
2917/* Handling Parameterized Derived Types */
2918bool gfc_insert_kind_parameter_exprs (gfc_expr *);
2919bool gfc_insert_parameter_exprs (gfc_expr *, gfc_actual_arglist *);
2920match gfc_get_pdt_instance (gfc_actual_arglist *, gfc_symbol **,
2921 gfc_actual_arglist **);
2922
7848054c
AB
2923
2924/* Given a symbol, test whether it is a module procedure in a submodule */
2925#define gfc_submodule_procedure(attr) \
2926 (gfc_state_stack->previous && gfc_state_stack->previous->previous \
2927 && gfc_state_stack->previous->previous->state == COMP_SUBMODULE \
2928 && attr->module_procedure)
2929
6de9cd9a
DN
2930/* scanner.c */
2931void gfc_scanner_done_1 (void);
2932void gfc_scanner_init_1 (void);
2933
308f961b 2934void gfc_add_include_path (const char *, bool, bool, bool);
31198773 2935void gfc_add_intrinsic_modules_path (const char *);
6de9cd9a 2936void gfc_release_include_path (void);
31198773 2937FILE *gfc_open_included_file (const char *, bool, bool);
6de9cd9a 2938
6de9cd9a
DN
2939int gfc_at_end (void);
2940int gfc_at_eof (void);
2941int gfc_at_bol (void);
2942int gfc_at_eol (void);
2943void gfc_advance_line (void);
2944int gfc_check_include (void);
9e8a6720 2945int gfc_define_undef_line (void);
6de9cd9a 2946
8fc541d3
FXC
2947int gfc_wide_is_printable (gfc_char_t);
2948int gfc_wide_is_digit (gfc_char_t);
2949int gfc_wide_fits_in_byte (gfc_char_t);
2950gfc_char_t gfc_wide_tolower (gfc_char_t);
00660189 2951gfc_char_t gfc_wide_toupper (gfc_char_t);
8fc541d3 2952size_t gfc_wide_strlen (const gfc_char_t *);
00660189
FXC
2953int gfc_wide_strncasecmp (const gfc_char_t *, const char *, size_t);
2954gfc_char_t *gfc_wide_memset (gfc_char_t *, gfc_char_t, size_t);
2955char *gfc_widechar_to_char (const gfc_char_t *, int);
2956gfc_char_t *gfc_char_to_widechar (const char *);
2957
ece3f663 2958#define gfc_get_wide_string(n) XCNEWVEC (gfc_char_t, n)
8fc541d3 2959
6de9cd9a 2960void gfc_skip_comments (void);
696abb30 2961gfc_char_t gfc_next_char_literal (gfc_instring);
8fc541d3
FXC
2962gfc_char_t gfc_next_char (void);
2963char gfc_next_ascii_char (void);
2964gfc_char_t gfc_peek_char (void);
2965char gfc_peek_ascii_char (void);
6de9cd9a
DN
2966void gfc_error_recovery (void);
2967void gfc_gobble_whitespace (void);
524af0d6 2968bool gfc_new_file (void);
2d7c7df6 2969const char * gfc_read_orig_filename (const char *, const char **);
6de9cd9a 2970
d4fa05b9 2971extern gfc_source_form gfc_current_form;
e0bcf78c 2972extern const char *gfc_source_file;
63645982 2973extern locus gfc_current_locus;
6de9cd9a 2974
60332588
JJ
2975void gfc_start_source_files (void);
2976void gfc_end_source_files (void);
2977
6de9cd9a 2978/* misc.c */
6de9cd9a
DN
2979void gfc_clear_ts (gfc_typespec *);
2980FILE *gfc_open_file (const char *);
6de9cd9a 2981const char *gfc_basic_typename (bt);
f61e54e5 2982const char *gfc_dummy_typename (gfc_typespec *);
5958b926 2983const char *gfc_typename (gfc_typespec *, bool for_hash = false);
f61e54e5 2984const char *gfc_typename (gfc_expr *);
ba3ba492 2985const char *gfc_op2string (gfc_intrinsic_op);
6de9cd9a
DN
2986const char *gfc_code2string (const mstring *, int);
2987int gfc_string2code (const mstring *, const char *);
2988const char *gfc_intent_string (sym_intent);
2989
2990void gfc_init_1 (void);
2991void gfc_init_2 (void);
2992void gfc_done_1 (void);
2993void gfc_done_2 (void);
2994
a8b3b0b6
CR
2995int get_c_kind (const char *, CInteropKind_t *);
2996
bcc478b9
BRF
2997const char *gfc_closest_fuzzy_match (const char *, char **);
2998static inline void
2999vec_push (char **&optr, size_t &osz, const char *elt)
3000{
3001 /* {auto,}vec.safe_push () replacement. Don't ask.. */
3002 // if (strlen (elt) < 4) return; premature optimization: eliminated by cutoff
3003 optr = XRESIZEVEC (char *, optr, osz + 2);
3004 optr[osz] = CONST_CAST (char *, elt);
3005 optr[++osz] = NULL;
3006}
3007
f622221a
JB
3008HOST_WIDE_INT gfc_mpz_get_hwi (mpz_t);
3009void gfc_mpz_set_hwi (mpz_t, const HOST_WIDE_INT);
3010
6de9cd9a 3011/* options.c */
7a9bf9a4 3012unsigned int gfc_option_lang_mask (void);
a75bfaa6 3013void gfc_init_options_struct (struct gcc_options *);
7a9bf9a4
JM
3014void gfc_init_options (unsigned int,
3015 struct cl_decoded_option *);
00abf86c 3016bool gfc_handle_option (size_t, const char *, HOST_WIDE_INT, int, location_t,
5f20c657 3017 const struct cl_option_handlers *);
6de9cd9a 3018bool gfc_post_options (const char **);
41804a5b 3019char *gfc_get_option_string (void);
6de9cd9a 3020
602b8523
TB
3021/* f95-lang.c */
3022void gfc_maybe_initialize_eh (void);
3023
6de9cd9a 3024/* iresolve.c */
6b25a558 3025const char * gfc_get_string (const char *, ...) ATTRIBUTE_PRINTF_1;
a68ab351 3026bool gfc_find_sym_in_expr (gfc_symbol *, gfc_expr *);
6de9cd9a
DN
3027
3028/* error.c */
6de9cd9a 3029void gfc_error_init_1 (void);
3aa34c1d
MLI
3030void gfc_diagnostics_init (void);
3031void gfc_diagnostics_finish (void);
0f447a6e 3032void gfc_buffer_error (bool);
6de9cd9a 3033
00660189
FXC
3034const char *gfc_print_wide_char (gfc_char_t);
3035
48749dbc 3036bool gfc_warning (int opt, const char *, ...) ATTRIBUTE_GCC_GFC(2,3);
4daa149b 3037bool gfc_warning_now (int opt, const char *, ...) ATTRIBUTE_GCC_GFC(2,3);
be841e11 3038bool gfc_warning_internal (int opt, const char *, ...) ATTRIBUTE_GCC_GFC(2,3);
2a2703a2
MLI
3039bool gfc_warning_now_at (location_t loc, int opt, const char *gmsgid, ...)
3040 ATTRIBUTE_GCC_GFC(3,4);
8e54f6d3 3041
6de9cd9a
DN
3042void gfc_clear_warning (void);
3043void gfc_warning_check (void);
3044
2700d0e3 3045void gfc_error_opt (int opt, const char *, ...) ATTRIBUTE_GCC_GFC(2,3);
0ce0154c
KG
3046void gfc_error (const char *, ...) ATTRIBUTE_GCC_GFC(1,2);
3047void gfc_error_now (const char *, ...) ATTRIBUTE_GCC_GFC(1,2);
3048void gfc_fatal_error (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_GCC_GFC(1,2);
3049void gfc_internal_error (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_GCC_GFC(1,2);
6de9cd9a 3050void gfc_clear_error (void);
b5a9fd3e 3051bool gfc_error_check (void);
0f447a6e 3052bool gfc_error_flag_test (void);
6de9cd9a 3053
8f0d39a8 3054notification gfc_notification_std (int);
524af0d6 3055bool gfc_notify_std (int, const char *, ...) ATTRIBUTE_GCC_GFC(2,3);
6de9cd9a
DN
3056
3057/* A general purpose syntax error. */
3058#define gfc_syntax_error(ST) \
3059 gfc_error ("Syntax error in %s statement at %C", gfc_ascii_statement (ST));
3060
fea70c99
MLI
3061#include "pretty-print.h" /* For output_buffer. */
3062struct gfc_error_buffer
3063{
3064 bool flag;
3065 output_buffer buffer;
3066 gfc_error_buffer(void) : flag(false), buffer() {}
3067};
3068
3069void gfc_push_error (gfc_error_buffer *);
3070void gfc_pop_error (gfc_error_buffer *);
3071void gfc_free_error (gfc_error_buffer *);
6de9cd9a 3072
6de9cd9a 3073void gfc_get_errors (int *, int *);
f4031599 3074void gfc_errors_to_warnings (bool);
6de9cd9a
DN
3075
3076/* arith.c */
3077void gfc_arith_init_1 (void);
3078void gfc_arith_done_1 (void);
25d8f0a2 3079arith gfc_check_integer_range (mpz_t p, int kind);
d393bbd7 3080bool gfc_check_character_range (gfc_char_t, int);
6de9cd9a 3081
67251118
TK
3082extern bool gfc_seen_div0;
3083
5e8e542f 3084/* trans-types.c */
524af0d6 3085bool gfc_check_any_c_kind (gfc_typespec *);
e7a2d5fb 3086int gfc_validate_kind (bt, int, bool);
e0a6661b
FXC
3087int gfc_get_int_kind_from_width_isofortranenv (int size);
3088int gfc_get_real_kind_from_width_isofortranenv (int size);
f6288c24 3089tree gfc_get_union_type (gfc_symbol *);
de91486c 3090tree gfc_get_derived_type (gfc_symbol * derived, int codimen = 0);
6de9cd9a 3091extern int gfc_index_integer_kind;
9d64df18 3092extern int gfc_default_integer_kind;
f4e7375a 3093extern int gfc_max_integer_kind;
9d64df18
TS
3094extern int gfc_default_real_kind;
3095extern int gfc_default_double_kind;
3096extern int gfc_default_character_kind;
3097extern int gfc_default_logical_kind;
3098extern int gfc_default_complex_kind;
e8525382 3099extern int gfc_c_int_kind;
da661a58
TB
3100extern int gfc_atomic_int_kind;
3101extern int gfc_atomic_logical_kind;
014ec6ee 3102extern int gfc_intio_kind;
f1412ca5 3103extern int gfc_charlen_int_kind;
f622221a 3104extern int gfc_size_kind;
39f87c03
FXC
3105extern int gfc_numeric_storage_size;
3106extern int gfc_character_storage_size;
6de9cd9a 3107
64b1806b 3108#define gfc_logical_4_kind 4
6ef1366a 3109#define gfc_integer_4_kind 4
13b1afe4 3110#define gfc_real_4_kind 4
64b1806b 3111
6de9cd9a
DN
3112/* symbol.c */
3113void gfc_clear_new_implicit (void);
524af0d6
JB
3114bool gfc_add_new_implicit_range (int, int);
3115bool gfc_merge_new_implicit (gfc_typespec *);
a6c63173 3116void gfc_set_implicit_none (bool, bool, locus *);
e9bd9f7d 3117void gfc_check_function_type (gfc_namespace *);
e9c06563 3118bool gfc_is_intrinsic_typename (const char *);
b323be61 3119bool gfc_check_conflict (symbol_attribute *, const char *, locus *);
6de9cd9a 3120
713485cc 3121gfc_typespec *gfc_get_default_type (const char *, gfc_namespace *);
524af0d6 3122bool gfc_set_default_type (gfc_symbol *, int, gfc_namespace *);
6de9cd9a 3123
66e4ab31 3124void gfc_set_sym_referenced (gfc_symbol *);
6de9cd9a 3125
524af0d6
JB
3126bool gfc_add_attribute (symbol_attribute *, locus *);
3127bool gfc_add_ext_attribute (symbol_attribute *, ext_attr_id_t, locus *);
3128bool gfc_add_allocatable (symbol_attribute *, locus *);
3129bool gfc_add_codimension (symbol_attribute *, const char *, locus *);
3130bool gfc_add_contiguous (symbol_attribute *, const char *, locus *);
3131bool gfc_add_dimension (symbol_attribute *, const char *, locus *);
3132bool gfc_add_external (symbol_attribute *, locus *);
3133bool gfc_add_intrinsic (symbol_attribute *, locus *);
3134bool gfc_add_optional (symbol_attribute *, locus *);
5bab4c96
PT
3135bool gfc_add_kind (symbol_attribute *, locus *);
3136bool gfc_add_len (symbol_attribute *, locus *);
524af0d6
JB
3137bool gfc_add_pointer (symbol_attribute *, locus *);
3138bool gfc_add_cray_pointer (symbol_attribute *, locus *);
3139bool gfc_add_cray_pointee (symbol_attribute *, locus *);
32e8bb8e 3140match gfc_mod_pointee_as (gfc_array_spec *);
524af0d6
JB
3141bool gfc_add_protected (symbol_attribute *, const char *, locus *);
3142bool gfc_add_result (symbol_attribute *, const char *, locus *);
34d567d1 3143bool gfc_add_automatic (symbol_attribute *, const char *, locus *);
524af0d6
JB
3144bool gfc_add_save (symbol_attribute *, save_state, const char *, locus *);
3145bool gfc_add_threadprivate (symbol_attribute *, const char *, locus *);
f014c653 3146bool gfc_add_omp_declare_target (symbol_attribute *, const char *, locus *);
b4c3a85b
JJ
3147bool gfc_add_omp_declare_target_link (symbol_attribute *, const char *,
3148 locus *);
524af0d6
JB
3149bool gfc_add_saved_common (symbol_attribute *, locus *);
3150bool gfc_add_target (symbol_attribute *, locus *);
3151bool gfc_add_dummy (symbol_attribute *, const char *, locus *);
3152bool gfc_add_generic (symbol_attribute *, const char *, locus *);
3153bool gfc_add_common (symbol_attribute *, locus *);
3154bool gfc_add_in_common (symbol_attribute *, const char *, locus *);
3155bool gfc_add_in_equivalence (symbol_attribute *, const char *, locus *);
3156bool gfc_add_data (symbol_attribute *, const char *, locus *);
3157bool gfc_add_in_namelist (symbol_attribute *, const char *, locus *);
3158bool gfc_add_sequence (symbol_attribute *, const char *, locus *);
3159bool gfc_add_elemental (symbol_attribute *, locus *);
3160bool gfc_add_pure (symbol_attribute *, locus *);
3161bool gfc_add_recursive (symbol_attribute *, locus *);
3162bool gfc_add_function (symbol_attribute *, const char *, locus *);
3163bool gfc_add_subroutine (symbol_attribute *, const char *, locus *);
3164bool gfc_add_volatile (symbol_attribute *, const char *, locus *);
3165bool gfc_add_asynchronous (symbol_attribute *, const char *, locus *);
3166bool gfc_add_proc (symbol_attribute *attr, const char *name, locus *where);
3167bool gfc_add_abstract (symbol_attribute* attr, locus* where);
3168
3169bool gfc_add_access (symbol_attribute *, gfc_access, const char *, locus *);
3170bool gfc_add_is_bind_c (symbol_attribute *, const char *, locus *, int);
3171bool gfc_add_extension (symbol_attribute *, locus *);
3172bool gfc_add_value (symbol_attribute *, const char *, locus *);
3173bool gfc_add_flavor (symbol_attribute *, sym_flavor, const char *, locus *);
3174bool gfc_add_entry (symbol_attribute *, const char *, locus *);
3175bool gfc_add_procedure (symbol_attribute *, procedure_type,
231b2fcc 3176 const char *, locus *);
524af0d6
JB
3177bool gfc_add_intent (symbol_attribute *, sym_intent, locus *);
3178bool gfc_add_explicit_interface (gfc_symbol *, ifsrc,
6de9cd9a 3179 gfc_formal_arglist *, locus *);
524af0d6 3180bool gfc_add_type (gfc_symbol *, gfc_typespec *, locus *);
6de9cd9a
DN
3181
3182void gfc_clear_attr (symbol_attribute *);
524af0d6
JB
3183bool gfc_missing_attr (symbol_attribute *, locus *);
3184bool gfc_copy_attr (symbol_attribute *, symbol_attribute *, locus *);
4668d6f9 3185int gfc_copy_dummy_sym (gfc_symbol **, gfc_symbol *, int);
524af0d6 3186bool gfc_add_component (gfc_symbol *, const char *, gfc_component **);
6de9cd9a
DN
3187gfc_symbol *gfc_use_derived (gfc_symbol *);
3188gfc_symtree *gfc_use_derived_tree (gfc_symtree *);
f6288c24
FR
3189gfc_component *gfc_find_component (gfc_symbol *, const char *, bool, bool,
3190 gfc_ref **);
6de9cd9a
DN
3191
3192gfc_st_label *gfc_get_st_label (int);
3193void gfc_free_st_label (gfc_st_label *);
3194void gfc_define_st_label (gfc_st_label *, gfc_sl_type, locus *);
524af0d6 3195bool gfc_reference_st_label (gfc_st_label *, gfc_sl_type);
6de9cd9a 3196
0366dfe9 3197gfc_namespace *gfc_get_namespace (gfc_namespace *, int);
6de9cd9a
DN
3198gfc_symtree *gfc_new_symtree (gfc_symtree **, const char *);
3199gfc_symtree *gfc_find_symtree (gfc_symtree *, const char *);
a99d95a2 3200void gfc_delete_symtree (gfc_symtree **, const char *);
aa84a9a5 3201gfc_symtree *gfc_get_unique_symtree (gfc_namespace *);
6de9cd9a
DN
3202gfc_user_op *gfc_get_uop (const char *);
3203gfc_user_op *gfc_find_uop (const char *, gfc_namespace *);
3204void gfc_free_symbol (gfc_symbol *);
3cb595ac 3205void gfc_release_symbol (gfc_symbol *);
6de9cd9a 3206gfc_symbol *gfc_new_symbol (const char *, gfc_namespace *);
61b644c2 3207gfc_symtree* gfc_find_symtree_in_proc (const char *, gfc_namespace *);
6de9cd9a
DN
3208int gfc_find_symbol (const char *, gfc_namespace *, int, gfc_symbol **);
3209int gfc_find_sym_tree (const char *, gfc_namespace *, int, gfc_symtree **);
3210int gfc_get_symbol (const char *, gfc_namespace *, gfc_symbol **);
524af0d6
JB
3211bool gfc_verify_c_interop (gfc_typespec *);
3212bool gfc_verify_c_interop_param (gfc_symbol *);
3213bool verify_bind_c_sym (gfc_symbol *, gfc_typespec *, int, gfc_common_head *);
3214bool verify_bind_c_derived_type (gfc_symbol *);
3215bool verify_com_block_vars_c_interop (gfc_common_head *);
cadddfdd
TB
3216gfc_symtree *generate_isocbinding_symbol (const char *, iso_c_binding_symbol,
3217 const char *, gfc_symtree *, bool);
44c57c2f 3218void gfc_save_symbol_data (gfc_symbol *);
08a6b8e0 3219int gfc_get_sym_tree (const char *, gfc_namespace *, gfc_symtree **, bool);
6de9cd9a
DN
3220int gfc_get_ha_symbol (const char *, gfc_symbol **);
3221int gfc_get_ha_sym_tree (const char *, gfc_symtree **);
3222
ab68a73e
MM
3223void gfc_drop_last_undo_checkpoint (void);
3224void gfc_restore_last_undo_checkpoint (void);
6de9cd9a
DN
3225void gfc_undo_symbols (void);
3226void gfc_commit_symbols (void);
66e4ab31 3227void gfc_commit_symbol (gfc_symbol *);
b76e28c6 3228gfc_charlen *gfc_new_charlen (gfc_namespace *, gfc_charlen *);
27f31e39 3229void gfc_free_charlen (gfc_charlen *, gfc_charlen *);
6de9cd9a
DN
3230void gfc_free_namespace (gfc_namespace *);
3231
3232void gfc_symbol_init_2 (void);
3233void gfc_symbol_done_2 (void);
3234
9056bd70 3235void gfc_traverse_symtree (gfc_symtree *, void (*)(gfc_symtree *));
6de9cd9a
DN
3236void gfc_traverse_ns (gfc_namespace *, void (*)(gfc_symbol *));
3237void gfc_traverse_user_op (gfc_namespace *, void (*)(gfc_user_op *));
3238void gfc_save_all (gfc_namespace *);
3239
4bc20f3a 3240void gfc_enforce_clean_symbol_state (void);
6de9cd9a 3241
55b9c612 3242gfc_gsymbol *gfc_get_gsymbol (const char *, bool bind_c);
cb9e4f55 3243gfc_gsymbol *gfc_find_gsymbol (gfc_gsymbol *, const char *);
98452460 3244gfc_gsymbol *gfc_find_case_gsymbol (gfc_gsymbol *, const char *);
5c6aa9a8 3245void gfc_traverse_gsymbol (gfc_gsymbol *, void (*)(gfc_gsymbol *, void *), void *);
c9543002 3246
3e15518b 3247gfc_typebound_proc* gfc_get_typebound_proc (gfc_typebound_proc*);
30b608eb 3248gfc_symbol* gfc_get_derived_super_type (gfc_symbol*);
cf2b3c22
TB
3249gfc_symbol* gfc_get_ultimate_derived_super_type (gfc_symbol*);
3250bool gfc_type_is_extension_of (gfc_symbol *, gfc_symbol *);
e74f1cc8 3251bool gfc_type_compatible (gfc_typespec *, gfc_typespec *);
30b608eb 3252
8fdcb6a9 3253void gfc_copy_formal_args_intr (gfc_symbol *, gfc_intrinsic_sym *,
47d13acb 3254 gfc_actual_arglist *, bool copy_type = false);
69773742 3255
34523524
DK
3256void gfc_free_finalizer (gfc_finalizer *el); /* Needed in resolve.c, too */
3257
524af0d6 3258bool gfc_check_symbol_typed (gfc_symbol*, gfc_namespace*, bool, locus);
52bf62f9 3259gfc_namespace* gfc_find_proc_namespace (gfc_namespace*);
f37e928c 3260
571d54de 3261bool gfc_is_associate_pointer (gfc_symbol*);
c3f34952 3262gfc_symbol * gfc_find_dt_in_generic (gfc_symbol *);
4cbc9039 3263gfc_formal_arglist *gfc_sym_get_dummy_args (gfc_symbol *);
571d54de 3264
f2cbd86c
DF
3265/* intrinsic.c -- true if working in an init-expr, false otherwise. */
3266extern bool gfc_init_expr_flag;
6de9cd9a
DN
3267
3268/* Given a symbol that we have decided is intrinsic, mark it as such
3269 by placing it into a special module that is otherwise impossible to
3270 read or write. */
3271
cb9e4f55 3272#define gfc_intrinsic_symbol(SYM) SYM->module = gfc_get_string ("(intrinsic)")
6de9cd9a
DN
3273
3274void gfc_intrinsic_init_1 (void);
3275void gfc_intrinsic_done_1 (void);
3276
01ce9e31 3277char gfc_type_letter (bt, bool logical_equals_int = false);
6de9cd9a 3278gfc_symbol * gfc_get_intrinsic_sub_symbol (const char *);
47d13acb
TK
3279gfc_symbol *gfc_get_intrinsic_function_symbol (gfc_expr *);
3280gfc_symbol *gfc_find_intrinsic_symbol (gfc_expr *);
524af0d6 3281bool gfc_convert_type (gfc_expr *, gfc_typespec *, int);
8405874a
ME
3282bool gfc_convert_type_warn (gfc_expr *, gfc_typespec *, int, int,
3283 bool array = false);
524af0d6 3284bool gfc_convert_chartype (gfc_expr *, gfc_typespec *);
6de9cd9a
DN
3285int gfc_generic_intrinsic (const char *);
3286int gfc_specific_intrinsic (const char *);
c3005b0f 3287bool gfc_is_intrinsic (gfc_symbol*, int, locus);
0e7e7e6e 3288int gfc_intrinsic_actual_ok (const char *, const bool);
6de9cd9a 3289gfc_intrinsic_sym *gfc_find_function (const char *);
cd5ecab6 3290gfc_intrinsic_sym *gfc_find_subroutine (const char *);
d000aa67 3291gfc_intrinsic_sym *gfc_intrinsic_function_by_id (gfc_isym_id);
cadddfdd
TB
3292gfc_intrinsic_sym *gfc_intrinsic_subroutine_by_id (gfc_isym_id);
3293gfc_isym_id gfc_isym_id_by_intmod (intmod_id, int);
3294gfc_isym_id gfc_isym_id_by_intmod_sym (gfc_symbol *);
3295
6de9cd9a
DN
3296
3297match gfc_intrinsic_func_interface (gfc_expr *, int);
3298match gfc_intrinsic_sub_interface (gfc_code *, int);
3299
c3005b0f 3300void gfc_warn_intrinsic_shadow (const gfc_symbol*, bool, bool);
524af0d6 3301bool gfc_check_intrinsic_standard (const gfc_intrinsic_sym*, const char**,
17b1d2a0 3302 bool, locus);
c3005b0f 3303
6de9cd9a
DN
3304/* match.c -- FIXME */
3305void gfc_free_iterator (gfc_iterator *, int);
3306void gfc_free_forall_iterator (gfc_forall_iterator *);
3307void gfc_free_alloc_list (gfc_alloc *);
3308void gfc_free_namelist (gfc_namelist *);
dd2fc525 3309void gfc_free_omp_namelist (gfc_omp_namelist *);
6de9cd9a 3310void gfc_free_equiv (gfc_equiv *);
31fee91e 3311void gfc_free_equiv_until (gfc_equiv *, gfc_equiv *);
6de9cd9a 3312void gfc_free_data (gfc_data *);
d5e2274d 3313void gfc_reject_data (gfc_namespace *);
6de9cd9a
DN
3314void gfc_free_case_list (gfc_case *);
3315
b6398823
PT
3316/* matchexp.c -- FIXME too? */
3317gfc_expr *gfc_get_parentheses (gfc_expr *);
3318
6c7a4dfd 3319/* openmp.c */
c7d3bb76 3320struct gfc_omp_saved_state { void *ptrs[2]; int ints[1]; };
269322ec
TB
3321bool gfc_omp_requires_add_clause (gfc_omp_requires_kind, const char *,
3322 locus *, const char *);
3323void gfc_check_omp_requires (gfc_namespace *, int);
6c7a4dfd 3324void gfc_free_omp_clauses (gfc_omp_clauses *);
dc7a8b4b 3325void gfc_free_oacc_declare_clauses (struct gfc_oacc_declare *);
dd2fc525
JJ
3326void gfc_free_omp_declare_simd (gfc_omp_declare_simd *);
3327void gfc_free_omp_declare_simd_list (gfc_omp_declare_simd *);
5f23671d
JJ
3328void gfc_free_omp_udr (gfc_omp_udr *);
3329gfc_omp_udr *gfc_omp_udr_find (gfc_symtree *, gfc_typespec *);
6c7a4dfd 3330void gfc_resolve_omp_directive (gfc_code *, gfc_namespace *);
cd30a0b8
JJ
3331void gfc_resolve_do_iterator (gfc_code *, gfc_symbol *, bool);
3332void gfc_resolve_omp_local_vars (gfc_namespace *);
6c7a4dfd
JJ
3333void gfc_resolve_omp_parallel_blocks (gfc_code *, gfc_namespace *);
3334void gfc_resolve_omp_do_blocks (gfc_code *, gfc_namespace *);
dd2fc525 3335void gfc_resolve_omp_declare_simd (gfc_namespace *);
5f23671d 3336void gfc_resolve_omp_udrs (gfc_symtree *);
c7d3bb76
JJ
3337void gfc_omp_save_and_clear_state (struct gfc_omp_saved_state *);
3338void gfc_omp_restore_state (struct gfc_omp_saved_state *);
41dbbb37
TS
3339void gfc_free_expr_list (gfc_expr_list *);
3340void gfc_resolve_oacc_directive (gfc_code *, gfc_namespace *);
3341void gfc_resolve_oacc_declare (gfc_namespace *);
3342void gfc_resolve_oacc_parallel_loop_blocks (gfc_code *, gfc_namespace *);
3343void gfc_resolve_oacc_blocks (gfc_code *, gfc_namespace *);
f6bf4bc1 3344void gfc_resolve_oacc_routines (gfc_namespace *);
6c7a4dfd 3345
6de9cd9a
DN
3346/* expr.c */
3347void gfc_free_actual_arglist (gfc_actual_arglist *);
3348gfc_actual_arglist *gfc_copy_actual_arglist (gfc_actual_arglist *);
f622221a 3349
51f03c6b 3350bool gfc_extract_int (gfc_expr *, int *, int = 0);
f622221a
JB
3351bool gfc_extract_hwi (gfc_expr *, HOST_WIDE_INT *, int = 0);
3352
0d78e4aa 3353bool is_CFI_desc (gfc_symbol *, gfc_expr *);
1d6b7f39 3354bool is_subref_array (gfc_expr *);
460263d0 3355bool gfc_is_simply_contiguous (gfc_expr *, bool, bool);
419af57c 3356bool gfc_is_not_contiguous (gfc_expr *);
524af0d6 3357bool gfc_check_init_expr (gfc_expr *);
6de9cd9a
DN
3358
3359gfc_expr *gfc_build_conversion (gfc_expr *);
3360void gfc_free_ref_list (gfc_ref *);
dcea1b2f 3361void gfc_type_convert_binary (gfc_expr *, int);
7a28353e 3362bool gfc_is_constant_expr (gfc_expr *);
524af0d6 3363bool gfc_simplify_expr (gfc_expr *, int);
4075a94e 3364int gfc_has_vector_index (gfc_expr *);
6de9cd9a
DN
3365
3366gfc_expr *gfc_get_expr (void);
b7e75771
JD
3367gfc_expr *gfc_get_array_expr (bt type, int kind, locus *);
3368gfc_expr *gfc_get_null_expr (locus *);
3369gfc_expr *gfc_get_operator_expr (locus *, gfc_intrinsic_op,gfc_expr *, gfc_expr *);
3370gfc_expr *gfc_get_structure_constructor_expr (bt, int, locus *);
3371gfc_expr *gfc_get_constant_expr (bt, int, locus *);
f622221a
JB
3372gfc_expr *gfc_get_character_expr (int, locus *, const char *, gfc_charlen_t len);
3373gfc_expr *gfc_get_int_expr (int, locus *, HOST_WIDE_INT);
b7e75771
JD
3374gfc_expr *gfc_get_logical_expr (int, locus *, bool);
3375gfc_expr *gfc_get_iokind_expr (locus *, io_kind);
3376
7d7212ec
MM
3377void gfc_clear_shape (mpz_t *shape, int rank);
3378void gfc_free_shape (mpz_t **shape, int rank);
6de9cd9a
DN
3379void gfc_free_expr (gfc_expr *);
3380void gfc_replace_expr (gfc_expr *, gfc_expr *);
6de9cd9a 3381mpz_t *gfc_copy_shape (mpz_t *, int);
94538bd1 3382mpz_t *gfc_copy_shape_excluding (mpz_t *, int, gfc_expr *);
6de9cd9a 3383gfc_expr *gfc_copy_expr (gfc_expr *);
8e1f752a 3384gfc_ref* gfc_copy_ref (gfc_ref*);
6de9cd9a 3385
524af0d6 3386bool gfc_specification_expr (gfc_expr *);
6de9cd9a
DN
3387
3388int gfc_numeric_ts (gfc_typespec *);
3389int gfc_kind_max (gfc_expr *, gfc_expr *);
3390
524af0d6 3391bool gfc_check_conformance (gfc_expr *, gfc_expr *, const char *, ...) ATTRIBUTE_PRINTF_3;
3c9f5092 3392bool gfc_check_assign (gfc_expr *, gfc_expr *, int, bool c = true);
83fad929 3393bool gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue,
cedf8d2e
TK
3394 bool suppres_type_test = false,
3395 bool is_init_expr = false);
524af0d6 3396bool gfc_check_assign_symbol (gfc_symbol *, gfc_component *, gfc_expr *);
6de9cd9a 3397
7fc61626 3398gfc_expr *gfc_build_default_init_expr (gfc_typespec *, locus *);
13051352 3399gfc_expr *gfc_build_init_expr (gfc_typespec *, locus *, bool);
7fc61626 3400void gfc_apply_init (gfc_typespec *, symbol_attribute *, gfc_expr *);
16e520b6 3401bool gfc_has_default_initializer (gfc_symbol *);
54b4ba60 3402gfc_expr *gfc_default_initializer (gfc_typespec *);
7fc61626 3403gfc_expr *gfc_generate_initializer (gfc_typespec *, bool);
294fbfc8 3404gfc_expr *gfc_get_variable_expr (gfc_symtree *);
4d382327 3405void gfc_add_full_array_ref (gfc_expr *, gfc_array_spec *);
0d87fa8c 3406gfc_expr * gfc_lval_expr_from_sym (gfc_symbol *);
294fbfc8 3407
b7d1d8b4
PT
3408gfc_array_spec *gfc_get_full_arrayspec_from_expr (gfc_expr *expr);
3409
640670c7
PT
3410bool gfc_traverse_expr (gfc_expr *, gfc_symbol *,
3411 bool (*)(gfc_expr *, gfc_symbol *, int*),
3412 int);
66e4ab31 3413void gfc_expr_set_symbols_referenced (gfc_expr *);
524af0d6 3414bool gfc_expr_check_typed (gfc_expr*, gfc_namespace*, bool);
5bab4c96
PT
3415bool gfc_derived_parameter_expr (gfc_expr *);
3416gfc_param_spec_type gfc_spec_list_type (gfc_actual_arglist *, gfc_symbol *);
2a573572
MM
3417gfc_component * gfc_get_proc_ptr_comp (gfc_expr *);
3418bool gfc_is_proc_ptr_comp (gfc_expr *);
43a68a9d 3419bool gfc_is_alloc_class_scalar_function (gfc_expr *);
a6b22eea 3420bool gfc_is_class_array_function (gfc_expr *);
713485cc 3421
badd9e69 3422bool gfc_ref_this_image (gfc_ref *ref);
d3a9eea2 3423bool gfc_is_coindexed (gfc_expr *);
394d3a2e 3424bool gfc_is_coarray (gfc_expr *);
4dc694b2 3425int gfc_get_corank (gfc_expr *);
d3a9eea2
TB
3426bool gfc_has_ultimate_allocatable (gfc_expr *);
3427bool gfc_has_ultimate_pointer (gfc_expr *);
f8862a1b 3428gfc_expr* gfc_find_team_co (gfc_expr *);
20d0bfce 3429gfc_expr* gfc_find_stat_co (gfc_expr *);
6838c137
TB
3430gfc_expr* gfc_build_intrinsic_call (gfc_namespace *, gfc_isym_id, const char*,
3431 locus, unsigned, ...);
524af0d6 3432bool gfc_check_vardef_context (gfc_expr*, bool, bool, bool, const char*);
69dcd06a 3433
d3a9eea2 3434
6de9cd9a
DN
3435/* st.c */
3436extern gfc_code new_st;
3437
3438void gfc_clear_new_st (void);
11e5274a 3439gfc_code *gfc_get_code (gfc_exec_op);
6de9cd9a
DN
3440gfc_code *gfc_append_code (gfc_code *, gfc_code *);
3441void gfc_free_statement (gfc_code *);
3442void gfc_free_statements (gfc_code *);
03af1e4c 3443void gfc_free_association_list (gfc_association_list *);
6de9cd9a
DN
3444
3445/* resolve.c */
de89b574
TB
3446void gfc_expression_rank (gfc_expr *);
3447bool gfc_resolve_ref (gfc_expr *);
524af0d6 3448bool gfc_resolve_expr (gfc_expr *);
6de9cd9a 3449void gfc_resolve (gfc_namespace *);
b46ebd6c 3450void gfc_resolve_code (gfc_code *, gfc_namespace *);
6c7a4dfd 3451void gfc_resolve_blocks (gfc_code *, gfc_namespace *);
3ab216a4 3452void gfc_resolve_formal_arglist (gfc_symbol *);
6de9cd9a
DN
3453int gfc_impure_variable (gfc_symbol *);
3454int gfc_pure (gfc_symbol *);
f1f39033 3455int gfc_implicit_pure (gfc_symbol *);
ccd7751b 3456void gfc_unset_implicit_pure (gfc_symbol *);
6de9cd9a 3457int gfc_elemental (gfc_symbol *);
524af0d6
JB
3458bool gfc_resolve_iterator (gfc_iterator *, bool, bool);
3459bool find_forall_index (gfc_expr *, gfc_symbol *, int);
3460bool gfc_resolve_index (gfc_expr *, int);
3461bool gfc_resolve_dim_arg (gfc_expr *);
7a28353e 3462bool gfc_is_formal_arg (void);
07368af0 3463void gfc_resolve_substring_charlen (gfc_expr *);
a8b3b0b6 3464match gfc_iso_c_sub_interface(gfc_code *, gfc_symbol *);
cf2b3c22 3465gfc_expr *gfc_expr_to_initialize (gfc_expr *);
2dda89a8 3466bool gfc_type_is_extensible (gfc_symbol *);
524af0d6 3467bool gfc_resolve_intrinsic (gfc_symbol *, locus *);
96486998 3468bool gfc_explicit_interface_required (gfc_symbol *, char *, int);
ce96d372 3469extern int gfc_do_concurrent_flag;
bcc478b9 3470const char* gfc_lookup_function_fuzzy (const char *, gfc_symtree *);
6457b1f0
JW
3471int gfc_pure_function (gfc_expr *e, const char **name);
3472int gfc_implicit_pure_function (gfc_expr *e);
a8b3b0b6 3473
6de9cd9a
DN
3474
3475/* array.c */
b7e75771
JD
3476gfc_iterator *gfc_copy_iterator (gfc_iterator *);
3477
6de9cd9a
DN
3478void gfc_free_array_spec (gfc_array_spec *);
3479gfc_array_ref *gfc_copy_array_ref (gfc_array_ref *);
3480
524af0d6 3481bool gfc_set_array_spec (gfc_symbol *, gfc_array_spec *, locus *);
6de9cd9a 3482gfc_array_spec *gfc_copy_array_spec (gfc_array_spec *);
524af0d6 3483bool gfc_resolve_array_spec (gfc_array_spec *, int);
6de9cd9a
DN
3484
3485int gfc_compare_array_spec (gfc_array_spec *, gfc_array_spec *);
3486
6de9cd9a 3487void gfc_simplify_iterator_var (gfc_expr *);
524af0d6 3488bool gfc_expand_constructor (gfc_expr *, bool);
6de9cd9a
DN
3489int gfc_constant_ac (gfc_expr *);
3490int gfc_expanded_ac (gfc_expr *);
524af0d6
JB
3491bool gfc_resolve_character_array_constructor (gfc_expr *);
3492bool gfc_resolve_array_constructor (gfc_expr *);
3493bool gfc_check_constructor_type (gfc_expr *);
3494bool gfc_check_iter_variable (gfc_expr *);
3495bool gfc_check_constructor (gfc_expr *, bool (*)(gfc_expr *));
3496bool gfc_array_size (gfc_expr *, mpz_t *);
3497bool gfc_array_dimen_size (gfc_expr *, int, mpz_t *);
3498bool gfc_array_ref_shape (gfc_array_ref *, mpz_t *);
eb401400 3499gfc_array_ref *gfc_find_array_ref (gfc_expr *, bool a = false);
66e4ab31 3500tree gfc_conv_array_initializer (tree type, gfc_expr *);
524af0d6
JB
3501bool spec_size (gfc_array_spec *, mpz_t *);
3502bool spec_dimen_size (gfc_array_spec *, int, mpz_t *);
7a28353e 3503bool gfc_is_compile_time_shape (gfc_array_spec *);
6de9cd9a 3504
524af0d6 3505bool gfc_ref_dimen_size (gfc_array_ref *, int dimen, mpz_t *, mpz_t *);
543af7ab
TK
3506
3507
2eb3745a
JW
3508#define gfc_str_startswith(str, pref) \
3509 (strncmp ((str), (pref), strlen (pref)) == 0)
3510
6de9cd9a
DN
3511/* interface.c -- FIXME: some of these should be in symbol.c */
3512void gfc_free_interface (gfc_interface *);
f3e1097b
JW
3513bool gfc_compare_derived_types (gfc_symbol *, gfc_symbol *);
3514bool gfc_compare_types (gfc_typespec *, gfc_typespec *);
4668d6f9
PT
3515bool gfc_check_dummy_characteristics (gfc_symbol *, gfc_symbol *,
3516 bool, char *, int);
3517bool gfc_check_result_characteristics (gfc_symbol *, gfc_symbol *,
3518 char *, int);
f3e1097b 3519bool gfc_compare_interfaces (gfc_symbol*, gfc_symbol*, const char *, int, int,
2298af08
TK
3520 char *, int, const char *, const char *,
3521 bool *bad_result_characteristics = NULL);
6de9cd9a 3522void gfc_check_interfaces (gfc_namespace *);
524af0d6 3523bool gfc_procedure_use (gfc_symbol *, gfc_actual_arglist **, locus *);
7e196f89 3524void gfc_ppc_use (gfc_component *, gfc_actual_arglist **, locus *);
6de9cd9a
DN
3525gfc_symbol *gfc_search_interface (gfc_interface *, int,
3526 gfc_actual_arglist **);
eaee02a5 3527match gfc_extend_expr (gfc_expr *);
6de9cd9a 3528void gfc_free_formal_arglist (gfc_formal_arglist *);
524af0d6
JB
3529bool gfc_extend_assign (gfc_code *, gfc_namespace *);
3530bool gfc_check_new_interface (gfc_interface *, gfc_symbol *, locus);
3531bool gfc_add_interface (gfc_symbol *);
2b77e908
FXC
3532gfc_interface *gfc_current_interface_head (void);
3533void gfc_set_current_interface_head (gfc_interface *);
f6fad28e 3534gfc_symtree* gfc_find_sym_in_symtree (gfc_symbol*);
f0ac18b7 3535bool gfc_arglist_matches_symbol (gfc_actual_arglist**, gfc_symbol*);
94747289 3536bool gfc_check_operator_interface (gfc_symbol*, gfc_intrinsic_op, locus);
f3e1097b 3537bool gfc_has_vector_subscript (gfc_expr*);
fb03a37e 3538gfc_intrinsic_op gfc_equivalent_op (gfc_intrinsic_op);
524af0d6 3539bool gfc_check_typebound_override (gfc_symtree*, gfc_symtree*);
e73d3ca6 3540void gfc_check_dtio_interfaces (gfc_symbol*);
e4e659b9 3541gfc_symtree* gfc_find_typebound_dtio_proc (gfc_symbol *, bool, bool);
e73d3ca6 3542gfc_symbol* gfc_find_specific_dtio_proc (gfc_symbol*, bool, bool);
e68a35ae
TK
3543void gfc_get_formal_from_actual_arglist (gfc_symbol *, gfc_actual_arglist *);
3544bool gfc_compare_actual_formal (gfc_actual_arglist **, gfc_formal_arglist *,
3545 int, int, bool, locus *);
e73d3ca6 3546
6de9cd9a
DN
3547
3548/* io.c */
3549extern gfc_st_label format_asterisk;
3550
3551void gfc_free_open (gfc_open *);
44facdb7 3552bool gfc_resolve_open (gfc_open *, locus *);
6de9cd9a 3553void gfc_free_close (gfc_close *);
44facdb7 3554bool gfc_resolve_close (gfc_close *, locus *);
6de9cd9a 3555void gfc_free_filepos (gfc_filepos *);
3d07fb21 3556bool gfc_resolve_filepos (gfc_filepos *, locus *);
6de9cd9a 3557void gfc_free_inquire (gfc_inquire *);
524af0d6 3558bool gfc_resolve_inquire (gfc_inquire *);
6de9cd9a 3559void gfc_free_dt (gfc_dt *);
44facdb7 3560bool gfc_resolve_dt (gfc_code *, gfc_dt *, locus *);
6f0f0b2e 3561void gfc_free_wait (gfc_wait *);
524af0d6 3562bool gfc_resolve_wait (gfc_wait *);
6de9cd9a
DN
3563
3564/* module.c */
3565void gfc_module_init_2 (void);
3566void gfc_module_done_2 (void);
3567void gfc_dump_module (const char *, int);
6e2062b0 3568bool gfc_check_symbol_access (gfc_symbol *);
a64f5186 3569void gfc_free_use_stmts (gfc_use_list *);
f6288c24
FR
3570const char *gfc_dt_lower_string (const char *);
3571const char *gfc_dt_upper_string (const char *);
6de9cd9a
DN
3572
3573/* primary.c */
3574symbol_attribute gfc_variable_attr (gfc_expr *, gfc_typespec *);
3575symbol_attribute gfc_expr_attr (gfc_expr *);
ba85c8c3 3576symbol_attribute gfc_caf_attr (gfc_expr *, bool i = false, bool *r = NULL);
eb77cddf 3577match gfc_match_rvalue (gfc_expr **);
713485cc 3578match gfc_match_varspec (gfc_expr*, int, bool, bool);
8fc541d3 3579int gfc_check_digit (char, int);
2d71b918 3580bool gfc_is_function_return_value (gfc_symbol *, gfc_namespace *);
524af0d6 3581bool gfc_convert_to_structure_constructor (gfc_expr *, gfc_symbol *,
c3f34952
TB
3582 gfc_expr **,
3583 gfc_actual_arglist **, bool);
6de9cd9a
DN
3584
3585/* trans.c */
3586void gfc_generate_code (gfc_namespace *);
3587void gfc_generate_module_code (gfc_namespace *);
3588
9645e798
MM
3589/* trans-intrinsic.c */
3590bool gfc_inline_intrinsic_function_p (gfc_expr *);
3591
6de9cd9a
DN
3592/* bbt.c */
3593typedef int (*compare_fn) (void *, void *);
3594void gfc_insert_bbt (void *, void *, compare_fn);
3595void gfc_delete_bbt (void *, void *, compare_fn);
3596
3597/* dump-parse-tree.c */
6c1abb5c 3598void gfc_dump_parse_tree (gfc_namespace *, FILE *);
e655a6cc 3599void gfc_dump_c_prototypes (gfc_namespace *, FILE *);
6328ce1f 3600void gfc_dump_external_c_prototypes (FILE *);
5c6aa9a8 3601void gfc_dump_global_symbols (FILE *);
fb078366
TK
3602void debug (gfc_symbol *);
3603void debug (gfc_expr *);
6de9cd9a
DN
3604
3605/* parse.c */
524af0d6 3606bool gfc_parse_file (void);
ca39e6f2 3607void gfc_global_used (gfc_gsymbol *, locus *);
3e78238a 3608gfc_namespace* gfc_build_block_ns (gfc_namespace *);
6de9cd9a 3609
2990f854 3610/* dependency.c */
2757d5ec 3611int gfc_dep_compare_functions (gfc_expr *, gfc_expr *, bool);
2990f854 3612int gfc_dep_compare_expr (gfc_expr *, gfc_expr *);
eab19a1a 3613bool gfc_dep_difference (gfc_expr *, gfc_expr *, mpz_t *);
2990f854 3614
fb5bc08b 3615/* check.c */
524af0d6
JB
3616bool gfc_check_same_strlen (const gfc_expr*, const gfc_expr*, const char*);
3617bool gfc_calculate_transfer_sizes (gfc_expr*, gfc_expr*, gfc_expr*,
86dbed7d 3618 size_t*, size_t*, size_t*);
8dc63166
SK
3619bool gfc_boz2int (gfc_expr *, int);
3620bool gfc_boz2real (gfc_expr *, int);
3621bool gfc_invalid_boz (const char *, locus *);
7fd614ee 3622bool gfc_invalid_null_arg (gfc_expr *);
8dc63166 3623
fb5bc08b 3624
d15bac21 3625/* class.c */
37da591f 3626void gfc_fix_class_refs (gfc_expr *e);
d15bac21 3627void gfc_add_component_ref (gfc_expr *, const char *);
c49ea23d 3628void gfc_add_class_array_ref (gfc_expr *);
b04533af
JW
3629#define gfc_add_data_component(e) gfc_add_component_ref(e,"_data")
3630#define gfc_add_vptr_component(e) gfc_add_component_ref(e,"_vptr")
34d9d749 3631#define gfc_add_len_component(e) gfc_add_component_ref(e,"_len")
b04533af
JW
3632#define gfc_add_hash_component(e) gfc_add_component_ref(e,"_hash")
3633#define gfc_add_size_component(e) gfc_add_component_ref(e,"_size")
3634#define gfc_add_def_init_component(e) gfc_add_component_ref(e,"_def_init")
86035eec 3635#define gfc_add_final_component(e) gfc_add_component_ref(e,"_final")
c49ea23d
PT
3636bool gfc_is_class_array_ref (gfc_expr *, bool *);
3637bool gfc_is_class_scalar_expr (gfc_expr *);
5bf5fa56 3638bool gfc_is_class_container_ref (gfc_expr *e);
2cc6320d 3639gfc_expr *gfc_class_initializer (gfc_typespec *, gfc_expr *);
4fa02692 3640unsigned int gfc_hash_value (gfc_symbol *);
9e6644c6 3641gfc_expr *gfc_get_len_component (gfc_expr *e, int);
524af0d6 3642bool gfc_build_class_symbol (gfc_typespec *, symbol_attribute *,
9b6da3c7 3643 gfc_array_spec **);
88ce8031 3644gfc_symbol *gfc_find_derived_vtab (gfc_symbol *);
7289d1c9 3645gfc_symbol *gfc_find_vtab (gfc_typespec *);
524af0d6 3646gfc_symtree* gfc_find_typebound_proc (gfc_symbol*, bool*,
d15bac21 3647 const char*, bool, locus*);
524af0d6 3648gfc_symtree* gfc_find_typebound_user_op (gfc_symbol*, bool*,
d15bac21 3649 const char*, bool, locus*);
524af0d6 3650gfc_typebound_proc* gfc_find_typebound_intrinsic_op (gfc_symbol*, bool*,
d15bac21
JW
3651 gfc_intrinsic_op, bool,
3652 locus*);
3653gfc_symtree* gfc_get_tbp_symtree (gfc_symtree**, const char*);
86035eec 3654bool gfc_is_finalizable (gfc_symbol *, gfc_expr **);
d15bac21 3655
7a08eda1 3656#define CLASS_DATA(sym) sym->ts.u.derived->components
8b704316
PT
3657#define UNLIMITED_POLY(sym) \
3658 (sym != NULL && sym->ts.type == BT_CLASS \
3659 && CLASS_DATA (sym) \
3660 && CLASS_DATA (sym)->ts.u.derived \
3661 && CLASS_DATA (sym)->ts.u.derived->attr.unlimited_polymorphic)
f3b0bb7a
AV
3662#define IS_CLASS_ARRAY(sym) \
3663 (sym->ts.type == BT_CLASS \
3664 && CLASS_DATA (sym) \
3665 && CLASS_DATA (sym)->attr.dimension \
3666 && !CLASS_DATA (sym)->attr.class_pointer)
7a08eda1 3667
601d98be
TK
3668/* frontend-passes.c */
3669
3670void gfc_run_passes (gfc_namespace *);
3671
4d42b5cd
JJ
3672typedef int (*walk_code_fn_t) (gfc_code **, int *, void *);
3673typedef int (*walk_expr_fn_t) (gfc_expr **, int *, void *);
3674
5f23671d 3675int gfc_dummy_code_callback (gfc_code **, int *, void *);
4d42b5cd
JJ
3676int gfc_expr_walker (gfc_expr **, walk_expr_fn_t, void *);
3677int gfc_code_walker (gfc_code **, walk_code_fn_t, walk_expr_fn_t, void *);
1585b483 3678bool gfc_has_dimen_vector_ref (gfc_expr *e);
fb078366 3679void gfc_check_externals (gfc_namespace *);
3055d879 3680bool gfc_fix_implicit_pure (gfc_namespace *);
4d42b5cd 3681
d01b2c21
TK
3682/* simplify.c */
3683
3684void gfc_convert_mpz_to_signed (mpz_t, int);
0e360db9 3685gfc_expr *gfc_simplify_ieee_functions (gfc_expr *);
5867bb9a 3686bool gfc_is_size_zero_array (gfc_expr *);
d01b2c21 3687
f1abbf69
TK
3688/* trans-array.c */
3689
3690bool gfc_is_reallocatable_lhs (gfc_expr *);
3691
dc7a8b4b
JN
3692/* trans-decl.c */
3693
3694void finish_oacc_declare (gfc_namespace *, gfc_symbol *, bool);
facf0354 3695void gfc_adjust_builtins (void);
dc7a8b4b 3696
53814b8f 3697#endif /* GCC_GFORTRAN_H */