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