Don't warn when alignment of global common data exceeds maximum alignment.
[official-gcc.git] / gcc / fortran / gfortran.h
blob4b26cb430d4318b29f616e53dcdab131e6d4db70
1 /* gfortran header file
2 Copyright (C) 2000-2021 Free Software Foundation, Inc.
3 Contributed by Andy Vaught
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GCC_GFORTRAN_H
22 #define GCC_GFORTRAN_H
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. */
30 #ifndef GCC_CORETYPES_H
31 #error "gfortran.h must be included after coretypes.h"
32 #endif
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 \
42 In order for the format checking to accept the Fortran front end diagnostic \
43 framework extensions, you must include this file before diagnostic-core.h, \
44 not after.
45 #endif
47 /* Declarations common to the front-end and library are put in
48 libgfortran/libgfortran_frontend.h */
49 #include "libgfortran.h"
52 #include "intl.h"
53 #include "splay-tree.h"
55 /* Major control parameters. */
57 #define GFC_MAX_SYMBOL_LEN 63 /* Must be at least 63 for F2003. */
58 #define GFC_LETTERS 26 /* Number of letters in the alphabet. */
60 #define MAX_SUBRECORD_LENGTH 2147483639 /* 2**31-9 */
63 #define gfc_is_whitespace(c) ((c==' ') || (c=='\t') || (c=='\f'))
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
74 /* Stringization. */
75 #define stringize(x) expand_macro(x)
76 #define expand_macro(x) # x
78 /* For the runtime library, a standard prefix is a requirement to
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
83 #define PREFIX_LEN 10
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
94 #define BLANK_COMMON_NAME "__BLNK__"
96 /* Macro to initialize an mstring structure. */
97 #define minit(s, t) { s, NULL, t }
99 /* Structure for storing strings to be matched by gfc_match_string. */
100 typedef struct
102 const char *string;
103 const char *mp;
104 int tag;
106 mstring;
110 /*************************** Enums *****************************/
112 /* Used when matching and resolving data I/O transfer statements. */
114 enum io_kind
115 { M_READ, M_WRITE, M_PRINT, M_INQUIRE };
118 /* These are flags for identifying whether we are reading a character literal
119 between quotes or normal source code. */
121 enum gfc_instring
122 { NONSTRING = 0, INSTRING_WARN, INSTRING_NOWARN };
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. */
128 enum notification
129 { SILENT, WARNING, ERROR };
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. */
136 enum match
137 { MATCH_NO = 1, MATCH_YES, MATCH_ERROR };
139 /* Used for different Fortran source forms in places like scanner.c. */
140 enum gfc_source_form
141 { FORM_FREE, FORM_FIXED, FORM_UNKNOWN };
143 /* Expression node types. */
144 enum expr_t
145 { EXPR_UNKNOWN = 0, EXPR_OP = 1, EXPR_FUNCTION, EXPR_CONSTANT, EXPR_VARIABLE,
146 EXPR_SUBSTRING, EXPR_STRUCTURE, EXPR_ARRAY, EXPR_NULL, EXPR_COMPCALL, EXPR_PPC
149 /* Array types. */
150 enum array_type
151 { AS_EXPLICIT = 1, AS_ASSUMED_SHAPE, AS_DEFERRED,
152 AS_ASSUMED_SIZE, AS_IMPLIED_SHAPE, AS_ASSUMED_RANK,
153 AS_UNKNOWN
156 enum ar_type
157 { AR_FULL = 1, AR_ELEMENT, AR_SECTION, AR_UNKNOWN };
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. */
162 enum gfc_sl_type
163 { ST_LABEL_UNKNOWN = 1, ST_LABEL_TARGET, ST_LABEL_DO_TARGET,
164 ST_LABEL_BAD_TARGET, ST_LABEL_FORMAT
167 /* Intrinsic operators. */
168 enum gfc_intrinsic_op
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,
174 /* ==, /=, >, >=, <, <= */
175 INTRINSIC_EQ, INTRINSIC_NE, INTRINSIC_GT, INTRINSIC_GE,
176 INTRINSIC_LT, INTRINSIC_LE,
177 /* .EQ., .NE., .GT., .GE., .LT., .LE. (OS = Old-Style) */
178 INTRINSIC_EQ_OS, INTRINSIC_NE_OS, INTRINSIC_GT_OS, INTRINSIC_GE_OS,
179 INTRINSIC_LT_OS, INTRINSIC_LE_OS,
180 INTRINSIC_NOT, INTRINSIC_USER, INTRINSIC_ASSIGN, INTRINSIC_PARENTHESES,
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
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
191 /* Arithmetic results. */
192 enum arith
193 { ARITH_OK = 1, ARITH_OVERFLOW, ARITH_UNDERFLOW, ARITH_NAN,
194 ARITH_DIV0, ARITH_INCOMMENSURATE, ARITH_ASYMMETRIC, ARITH_PROHIBIT,
195 ARITH_WRONGCONCAT
198 /* Statements. */
199 enum gfc_statement
201 ST_ARITHMETIC_IF, ST_ALLOCATE, ST_ATTR_DECL, ST_ASSOCIATE,
202 ST_BACKSPACE, ST_BLOCK, ST_BLOCK_DATA,
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,
205 ST_ELSEWHERE, ST_END_ASSOCIATE, ST_END_BLOCK, ST_END_BLOCK_DATA,
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,
219 ST_SELECT_RANK, ST_RANK, ST_STRUCTURE_DECL, ST_END_STRUCTURE,
220 ST_UNION, ST_END_UNION, ST_MAP, ST_END_MAP,
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_SERIAL_LOOP, ST_OACC_END_SERIAL_LOOP, ST_OACC_SERIAL,
227 ST_OACC_END_SERIAL, ST_OACC_ENTER_DATA, ST_OACC_EXIT_DATA, ST_OACC_ROUTINE,
228 ST_OACC_ATOMIC, ST_OACC_END_ATOMIC,
229 ST_OMP_ATOMIC, ST_OMP_BARRIER, ST_OMP_CRITICAL, ST_OMP_END_ATOMIC,
230 ST_OMP_END_CRITICAL, ST_OMP_END_DO, ST_OMP_END_MASTER, ST_OMP_END_ORDERED,
231 ST_OMP_END_PARALLEL, ST_OMP_END_PARALLEL_DO, ST_OMP_END_PARALLEL_SECTIONS,
232 ST_OMP_END_PARALLEL_WORKSHARE, ST_OMP_END_SECTIONS, ST_OMP_END_SINGLE,
233 ST_OMP_END_WORKSHARE, ST_OMP_DO, ST_OMP_FLUSH, ST_OMP_MASTER, ST_OMP_ORDERED,
234 ST_OMP_PARALLEL, ST_OMP_PARALLEL_DO, ST_OMP_PARALLEL_SECTIONS,
235 ST_OMP_PARALLEL_WORKSHARE, ST_OMP_SECTIONS, ST_OMP_SECTION, ST_OMP_SINGLE,
236 ST_OMP_THREADPRIVATE, ST_OMP_WORKSHARE, ST_OMP_TASK, ST_OMP_END_TASK,
237 ST_OMP_TASKWAIT, ST_OMP_TASKYIELD, ST_OMP_CANCEL, ST_OMP_CANCELLATION_POINT,
238 ST_OMP_TASKGROUP, ST_OMP_END_TASKGROUP, ST_OMP_SIMD, ST_OMP_END_SIMD,
239 ST_OMP_DO_SIMD, ST_OMP_END_DO_SIMD, ST_OMP_PARALLEL_DO_SIMD,
240 ST_OMP_END_PARALLEL_DO_SIMD, ST_OMP_DECLARE_SIMD, ST_OMP_DECLARE_REDUCTION,
241 ST_OMP_TARGET, ST_OMP_END_TARGET, ST_OMP_TARGET_DATA, ST_OMP_END_TARGET_DATA,
242 ST_OMP_TARGET_UPDATE, ST_OMP_DECLARE_TARGET,
243 ST_OMP_TEAMS, ST_OMP_END_TEAMS, ST_OMP_DISTRIBUTE, ST_OMP_END_DISTRIBUTE,
244 ST_OMP_DISTRIBUTE_SIMD, ST_OMP_END_DISTRIBUTE_SIMD,
245 ST_OMP_DISTRIBUTE_PARALLEL_DO, ST_OMP_END_DISTRIBUTE_PARALLEL_DO,
246 ST_OMP_DISTRIBUTE_PARALLEL_DO_SIMD, ST_OMP_END_DISTRIBUTE_PARALLEL_DO_SIMD,
247 ST_OMP_TARGET_TEAMS, ST_OMP_END_TARGET_TEAMS, ST_OMP_TEAMS_DISTRIBUTE,
248 ST_OMP_END_TEAMS_DISTRIBUTE, ST_OMP_TEAMS_DISTRIBUTE_SIMD,
249 ST_OMP_END_TEAMS_DISTRIBUTE_SIMD, ST_OMP_TARGET_TEAMS_DISTRIBUTE,
250 ST_OMP_END_TARGET_TEAMS_DISTRIBUTE, ST_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD,
251 ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_SIMD, ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO,
252 ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO,
253 ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO,
254 ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO,
255 ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD,
256 ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD,
257 ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD,
258 ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD,
259 ST_OMP_TARGET_PARALLEL, ST_OMP_END_TARGET_PARALLEL,
260 ST_OMP_TARGET_PARALLEL_DO, ST_OMP_END_TARGET_PARALLEL_DO,
261 ST_OMP_TARGET_PARALLEL_DO_SIMD, ST_OMP_END_TARGET_PARALLEL_DO_SIMD,
262 ST_OMP_TARGET_ENTER_DATA, ST_OMP_TARGET_EXIT_DATA,
263 ST_OMP_TARGET_SIMD, ST_OMP_END_TARGET_SIMD,
264 ST_OMP_TASKLOOP, ST_OMP_END_TASKLOOP, ST_OMP_SCAN, ST_OMP_DEPOBJ,
265 ST_OMP_TASKLOOP_SIMD, ST_OMP_END_TASKLOOP_SIMD, ST_OMP_ORDERED_DEPEND,
266 ST_OMP_REQUIRES, ST_PROCEDURE, ST_GENERIC, ST_CRITICAL, ST_END_CRITICAL,
267 ST_GET_FCN_CHARACTERISTICS, ST_LOCK, ST_UNLOCK, ST_EVENT_POST,
268 ST_EVENT_WAIT, ST_FAIL_IMAGE, ST_FORM_TEAM, ST_CHANGE_TEAM,
269 ST_END_TEAM, ST_SYNC_TEAM, ST_OMP_PARALLEL_MASTER,
270 ST_OMP_END_PARALLEL_MASTER, ST_OMP_PARALLEL_MASTER_TASKLOOP,
271 ST_OMP_END_PARALLEL_MASTER_TASKLOOP, ST_OMP_PARALLEL_MASTER_TASKLOOP_SIMD,
272 ST_OMP_END_PARALLEL_MASTER_TASKLOOP_SIMD, ST_OMP_MASTER_TASKLOOP,
273 ST_OMP_END_MASTER_TASKLOOP, ST_OMP_MASTER_TASKLOOP_SIMD,
274 ST_OMP_END_MASTER_TASKLOOP_SIMD, ST_OMP_LOOP, ST_OMP_END_LOOP,
275 ST_OMP_PARALLEL_LOOP, ST_OMP_END_PARALLEL_LOOP, ST_OMP_TEAMS_LOOP,
276 ST_OMP_END_TEAMS_LOOP, ST_OMP_TARGET_PARALLEL_LOOP,
277 ST_OMP_END_TARGET_PARALLEL_LOOP, ST_OMP_TARGET_TEAMS_LOOP,
278 ST_OMP_END_TARGET_TEAMS_LOOP, ST_OMP_MASKED, ST_OMP_END_MASKED,
279 ST_OMP_PARALLEL_MASKED, ST_OMP_END_PARALLEL_MASKED,
280 ST_OMP_PARALLEL_MASKED_TASKLOOP, ST_OMP_END_PARALLEL_MASKED_TASKLOOP,
281 ST_OMP_PARALLEL_MASKED_TASKLOOP_SIMD,
282 ST_OMP_END_PARALLEL_MASKED_TASKLOOP_SIMD, ST_OMP_MASKED_TASKLOOP,
283 ST_OMP_END_MASKED_TASKLOOP, ST_OMP_MASKED_TASKLOOP_SIMD,
284 ST_OMP_END_MASKED_TASKLOOP_SIMD, ST_OMP_SCOPE, ST_OMP_END_SCOPE,
285 ST_OMP_ERROR, ST_NONE
288 /* Types of interfaces that we can have. Assignment interfaces are
289 considered to be intrinsic operators. */
290 enum interface_type
292 INTERFACE_NAMELESS = 1, INTERFACE_GENERIC,
293 INTERFACE_INTRINSIC_OP, INTERFACE_USER_OP, INTERFACE_ABSTRACT,
294 INTERFACE_DTIO
297 /* Symbol flavors: these are all mutually exclusive.
298 12 elements = 4 bits. */
299 enum sym_flavor
301 FL_UNKNOWN = 0, FL_PROGRAM, FL_BLOCK_DATA, FL_MODULE, FL_VARIABLE,
302 FL_PARAMETER, FL_LABEL, FL_PROCEDURE, FL_DERIVED, FL_NAMELIST,
303 FL_UNION, FL_STRUCT, FL_VOID
306 /* Procedure types. 7 elements = 3 bits. */
307 enum procedure_type
308 { PROC_UNKNOWN, PROC_MODULE, PROC_INTERNAL, PROC_DUMMY,
309 PROC_INTRINSIC, PROC_ST_FUNCTION, PROC_EXTERNAL
312 /* Intent types. Note that these values are also used in another enum in
313 decl.c (match_attr_spec). */
314 enum sym_intent
315 { INTENT_UNKNOWN = 0, INTENT_IN, INTENT_OUT, INTENT_INOUT
318 /* Access types. */
319 enum gfc_access
320 { ACCESS_UNKNOWN = 0, ACCESS_PUBLIC, ACCESS_PRIVATE
323 /* Flags to keep track of where an interface came from.
324 3 elements = 2 bits. */
325 enum ifsrc
326 { IFSRC_UNKNOWN = 0, /* Interface unknown, only return type may be known. */
327 IFSRC_DECL, /* FUNCTION or SUBROUTINE declaration. */
328 IFSRC_IFBODY /* INTERFACE statement or PROCEDURE statement
329 with explicit interface. */
332 /* Whether a SAVE attribute was set explicitly or implicitly. */
333 enum save_state
334 { SAVE_NONE = 0, SAVE_EXPLICIT, SAVE_IMPLICIT
337 /* OpenACC 'routine' directive's level of parallelism. */
338 enum oacc_routine_lop
339 { OACC_ROUTINE_LOP_NONE = 0,
340 OACC_ROUTINE_LOP_GANG,
341 OACC_ROUTINE_LOP_WORKER,
342 OACC_ROUTINE_LOP_VECTOR,
343 OACC_ROUTINE_LOP_SEQ,
344 OACC_ROUTINE_LOP_ERROR
347 /* Strings for all symbol attributes. We use these for dumping the
348 parse tree, in error messages, and also when reading and writing
349 modules. In symbol.c. */
350 extern const mstring flavors[];
351 extern const mstring procedures[];
352 extern const mstring intents[];
353 extern const mstring access_types[];
354 extern const mstring ifsrc_types[];
355 extern const mstring save_status[];
357 /* Strings for DTIO procedure names. In symbol.c. */
358 extern const mstring dtio_procs[];
360 enum dtio_codes
361 { DTIO_RF = 0, DTIO_WF, DTIO_RUF, DTIO_WUF };
363 /* Enumeration of all the generic intrinsic functions. Used by the
364 backend for identification of a function. */
366 enum gfc_isym_id
368 /* GFC_ISYM_NONE is used for intrinsics which will never be seen by
369 the backend (e.g. KIND). */
370 GFC_ISYM_NONE = 0,
371 GFC_ISYM_ABORT,
372 GFC_ISYM_ABS,
373 GFC_ISYM_ACCESS,
374 GFC_ISYM_ACHAR,
375 GFC_ISYM_ACOS,
376 GFC_ISYM_ACOSD,
377 GFC_ISYM_ACOSH,
378 GFC_ISYM_ADJUSTL,
379 GFC_ISYM_ADJUSTR,
380 GFC_ISYM_AIMAG,
381 GFC_ISYM_AINT,
382 GFC_ISYM_ALARM,
383 GFC_ISYM_ALL,
384 GFC_ISYM_ALLOCATED,
385 GFC_ISYM_AND,
386 GFC_ISYM_ANINT,
387 GFC_ISYM_ANY,
388 GFC_ISYM_ASIN,
389 GFC_ISYM_ASIND,
390 GFC_ISYM_ASINH,
391 GFC_ISYM_ASSOCIATED,
392 GFC_ISYM_ATAN,
393 GFC_ISYM_ATAN2,
394 GFC_ISYM_ATAN2D,
395 GFC_ISYM_ATAND,
396 GFC_ISYM_ATANH,
397 GFC_ISYM_ATOMIC_ADD,
398 GFC_ISYM_ATOMIC_AND,
399 GFC_ISYM_ATOMIC_CAS,
400 GFC_ISYM_ATOMIC_DEF,
401 GFC_ISYM_ATOMIC_FETCH_ADD,
402 GFC_ISYM_ATOMIC_FETCH_AND,
403 GFC_ISYM_ATOMIC_FETCH_OR,
404 GFC_ISYM_ATOMIC_FETCH_XOR,
405 GFC_ISYM_ATOMIC_OR,
406 GFC_ISYM_ATOMIC_REF,
407 GFC_ISYM_ATOMIC_XOR,
408 GFC_ISYM_BGE,
409 GFC_ISYM_BGT,
410 GFC_ISYM_BIT_SIZE,
411 GFC_ISYM_BLE,
412 GFC_ISYM_BLT,
413 GFC_ISYM_BTEST,
414 GFC_ISYM_CAF_GET,
415 GFC_ISYM_CAF_SEND,
416 GFC_ISYM_CEILING,
417 GFC_ISYM_CHAR,
418 GFC_ISYM_CHDIR,
419 GFC_ISYM_CHMOD,
420 GFC_ISYM_CMPLX,
421 GFC_ISYM_CO_BROADCAST,
422 GFC_ISYM_CO_MAX,
423 GFC_ISYM_CO_MIN,
424 GFC_ISYM_CO_REDUCE,
425 GFC_ISYM_CO_SUM,
426 GFC_ISYM_COMMAND_ARGUMENT_COUNT,
427 GFC_ISYM_COMPILER_OPTIONS,
428 GFC_ISYM_COMPILER_VERSION,
429 GFC_ISYM_COMPLEX,
430 GFC_ISYM_CONJG,
431 GFC_ISYM_CONVERSION,
432 GFC_ISYM_COS,
433 GFC_ISYM_COSD,
434 GFC_ISYM_COSH,
435 GFC_ISYM_COTAN,
436 GFC_ISYM_COTAND,
437 GFC_ISYM_COUNT,
438 GFC_ISYM_CPU_TIME,
439 GFC_ISYM_CSHIFT,
440 GFC_ISYM_CTIME,
441 GFC_ISYM_C_ASSOCIATED,
442 GFC_ISYM_C_F_POINTER,
443 GFC_ISYM_C_F_PROCPOINTER,
444 GFC_ISYM_C_FUNLOC,
445 GFC_ISYM_C_LOC,
446 GFC_ISYM_C_SIZEOF,
447 GFC_ISYM_DATE_AND_TIME,
448 GFC_ISYM_DBLE,
449 GFC_ISYM_DFLOAT,
450 GFC_ISYM_DIGITS,
451 GFC_ISYM_DIM,
452 GFC_ISYM_DOT_PRODUCT,
453 GFC_ISYM_DPROD,
454 GFC_ISYM_DSHIFTL,
455 GFC_ISYM_DSHIFTR,
456 GFC_ISYM_DTIME,
457 GFC_ISYM_EOSHIFT,
458 GFC_ISYM_EPSILON,
459 GFC_ISYM_ERF,
460 GFC_ISYM_ERFC,
461 GFC_ISYM_ERFC_SCALED,
462 GFC_ISYM_ETIME,
463 GFC_ISYM_EVENT_QUERY,
464 GFC_ISYM_EXECUTE_COMMAND_LINE,
465 GFC_ISYM_EXIT,
466 GFC_ISYM_EXP,
467 GFC_ISYM_EXPONENT,
468 GFC_ISYM_EXTENDS_TYPE_OF,
469 GFC_ISYM_FAILED_IMAGES,
470 GFC_ISYM_FDATE,
471 GFC_ISYM_FE_RUNTIME_ERROR,
472 GFC_ISYM_FGET,
473 GFC_ISYM_FGETC,
474 GFC_ISYM_FINDLOC,
475 GFC_ISYM_FLOAT,
476 GFC_ISYM_FLOOR,
477 GFC_ISYM_FLUSH,
478 GFC_ISYM_FNUM,
479 GFC_ISYM_FPUT,
480 GFC_ISYM_FPUTC,
481 GFC_ISYM_FRACTION,
482 GFC_ISYM_FREE,
483 GFC_ISYM_FSEEK,
484 GFC_ISYM_FSTAT,
485 GFC_ISYM_FTELL,
486 GFC_ISYM_TGAMMA,
487 GFC_ISYM_GERROR,
488 GFC_ISYM_GETARG,
489 GFC_ISYM_GET_COMMAND,
490 GFC_ISYM_GET_COMMAND_ARGUMENT,
491 GFC_ISYM_GETCWD,
492 GFC_ISYM_GETENV,
493 GFC_ISYM_GET_ENVIRONMENT_VARIABLE,
494 GFC_ISYM_GETGID,
495 GFC_ISYM_GETLOG,
496 GFC_ISYM_GETPID,
497 GFC_ISYM_GET_TEAM,
498 GFC_ISYM_GETUID,
499 GFC_ISYM_GMTIME,
500 GFC_ISYM_HOSTNM,
501 GFC_ISYM_HUGE,
502 GFC_ISYM_HYPOT,
503 GFC_ISYM_IACHAR,
504 GFC_ISYM_IALL,
505 GFC_ISYM_IAND,
506 GFC_ISYM_IANY,
507 GFC_ISYM_IARGC,
508 GFC_ISYM_IBCLR,
509 GFC_ISYM_IBITS,
510 GFC_ISYM_IBSET,
511 GFC_ISYM_ICHAR,
512 GFC_ISYM_IDATE,
513 GFC_ISYM_IEOR,
514 GFC_ISYM_IERRNO,
515 GFC_ISYM_IMAGE_INDEX,
516 GFC_ISYM_IMAGE_STATUS,
517 GFC_ISYM_INDEX,
518 GFC_ISYM_INT,
519 GFC_ISYM_INT2,
520 GFC_ISYM_INT8,
521 GFC_ISYM_IOR,
522 GFC_ISYM_IPARITY,
523 GFC_ISYM_IRAND,
524 GFC_ISYM_ISATTY,
525 GFC_ISYM_IS_CONTIGUOUS,
526 GFC_ISYM_IS_IOSTAT_END,
527 GFC_ISYM_IS_IOSTAT_EOR,
528 GFC_ISYM_ISNAN,
529 GFC_ISYM_ISHFT,
530 GFC_ISYM_ISHFTC,
531 GFC_ISYM_ITIME,
532 GFC_ISYM_J0,
533 GFC_ISYM_J1,
534 GFC_ISYM_JN,
535 GFC_ISYM_JN2,
536 GFC_ISYM_KILL,
537 GFC_ISYM_KIND,
538 GFC_ISYM_LBOUND,
539 GFC_ISYM_LCOBOUND,
540 GFC_ISYM_LEADZ,
541 GFC_ISYM_LEN,
542 GFC_ISYM_LEN_TRIM,
543 GFC_ISYM_LGAMMA,
544 GFC_ISYM_LGE,
545 GFC_ISYM_LGT,
546 GFC_ISYM_LINK,
547 GFC_ISYM_LLE,
548 GFC_ISYM_LLT,
549 GFC_ISYM_LOC,
550 GFC_ISYM_LOG,
551 GFC_ISYM_LOG10,
552 GFC_ISYM_LOGICAL,
553 GFC_ISYM_LONG,
554 GFC_ISYM_LSHIFT,
555 GFC_ISYM_LSTAT,
556 GFC_ISYM_LTIME,
557 GFC_ISYM_MALLOC,
558 GFC_ISYM_MASKL,
559 GFC_ISYM_MASKR,
560 GFC_ISYM_MATMUL,
561 GFC_ISYM_MAX,
562 GFC_ISYM_MAXEXPONENT,
563 GFC_ISYM_MAXLOC,
564 GFC_ISYM_MAXVAL,
565 GFC_ISYM_MCLOCK,
566 GFC_ISYM_MCLOCK8,
567 GFC_ISYM_MERGE,
568 GFC_ISYM_MERGE_BITS,
569 GFC_ISYM_MIN,
570 GFC_ISYM_MINEXPONENT,
571 GFC_ISYM_MINLOC,
572 GFC_ISYM_MINVAL,
573 GFC_ISYM_MOD,
574 GFC_ISYM_MODULO,
575 GFC_ISYM_MOVE_ALLOC,
576 GFC_ISYM_MVBITS,
577 GFC_ISYM_NEAREST,
578 GFC_ISYM_NEW_LINE,
579 GFC_ISYM_NINT,
580 GFC_ISYM_NORM2,
581 GFC_ISYM_NOT,
582 GFC_ISYM_NULL,
583 GFC_ISYM_NUM_IMAGES,
584 GFC_ISYM_OR,
585 GFC_ISYM_PACK,
586 GFC_ISYM_PARITY,
587 GFC_ISYM_PERROR,
588 GFC_ISYM_POPCNT,
589 GFC_ISYM_POPPAR,
590 GFC_ISYM_PRECISION,
591 GFC_ISYM_PRESENT,
592 GFC_ISYM_PRODUCT,
593 GFC_ISYM_RADIX,
594 GFC_ISYM_RAND,
595 GFC_ISYM_RANDOM_INIT,
596 GFC_ISYM_RANDOM_NUMBER,
597 GFC_ISYM_RANDOM_SEED,
598 GFC_ISYM_RANGE,
599 GFC_ISYM_RANK,
600 GFC_ISYM_REAL,
601 GFC_ISYM_REALPART,
602 GFC_ISYM_RENAME,
603 GFC_ISYM_REPEAT,
604 GFC_ISYM_RESHAPE,
605 GFC_ISYM_RRSPACING,
606 GFC_ISYM_RSHIFT,
607 GFC_ISYM_SAME_TYPE_AS,
608 GFC_ISYM_SC_KIND,
609 GFC_ISYM_SCALE,
610 GFC_ISYM_SCAN,
611 GFC_ISYM_SECNDS,
612 GFC_ISYM_SECOND,
613 GFC_ISYM_SET_EXPONENT,
614 GFC_ISYM_SHAPE,
615 GFC_ISYM_SHIFTA,
616 GFC_ISYM_SHIFTL,
617 GFC_ISYM_SHIFTR,
618 GFC_ISYM_BACKTRACE,
619 GFC_ISYM_SIGN,
620 GFC_ISYM_SIGNAL,
621 GFC_ISYM_SI_KIND,
622 GFC_ISYM_SIN,
623 GFC_ISYM_SIND,
624 GFC_ISYM_SINH,
625 GFC_ISYM_SIZE,
626 GFC_ISYM_SLEEP,
627 GFC_ISYM_SIZEOF,
628 GFC_ISYM_SNGL,
629 GFC_ISYM_SPACING,
630 GFC_ISYM_SPREAD,
631 GFC_ISYM_SQRT,
632 GFC_ISYM_SRAND,
633 GFC_ISYM_SR_KIND,
634 GFC_ISYM_STAT,
635 GFC_ISYM_STOPPED_IMAGES,
636 GFC_ISYM_STORAGE_SIZE,
637 GFC_ISYM_STRIDE,
638 GFC_ISYM_SUM,
639 GFC_ISYM_SYMLINK,
640 GFC_ISYM_SYMLNK,
641 GFC_ISYM_SYSTEM,
642 GFC_ISYM_SYSTEM_CLOCK,
643 GFC_ISYM_TAN,
644 GFC_ISYM_TAND,
645 GFC_ISYM_TANH,
646 GFC_ISYM_TEAM_NUMBER,
647 GFC_ISYM_THIS_IMAGE,
648 GFC_ISYM_TIME,
649 GFC_ISYM_TIME8,
650 GFC_ISYM_TINY,
651 GFC_ISYM_TRAILZ,
652 GFC_ISYM_TRANSFER,
653 GFC_ISYM_TRANSPOSE,
654 GFC_ISYM_TRIM,
655 GFC_ISYM_TTYNAM,
656 GFC_ISYM_UBOUND,
657 GFC_ISYM_UCOBOUND,
658 GFC_ISYM_UMASK,
659 GFC_ISYM_UNLINK,
660 GFC_ISYM_UNPACK,
661 GFC_ISYM_VERIFY,
662 GFC_ISYM_XOR,
663 GFC_ISYM_Y0,
664 GFC_ISYM_Y1,
665 GFC_ISYM_YN,
666 GFC_ISYM_YN2
669 enum init_local_logical
671 GFC_INIT_LOGICAL_OFF = 0,
672 GFC_INIT_LOGICAL_FALSE,
673 GFC_INIT_LOGICAL_TRUE
676 enum init_local_character
678 GFC_INIT_CHARACTER_OFF = 0,
679 GFC_INIT_CHARACTER_ON
682 enum init_local_integer
684 GFC_INIT_INTEGER_OFF = 0,
685 GFC_INIT_INTEGER_ON
688 enum gfc_reverse
690 GFC_ENABLE_REVERSE,
691 GFC_FORWARD_SET,
692 GFC_REVERSE_SET,
693 GFC_INHIBIT_REVERSE
696 enum gfc_param_spec_type
698 SPEC_EXPLICIT,
699 SPEC_ASSUMED,
700 SPEC_DEFERRED
703 /************************* Structures *****************************/
705 /* Used for keeping things in balanced binary trees. */
706 #define BBT_HEADER(self) int priority; struct self *left, *right
708 #define NAMED_INTCST(a,b,c,d) a,
709 #define NAMED_KINDARRAY(a,b,c,d) a,
710 #define NAMED_FUNCTION(a,b,c,d) a,
711 #define NAMED_SUBROUTINE(a,b,c,d) a,
712 #define NAMED_DERIVED_TYPE(a,b,c,d) a,
713 enum iso_fortran_env_symbol
715 ISOFORTRANENV_INVALID = -1,
716 #include "iso-fortran-env.def"
717 ISOFORTRANENV_LAST, ISOFORTRANENV_NUMBER = ISOFORTRANENV_LAST
719 #undef NAMED_INTCST
720 #undef NAMED_KINDARRAY
721 #undef NAMED_FUNCTION
722 #undef NAMED_SUBROUTINE
723 #undef NAMED_DERIVED_TYPE
725 #define NAMED_INTCST(a,b,c,d) a,
726 #define NAMED_REALCST(a,b,c,d) a,
727 #define NAMED_CMPXCST(a,b,c,d) a,
728 #define NAMED_LOGCST(a,b,c) a,
729 #define NAMED_CHARKNDCST(a,b,c) a,
730 #define NAMED_CHARCST(a,b,c) a,
731 #define DERIVED_TYPE(a,b,c) a,
732 #define NAMED_FUNCTION(a,b,c,d) a,
733 #define NAMED_SUBROUTINE(a,b,c,d) a,
734 enum iso_c_binding_symbol
736 ISOCBINDING_INVALID = -1,
737 #include "iso-c-binding.def"
738 ISOCBINDING_LAST,
739 ISOCBINDING_NUMBER = ISOCBINDING_LAST
741 #undef NAMED_INTCST
742 #undef NAMED_REALCST
743 #undef NAMED_CMPXCST
744 #undef NAMED_LOGCST
745 #undef NAMED_CHARKNDCST
746 #undef NAMED_CHARCST
747 #undef DERIVED_TYPE
748 #undef NAMED_FUNCTION
749 #undef NAMED_SUBROUTINE
751 enum intmod_id
753 INTMOD_NONE = 0, INTMOD_ISO_FORTRAN_ENV, INTMOD_ISO_C_BINDING,
754 INTMOD_IEEE_FEATURES, INTMOD_IEEE_EXCEPTIONS, INTMOD_IEEE_ARITHMETIC
757 typedef struct
759 char name[GFC_MAX_SYMBOL_LEN + 1];
760 int value; /* Used for both integer and character values. */
761 bt f90_type;
763 CInteropKind_t;
765 /* Array of structs, where the structs represent the C interop kinds.
766 The list will be implemented based on a hash of the kind name since
767 these could be accessed multiple times.
768 Declared in trans-types.c as a global, since it's in that file
769 that the list is initialized. */
770 extern CInteropKind_t c_interop_kinds_table[];
772 enum gfc_omp_device_type
774 OMP_DEVICE_TYPE_UNSET,
775 OMP_DEVICE_TYPE_HOST,
776 OMP_DEVICE_TYPE_NOHOST,
777 OMP_DEVICE_TYPE_ANY
780 enum gfc_omp_severity_type
782 OMP_SEVERITY_UNSET,
783 OMP_SEVERITY_WARNING,
784 OMP_SEVERITY_FATAL
787 enum gfc_omp_at_type
789 OMP_AT_UNSET,
790 OMP_AT_COMPILATION,
791 OMP_AT_EXECUTION
794 /* Structure and list of supported extension attributes. */
795 typedef enum
797 EXT_ATTR_DLLIMPORT = 0,
798 EXT_ATTR_DLLEXPORT,
799 EXT_ATTR_STDCALL,
800 EXT_ATTR_CDECL,
801 EXT_ATTR_FASTCALL,
802 EXT_ATTR_NO_ARG_CHECK,
803 EXT_ATTR_DEPRECATED,
804 EXT_ATTR_LAST, EXT_ATTR_NUM = EXT_ATTR_LAST
806 ext_attr_id_t;
808 typedef struct
810 const char *name;
811 unsigned id;
812 const char *middle_end_name;
814 ext_attr_t;
816 extern const ext_attr_t ext_attr_list[];
818 /* Symbol attribute structure. */
819 typedef struct
821 /* Variable attributes. */
822 unsigned allocatable:1, dimension:1, codimension:1, external:1, intrinsic:1,
823 optional:1, pointer:1, target:1, value:1, volatile_:1, temporary:1,
824 dummy:1, result:1, assign:1, threadprivate:1, not_always_present:1,
825 implied_index:1, subref_array_pointer:1, proc_pointer:1, asynchronous:1,
826 contiguous:1, fe_temp: 1, automatic: 1;
828 /* For CLASS containers, the pointer attribute is sometimes set internally
829 even though it was not directly specified. In this case, keep the
830 "real" (original) value here. */
831 unsigned class_pointer:1;
833 ENUM_BITFIELD (save_state) save:2;
835 unsigned data:1, /* Symbol is named in a DATA statement. */
836 is_protected:1, /* Symbol has been marked as protected. */
837 use_assoc:1, /* Symbol has been use-associated. */
838 used_in_submodule:1, /* Symbol has been use-associated in a
839 submodule. Needed since these entities must
840 be set host associated to be compliant. */
841 use_only:1, /* Symbol has been use-associated, with ONLY. */
842 use_rename:1, /* Symbol has been use-associated and renamed. */
843 imported:1, /* Symbol has been associated by IMPORT. */
844 host_assoc:1; /* Symbol has been host associated. */
846 unsigned in_namelist:1, in_common:1, in_equivalence:1;
847 unsigned function:1, subroutine:1, procedure:1;
848 unsigned generic:1, generic_copy:1;
849 unsigned implicit_type:1; /* Type defined via implicit rules. */
850 unsigned untyped:1; /* No implicit type could be found. */
852 unsigned is_bind_c:1; /* say if is bound to C. */
853 unsigned extension:8; /* extension level of a derived type. */
854 unsigned is_class:1; /* is a CLASS container. */
855 unsigned class_ok:1; /* is a CLASS object with correct attributes. */
856 unsigned vtab:1; /* is a derived type vtab, pointed to by CLASS objects. */
857 unsigned vtype:1; /* is a derived type of a vtab. */
859 /* These flags are both in the typespec and attribute. The attribute
860 list is what gets read from/written to a module file. The typespec
861 is created from a decl being processed. */
862 unsigned is_c_interop:1; /* It's c interoperable. */
863 unsigned is_iso_c:1; /* Symbol is from iso_c_binding. */
865 /* Function/subroutine attributes */
866 unsigned sequence:1, elemental:1, pure:1, recursive:1;
867 unsigned unmaskable:1, masked:1, contained:1, mod_proc:1, abstract:1;
869 /* Set if this is a module function or subroutine. Note that it is an
870 attribute because it appears as a prefix in the declaration like
871 PURE, etc.. */
872 unsigned module_procedure:1;
874 /* Set if a (public) symbol [e.g. generic name] exposes this symbol,
875 which is relevant for private module procedures. */
876 unsigned public_used:1;
878 /* This is set if a contained procedure could be declared pure. This is
879 used for certain optimizations that require the result or arguments
880 cannot alias. Note that this is zero for PURE procedures. */
881 unsigned implicit_pure:1;
883 /* This is set for a procedure that contains expressions referencing
884 arrays coming from outside its namespace.
885 This is used to force the creation of a temporary when the LHS of
886 an array assignment may be used by an elemental procedure appearing
887 on the RHS. */
888 unsigned array_outer_dependency:1;
890 /* This is set if the subroutine doesn't return. Currently, this
891 is only possible for intrinsic subroutines. */
892 unsigned noreturn:1;
894 /* Set if this procedure is an alternate entry point. These procedures
895 don't have any code associated, and the backend will turn them into
896 thunks to the master function. */
897 unsigned entry:1;
899 /* Set if this is the master function for a procedure with multiple
900 entry points. */
901 unsigned entry_master:1;
903 /* Set if this is the master function for a function with multiple
904 entry points where characteristics of the entry points differ. */
905 unsigned mixed_entry_master:1;
907 /* Set if a function must always be referenced by an explicit interface. */
908 unsigned always_explicit:1;
910 /* Set if the symbol is generated and, hence, standard violations
911 shouldn't be flaged. */
912 unsigned artificial:1;
914 /* Set if the symbol has been referenced in an expression. No further
915 modification of type or type parameters is permitted. */
916 unsigned referenced:1;
918 /* Set if this is the symbol for the main program. */
919 unsigned is_main_program:1;
921 /* Mutually exclusive multibit attributes. */
922 ENUM_BITFIELD (gfc_access) access:2;
923 ENUM_BITFIELD (sym_intent) intent:2;
924 ENUM_BITFIELD (sym_flavor) flavor:4;
925 ENUM_BITFIELD (ifsrc) if_source:2;
927 ENUM_BITFIELD (procedure_type) proc:3;
929 /* Special attributes for Cray pointers, pointees. */
930 unsigned cray_pointer:1, cray_pointee:1;
932 /* The symbol is a derived type with allocatable components, pointer
933 components or private components, procedure pointer components,
934 possibly nested. zero_comp is true if the derived type has no
935 component at all. defined_assign_comp is true if the derived
936 type or a (sub-)component has a typebound defined assignment.
937 unlimited_polymorphic flags the type of the container for these
938 entities. */
939 unsigned alloc_comp:1, pointer_comp:1, proc_pointer_comp:1,
940 private_comp:1, zero_comp:1, coarray_comp:1, lock_comp:1,
941 event_comp:1, defined_assign_comp:1, unlimited_polymorphic:1,
942 has_dtio_procs:1, caf_token:1;
944 /* This is a temporary selector for SELECT TYPE/RANK or an associate
945 variable for SELECT TYPE/RANK or ASSOCIATE. */
946 unsigned select_type_temporary:1, select_rank_temporary:1, associate_var:1;
948 /* These are the attributes required for parameterized derived
949 types. */
950 unsigned pdt_kind:1, pdt_len:1, pdt_type:1, pdt_template:1,
951 pdt_array:1, pdt_string:1;
953 /* This is omp_{out,in,priv,orig} artificial variable in
954 !$OMP DECLARE REDUCTION. */
955 unsigned omp_udr_artificial_var:1;
957 /* Mentioned in OMP DECLARE TARGET. */
958 unsigned omp_declare_target:1;
959 unsigned omp_declare_target_link:1;
960 ENUM_BITFIELD (gfc_omp_device_type) omp_device_type:2;
962 /* Mentioned in OACC DECLARE. */
963 unsigned oacc_declare_create:1;
964 unsigned oacc_declare_copyin:1;
965 unsigned oacc_declare_deviceptr:1;
966 unsigned oacc_declare_device_resident:1;
967 unsigned oacc_declare_link:1;
969 /* OpenACC 'routine' directive's level of parallelism. */
970 ENUM_BITFIELD (oacc_routine_lop) oacc_routine_lop:3;
971 unsigned oacc_routine_nohost:1;
973 /* Attributes set by compiler extensions (!GCC$ ATTRIBUTES). */
974 unsigned ext_attr:EXT_ATTR_NUM;
976 /* The namespace where the attribute has been set. */
977 struct gfc_namespace *volatile_ns, *asynchronous_ns;
979 symbol_attribute;
982 /* We need to store source lines as sequences of multibyte source
983 characters. We define here a type wide enough to hold any multibyte
984 source character, just like libcpp does. A 32-bit type is enough. */
986 #if HOST_BITS_PER_INT >= 32
987 typedef unsigned int gfc_char_t;
988 #elif HOST_BITS_PER_LONG >= 32
989 typedef unsigned long gfc_char_t;
990 #elif defined(HAVE_LONG_LONG) && (HOST_BITS_PER_LONGLONG >= 32)
991 typedef unsigned long long gfc_char_t;
992 #else
993 # error "Cannot find an integer type with at least 32 bits"
994 #endif
997 /* The following three structures are used to identify a location in
998 the sources.
1000 gfc_file is used to maintain a tree of the source files and how
1001 they include each other
1003 gfc_linebuf holds a single line of source code and information
1004 which file it resides in
1006 locus point to the sourceline and the character in the source
1007 line.
1010 typedef struct gfc_file
1012 struct gfc_file *next, *up;
1013 int inclusion_line, line;
1014 char *filename;
1015 } gfc_file;
1017 typedef struct gfc_linebuf
1019 location_t location;
1020 struct gfc_file *file;
1021 struct gfc_linebuf *next;
1023 int truncated;
1024 bool dbg_emitted;
1026 gfc_char_t line[1];
1027 } gfc_linebuf;
1029 #define gfc_linebuf_header_size (offsetof (gfc_linebuf, line))
1031 #define gfc_linebuf_linenum(LBUF) (LOCATION_LINE ((LBUF)->location))
1033 typedef struct
1035 gfc_char_t *nextc;
1036 gfc_linebuf *lb;
1037 } locus;
1039 /* In order for the "gfc" format checking to work correctly, you must
1040 have declared a typedef locus first. */
1041 #if GCC_VERSION >= 4001
1042 #define ATTRIBUTE_GCC_GFC(m, n) __attribute__ ((__format__ (__gcc_gfc__, m, n))) ATTRIBUTE_NONNULL(m)
1043 #else
1044 #define ATTRIBUTE_GCC_GFC(m, n) ATTRIBUTE_NONNULL(m)
1045 #endif
1048 /* Suppress error messages or re-enable them. */
1050 void gfc_push_suppress_errors (void);
1051 void gfc_pop_suppress_errors (void);
1054 /* Character length structures hold the expression that gives the
1055 length of a character variable. We avoid putting these into
1056 gfc_typespec because doing so prevents us from doing structure
1057 copies and forces us to deallocate any typespecs we create, as well
1058 as structures that contain typespecs. They also can have multiple
1059 character typespecs pointing to them.
1061 These structures form a singly linked list within the current
1062 namespace and are deallocated with the namespace. It is possible to
1063 end up with gfc_charlen structures that have nothing pointing to them. */
1065 typedef struct gfc_charlen
1067 struct gfc_expr *length;
1068 struct gfc_charlen *next;
1069 bool length_from_typespec; /* Length from explicit array ctor typespec? */
1070 tree backend_decl;
1071 tree passed_length; /* Length argument explicitly passed. */
1073 int resolved;
1075 gfc_charlen;
1077 #define gfc_get_charlen() XCNEW (gfc_charlen)
1079 /* Type specification structure. */
1080 typedef struct
1082 bt type;
1083 int kind;
1085 union
1087 struct gfc_symbol *derived; /* For derived types only. */
1088 gfc_charlen *cl; /* For character types only. */
1089 int pad; /* For hollerith types only. */
1093 struct gfc_symbol *interface; /* For PROCEDURE declarations. */
1094 int is_c_interop;
1095 int is_iso_c;
1096 bt f90_type;
1097 bool deferred;
1098 gfc_symbol *interop_kind;
1100 gfc_typespec;
1102 /* Array specification. */
1103 typedef struct
1105 int rank; /* A scalar has a rank of 0, an assumed-rank array has -1. */
1106 int corank;
1107 array_type type, cotype;
1108 struct gfc_expr *lower[GFC_MAX_DIMENSIONS], *upper[GFC_MAX_DIMENSIONS];
1110 /* These two fields are used with the Cray Pointer extension. */
1111 bool cray_pointee; /* True iff this spec belongs to a cray pointee. */
1112 bool cp_was_assumed; /* AS_ASSUMED_SIZE cp arrays are converted to
1113 AS_EXPLICIT, but we want to remember that we
1114 did this. */
1116 bool resolved;
1118 gfc_array_spec;
1120 #define gfc_get_array_spec() XCNEW (gfc_array_spec)
1123 /* Components of derived types. */
1124 typedef struct gfc_component
1126 const char *name;
1127 gfc_typespec ts;
1129 symbol_attribute attr;
1130 gfc_array_spec *as;
1132 tree backend_decl;
1133 /* Used to cache a FIELD_DECL matching this same component
1134 but applied to a different backend containing type that was
1135 generated by gfc_nonrestricted_type. */
1136 tree norestrict_decl;
1137 locus loc;
1138 struct gfc_expr *initializer;
1139 /* Used in parameterized derived type declarations to store parameterized
1140 kind expressions. */
1141 struct gfc_expr *kind_expr;
1142 struct gfc_actual_arglist *param_list;
1144 struct gfc_component *next;
1146 /* Needed for procedure pointer components. */
1147 struct gfc_typebound_proc *tb;
1148 /* When allocatable/pointer and in a coarray the associated token. */
1149 tree caf_token;
1151 gfc_component;
1153 #define gfc_get_component() XCNEW (gfc_component)
1155 /* Formal argument lists are lists of symbols. */
1156 typedef struct gfc_formal_arglist
1158 /* Symbol representing the argument at this position in the arglist. */
1159 struct gfc_symbol *sym;
1160 /* Points to the next formal argument. */
1161 struct gfc_formal_arglist *next;
1163 gfc_formal_arglist;
1165 #define gfc_get_formal_arglist() XCNEW (gfc_formal_arglist)
1168 /* The gfc_actual_arglist structure is for actual arguments and
1169 for type parameter specification lists. */
1170 typedef struct gfc_actual_arglist
1172 const char *name;
1173 /* Alternate return label when the expr member is null. */
1174 struct gfc_st_label *label;
1176 /* This is set to the type of an eventual omitted optional
1177 argument. This is used to determine if a hidden string length
1178 argument has to be added to a function call. */
1179 bt missing_arg_type;
1181 gfc_param_spec_type spec_type;
1183 struct gfc_expr *expr;
1184 struct gfc_actual_arglist *next;
1186 gfc_actual_arglist;
1188 #define gfc_get_actual_arglist() XCNEW (gfc_actual_arglist)
1191 /* Because a symbol can belong to multiple namelists, they must be
1192 linked externally to the symbol itself. */
1193 typedef struct gfc_namelist
1195 struct gfc_symbol *sym;
1196 struct gfc_namelist *next;
1198 gfc_namelist;
1200 #define gfc_get_namelist() XCNEW (gfc_namelist)
1202 /* Likewise to gfc_namelist, but contains expressions. */
1203 typedef struct gfc_expr_list
1205 struct gfc_expr *expr;
1206 struct gfc_expr_list *next;
1208 gfc_expr_list;
1210 #define gfc_get_expr_list() XCNEW (gfc_expr_list)
1212 enum gfc_omp_reduction_op
1214 OMP_REDUCTION_NONE = -1,
1215 OMP_REDUCTION_PLUS = INTRINSIC_PLUS,
1216 OMP_REDUCTION_MINUS = INTRINSIC_MINUS,
1217 OMP_REDUCTION_TIMES = INTRINSIC_TIMES,
1218 OMP_REDUCTION_AND = INTRINSIC_AND,
1219 OMP_REDUCTION_OR = INTRINSIC_OR,
1220 OMP_REDUCTION_EQV = INTRINSIC_EQV,
1221 OMP_REDUCTION_NEQV = INTRINSIC_NEQV,
1222 OMP_REDUCTION_MAX = GFC_INTRINSIC_END,
1223 OMP_REDUCTION_MIN,
1224 OMP_REDUCTION_IAND,
1225 OMP_REDUCTION_IOR,
1226 OMP_REDUCTION_IEOR,
1227 OMP_REDUCTION_USER
1230 enum gfc_omp_depend_op
1232 OMP_DEPEND_UNSET,
1233 OMP_DEPEND_IN,
1234 OMP_DEPEND_OUT,
1235 OMP_DEPEND_INOUT,
1236 OMP_DEPEND_MUTEXINOUTSET,
1237 OMP_DEPEND_DEPOBJ,
1238 OMP_DEPEND_SINK_FIRST,
1239 OMP_DEPEND_SINK
1242 enum gfc_omp_map_op
1244 OMP_MAP_ALLOC,
1245 OMP_MAP_IF_PRESENT,
1246 OMP_MAP_ATTACH,
1247 OMP_MAP_TO,
1248 OMP_MAP_FROM,
1249 OMP_MAP_TOFROM,
1250 OMP_MAP_DELETE,
1251 OMP_MAP_DETACH,
1252 OMP_MAP_FORCE_ALLOC,
1253 OMP_MAP_FORCE_TO,
1254 OMP_MAP_FORCE_FROM,
1255 OMP_MAP_FORCE_TOFROM,
1256 OMP_MAP_FORCE_PRESENT,
1257 OMP_MAP_FORCE_DEVICEPTR,
1258 OMP_MAP_DEVICE_RESIDENT,
1259 OMP_MAP_LINK,
1260 OMP_MAP_RELEASE,
1261 OMP_MAP_ALWAYS_TO,
1262 OMP_MAP_ALWAYS_FROM,
1263 OMP_MAP_ALWAYS_TOFROM
1266 enum gfc_omp_defaultmap
1268 OMP_DEFAULTMAP_UNSET,
1269 OMP_DEFAULTMAP_ALLOC,
1270 OMP_DEFAULTMAP_TO,
1271 OMP_DEFAULTMAP_FROM,
1272 OMP_DEFAULTMAP_TOFROM,
1273 OMP_DEFAULTMAP_FIRSTPRIVATE,
1274 OMP_DEFAULTMAP_NONE,
1275 OMP_DEFAULTMAP_DEFAULT,
1276 OMP_DEFAULTMAP_PRESENT
1279 enum gfc_omp_defaultmap_category
1281 OMP_DEFAULTMAP_CAT_UNCATEGORIZED,
1282 OMP_DEFAULTMAP_CAT_SCALAR,
1283 OMP_DEFAULTMAP_CAT_AGGREGATE,
1284 OMP_DEFAULTMAP_CAT_ALLOCATABLE,
1285 OMP_DEFAULTMAP_CAT_POINTER,
1286 OMP_DEFAULTMAP_CAT_NUM
1289 enum gfc_omp_linear_op
1291 OMP_LINEAR_DEFAULT,
1292 OMP_LINEAR_REF,
1293 OMP_LINEAR_VAL,
1294 OMP_LINEAR_UVAL
1297 /* For use in OpenMP clauses in case we need extra information
1298 (aligned clause alignment, linear clause step, etc.). */
1300 typedef struct gfc_omp_namelist
1302 struct gfc_symbol *sym;
1303 struct gfc_expr *expr;
1304 union
1306 gfc_omp_reduction_op reduction_op;
1307 gfc_omp_depend_op depend_op;
1308 gfc_omp_map_op map_op;
1309 gfc_omp_linear_op linear_op;
1310 struct gfc_common_head *common;
1311 bool lastprivate_conditional;
1312 } u;
1313 union
1315 struct gfc_omp_namelist_udr *udr;
1316 gfc_namespace *ns;
1317 } u2;
1318 struct gfc_omp_namelist *next;
1319 locus where;
1321 gfc_omp_namelist;
1323 #define gfc_get_omp_namelist() XCNEW (gfc_omp_namelist)
1325 enum
1327 OMP_LIST_FIRST,
1328 OMP_LIST_PRIVATE = OMP_LIST_FIRST,
1329 OMP_LIST_FIRSTPRIVATE,
1330 OMP_LIST_LASTPRIVATE,
1331 OMP_LIST_COPYPRIVATE,
1332 OMP_LIST_SHARED,
1333 OMP_LIST_COPYIN,
1334 OMP_LIST_UNIFORM,
1335 OMP_LIST_AFFINITY,
1336 OMP_LIST_ALIGNED,
1337 OMP_LIST_LINEAR,
1338 OMP_LIST_DEPEND,
1339 OMP_LIST_MAP,
1340 OMP_LIST_TO,
1341 OMP_LIST_FROM,
1342 OMP_LIST_SCAN_IN,
1343 OMP_LIST_SCAN_EX,
1344 OMP_LIST_REDUCTION,
1345 OMP_LIST_REDUCTION_INSCAN,
1346 OMP_LIST_REDUCTION_TASK,
1347 OMP_LIST_IN_REDUCTION,
1348 OMP_LIST_TASK_REDUCTION,
1349 OMP_LIST_DEVICE_RESIDENT,
1350 OMP_LIST_LINK,
1351 OMP_LIST_USE_DEVICE,
1352 OMP_LIST_CACHE,
1353 OMP_LIST_IS_DEVICE_PTR,
1354 OMP_LIST_USE_DEVICE_PTR,
1355 OMP_LIST_USE_DEVICE_ADDR,
1356 OMP_LIST_NONTEMPORAL,
1357 OMP_LIST_NUM
1360 /* Because a symbol can belong to multiple namelists, they must be
1361 linked externally to the symbol itself. */
1363 enum gfc_omp_sched_kind
1365 OMP_SCHED_NONE,
1366 OMP_SCHED_STATIC,
1367 OMP_SCHED_DYNAMIC,
1368 OMP_SCHED_GUIDED,
1369 OMP_SCHED_RUNTIME,
1370 OMP_SCHED_AUTO
1373 enum gfc_omp_default_sharing
1375 OMP_DEFAULT_UNKNOWN,
1376 OMP_DEFAULT_NONE,
1377 OMP_DEFAULT_PRIVATE,
1378 OMP_DEFAULT_SHARED,
1379 OMP_DEFAULT_FIRSTPRIVATE,
1380 OMP_DEFAULT_PRESENT
1383 enum gfc_omp_proc_bind_kind
1385 OMP_PROC_BIND_UNKNOWN,
1386 OMP_PROC_BIND_PRIMARY,
1387 OMP_PROC_BIND_MASTER,
1388 OMP_PROC_BIND_SPREAD,
1389 OMP_PROC_BIND_CLOSE
1392 enum gfc_omp_cancel_kind
1394 OMP_CANCEL_UNKNOWN,
1395 OMP_CANCEL_PARALLEL,
1396 OMP_CANCEL_SECTIONS,
1397 OMP_CANCEL_DO,
1398 OMP_CANCEL_TASKGROUP
1401 enum gfc_omp_if_kind
1403 OMP_IF_CANCEL,
1404 OMP_IF_PARALLEL,
1405 OMP_IF_SIMD,
1406 OMP_IF_TASK,
1407 OMP_IF_TASKLOOP,
1408 OMP_IF_TARGET,
1409 OMP_IF_TARGET_DATA,
1410 OMP_IF_TARGET_UPDATE,
1411 OMP_IF_TARGET_ENTER_DATA,
1412 OMP_IF_TARGET_EXIT_DATA,
1413 OMP_IF_LAST
1416 enum gfc_omp_atomic_op
1418 GFC_OMP_ATOMIC_UNSET = 0,
1419 GFC_OMP_ATOMIC_UPDATE = 1,
1420 GFC_OMP_ATOMIC_READ = 2,
1421 GFC_OMP_ATOMIC_WRITE = 3,
1422 GFC_OMP_ATOMIC_MASK = 3,
1423 GFC_OMP_ATOMIC_SWAP = 16
1426 enum gfc_omp_requires_kind
1428 /* Keep in sync with gfc_namespace, esp. with omp_req_mem_order. */
1429 OMP_REQ_ATOMIC_MEM_ORDER_SEQ_CST = 1, /* 01 */
1430 OMP_REQ_ATOMIC_MEM_ORDER_ACQ_REL = 2, /* 10 */
1431 OMP_REQ_ATOMIC_MEM_ORDER_RELAXED = 3, /* 11 */
1432 OMP_REQ_REVERSE_OFFLOAD = (1 << 2),
1433 OMP_REQ_UNIFIED_ADDRESS = (1 << 3),
1434 OMP_REQ_UNIFIED_SHARED_MEMORY = (1 << 4),
1435 OMP_REQ_DYNAMIC_ALLOCATORS = (1 << 5),
1436 OMP_REQ_TARGET_MASK = (OMP_REQ_REVERSE_OFFLOAD
1437 | OMP_REQ_UNIFIED_ADDRESS
1438 | OMP_REQ_UNIFIED_SHARED_MEMORY),
1439 OMP_REQ_ATOMIC_MEM_ORDER_MASK = (OMP_REQ_ATOMIC_MEM_ORDER_SEQ_CST
1440 | OMP_REQ_ATOMIC_MEM_ORDER_ACQ_REL
1441 | OMP_REQ_ATOMIC_MEM_ORDER_RELAXED)
1444 enum gfc_omp_memorder
1446 OMP_MEMORDER_UNSET,
1447 OMP_MEMORDER_SEQ_CST,
1448 OMP_MEMORDER_ACQ_REL,
1449 OMP_MEMORDER_RELEASE,
1450 OMP_MEMORDER_ACQUIRE,
1451 OMP_MEMORDER_RELAXED
1454 enum gfc_omp_bind_type
1456 OMP_BIND_UNSET,
1457 OMP_BIND_TEAMS,
1458 OMP_BIND_PARALLEL,
1459 OMP_BIND_THREAD
1462 typedef struct gfc_omp_clauses
1464 gfc_omp_namelist *lists[OMP_LIST_NUM];
1465 struct gfc_expr *if_expr;
1466 struct gfc_expr *final_expr;
1467 struct gfc_expr *num_threads;
1468 struct gfc_expr *chunk_size;
1469 struct gfc_expr *safelen_expr;
1470 struct gfc_expr *simdlen_expr;
1471 struct gfc_expr *num_teams;
1472 struct gfc_expr *device;
1473 struct gfc_expr *thread_limit;
1474 struct gfc_expr *grainsize;
1475 struct gfc_expr *filter;
1476 struct gfc_expr *hint;
1477 struct gfc_expr *num_tasks;
1478 struct gfc_expr *priority;
1479 struct gfc_expr *detach;
1480 struct gfc_expr *depobj;
1481 struct gfc_expr *if_exprs[OMP_IF_LAST];
1482 struct gfc_expr *dist_chunk_size;
1483 struct gfc_expr *message;
1484 const char *critical_name;
1485 enum gfc_omp_default_sharing default_sharing;
1486 enum gfc_omp_atomic_op atomic_op;
1487 enum gfc_omp_defaultmap defaultmap[OMP_DEFAULTMAP_CAT_NUM];
1488 int collapse, orderedc;
1489 unsigned nowait:1, ordered:1, untied:1, mergeable:1;
1490 unsigned inbranch:1, notinbranch:1, nogroup:1;
1491 unsigned sched_simd:1, sched_monotonic:1, sched_nonmonotonic:1;
1492 unsigned simd:1, threads:1, depend_source:1, destroy:1, order_concurrent:1;
1493 unsigned capture:1;
1494 ENUM_BITFIELD (gfc_omp_sched_kind) sched_kind:3;
1495 ENUM_BITFIELD (gfc_omp_device_type) device_type:2;
1496 ENUM_BITFIELD (gfc_omp_memorder) memorder:3;
1497 ENUM_BITFIELD (gfc_omp_cancel_kind) cancel:3;
1498 ENUM_BITFIELD (gfc_omp_proc_bind_kind) proc_bind:3;
1499 ENUM_BITFIELD (gfc_omp_depend_op) depobj_update:3;
1500 ENUM_BITFIELD (gfc_omp_bind_type) bind:2;
1501 ENUM_BITFIELD (gfc_omp_at_type) at:2;
1502 ENUM_BITFIELD (gfc_omp_severity_type) severity:2;
1503 ENUM_BITFIELD (gfc_omp_sched_kind) dist_sched_kind:3;
1505 /* OpenACC. */
1506 struct gfc_expr *async_expr;
1507 struct gfc_expr *gang_static_expr;
1508 struct gfc_expr *gang_num_expr;
1509 struct gfc_expr *worker_expr;
1510 struct gfc_expr *vector_expr;
1511 struct gfc_expr *num_gangs_expr;
1512 struct gfc_expr *num_workers_expr;
1513 struct gfc_expr *vector_length_expr;
1514 gfc_expr_list *wait_list;
1515 gfc_expr_list *tile_list;
1516 unsigned async:1, gang:1, worker:1, vector:1, seq:1, independent:1;
1517 unsigned par_auto:1, gang_static:1;
1518 unsigned if_present:1, finalize:1;
1519 unsigned nohost:1;
1520 locus loc;
1522 gfc_omp_clauses;
1524 #define gfc_get_omp_clauses() XCNEW (gfc_omp_clauses)
1527 /* Node in the linked list used for storing !$oacc declare constructs. */
1529 typedef struct gfc_oacc_declare
1531 struct gfc_oacc_declare *next;
1532 bool module_var;
1533 gfc_omp_clauses *clauses;
1534 locus loc;
1536 gfc_oacc_declare;
1538 #define gfc_get_oacc_declare() XCNEW (gfc_oacc_declare)
1541 /* Node in the linked list used for storing !$omp declare simd constructs. */
1543 typedef struct gfc_omp_declare_simd
1545 struct gfc_omp_declare_simd *next;
1546 locus where; /* Where the !$omp declare simd construct occurred. */
1548 gfc_symbol *proc_name;
1550 gfc_omp_clauses *clauses;
1552 gfc_omp_declare_simd;
1553 #define gfc_get_omp_declare_simd() XCNEW (gfc_omp_declare_simd)
1555 typedef struct gfc_omp_udr
1557 struct gfc_omp_udr *next;
1558 locus where; /* Where the !$omp declare reduction construct occurred. */
1560 const char *name;
1561 gfc_typespec ts;
1562 gfc_omp_reduction_op rop;
1564 struct gfc_symbol *omp_out;
1565 struct gfc_symbol *omp_in;
1566 struct gfc_namespace *combiner_ns;
1568 struct gfc_symbol *omp_priv;
1569 struct gfc_symbol *omp_orig;
1570 struct gfc_namespace *initializer_ns;
1572 gfc_omp_udr;
1573 #define gfc_get_omp_udr() XCNEW (gfc_omp_udr)
1575 typedef struct gfc_omp_namelist_udr
1577 struct gfc_omp_udr *udr;
1578 struct gfc_code *combiner;
1579 struct gfc_code *initializer;
1581 gfc_omp_namelist_udr;
1582 #define gfc_get_omp_namelist_udr() XCNEW (gfc_omp_namelist_udr)
1584 /* The gfc_st_label structure is a BBT attached to a namespace that
1585 records the usage of statement labels within that space. */
1587 typedef struct gfc_st_label
1589 BBT_HEADER(gfc_st_label);
1591 int value;
1593 gfc_sl_type defined, referenced;
1595 struct gfc_expr *format;
1597 tree backend_decl;
1599 locus where;
1601 gfc_namespace *ns;
1603 gfc_st_label;
1606 /* gfc_interface()-- Interfaces are lists of symbols strung together. */
1607 typedef struct gfc_interface
1609 struct gfc_symbol *sym;
1610 locus where;
1611 struct gfc_interface *next;
1613 gfc_interface;
1615 #define gfc_get_interface() XCNEW (gfc_interface)
1617 /* User operator nodes. These are like stripped down symbols. */
1618 typedef struct
1620 const char *name;
1622 gfc_interface *op;
1623 struct gfc_namespace *ns;
1624 gfc_access access;
1626 gfc_user_op;
1629 /* A list of specific bindings that are associated with a generic spec. */
1630 typedef struct gfc_tbp_generic
1632 /* The parser sets specific_st, upon resolution we look for the corresponding
1633 gfc_typebound_proc and set specific for further use. */
1634 struct gfc_symtree* specific_st;
1635 struct gfc_typebound_proc* specific;
1637 struct gfc_tbp_generic* next;
1638 bool is_operator;
1640 gfc_tbp_generic;
1642 #define gfc_get_tbp_generic() XCNEW (gfc_tbp_generic)
1645 /* Data needed for type-bound procedures. */
1646 typedef struct gfc_typebound_proc
1648 locus where; /* Where the PROCEDURE/GENERIC definition was. */
1650 union
1652 struct gfc_symtree* specific; /* The interface if DEFERRED. */
1653 gfc_tbp_generic* generic;
1657 gfc_access access;
1658 const char* pass_arg; /* Argument-name for PASS. NULL if not specified. */
1660 /* The overridden type-bound proc (or GENERIC with this name in the
1661 parent-type) or NULL if non. */
1662 struct gfc_typebound_proc* overridden;
1664 /* Once resolved, we use the position of pass_arg in the formal arglist of
1665 the binding-target procedure to identify it. The first argument has
1666 number 1 here, the second 2, and so on. */
1667 unsigned pass_arg_num;
1669 unsigned nopass:1; /* Whether we have NOPASS (PASS otherwise). */
1670 unsigned non_overridable:1;
1671 unsigned deferred:1;
1672 unsigned is_generic:1;
1673 unsigned function:1, subroutine:1;
1674 unsigned error:1; /* Ignore it, when an error occurred during resolution. */
1675 unsigned ppc:1;
1677 gfc_typebound_proc;
1680 /* Symbol nodes. These are important things. They are what the
1681 standard refers to as "entities". The possibly multiple names that
1682 refer to the same entity are accomplished by a binary tree of
1683 symtree structures that is balanced by the red-black method-- more
1684 than one symtree node can point to any given symbol. */
1686 typedef struct gfc_symbol
1688 const char *name; /* Primary name, before renaming */
1689 const char *module; /* Module this symbol came from */
1690 locus declared_at;
1692 gfc_typespec ts;
1693 symbol_attribute attr;
1695 /* The formal member points to the formal argument list if the
1696 symbol is a function or subroutine name. If the symbol is a
1697 generic name, the generic member points to the list of
1698 interfaces. */
1700 gfc_interface *generic;
1701 gfc_access component_access;
1703 gfc_formal_arglist *formal;
1704 struct gfc_namespace *formal_ns;
1705 struct gfc_namespace *f2k_derived;
1707 /* List of PDT parameter expressions */
1708 struct gfc_actual_arglist *param_list;
1710 struct gfc_expr *value; /* Parameter/Initializer value */
1711 gfc_array_spec *as;
1712 struct gfc_symbol *result; /* function result symbol */
1713 gfc_component *components; /* Derived type components */
1715 /* Defined only for Cray pointees; points to their pointer. */
1716 struct gfc_symbol *cp_pointer;
1718 int entry_id; /* Used in resolve.c for entries. */
1720 /* CLASS hashed name for declared and dynamic types in the class. */
1721 int hash_value;
1723 struct gfc_symbol *common_next; /* Links for COMMON syms */
1725 /* This is only used for pointer comparisons to check if symbols
1726 are in the same common block.
1727 In opposition to common_block, the common_head pointer takes into account
1728 equivalences: if A is in a common block C and A and B are in equivalence,
1729 then both A and B have common_head pointing to C, while A's common_block
1730 points to C and B's is NULL. */
1731 struct gfc_common_head* common_head;
1733 /* Make sure setup code for dummy arguments is generated in the correct
1734 order. */
1735 int dummy_order;
1737 gfc_namelist *namelist, *namelist_tail;
1739 /* Change management fields. Symbols that might be modified by the
1740 current statement have the mark member nonzero. Of these symbols,
1741 symbols with old_symbol equal to NULL are symbols created within
1742 the current statement. Otherwise, old_symbol points to a copy of
1743 the old symbol. gfc_new is used in symbol.c to flag new symbols.
1744 comp_mark is used to indicate variables which have component accesses
1745 in OpenMP/OpenACC directive clauses. */
1746 struct gfc_symbol *old_symbol;
1747 unsigned mark:1, comp_mark:1, gfc_new:1;
1749 /* The tlink field is used in the front end to carry the module
1750 declaration of separate module procedures so that the characteristics
1751 can be compared with the corresponding declaration in a submodule. In
1752 translation this field carries a linked list of symbols that require
1753 deferred initialization. */
1754 struct gfc_symbol *tlink;
1756 /* Nonzero if all equivalences associated with this symbol have been
1757 processed. */
1758 unsigned equiv_built:1;
1759 /* Set if this variable is used as an index name in a FORALL. */
1760 unsigned forall_index:1;
1761 /* Set if the symbol is used in a function result specification . */
1762 unsigned fn_result_spec:1;
1763 /* Used to avoid multiple resolutions of a single symbol. */
1764 /* = 2 if this has already been resolved as an intrinsic,
1765 in gfc_resolve_intrinsic,
1766 = 1 if it has been resolved in resolve_symbol. */
1767 unsigned resolve_symbol_called:2;
1768 /* Set if this is a module function or subroutine with the
1769 abreviated declaration in a submodule. */
1770 unsigned abr_modproc_decl:1;
1771 /* Set if a previous error or warning has occurred and no other
1772 should be reported. */
1773 unsigned error:1;
1774 /* Set if the dummy argument of a procedure could be an array despite
1775 being called with a scalar actual argument. */
1776 unsigned maybe_array:1;
1777 /* Set if this should be passed by value, but is not a VALUE argument
1778 according to the Fortran standard. */
1779 unsigned pass_as_value:1;
1781 int refs;
1782 struct gfc_namespace *ns; /* namespace containing this symbol */
1784 tree backend_decl;
1786 /* Identity of the intrinsic module the symbol comes from, or
1787 INTMOD_NONE if it's not imported from a intrinsic module. */
1788 intmod_id from_intmod;
1789 /* Identity of the symbol from intrinsic modules, from enums maintained
1790 separately by each intrinsic module. Used together with from_intmod,
1791 it uniquely identifies a symbol from an intrinsic module. */
1792 int intmod_sym_id;
1794 /* This may be repetitive, since the typespec now has a binding
1795 label field. */
1796 const char* binding_label;
1797 /* Store a reference to the common_block, if this symbol is in one. */
1798 struct gfc_common_head *common_block;
1800 /* Link to corresponding association-list if this is an associate name. */
1801 struct gfc_association_list *assoc;
1803 /* Link to next entry in derived type list */
1804 struct gfc_symbol *dt_next;
1806 gfc_symbol;
1809 struct gfc_undo_change_set
1811 vec<gfc_symbol *> syms;
1812 vec<gfc_typebound_proc *> tbps;
1813 gfc_undo_change_set *previous;
1817 /* This structure is used to keep track of symbols in common blocks. */
1818 typedef struct gfc_common_head
1820 locus where;
1821 char use_assoc, saved, threadprivate;
1822 unsigned char omp_declare_target : 1;
1823 unsigned char omp_declare_target_link : 1;
1824 ENUM_BITFIELD (gfc_omp_device_type) omp_device_type:2;
1825 /* Provide sufficient space to hold "symbol.symbol.eq.1234567890". */
1826 char name[2*GFC_MAX_SYMBOL_LEN + 1 + 14 + 1];
1827 struct gfc_symbol *head;
1828 const char* binding_label;
1829 int is_bind_c;
1830 int refs;
1832 gfc_common_head;
1834 #define gfc_get_common_head() XCNEW (gfc_common_head)
1837 /* A list of all the alternate entry points for a procedure. */
1839 typedef struct gfc_entry_list
1841 /* The symbol for this entry point. */
1842 gfc_symbol *sym;
1843 /* The zero-based id of this entry point. */
1844 int id;
1845 /* The LABEL_EXPR marking this entry point. */
1846 tree label;
1847 /* The next item in the list. */
1848 struct gfc_entry_list *next;
1850 gfc_entry_list;
1852 #define gfc_get_entry_list() XCNEW (gfc_entry_list)
1854 /* Lists of rename info for the USE statement. */
1856 typedef struct gfc_use_rename
1858 char local_name[GFC_MAX_SYMBOL_LEN + 1], use_name[GFC_MAX_SYMBOL_LEN + 1];
1859 struct gfc_use_rename *next;
1860 int found;
1861 gfc_intrinsic_op op;
1862 locus where;
1864 gfc_use_rename;
1866 #define gfc_get_use_rename() XCNEW (gfc_use_rename);
1868 /* A list of all USE statements in a namespace. */
1870 typedef struct gfc_use_list
1872 const char *module_name;
1873 const char *submodule_name;
1874 bool intrinsic;
1875 bool non_intrinsic;
1876 bool only_flag;
1877 struct gfc_use_rename *rename;
1878 locus where;
1879 /* Next USE statement. */
1880 struct gfc_use_list *next;
1882 gfc_use_list;
1884 #define gfc_get_use_list() XCNEW (gfc_use_list)
1886 /* Within a namespace, symbols are pointed to by symtree nodes that
1887 are linked together in a balanced binary tree. There can be
1888 several symtrees pointing to the same symbol node via USE
1889 statements. */
1891 typedef struct gfc_symtree
1893 BBT_HEADER (gfc_symtree);
1894 const char *name;
1895 int ambiguous;
1896 union
1898 gfc_symbol *sym; /* Symbol associated with this node */
1899 gfc_user_op *uop;
1900 gfc_common_head *common;
1901 gfc_typebound_proc *tb;
1902 gfc_omp_udr *omp_udr;
1906 gfc_symtree;
1908 /* A list of all derived types. */
1909 extern gfc_symbol *gfc_derived_types;
1911 typedef struct gfc_oacc_routine_name
1913 struct gfc_symbol *sym;
1914 struct gfc_omp_clauses *clauses;
1915 struct gfc_oacc_routine_name *next;
1916 locus loc;
1918 gfc_oacc_routine_name;
1920 #define gfc_get_oacc_routine_name() XCNEW (gfc_oacc_routine_name)
1922 /* Node in linked list to see what has already been finalized
1923 earlier. */
1925 typedef struct gfc_was_finalized {
1926 gfc_expr *e;
1927 gfc_component *c;
1928 struct gfc_was_finalized *next;
1930 gfc_was_finalized;
1932 /* A namespace describes the contents of procedure, module, interface block
1933 or BLOCK construct. */
1934 /* ??? Anything else use these? */
1936 typedef struct gfc_namespace
1938 /* Tree containing all the symbols in this namespace. */
1939 gfc_symtree *sym_root;
1940 /* Tree containing all the user-defined operators in the namespace. */
1941 gfc_symtree *uop_root;
1942 /* Tree containing all the common blocks. */
1943 gfc_symtree *common_root;
1944 /* Tree containing all the OpenMP user defined reductions. */
1945 gfc_symtree *omp_udr_root;
1947 /* Tree containing type-bound procedures. */
1948 gfc_symtree *tb_sym_root;
1949 /* Type-bound user operators. */
1950 gfc_symtree *tb_uop_root;
1951 /* For derived-types, store type-bound intrinsic operators here. */
1952 gfc_typebound_proc *tb_op[GFC_INTRINSIC_OPS];
1953 /* Linked list of finalizer procedures. */
1954 struct gfc_finalizer *finalizers;
1956 /* If set_flag[letter] is set, an implicit type has been set for letter. */
1957 int set_flag[GFC_LETTERS];
1958 /* Keeps track of the implicit types associated with the letters. */
1959 gfc_typespec default_type[GFC_LETTERS];
1960 /* Store the positions of IMPLICIT statements. */
1961 locus implicit_loc[GFC_LETTERS];
1963 /* If this is a namespace of a procedure, this points to the procedure. */
1964 struct gfc_symbol *proc_name;
1965 /* If this is the namespace of a unit which contains executable
1966 code, this points to it. */
1967 struct gfc_code *code;
1969 /* Points to the equivalences set up in this namespace. */
1970 struct gfc_equiv *equiv, *old_equiv;
1972 /* Points to the equivalence groups produced by trans_common. */
1973 struct gfc_equiv_list *equiv_lists;
1975 gfc_interface *op[GFC_INTRINSIC_OPS];
1977 /* Points to the parent namespace, i.e. the namespace of a module or
1978 procedure in which the procedure belonging to this namespace is
1979 contained. The parent namespace points to this namespace either
1980 directly via CONTAINED, or indirectly via the chain built by
1981 SIBLING. */
1982 struct gfc_namespace *parent;
1983 /* CONTAINED points to the first contained namespace. Sibling
1984 namespaces are chained via SIBLING. */
1985 struct gfc_namespace *contained, *sibling;
1987 gfc_common_head blank_common;
1988 gfc_access default_access, operator_access[GFC_INTRINSIC_OPS];
1990 gfc_st_label *st_labels;
1991 /* This list holds information about all the data initializers in
1992 this namespace. */
1993 struct gfc_data *data, *old_data;
1995 /* !$ACC DECLARE. */
1996 gfc_oacc_declare *oacc_declare;
1998 /* !$ACC ROUTINE clauses. */
1999 gfc_omp_clauses *oacc_routine_clauses;
2001 /* !$ACC ROUTINE names. */
2002 gfc_oacc_routine_name *oacc_routine_names;
2004 gfc_charlen *cl_list;
2006 gfc_symbol *derived_types;
2008 int save_all, seen_save, seen_implicit_none;
2010 /* Normally we don't need to refcount namespaces. However when we read
2011 a module containing a function with multiple entry points, this
2012 will appear as several functions with the same formal namespace. */
2013 int refs;
2015 /* A list of all alternate entry points to this procedure (or NULL). */
2016 gfc_entry_list *entries;
2018 /* A list of USE statements in this namespace. */
2019 gfc_use_list *use_stmts;
2021 /* Linked list of !$omp declare simd constructs. */
2022 struct gfc_omp_declare_simd *omp_declare_simd;
2024 /* A hash set for the the gfc expressions that have already
2025 been finalized in this namespace. */
2027 gfc_was_finalized *was_finalized;
2029 /* Set to 1 if namespace is a BLOCK DATA program unit. */
2030 unsigned is_block_data:1;
2032 /* Set to 1 if namespace is an interface body with "IMPORT" used. */
2033 unsigned has_import_set:1;
2035 /* Set to 1 if the namespace uses "IMPLICT NONE (export)". */
2036 unsigned has_implicit_none_export:1;
2038 /* Set to 1 if resolved has been called for this namespace.
2039 Holds -1 during resolution. */
2040 signed resolved:2;
2042 /* Set when resolve_types has been called for this namespace. */
2043 unsigned types_resolved:1;
2045 /* Set to 1 if code has been generated for this namespace. */
2046 unsigned translated:1;
2048 /* Set to 1 if symbols in this namespace should be 'construct entities',
2049 i.e. for BLOCK local variables. */
2050 unsigned construct_entities:1;
2052 /* Set to 1 for !$OMP DECLARE REDUCTION namespaces. */
2053 unsigned omp_udr_ns:1;
2055 /* Set to 1 for !$ACC ROUTINE namespaces. */
2056 unsigned oacc_routine:1;
2058 /* Set to 1 if there are any calls to procedures with implicit interface. */
2059 unsigned implicit_interface_calls:1;
2061 /* OpenMP requires. */
2062 unsigned omp_requires:6;
2063 unsigned omp_target_seen:1;
2065 gfc_namespace;
2067 extern gfc_namespace *gfc_current_ns;
2068 extern gfc_namespace *gfc_global_ns_list;
2070 /* Global symbols are symbols of global scope. Currently we only use
2071 this to detect collisions already when parsing.
2072 TODO: Extend to verify procedure calls. */
2074 enum gfc_symbol_type
2076 GSYM_UNKNOWN=1, GSYM_PROGRAM, GSYM_FUNCTION, GSYM_SUBROUTINE,
2077 GSYM_MODULE, GSYM_COMMON, GSYM_BLOCK_DATA
2080 typedef struct gfc_gsymbol
2082 BBT_HEADER(gfc_gsymbol);
2084 const char *name;
2085 const char *sym_name;
2086 const char *mod_name;
2087 const char *binding_label;
2088 enum gfc_symbol_type type;
2090 int defined, used;
2091 bool bind_c;
2092 locus where;
2093 gfc_namespace *ns;
2095 gfc_gsymbol;
2097 extern gfc_gsymbol *gfc_gsym_root;
2099 /* Information on interfaces being built. */
2100 typedef struct
2102 interface_type type;
2103 gfc_symbol *sym;
2104 gfc_namespace *ns;
2105 gfc_user_op *uop;
2106 gfc_intrinsic_op op;
2108 gfc_interface_info;
2110 extern gfc_interface_info current_interface;
2113 /* Array reference. */
2115 enum gfc_array_ref_dimen_type
2117 DIMEN_ELEMENT = 1, DIMEN_RANGE, DIMEN_VECTOR, DIMEN_STAR, DIMEN_THIS_IMAGE, DIMEN_UNKNOWN
2120 typedef struct gfc_array_ref
2122 ar_type type;
2123 int dimen; /* # of components in the reference */
2124 int codimen;
2125 bool in_allocate; /* For coarray checks. */
2126 gfc_expr *team;
2127 gfc_expr *stat;
2128 locus where;
2129 gfc_array_spec *as;
2131 locus c_where[GFC_MAX_DIMENSIONS]; /* All expressions can be NULL */
2132 struct gfc_expr *start[GFC_MAX_DIMENSIONS], *end[GFC_MAX_DIMENSIONS],
2133 *stride[GFC_MAX_DIMENSIONS];
2135 enum gfc_array_ref_dimen_type dimen_type[GFC_MAX_DIMENSIONS];
2137 gfc_array_ref;
2139 #define gfc_get_array_ref() XCNEW (gfc_array_ref)
2142 /* Component reference nodes. A variable is stored as an expression
2143 node that points to the base symbol. After that, a singly linked
2144 list of component reference nodes gives the variable's complete
2145 resolution. The array_ref component may be present and comes
2146 before the component component. */
2148 enum ref_type
2149 { REF_ARRAY, REF_COMPONENT, REF_SUBSTRING, REF_INQUIRY };
2151 enum inquiry_type
2152 { INQUIRY_RE, INQUIRY_IM, INQUIRY_KIND, INQUIRY_LEN };
2154 typedef struct gfc_ref
2156 ref_type type;
2158 union
2160 struct gfc_array_ref ar;
2162 struct
2164 gfc_component *component;
2165 gfc_symbol *sym;
2169 struct
2171 struct gfc_expr *start, *end; /* Substring */
2172 gfc_charlen *length;
2176 inquiry_type i;
2181 struct gfc_ref *next;
2183 gfc_ref;
2185 #define gfc_get_ref() XCNEW (gfc_ref)
2188 /* Structures representing intrinsic symbols and their arguments lists. */
2189 typedef struct gfc_intrinsic_arg
2191 char name[GFC_MAX_SYMBOL_LEN + 1];
2193 gfc_typespec ts;
2194 unsigned optional:1, value:1;
2195 ENUM_BITFIELD (sym_intent) intent:2;
2196 gfc_actual_arglist *actual;
2198 struct gfc_intrinsic_arg *next;
2201 gfc_intrinsic_arg;
2204 /* Specifies the various kinds of check functions used to verify the
2205 argument lists of intrinsic functions. fX with X an integer refer
2206 to check functions of intrinsics with X arguments. f1m is used for
2207 the MAX and MIN intrinsics which can have an arbitrary number of
2208 arguments, f4ml is used for the MINLOC and MAXLOC intrinsics as
2209 these have special semantics. */
2211 typedef union
2213 bool (*f0)(void);
2214 bool (*f1)(struct gfc_expr *);
2215 bool (*f1m)(gfc_actual_arglist *);
2216 bool (*f2)(struct gfc_expr *, struct gfc_expr *);
2217 bool (*f3)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *);
2218 bool (*f5ml)(gfc_actual_arglist *);
2219 bool (*f6fl)(gfc_actual_arglist *);
2220 bool (*f3red)(gfc_actual_arglist *);
2221 bool (*f4)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *,
2222 struct gfc_expr *);
2223 bool (*f5)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *,
2224 struct gfc_expr *, struct gfc_expr *);
2226 gfc_check_f;
2228 /* Like gfc_check_f, these specify the type of the simplification
2229 function associated with an intrinsic. The fX are just like in
2230 gfc_check_f. cc is used for type conversion functions. */
2232 typedef union
2234 struct gfc_expr *(*f0)(void);
2235 struct gfc_expr *(*f1)(struct gfc_expr *);
2236 struct gfc_expr *(*f2)(struct gfc_expr *, struct gfc_expr *);
2237 struct gfc_expr *(*f3)(struct gfc_expr *, struct gfc_expr *,
2238 struct gfc_expr *);
2239 struct gfc_expr *(*f4)(struct gfc_expr *, struct gfc_expr *,
2240 struct gfc_expr *, struct gfc_expr *);
2241 struct gfc_expr *(*f5)(struct gfc_expr *, struct gfc_expr *,
2242 struct gfc_expr *, struct gfc_expr *,
2243 struct gfc_expr *);
2244 struct gfc_expr *(*f6)(struct gfc_expr *, struct gfc_expr *,
2245 struct gfc_expr *, struct gfc_expr *,
2246 struct gfc_expr *, struct gfc_expr *);
2247 struct gfc_expr *(*cc)(struct gfc_expr *, bt, int);
2249 gfc_simplify_f;
2251 /* Again like gfc_check_f, these specify the type of the resolution
2252 function associated with an intrinsic. The fX are just like in
2253 gfc_check_f. f1m is used for MIN and MAX, s1 is used for abort(). */
2255 typedef union
2257 void (*f0)(struct gfc_expr *);
2258 void (*f1)(struct gfc_expr *, struct gfc_expr *);
2259 void (*f1m)(struct gfc_expr *, struct gfc_actual_arglist *);
2260 void (*f2)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *);
2261 void (*f3)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *,
2262 struct gfc_expr *);
2263 void (*f4)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *,
2264 struct gfc_expr *, struct gfc_expr *);
2265 void (*f5)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *,
2266 struct gfc_expr *, struct gfc_expr *, struct gfc_expr *);
2267 void (*f6)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *,
2268 struct gfc_expr *, struct gfc_expr *, struct gfc_expr *,
2269 struct gfc_expr *);
2270 void (*s1)(struct gfc_code *);
2272 gfc_resolve_f;
2275 typedef struct gfc_intrinsic_sym
2277 const char *name, *lib_name;
2278 gfc_intrinsic_arg *formal;
2279 gfc_typespec ts;
2280 unsigned elemental:1, inquiry:1, transformational:1, pure:1,
2281 generic:1, specific:1, actual_ok:1, noreturn:1, conversion:1,
2282 from_module:1, vararg:1;
2284 int standard;
2286 gfc_simplify_f simplify;
2287 gfc_check_f check;
2288 gfc_resolve_f resolve;
2289 struct gfc_intrinsic_sym *specific_head, *next;
2290 gfc_isym_id id;
2293 gfc_intrinsic_sym;
2296 /* Expression nodes. The expression node types deserve explanations,
2297 since the last couple can be easily misconstrued:
2299 EXPR_OP Operator node pointing to one or two other nodes
2300 EXPR_FUNCTION Function call, symbol points to function's name
2301 EXPR_CONSTANT A scalar constant: Logical, String, Real, Int or Complex
2302 EXPR_VARIABLE An Lvalue with a root symbol and possible reference list
2303 which expresses structure, array and substring refs.
2304 EXPR_NULL The NULL pointer value (which also has a basic type).
2305 EXPR_SUBSTRING A substring of a constant string
2306 EXPR_STRUCTURE A structure constructor
2307 EXPR_ARRAY An array constructor.
2308 EXPR_COMPCALL Function (or subroutine) call of a procedure pointer
2309 component or type-bound procedure. */
2311 #include <mpfr.h>
2312 #include <mpc.h>
2313 #define GFC_RND_MODE MPFR_RNDN
2314 #define GFC_MPC_RND_MODE MPC_RNDNN
2316 typedef splay_tree gfc_constructor_base;
2319 /* This should be an unsigned variable of type size_t. But to handle
2320 compiling to a 64-bit target from a 32-bit host, we need to use a
2321 HOST_WIDE_INT. Also, occasionally the string length field is used
2322 as a flag with values -1 and -2, see e.g. gfc_add_assign_aux_vars.
2323 So it needs to be signed. */
2324 typedef HOST_WIDE_INT gfc_charlen_t;
2326 typedef struct gfc_expr
2328 expr_t expr_type;
2330 gfc_typespec ts; /* These two refer to the overall expression */
2332 int rank; /* 0 indicates a scalar, -1 an assumed-rank array. */
2333 mpz_t *shape; /* Can be NULL if shape is unknown at compile time */
2335 /* Nonnull for functions and structure constructors, may also used to hold the
2336 base-object for component calls. */
2337 gfc_symtree *symtree;
2339 gfc_ref *ref;
2341 locus where;
2343 /* Used to store the base expression in component calls, when the expression
2344 is not a variable. */
2345 struct gfc_expr *base_expr;
2347 /* is_snan denotes a signalling not-a-number. */
2348 unsigned int is_snan : 1;
2350 /* Sometimes, when an error has been emitted, it is necessary to prevent
2351 it from recurring. */
2352 unsigned int error : 1;
2354 /* Mark an expression where a user operator has been substituted by
2355 a function call in interface.c(gfc_extend_expr). */
2356 unsigned int user_operator : 1;
2358 /* Mark an expression as being a MOLD argument of ALLOCATE. */
2359 unsigned int mold : 1;
2361 /* Will require finalization after use. */
2362 unsigned int must_finalize : 1;
2364 /* Set this if no range check should be performed on this expression. */
2366 unsigned int no_bounds_check : 1;
2368 /* Set this if a matmul expression has already been evaluated for conversion
2369 to a BLAS call. */
2371 unsigned int external_blas : 1;
2373 /* Set this if resolution has already happened. It could be harmful
2374 if done again. */
2376 unsigned int do_not_resolve_again : 1;
2378 /* Set this if no warning should be given somewhere in a lower level. */
2380 unsigned int do_not_warn : 1;
2382 /* Set this if the expression came from expanding an array constructor. */
2383 unsigned int from_constructor : 1;
2385 /* If an expression comes from a Hollerith constant or compile-time
2386 evaluation of a transfer statement, it may have a prescribed target-
2387 memory representation, and these cannot always be backformed from
2388 the value. */
2389 struct
2391 gfc_charlen_t length;
2392 char *string;
2394 representation;
2396 struct
2398 int len; /* Length of BOZ string without terminating NULL. */
2399 int rdx; /* Radix of BOZ. */
2400 char *str; /* BOZ string with NULL terminating character. */
2402 boz;
2404 union
2406 int logical;
2408 io_kind iokind;
2410 mpz_t integer;
2412 mpfr_t real;
2414 mpc_t complex;
2416 struct
2418 gfc_intrinsic_op op;
2419 gfc_user_op *uop;
2420 struct gfc_expr *op1, *op2;
2424 struct
2426 gfc_actual_arglist *actual;
2427 const char *name; /* Points to the ultimate name of the function */
2428 gfc_intrinsic_sym *isym;
2429 gfc_symbol *esym;
2431 function;
2433 struct
2435 gfc_actual_arglist* actual;
2436 const char* name;
2437 /* Base-object, whose component was called. NULL means that it should
2438 be taken from symtree/ref. */
2439 struct gfc_expr* base_object;
2440 gfc_typebound_proc* tbp; /* Should overlap with esym. */
2442 /* For type-bound operators, we want to call PASS procedures but already
2443 have the full arglist; mark this, so that it is not extended by the
2444 PASS argument. */
2445 unsigned ignore_pass:1;
2447 /* Do assign-calls rather than calls, that is appropriate dependency
2448 checking. */
2449 unsigned assign:1;
2451 compcall;
2453 struct
2455 gfc_charlen_t length;
2456 gfc_char_t *string;
2458 character;
2460 gfc_constructor_base constructor;
2462 value;
2464 /* Used to store PDT expression lists associated with expressions. */
2465 gfc_actual_arglist *param_list;
2468 gfc_expr;
2471 #define gfc_get_shape(rank) (XCNEWVEC (mpz_t, (rank)))
2473 /* Structures for information associated with different kinds of
2474 numbers. The first set of integer parameters define all there is
2475 to know about a particular kind. The rest of the elements are
2476 computed from the first elements. */
2478 typedef struct
2480 /* Values really representable by the target. */
2481 mpz_t huge, pedantic_min_int, min_int;
2483 int kind, radix, digits, bit_size, range;
2485 /* True if the C type of the given name maps to this precision.
2486 Note that more than one bit can be set. */
2487 unsigned int c_char : 1;
2488 unsigned int c_short : 1;
2489 unsigned int c_int : 1;
2490 unsigned int c_long : 1;
2491 unsigned int c_long_long : 1;
2493 gfc_integer_info;
2495 extern gfc_integer_info gfc_integer_kinds[];
2498 typedef struct
2500 int kind, bit_size;
2502 /* True if the C++ type bool, C99 type _Bool, maps to this precision. */
2503 unsigned int c_bool : 1;
2505 gfc_logical_info;
2507 extern gfc_logical_info gfc_logical_kinds[];
2510 typedef struct
2512 mpfr_t epsilon, huge, tiny, subnormal;
2513 int kind, radix, digits, min_exponent, max_exponent;
2514 int range, precision;
2516 /* The precision of the type as reported by GET_MODE_PRECISION. */
2517 int mode_precision;
2519 /* True if the C type of the given name maps to this precision.
2520 Note that more than one bit can be set. */
2521 unsigned int c_float : 1;
2522 unsigned int c_double : 1;
2523 unsigned int c_long_double : 1;
2524 unsigned int c_float128 : 1;
2526 gfc_real_info;
2528 extern gfc_real_info gfc_real_kinds[];
2530 typedef struct
2532 int kind, bit_size;
2533 const char *name;
2535 gfc_character_info;
2537 extern gfc_character_info gfc_character_kinds[];
2540 /* Equivalence structures. Equivalent lvalues are linked along the
2541 *eq pointer, equivalence sets are strung along the *next node. */
2542 typedef struct gfc_equiv
2544 struct gfc_equiv *next, *eq;
2545 gfc_expr *expr;
2546 const char *module;
2547 int used;
2549 gfc_equiv;
2551 #define gfc_get_equiv() XCNEW (gfc_equiv)
2553 /* Holds a single equivalence member after processing. */
2554 typedef struct gfc_equiv_info
2556 gfc_symbol *sym;
2557 HOST_WIDE_INT offset;
2558 HOST_WIDE_INT length;
2559 struct gfc_equiv_info *next;
2560 } gfc_equiv_info;
2562 /* Holds equivalence groups, after they have been processed. */
2563 typedef struct gfc_equiv_list
2565 gfc_equiv_info *equiv;
2566 struct gfc_equiv_list *next;
2567 } gfc_equiv_list;
2569 /* gfc_case stores the selector list of a case statement. The *low
2570 and *high pointers can point to the same expression in the case of
2571 a single value. If *high is NULL, the selection is from *low
2572 upwards, if *low is NULL the selection is *high downwards.
2574 This structure has separate fields to allow single and double linked
2575 lists of CASEs at the same time. The singe linked list along the NEXT
2576 field is a list of cases for a single CASE label. The double linked
2577 list along the LEFT/RIGHT fields is used to detect overlap and to
2578 build a table of the cases for SELECT constructs with a CHARACTER
2579 case expression. */
2581 typedef struct gfc_case
2583 /* Where we saw this case. */
2584 locus where;
2585 int n;
2587 /* Case range values. If (low == high), it's a single value. If one of
2588 the labels is NULL, it's an unbounded case. If both are NULL, this
2589 represents the default case. */
2590 gfc_expr *low, *high;
2592 /* Only used for SELECT TYPE. */
2593 gfc_typespec ts;
2595 /* Next case label in the list of cases for a single CASE label. */
2596 struct gfc_case *next;
2598 /* Used for detecting overlap, and for code generation. */
2599 struct gfc_case *left, *right;
2601 /* True if this case label can never be matched. */
2602 int unreachable;
2604 gfc_case;
2606 #define gfc_get_case() XCNEW (gfc_case)
2609 typedef struct
2611 gfc_expr *var, *start, *end, *step;
2612 unsigned short unroll;
2613 bool ivdep;
2614 bool vector;
2615 bool novector;
2617 gfc_iterator;
2619 #define gfc_get_iterator() XCNEW (gfc_iterator)
2622 /* Allocation structure for ALLOCATE, DEALLOCATE and NULLIFY statements. */
2624 typedef struct gfc_alloc
2626 gfc_expr *expr;
2627 struct gfc_alloc *next;
2629 gfc_alloc;
2631 #define gfc_get_alloc() XCNEW (gfc_alloc)
2634 typedef struct
2636 gfc_expr *unit, *file, *status, *access, *form, *recl,
2637 *blank, *position, *action, *delim, *pad, *iostat, *iomsg, *convert,
2638 *decimal, *encoding, *round, *sign, *asynchronous, *id, *newunit,
2639 *share, *cc;
2640 char readonly;
2641 gfc_st_label *err;
2643 gfc_open;
2646 typedef struct
2648 gfc_expr *unit, *status, *iostat, *iomsg;
2649 gfc_st_label *err;
2651 gfc_close;
2654 typedef struct
2656 gfc_expr *unit, *iostat, *iomsg;
2657 gfc_st_label *err;
2659 gfc_filepos;
2662 typedef struct
2664 gfc_expr *unit, *file, *iostat, *exist, *opened, *number, *named,
2665 *name, *access, *sequential, *direct, *form, *formatted,
2666 *unformatted, *recl, *nextrec, *blank, *position, *action, *read,
2667 *write, *readwrite, *delim, *pad, *iolength, *iomsg, *convert, *strm_pos,
2668 *asynchronous, *decimal, *encoding, *pending, *round, *sign, *size, *id,
2669 *iqstream, *share, *cc;
2671 gfc_st_label *err;
2674 gfc_inquire;
2677 typedef struct
2679 gfc_expr *unit, *iostat, *iomsg, *id;
2680 gfc_st_label *err, *end, *eor;
2682 gfc_wait;
2685 typedef struct
2687 gfc_expr *io_unit, *format_expr, *rec, *advance, *iostat, *size, *iomsg,
2688 *id, *pos, *asynchronous, *blank, *decimal, *delim, *pad, *round,
2689 *sign, *extra_comma, *dt_io_kind, *udtio;
2690 char dec_ext;
2692 gfc_symbol *namelist;
2693 /* A format_label of `format_asterisk' indicates the "*" format */
2694 gfc_st_label *format_label;
2695 gfc_st_label *err, *end, *eor;
2697 locus eor_where, end_where, err_where;
2699 gfc_dt;
2702 typedef struct gfc_forall_iterator
2704 gfc_expr *var, *start, *end, *stride;
2705 struct gfc_forall_iterator *next;
2707 gfc_forall_iterator;
2710 /* Linked list to store associations in an ASSOCIATE statement. */
2712 typedef struct gfc_association_list
2714 struct gfc_association_list *next;
2716 /* Whether this is association to a variable that can be changed; otherwise,
2717 it's association to an expression and the name may not be used as
2718 lvalue. */
2719 unsigned variable:1;
2721 /* True if this struct is currently only linked to from a gfc_symbol rather
2722 than as part of a real list in gfc_code->ext.block.assoc. This may
2723 happen for SELECT TYPE temporaries and must be considered
2724 for memory handling. */
2725 unsigned dangling:1;
2727 /* True when the rank of the target expression is guessed during parsing. */
2728 unsigned rankguessed:1;
2730 char name[GFC_MAX_SYMBOL_LEN + 1];
2731 gfc_symtree *st; /* Symtree corresponding to name. */
2732 locus where;
2734 gfc_expr *target;
2736 gfc_association_list;
2737 #define gfc_get_association_list() XCNEW (gfc_association_list)
2740 /* Executable statements that fill gfc_code structures. */
2741 enum gfc_exec_op
2743 EXEC_NOP = 1, EXEC_END_NESTED_BLOCK, EXEC_END_BLOCK, EXEC_ASSIGN,
2744 EXEC_LABEL_ASSIGN, EXEC_POINTER_ASSIGN, EXEC_CRITICAL, EXEC_ERROR_STOP,
2745 EXEC_GOTO, EXEC_CALL, EXEC_COMPCALL, EXEC_ASSIGN_CALL, EXEC_RETURN,
2746 EXEC_ENTRY, EXEC_PAUSE, EXEC_STOP, EXEC_CONTINUE, EXEC_INIT_ASSIGN,
2747 EXEC_IF, EXEC_ARITHMETIC_IF, EXEC_DO, EXEC_DO_CONCURRENT, EXEC_DO_WHILE,
2748 EXEC_SELECT, EXEC_BLOCK, EXEC_FORALL, EXEC_WHERE, EXEC_CYCLE, EXEC_EXIT,
2749 EXEC_CALL_PPC, EXEC_ALLOCATE, EXEC_DEALLOCATE, EXEC_END_PROCEDURE,
2750 EXEC_SELECT_TYPE, EXEC_SELECT_RANK, EXEC_SYNC_ALL, EXEC_SYNC_MEMORY,
2751 EXEC_SYNC_IMAGES, EXEC_OPEN, EXEC_CLOSE, EXEC_WAIT,
2752 EXEC_READ, EXEC_WRITE, EXEC_IOLENGTH, EXEC_TRANSFER, EXEC_DT_END,
2753 EXEC_BACKSPACE, EXEC_ENDFILE, EXEC_INQUIRE, EXEC_REWIND, EXEC_FLUSH,
2754 EXEC_FORM_TEAM, EXEC_CHANGE_TEAM, EXEC_END_TEAM, EXEC_SYNC_TEAM,
2755 EXEC_LOCK, EXEC_UNLOCK, EXEC_EVENT_POST, EXEC_EVENT_WAIT, EXEC_FAIL_IMAGE,
2756 EXEC_OACC_KERNELS_LOOP, EXEC_OACC_PARALLEL_LOOP, EXEC_OACC_SERIAL_LOOP,
2757 EXEC_OACC_ROUTINE, EXEC_OACC_PARALLEL, EXEC_OACC_KERNELS, EXEC_OACC_SERIAL,
2758 EXEC_OACC_DATA, EXEC_OACC_HOST_DATA, EXEC_OACC_LOOP, EXEC_OACC_UPDATE,
2759 EXEC_OACC_WAIT, EXEC_OACC_CACHE, EXEC_OACC_ENTER_DATA, EXEC_OACC_EXIT_DATA,
2760 EXEC_OACC_ATOMIC, EXEC_OACC_DECLARE,
2761 EXEC_OMP_CRITICAL, EXEC_OMP_DO, EXEC_OMP_FLUSH, EXEC_OMP_MASTER,
2762 EXEC_OMP_ORDERED, EXEC_OMP_PARALLEL, EXEC_OMP_PARALLEL_DO,
2763 EXEC_OMP_PARALLEL_SECTIONS, EXEC_OMP_PARALLEL_WORKSHARE,
2764 EXEC_OMP_SECTIONS, EXEC_OMP_SINGLE, EXEC_OMP_WORKSHARE,
2765 EXEC_OMP_ATOMIC, EXEC_OMP_BARRIER, EXEC_OMP_END_NOWAIT,
2766 EXEC_OMP_END_SINGLE, EXEC_OMP_TASK, EXEC_OMP_TASKWAIT,
2767 EXEC_OMP_TASKYIELD, EXEC_OMP_CANCEL, EXEC_OMP_CANCELLATION_POINT,
2768 EXEC_OMP_TASKGROUP, EXEC_OMP_SIMD, EXEC_OMP_DO_SIMD,
2769 EXEC_OMP_PARALLEL_DO_SIMD, EXEC_OMP_TARGET, EXEC_OMP_TARGET_DATA,
2770 EXEC_OMP_TEAMS, EXEC_OMP_DISTRIBUTE, EXEC_OMP_DISTRIBUTE_SIMD,
2771 EXEC_OMP_DISTRIBUTE_PARALLEL_DO, EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD,
2772 EXEC_OMP_TARGET_TEAMS, EXEC_OMP_TEAMS_DISTRIBUTE,
2773 EXEC_OMP_TEAMS_DISTRIBUTE_SIMD, EXEC_OMP_TARGET_TEAMS_DISTRIBUTE,
2774 EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD,
2775 EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO,
2776 EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO,
2777 EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD,
2778 EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD,
2779 EXEC_OMP_TARGET_UPDATE, EXEC_OMP_END_CRITICAL,
2780 EXEC_OMP_TARGET_ENTER_DATA, EXEC_OMP_TARGET_EXIT_DATA,
2781 EXEC_OMP_TARGET_PARALLEL, EXEC_OMP_TARGET_PARALLEL_DO,
2782 EXEC_OMP_TARGET_PARALLEL_DO_SIMD, EXEC_OMP_TARGET_SIMD,
2783 EXEC_OMP_TASKLOOP, EXEC_OMP_TASKLOOP_SIMD, EXEC_OMP_SCAN, EXEC_OMP_DEPOBJ,
2784 EXEC_OMP_PARALLEL_MASTER, EXEC_OMP_PARALLEL_MASTER_TASKLOOP,
2785 EXEC_OMP_PARALLEL_MASTER_TASKLOOP_SIMD, EXEC_OMP_MASTER_TASKLOOP,
2786 EXEC_OMP_MASTER_TASKLOOP_SIMD, EXEC_OMP_LOOP, EXEC_OMP_PARALLEL_LOOP,
2787 EXEC_OMP_TEAMS_LOOP, EXEC_OMP_TARGET_PARALLEL_LOOP,
2788 EXEC_OMP_TARGET_TEAMS_LOOP, EXEC_OMP_MASKED, EXEC_OMP_PARALLEL_MASKED,
2789 EXEC_OMP_PARALLEL_MASKED_TASKLOOP, EXEC_OMP_PARALLEL_MASKED_TASKLOOP_SIMD,
2790 EXEC_OMP_MASKED_TASKLOOP, EXEC_OMP_MASKED_TASKLOOP_SIMD, EXEC_OMP_SCOPE,
2791 EXEC_OMP_ERROR
2794 typedef struct gfc_code
2796 gfc_exec_op op;
2798 struct gfc_code *block, *next;
2799 locus loc;
2801 gfc_st_label *here, *label1, *label2, *label3;
2802 gfc_symtree *symtree;
2803 gfc_expr *expr1, *expr2, *expr3, *expr4;
2804 /* A name isn't sufficient to identify a subroutine, we need the actual
2805 symbol for the interface definition.
2806 const char *sub_name; */
2807 gfc_symbol *resolved_sym;
2808 gfc_intrinsic_sym *resolved_isym;
2810 union
2812 gfc_actual_arglist *actual;
2813 gfc_iterator *iterator;
2815 struct
2817 gfc_typespec ts;
2818 gfc_alloc *list;
2819 /* Take the array specification from expr3 to allocate arrays
2820 without an explicit array specification. */
2821 unsigned arr_spec_from_expr3:1;
2823 alloc;
2825 struct
2827 gfc_namespace *ns;
2828 gfc_association_list *assoc;
2829 gfc_case *case_list;
2831 block;
2833 gfc_open *open;
2834 gfc_close *close;
2835 gfc_filepos *filepos;
2836 gfc_inquire *inquire;
2837 gfc_wait *wait;
2838 gfc_dt *dt;
2839 gfc_forall_iterator *forall_iterator;
2840 struct gfc_code *which_construct;
2841 int stop_code;
2842 gfc_entry_list *entry;
2843 gfc_oacc_declare *oacc_declare;
2844 gfc_omp_clauses *omp_clauses;
2845 const char *omp_name;
2846 gfc_omp_namelist *omp_namelist;
2847 bool omp_bool;
2849 ext; /* Points to additional structures required by statement */
2851 /* Cycle and break labels in constructs. */
2852 tree cycle_label;
2853 tree exit_label;
2855 gfc_code;
2858 /* Storage for DATA statements. */
2859 typedef struct gfc_data_variable
2861 gfc_expr *expr;
2862 gfc_iterator iter;
2863 struct gfc_data_variable *list, *next;
2865 gfc_data_variable;
2868 typedef struct gfc_data_value
2870 mpz_t repeat;
2871 gfc_expr *expr;
2872 struct gfc_data_value *next;
2874 gfc_data_value;
2877 typedef struct gfc_data
2879 gfc_data_variable *var;
2880 gfc_data_value *value;
2881 locus where;
2883 struct gfc_data *next;
2885 gfc_data;
2888 /* Structure for holding compile options */
2889 typedef struct
2891 char *module_dir;
2892 gfc_source_form source_form;
2893 int max_continue_fixed;
2894 int max_continue_free;
2895 int max_identifier_length;
2897 int max_errors;
2899 int flag_preprocessed;
2900 int flag_d_lines;
2901 int flag_init_integer;
2902 long flag_init_integer_value;
2903 int flag_init_logical;
2904 int flag_init_character;
2905 char flag_init_character_value;
2907 int fpe;
2908 int fpe_summary;
2909 int rtcheck;
2911 int warn_std;
2912 int allow_std;
2914 gfc_option_t;
2916 extern gfc_option_t gfc_option;
2918 /* Constructor nodes for array and structure constructors. */
2919 typedef struct gfc_constructor
2921 gfc_constructor_base base;
2922 mpz_t offset; /* Offset within a constructor, used as
2923 key within base. */
2925 gfc_expr *expr;
2926 gfc_iterator *iterator;
2927 locus where;
2929 union
2931 gfc_component *component; /* Record the component being initialized. */
2934 mpz_t repeat; /* Record the repeat number of initial values in data
2935 statement like "data a/5*10/". */
2937 gfc_constructor;
2940 typedef struct iterator_stack
2942 gfc_symtree *variable;
2943 mpz_t value;
2944 struct iterator_stack *prev;
2946 iterator_stack;
2947 extern iterator_stack *iter_stack;
2950 /* Used for (possibly nested) SELECT TYPE statements. */
2951 typedef struct gfc_select_type_stack
2953 gfc_symbol *selector; /* Current selector variable. */
2954 gfc_symtree *tmp; /* Current temporary variable. */
2955 struct gfc_select_type_stack *prev; /* Previous element on stack. */
2957 gfc_select_type_stack;
2958 extern gfc_select_type_stack *select_type_stack;
2959 #define gfc_get_select_type_stack() XCNEW (gfc_select_type_stack)
2962 /* Node in the linked list used for storing finalizer procedures. */
2964 typedef struct gfc_finalizer
2966 struct gfc_finalizer* next;
2967 locus where; /* Where the FINAL declaration occurred. */
2969 /* Up to resolution, we want the gfc_symbol, there we lookup the corresponding
2970 symtree and later need only that. This way, we can access and call the
2971 finalizers from every context as they should be "always accessible". I
2972 don't make this a union because we need the information whether proc_sym is
2973 still referenced or not for dereferencing it on deleting a gfc_finalizer
2974 structure. */
2975 gfc_symbol* proc_sym;
2976 gfc_symtree* proc_tree;
2978 gfc_finalizer;
2979 #define gfc_get_finalizer() XCNEW (gfc_finalizer)
2982 /************************ Function prototypes *************************/
2984 /* decl.c */
2985 bool gfc_in_match_data (void);
2986 match gfc_match_char_spec (gfc_typespec *);
2987 extern int directive_unroll;
2988 extern bool directive_ivdep;
2989 extern bool directive_vector;
2990 extern bool directive_novector;
2992 /* SIMD clause enum. */
2993 enum gfc_simd_clause
2995 SIMD_NONE = (1 << 0),
2996 SIMD_INBRANCH = (1 << 1),
2997 SIMD_NOTINBRANCH = (1 << 2)
3000 /* Tuple for parsing of vectorized built-ins. */
3001 struct gfc_vect_builtin_tuple
3003 gfc_vect_builtin_tuple (const char *n, gfc_simd_clause t)
3004 : name (n), simd_type (t) {}
3006 const char *name;
3007 gfc_simd_clause simd_type;
3010 /* Map of middle-end built-ins that should be vectorized. */
3011 extern hash_map<nofree_string_hash, int> *gfc_vectorized_builtins;
3013 /* Handling Parameterized Derived Types */
3014 bool gfc_insert_kind_parameter_exprs (gfc_expr *);
3015 bool gfc_insert_parameter_exprs (gfc_expr *, gfc_actual_arglist *);
3016 match gfc_get_pdt_instance (gfc_actual_arglist *, gfc_symbol **,
3017 gfc_actual_arglist **);
3020 /* Given a symbol, test whether it is a module procedure in a submodule */
3021 #define gfc_submodule_procedure(attr) \
3022 (gfc_state_stack->previous && gfc_state_stack->previous->previous \
3023 && gfc_state_stack->previous->previous->state == COMP_SUBMODULE \
3024 && attr->module_procedure)
3026 /* scanner.c */
3027 void gfc_scanner_done_1 (void);
3028 void gfc_scanner_init_1 (void);
3030 void gfc_add_include_path (const char *, bool, bool, bool);
3031 void gfc_add_intrinsic_modules_path (const char *);
3032 void gfc_release_include_path (void);
3033 FILE *gfc_open_included_file (const char *, bool, bool);
3035 int gfc_at_end (void);
3036 int gfc_at_eof (void);
3037 int gfc_at_bol (void);
3038 int gfc_at_eol (void);
3039 void gfc_advance_line (void);
3040 int gfc_check_include (void);
3041 int gfc_define_undef_line (void);
3043 int gfc_wide_is_printable (gfc_char_t);
3044 int gfc_wide_is_digit (gfc_char_t);
3045 int gfc_wide_fits_in_byte (gfc_char_t);
3046 gfc_char_t gfc_wide_tolower (gfc_char_t);
3047 gfc_char_t gfc_wide_toupper (gfc_char_t);
3048 size_t gfc_wide_strlen (const gfc_char_t *);
3049 int gfc_wide_strncasecmp (const gfc_char_t *, const char *, size_t);
3050 gfc_char_t *gfc_wide_memset (gfc_char_t *, gfc_char_t, size_t);
3051 char *gfc_widechar_to_char (const gfc_char_t *, int);
3052 gfc_char_t *gfc_char_to_widechar (const char *);
3054 #define gfc_get_wide_string(n) XCNEWVEC (gfc_char_t, n)
3056 void gfc_skip_comments (void);
3057 gfc_char_t gfc_next_char_literal (gfc_instring);
3058 gfc_char_t gfc_next_char (void);
3059 char gfc_next_ascii_char (void);
3060 gfc_char_t gfc_peek_char (void);
3061 char gfc_peek_ascii_char (void);
3062 void gfc_error_recovery (void);
3063 void gfc_gobble_whitespace (void);
3064 bool gfc_new_file (void);
3065 const char * gfc_read_orig_filename (const char *, const char **);
3067 extern gfc_source_form gfc_current_form;
3068 extern const char *gfc_source_file;
3069 extern locus gfc_current_locus;
3071 void gfc_start_source_files (void);
3072 void gfc_end_source_files (void);
3074 /* misc.c */
3075 void gfc_clear_ts (gfc_typespec *);
3076 FILE *gfc_open_file (const char *);
3077 const char *gfc_basic_typename (bt);
3078 const char *gfc_dummy_typename (gfc_typespec *);
3079 const char *gfc_typename (gfc_typespec *, bool for_hash = false);
3080 const char *gfc_typename (gfc_expr *);
3081 const char *gfc_op2string (gfc_intrinsic_op);
3082 const char *gfc_code2string (const mstring *, int);
3083 int gfc_string2code (const mstring *, const char *);
3084 const char *gfc_intent_string (sym_intent);
3086 void gfc_init_1 (void);
3087 void gfc_init_2 (void);
3088 void gfc_done_1 (void);
3089 void gfc_done_2 (void);
3091 int get_c_kind (const char *, CInteropKind_t *);
3093 const char *gfc_closest_fuzzy_match (const char *, char **);
3094 static inline void
3095 vec_push (char **&optr, size_t &osz, const char *elt)
3097 /* {auto,}vec.safe_push () replacement. Don't ask.. */
3098 // if (strlen (elt) < 4) return; premature optimization: eliminated by cutoff
3099 optr = XRESIZEVEC (char *, optr, osz + 2);
3100 optr[osz] = CONST_CAST (char *, elt);
3101 optr[++osz] = NULL;
3104 HOST_WIDE_INT gfc_mpz_get_hwi (mpz_t);
3105 void gfc_mpz_set_hwi (mpz_t, const HOST_WIDE_INT);
3107 /* options.c */
3108 unsigned int gfc_option_lang_mask (void);
3109 void gfc_init_options_struct (struct gcc_options *);
3110 void gfc_init_options (unsigned int,
3111 struct cl_decoded_option *);
3112 bool gfc_handle_option (size_t, const char *, HOST_WIDE_INT, int, location_t,
3113 const struct cl_option_handlers *);
3114 bool gfc_post_options (const char **);
3115 char *gfc_get_option_string (void);
3117 /* f95-lang.c */
3118 void gfc_maybe_initialize_eh (void);
3120 /* iresolve.c */
3121 const char * gfc_get_string (const char *, ...) ATTRIBUTE_PRINTF_1;
3122 bool gfc_find_sym_in_expr (gfc_symbol *, gfc_expr *);
3124 /* error.c */
3125 void gfc_error_init_1 (void);
3126 void gfc_diagnostics_init (void);
3127 void gfc_diagnostics_finish (void);
3128 void gfc_buffer_error (bool);
3130 const char *gfc_print_wide_char (gfc_char_t);
3132 bool gfc_warning (int opt, const char *, ...) ATTRIBUTE_GCC_GFC(2,3);
3133 bool gfc_warning_now (int opt, const char *, ...) ATTRIBUTE_GCC_GFC(2,3);
3134 bool gfc_warning_internal (int opt, const char *, ...) ATTRIBUTE_GCC_GFC(2,3);
3135 bool gfc_warning_now_at (location_t loc, int opt, const char *gmsgid, ...)
3136 ATTRIBUTE_GCC_GFC(3,4);
3138 void gfc_clear_warning (void);
3139 void gfc_warning_check (void);
3141 void gfc_error_opt (int opt, const char *, ...) ATTRIBUTE_GCC_GFC(2,3);
3142 void gfc_error (const char *, ...) ATTRIBUTE_GCC_GFC(1,2);
3143 void gfc_error_now (const char *, ...) ATTRIBUTE_GCC_GFC(1,2);
3144 void gfc_fatal_error (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_GCC_GFC(1,2);
3145 void gfc_internal_error (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_GCC_GFC(1,2);
3146 void gfc_clear_error (void);
3147 bool gfc_error_check (void);
3148 bool gfc_error_flag_test (void);
3150 notification gfc_notification_std (int);
3151 bool gfc_notify_std (int, const char *, ...) ATTRIBUTE_GCC_GFC(2,3);
3153 /* A general purpose syntax error. */
3154 #define gfc_syntax_error(ST) \
3155 gfc_error ("Syntax error in %s statement at %C", gfc_ascii_statement (ST));
3157 #include "pretty-print.h" /* For output_buffer. */
3158 struct gfc_error_buffer
3160 bool flag;
3161 output_buffer buffer;
3162 gfc_error_buffer(void) : flag(false), buffer() {}
3165 void gfc_push_error (gfc_error_buffer *);
3166 void gfc_pop_error (gfc_error_buffer *);
3167 void gfc_free_error (gfc_error_buffer *);
3169 void gfc_get_errors (int *, int *);
3170 void gfc_errors_to_warnings (bool);
3172 /* arith.c */
3173 void gfc_arith_init_1 (void);
3174 void gfc_arith_done_1 (void);
3175 arith gfc_check_integer_range (mpz_t p, int kind);
3176 bool gfc_check_character_range (gfc_char_t, int);
3178 extern bool gfc_seen_div0;
3180 /* trans-types.c */
3181 bool gfc_check_any_c_kind (gfc_typespec *);
3182 int gfc_validate_kind (bt, int, bool);
3183 int gfc_get_int_kind_from_width_isofortranenv (int size);
3184 int gfc_get_real_kind_from_width_isofortranenv (int size);
3185 tree gfc_get_union_type (gfc_symbol *);
3186 tree gfc_get_derived_type (gfc_symbol * derived, int codimen = 0);
3187 extern int gfc_index_integer_kind;
3188 extern int gfc_default_integer_kind;
3189 extern int gfc_max_integer_kind;
3190 extern int gfc_default_real_kind;
3191 extern int gfc_default_double_kind;
3192 extern int gfc_default_character_kind;
3193 extern int gfc_default_logical_kind;
3194 extern int gfc_default_complex_kind;
3195 extern int gfc_c_int_kind;
3196 extern int gfc_c_intptr_kind;
3197 extern int gfc_atomic_int_kind;
3198 extern int gfc_atomic_logical_kind;
3199 extern int gfc_intio_kind;
3200 extern int gfc_charlen_int_kind;
3201 extern int gfc_size_kind;
3202 extern int gfc_numeric_storage_size;
3203 extern int gfc_character_storage_size;
3205 #define gfc_logical_4_kind 4
3206 #define gfc_integer_4_kind 4
3207 #define gfc_real_4_kind 4
3209 /* symbol.c */
3210 void gfc_clear_new_implicit (void);
3211 bool gfc_add_new_implicit_range (int, int);
3212 bool gfc_merge_new_implicit (gfc_typespec *);
3213 void gfc_set_implicit_none (bool, bool, locus *);
3214 void gfc_check_function_type (gfc_namespace *);
3215 bool gfc_is_intrinsic_typename (const char *);
3216 bool gfc_check_conflict (symbol_attribute *, const char *, locus *);
3218 gfc_typespec *gfc_get_default_type (const char *, gfc_namespace *);
3219 bool gfc_set_default_type (gfc_symbol *, int, gfc_namespace *);
3221 void gfc_set_sym_referenced (gfc_symbol *);
3223 bool gfc_add_attribute (symbol_attribute *, locus *);
3224 bool gfc_add_ext_attribute (symbol_attribute *, ext_attr_id_t, locus *);
3225 bool gfc_add_allocatable (symbol_attribute *, locus *);
3226 bool gfc_add_codimension (symbol_attribute *, const char *, locus *);
3227 bool gfc_add_contiguous (symbol_attribute *, const char *, locus *);
3228 bool gfc_add_dimension (symbol_attribute *, const char *, locus *);
3229 bool gfc_add_external (symbol_attribute *, locus *);
3230 bool gfc_add_intrinsic (symbol_attribute *, locus *);
3231 bool gfc_add_optional (symbol_attribute *, locus *);
3232 bool gfc_add_kind (symbol_attribute *, locus *);
3233 bool gfc_add_len (symbol_attribute *, locus *);
3234 bool gfc_add_pointer (symbol_attribute *, locus *);
3235 bool gfc_add_cray_pointer (symbol_attribute *, locus *);
3236 bool gfc_add_cray_pointee (symbol_attribute *, locus *);
3237 match gfc_mod_pointee_as (gfc_array_spec *);
3238 bool gfc_add_protected (symbol_attribute *, const char *, locus *);
3239 bool gfc_add_result (symbol_attribute *, const char *, locus *);
3240 bool gfc_add_automatic (symbol_attribute *, const char *, locus *);
3241 bool gfc_add_save (symbol_attribute *, save_state, const char *, locus *);
3242 bool gfc_add_threadprivate (symbol_attribute *, const char *, locus *);
3243 bool gfc_add_omp_declare_target (symbol_attribute *, const char *, locus *);
3244 bool gfc_add_omp_declare_target_link (symbol_attribute *, const char *,
3245 locus *);
3246 bool gfc_add_saved_common (symbol_attribute *, locus *);
3247 bool gfc_add_target (symbol_attribute *, locus *);
3248 bool gfc_add_dummy (symbol_attribute *, const char *, locus *);
3249 bool gfc_add_generic (symbol_attribute *, const char *, locus *);
3250 bool gfc_add_common (symbol_attribute *, locus *);
3251 bool gfc_add_in_common (symbol_attribute *, const char *, locus *);
3252 bool gfc_add_in_equivalence (symbol_attribute *, const char *, locus *);
3253 bool gfc_add_data (symbol_attribute *, const char *, locus *);
3254 bool gfc_add_in_namelist (symbol_attribute *, const char *, locus *);
3255 bool gfc_add_sequence (symbol_attribute *, const char *, locus *);
3256 bool gfc_add_elemental (symbol_attribute *, locus *);
3257 bool gfc_add_pure (symbol_attribute *, locus *);
3258 bool gfc_add_recursive (symbol_attribute *, locus *);
3259 bool gfc_add_function (symbol_attribute *, const char *, locus *);
3260 bool gfc_add_subroutine (symbol_attribute *, const char *, locus *);
3261 bool gfc_add_volatile (symbol_attribute *, const char *, locus *);
3262 bool gfc_add_asynchronous (symbol_attribute *, const char *, locus *);
3263 bool gfc_add_proc (symbol_attribute *attr, const char *name, locus *where);
3264 bool gfc_add_abstract (symbol_attribute* attr, locus* where);
3266 bool gfc_add_access (symbol_attribute *, gfc_access, const char *, locus *);
3267 bool gfc_add_is_bind_c (symbol_attribute *, const char *, locus *, int);
3268 bool gfc_add_extension (symbol_attribute *, locus *);
3269 bool gfc_add_value (symbol_attribute *, const char *, locus *);
3270 bool gfc_add_flavor (symbol_attribute *, sym_flavor, const char *, locus *);
3271 bool gfc_add_entry (symbol_attribute *, const char *, locus *);
3272 bool gfc_add_procedure (symbol_attribute *, procedure_type,
3273 const char *, locus *);
3274 bool gfc_add_intent (symbol_attribute *, sym_intent, locus *);
3275 bool gfc_add_explicit_interface (gfc_symbol *, ifsrc,
3276 gfc_formal_arglist *, locus *);
3277 bool gfc_add_type (gfc_symbol *, gfc_typespec *, locus *);
3279 void gfc_clear_attr (symbol_attribute *);
3280 bool gfc_missing_attr (symbol_attribute *, locus *);
3281 bool gfc_copy_attr (symbol_attribute *, symbol_attribute *, locus *);
3282 int gfc_copy_dummy_sym (gfc_symbol **, gfc_symbol *, int);
3283 bool gfc_add_component (gfc_symbol *, const char *, gfc_component **);
3284 gfc_symbol *gfc_use_derived (gfc_symbol *);
3285 gfc_symtree *gfc_use_derived_tree (gfc_symtree *);
3286 gfc_component *gfc_find_component (gfc_symbol *, const char *, bool, bool,
3287 gfc_ref **);
3289 gfc_st_label *gfc_get_st_label (int);
3290 void gfc_free_st_label (gfc_st_label *);
3291 void gfc_define_st_label (gfc_st_label *, gfc_sl_type, locus *);
3292 bool gfc_reference_st_label (gfc_st_label *, gfc_sl_type);
3294 gfc_namespace *gfc_get_namespace (gfc_namespace *, int);
3295 gfc_symtree *gfc_new_symtree (gfc_symtree **, const char *);
3296 gfc_symtree *gfc_find_symtree (gfc_symtree *, const char *);
3297 void gfc_delete_symtree (gfc_symtree **, const char *);
3298 gfc_symtree *gfc_get_unique_symtree (gfc_namespace *);
3299 gfc_user_op *gfc_get_uop (const char *);
3300 gfc_user_op *gfc_find_uop (const char *, gfc_namespace *);
3301 void gfc_free_symbol (gfc_symbol *);
3302 void gfc_release_symbol (gfc_symbol *);
3303 gfc_symbol *gfc_new_symbol (const char *, gfc_namespace *);
3304 gfc_symtree* gfc_find_symtree_in_proc (const char *, gfc_namespace *);
3305 int gfc_find_symbol (const char *, gfc_namespace *, int, gfc_symbol **);
3306 int gfc_find_sym_tree (const char *, gfc_namespace *, int, gfc_symtree **);
3307 int gfc_get_symbol (const char *, gfc_namespace *, gfc_symbol **);
3308 bool gfc_verify_c_interop (gfc_typespec *);
3309 bool gfc_verify_c_interop_param (gfc_symbol *);
3310 bool verify_bind_c_sym (gfc_symbol *, gfc_typespec *, int, gfc_common_head *);
3311 bool verify_bind_c_derived_type (gfc_symbol *);
3312 bool verify_com_block_vars_c_interop (gfc_common_head *);
3313 gfc_symtree *generate_isocbinding_symbol (const char *, iso_c_binding_symbol,
3314 const char *, gfc_symtree *, bool);
3315 void gfc_save_symbol_data (gfc_symbol *);
3316 int gfc_get_sym_tree (const char *, gfc_namespace *, gfc_symtree **, bool);
3317 int gfc_get_ha_symbol (const char *, gfc_symbol **);
3318 int gfc_get_ha_sym_tree (const char *, gfc_symtree **);
3320 void gfc_drop_last_undo_checkpoint (void);
3321 void gfc_restore_last_undo_checkpoint (void);
3322 void gfc_undo_symbols (void);
3323 void gfc_commit_symbols (void);
3324 void gfc_commit_symbol (gfc_symbol *);
3325 gfc_charlen *gfc_new_charlen (gfc_namespace *, gfc_charlen *);
3326 void gfc_free_charlen (gfc_charlen *, gfc_charlen *);
3327 void gfc_free_namespace (gfc_namespace *);
3329 void gfc_symbol_init_2 (void);
3330 void gfc_symbol_done_2 (void);
3332 void gfc_traverse_symtree (gfc_symtree *, void (*)(gfc_symtree *));
3333 void gfc_traverse_ns (gfc_namespace *, void (*)(gfc_symbol *));
3334 void gfc_traverse_user_op (gfc_namespace *, void (*)(gfc_user_op *));
3335 void gfc_save_all (gfc_namespace *);
3337 void gfc_enforce_clean_symbol_state (void);
3339 gfc_gsymbol *gfc_get_gsymbol (const char *, bool bind_c);
3340 gfc_gsymbol *gfc_find_gsymbol (gfc_gsymbol *, const char *);
3341 gfc_gsymbol *gfc_find_case_gsymbol (gfc_gsymbol *, const char *);
3342 void gfc_traverse_gsymbol (gfc_gsymbol *, void (*)(gfc_gsymbol *, void *), void *);
3344 gfc_typebound_proc* gfc_get_typebound_proc (gfc_typebound_proc*);
3345 gfc_symbol* gfc_get_derived_super_type (gfc_symbol*);
3346 gfc_symbol* gfc_get_ultimate_derived_super_type (gfc_symbol*);
3347 bool gfc_type_is_extension_of (gfc_symbol *, gfc_symbol *);
3348 bool gfc_type_compatible (gfc_typespec *, gfc_typespec *);
3350 void gfc_copy_formal_args_intr (gfc_symbol *, gfc_intrinsic_sym *,
3351 gfc_actual_arglist *, bool copy_type = false);
3353 void gfc_free_finalizer (gfc_finalizer *el); /* Needed in resolve.c, too */
3355 bool gfc_check_symbol_typed (gfc_symbol*, gfc_namespace*, bool, locus);
3356 gfc_namespace* gfc_find_proc_namespace (gfc_namespace*);
3358 bool gfc_is_associate_pointer (gfc_symbol*);
3359 gfc_symbol * gfc_find_dt_in_generic (gfc_symbol *);
3360 gfc_formal_arglist *gfc_sym_get_dummy_args (gfc_symbol *);
3362 /* intrinsic.c -- true if working in an init-expr, false otherwise. */
3363 extern bool gfc_init_expr_flag;
3365 /* Given a symbol that we have decided is intrinsic, mark it as such
3366 by placing it into a special module that is otherwise impossible to
3367 read or write. */
3369 #define gfc_intrinsic_symbol(SYM) SYM->module = gfc_get_string ("(intrinsic)")
3371 void gfc_intrinsic_init_1 (void);
3372 void gfc_intrinsic_done_1 (void);
3374 char gfc_type_letter (bt, bool logical_equals_int = false);
3375 gfc_symbol * gfc_get_intrinsic_sub_symbol (const char *);
3376 gfc_symbol *gfc_get_intrinsic_function_symbol (gfc_expr *);
3377 gfc_symbol *gfc_find_intrinsic_symbol (gfc_expr *);
3378 bool gfc_convert_type (gfc_expr *, gfc_typespec *, int);
3379 bool gfc_convert_type_warn (gfc_expr *, gfc_typespec *, int, int,
3380 bool array = false);
3381 bool gfc_convert_chartype (gfc_expr *, gfc_typespec *);
3382 int gfc_generic_intrinsic (const char *);
3383 int gfc_specific_intrinsic (const char *);
3384 bool gfc_is_intrinsic (gfc_symbol*, int, locus);
3385 int gfc_intrinsic_actual_ok (const char *, const bool);
3386 gfc_intrinsic_sym *gfc_find_function (const char *);
3387 gfc_intrinsic_sym *gfc_find_subroutine (const char *);
3388 gfc_intrinsic_sym *gfc_intrinsic_function_by_id (gfc_isym_id);
3389 gfc_intrinsic_sym *gfc_intrinsic_subroutine_by_id (gfc_isym_id);
3390 gfc_isym_id gfc_isym_id_by_intmod (intmod_id, int);
3391 gfc_isym_id gfc_isym_id_by_intmod_sym (gfc_symbol *);
3394 match gfc_intrinsic_func_interface (gfc_expr *, int);
3395 match gfc_intrinsic_sub_interface (gfc_code *, int);
3397 void gfc_warn_intrinsic_shadow (const gfc_symbol*, bool, bool);
3398 bool gfc_check_intrinsic_standard (const gfc_intrinsic_sym*, const char**,
3399 bool, locus);
3401 /* match.c -- FIXME */
3402 void gfc_free_iterator (gfc_iterator *, int);
3403 void gfc_free_forall_iterator (gfc_forall_iterator *);
3404 void gfc_free_alloc_list (gfc_alloc *);
3405 void gfc_free_namelist (gfc_namelist *);
3406 void gfc_free_omp_namelist (gfc_omp_namelist *, bool);
3407 void gfc_free_equiv (gfc_equiv *);
3408 void gfc_free_equiv_until (gfc_equiv *, gfc_equiv *);
3409 void gfc_free_data (gfc_data *);
3410 void gfc_reject_data (gfc_namespace *);
3411 void gfc_free_case_list (gfc_case *);
3413 /* matchexp.c -- FIXME too? */
3414 gfc_expr *gfc_get_parentheses (gfc_expr *);
3416 /* openmp.c */
3417 struct gfc_omp_saved_state { void *ptrs[2]; int ints[1]; };
3418 bool gfc_omp_requires_add_clause (gfc_omp_requires_kind, const char *,
3419 locus *, const char *);
3420 void gfc_check_omp_requires (gfc_namespace *, int);
3421 void gfc_free_omp_clauses (gfc_omp_clauses *);
3422 void gfc_free_oacc_declare_clauses (struct gfc_oacc_declare *);
3423 void gfc_free_omp_declare_simd (gfc_omp_declare_simd *);
3424 void gfc_free_omp_declare_simd_list (gfc_omp_declare_simd *);
3425 void gfc_free_omp_udr (gfc_omp_udr *);
3426 gfc_omp_udr *gfc_omp_udr_find (gfc_symtree *, gfc_typespec *);
3427 void gfc_resolve_omp_directive (gfc_code *, gfc_namespace *);
3428 void gfc_resolve_do_iterator (gfc_code *, gfc_symbol *, bool);
3429 void gfc_resolve_omp_local_vars (gfc_namespace *);
3430 void gfc_resolve_omp_parallel_blocks (gfc_code *, gfc_namespace *);
3431 void gfc_resolve_omp_do_blocks (gfc_code *, gfc_namespace *);
3432 void gfc_resolve_omp_declare_simd (gfc_namespace *);
3433 void gfc_resolve_omp_udrs (gfc_symtree *);
3434 void gfc_omp_save_and_clear_state (struct gfc_omp_saved_state *);
3435 void gfc_omp_restore_state (struct gfc_omp_saved_state *);
3436 void gfc_free_expr_list (gfc_expr_list *);
3437 void gfc_resolve_oacc_directive (gfc_code *, gfc_namespace *);
3438 void gfc_resolve_oacc_declare (gfc_namespace *);
3439 void gfc_resolve_oacc_parallel_loop_blocks (gfc_code *, gfc_namespace *);
3440 void gfc_resolve_oacc_blocks (gfc_code *, gfc_namespace *);
3441 void gfc_resolve_oacc_routines (gfc_namespace *);
3443 /* expr.c */
3444 void gfc_free_actual_arglist (gfc_actual_arglist *);
3445 gfc_actual_arglist *gfc_copy_actual_arglist (gfc_actual_arglist *);
3447 bool gfc_extract_int (gfc_expr *, int *, int = 0);
3448 bool gfc_extract_hwi (gfc_expr *, HOST_WIDE_INT *, int = 0);
3450 bool is_CFI_desc (gfc_symbol *, gfc_expr *);
3451 bool is_subref_array (gfc_expr *);
3452 bool gfc_is_simply_contiguous (gfc_expr *, bool, bool);
3453 bool gfc_is_not_contiguous (gfc_expr *);
3454 bool gfc_check_init_expr (gfc_expr *);
3456 gfc_expr *gfc_build_conversion (gfc_expr *);
3457 void gfc_free_ref_list (gfc_ref *);
3458 void gfc_type_convert_binary (gfc_expr *, int);
3459 bool gfc_is_constant_expr (gfc_expr *);
3460 bool gfc_simplify_expr (gfc_expr *, int);
3461 int gfc_has_vector_index (gfc_expr *);
3463 gfc_expr *gfc_get_expr (void);
3464 gfc_expr *gfc_get_array_expr (bt type, int kind, locus *);
3465 gfc_expr *gfc_get_null_expr (locus *);
3466 gfc_expr *gfc_get_operator_expr (locus *, gfc_intrinsic_op,gfc_expr *, gfc_expr *);
3467 gfc_expr *gfc_get_structure_constructor_expr (bt, int, locus *);
3468 gfc_expr *gfc_get_constant_expr (bt, int, locus *);
3469 gfc_expr *gfc_get_character_expr (int, locus *, const char *, gfc_charlen_t len);
3470 gfc_expr *gfc_get_int_expr (int, locus *, HOST_WIDE_INT);
3471 gfc_expr *gfc_get_logical_expr (int, locus *, bool);
3472 gfc_expr *gfc_get_iokind_expr (locus *, io_kind);
3474 void gfc_clear_shape (mpz_t *shape, int rank);
3475 void gfc_free_shape (mpz_t **shape, int rank);
3476 void gfc_free_expr (gfc_expr *);
3477 void gfc_replace_expr (gfc_expr *, gfc_expr *);
3478 mpz_t *gfc_copy_shape (mpz_t *, int);
3479 mpz_t *gfc_copy_shape_excluding (mpz_t *, int, gfc_expr *);
3480 gfc_expr *gfc_copy_expr (gfc_expr *);
3481 gfc_ref* gfc_copy_ref (gfc_ref*);
3483 bool gfc_specification_expr (gfc_expr *);
3485 int gfc_numeric_ts (gfc_typespec *);
3486 int gfc_kind_max (gfc_expr *, gfc_expr *);
3488 bool gfc_check_conformance (gfc_expr *, gfc_expr *, const char *, ...) ATTRIBUTE_PRINTF_3;
3489 bool gfc_check_assign (gfc_expr *, gfc_expr *, int, bool c = true);
3490 bool gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue,
3491 bool suppres_type_test = false,
3492 bool is_init_expr = false);
3493 bool gfc_check_assign_symbol (gfc_symbol *, gfc_component *, gfc_expr *);
3495 gfc_expr *gfc_build_default_init_expr (gfc_typespec *, locus *);
3496 gfc_expr *gfc_build_init_expr (gfc_typespec *, locus *, bool);
3497 void gfc_apply_init (gfc_typespec *, symbol_attribute *, gfc_expr *);
3498 bool gfc_has_default_initializer (gfc_symbol *);
3499 gfc_expr *gfc_default_initializer (gfc_typespec *);
3500 gfc_expr *gfc_generate_initializer (gfc_typespec *, bool);
3501 gfc_expr *gfc_get_variable_expr (gfc_symtree *);
3502 void gfc_add_full_array_ref (gfc_expr *, gfc_array_spec *);
3503 gfc_expr * gfc_lval_expr_from_sym (gfc_symbol *);
3505 gfc_array_spec *gfc_get_full_arrayspec_from_expr (gfc_expr *expr);
3507 bool gfc_traverse_expr (gfc_expr *, gfc_symbol *,
3508 bool (*)(gfc_expr *, gfc_symbol *, int*),
3509 int);
3510 void gfc_expr_set_symbols_referenced (gfc_expr *);
3511 bool gfc_expr_check_typed (gfc_expr*, gfc_namespace*, bool);
3512 bool gfc_derived_parameter_expr (gfc_expr *);
3513 gfc_param_spec_type gfc_spec_list_type (gfc_actual_arglist *, gfc_symbol *);
3514 gfc_component * gfc_get_proc_ptr_comp (gfc_expr *);
3515 bool gfc_is_proc_ptr_comp (gfc_expr *);
3516 bool gfc_is_alloc_class_scalar_function (gfc_expr *);
3517 bool gfc_is_class_array_function (gfc_expr *);
3519 bool gfc_ref_this_image (gfc_ref *ref);
3520 bool gfc_is_coindexed (gfc_expr *);
3521 bool gfc_is_coarray (gfc_expr *);
3522 int gfc_get_corank (gfc_expr *);
3523 bool gfc_has_ultimate_allocatable (gfc_expr *);
3524 bool gfc_has_ultimate_pointer (gfc_expr *);
3525 gfc_expr* gfc_find_team_co (gfc_expr *);
3526 gfc_expr* gfc_find_stat_co (gfc_expr *);
3527 gfc_expr* gfc_build_intrinsic_call (gfc_namespace *, gfc_isym_id, const char*,
3528 locus, unsigned, ...);
3529 bool gfc_check_vardef_context (gfc_expr*, bool, bool, bool, const char*);
3532 /* st.c */
3533 extern gfc_code new_st;
3535 void gfc_clear_new_st (void);
3536 gfc_code *gfc_get_code (gfc_exec_op);
3537 gfc_code *gfc_append_code (gfc_code *, gfc_code *);
3538 void gfc_free_statement (gfc_code *);
3539 void gfc_free_statements (gfc_code *);
3540 void gfc_free_association_list (gfc_association_list *);
3542 /* resolve.c */
3543 void gfc_expression_rank (gfc_expr *);
3544 bool gfc_resolve_ref (gfc_expr *);
3545 bool gfc_resolve_expr (gfc_expr *);
3546 void gfc_resolve (gfc_namespace *);
3547 void gfc_resolve_code (gfc_code *, gfc_namespace *);
3548 void gfc_resolve_blocks (gfc_code *, gfc_namespace *);
3549 void gfc_resolve_formal_arglist (gfc_symbol *);
3550 int gfc_impure_variable (gfc_symbol *);
3551 int gfc_pure (gfc_symbol *);
3552 int gfc_implicit_pure (gfc_symbol *);
3553 void gfc_unset_implicit_pure (gfc_symbol *);
3554 int gfc_elemental (gfc_symbol *);
3555 bool gfc_resolve_iterator (gfc_iterator *, bool, bool);
3556 bool find_forall_index (gfc_expr *, gfc_symbol *, int);
3557 bool gfc_resolve_index (gfc_expr *, int);
3558 bool gfc_resolve_dim_arg (gfc_expr *);
3559 bool gfc_is_formal_arg (void);
3560 bool gfc_resolve_substring (gfc_ref *, bool *);
3561 void gfc_resolve_substring_charlen (gfc_expr *);
3562 match gfc_iso_c_sub_interface(gfc_code *, gfc_symbol *);
3563 gfc_expr *gfc_expr_to_initialize (gfc_expr *);
3564 bool gfc_type_is_extensible (gfc_symbol *);
3565 bool gfc_resolve_intrinsic (gfc_symbol *, locus *);
3566 bool gfc_explicit_interface_required (gfc_symbol *, char *, int);
3567 extern int gfc_do_concurrent_flag;
3568 const char* gfc_lookup_function_fuzzy (const char *, gfc_symtree *);
3569 int gfc_pure_function (gfc_expr *e, const char **name);
3570 int gfc_implicit_pure_function (gfc_expr *e);
3573 /* array.c */
3574 gfc_iterator *gfc_copy_iterator (gfc_iterator *);
3576 void gfc_free_array_spec (gfc_array_spec *);
3577 gfc_array_ref *gfc_copy_array_ref (gfc_array_ref *);
3579 bool gfc_set_array_spec (gfc_symbol *, gfc_array_spec *, locus *);
3580 gfc_array_spec *gfc_copy_array_spec (gfc_array_spec *);
3581 bool gfc_resolve_array_spec (gfc_array_spec *, int);
3583 int gfc_compare_array_spec (gfc_array_spec *, gfc_array_spec *);
3585 void gfc_simplify_iterator_var (gfc_expr *);
3586 bool gfc_expand_constructor (gfc_expr *, bool);
3587 int gfc_constant_ac (gfc_expr *);
3588 int gfc_expanded_ac (gfc_expr *);
3589 bool gfc_resolve_character_array_constructor (gfc_expr *);
3590 bool gfc_resolve_array_constructor (gfc_expr *);
3591 bool gfc_check_constructor_type (gfc_expr *);
3592 bool gfc_check_iter_variable (gfc_expr *);
3593 bool gfc_check_constructor (gfc_expr *, bool (*)(gfc_expr *));
3594 bool gfc_array_size (gfc_expr *, mpz_t *);
3595 bool gfc_array_dimen_size (gfc_expr *, int, mpz_t *);
3596 bool gfc_array_ref_shape (gfc_array_ref *, mpz_t *);
3597 gfc_array_ref *gfc_find_array_ref (gfc_expr *, bool a = false);
3598 tree gfc_conv_array_initializer (tree type, gfc_expr *);
3599 bool spec_size (gfc_array_spec *, mpz_t *);
3600 bool spec_dimen_size (gfc_array_spec *, int, mpz_t *);
3601 bool gfc_is_compile_time_shape (gfc_array_spec *);
3603 bool gfc_ref_dimen_size (gfc_array_ref *, int dimen, mpz_t *, mpz_t *);
3605 /* interface.c -- FIXME: some of these should be in symbol.c */
3606 void gfc_free_interface (gfc_interface *);
3607 bool gfc_compare_derived_types (gfc_symbol *, gfc_symbol *);
3608 bool gfc_compare_types (gfc_typespec *, gfc_typespec *);
3609 bool gfc_check_dummy_characteristics (gfc_symbol *, gfc_symbol *,
3610 bool, char *, int);
3611 bool gfc_check_result_characteristics (gfc_symbol *, gfc_symbol *,
3612 char *, int);
3613 bool gfc_compare_interfaces (gfc_symbol*, gfc_symbol*, const char *, int, int,
3614 char *, int, const char *, const char *,
3615 bool *bad_result_characteristics = NULL);
3616 void gfc_check_interfaces (gfc_namespace *);
3617 bool gfc_procedure_use (gfc_symbol *, gfc_actual_arglist **, locus *);
3618 void gfc_ppc_use (gfc_component *, gfc_actual_arglist **, locus *);
3619 gfc_symbol *gfc_search_interface (gfc_interface *, int,
3620 gfc_actual_arglist **);
3621 match gfc_extend_expr (gfc_expr *);
3622 void gfc_free_formal_arglist (gfc_formal_arglist *);
3623 bool gfc_extend_assign (gfc_code *, gfc_namespace *);
3624 bool gfc_check_new_interface (gfc_interface *, gfc_symbol *, locus);
3625 bool gfc_add_interface (gfc_symbol *);
3626 gfc_interface *gfc_current_interface_head (void);
3627 void gfc_set_current_interface_head (gfc_interface *);
3628 gfc_symtree* gfc_find_sym_in_symtree (gfc_symbol*);
3629 bool gfc_arglist_matches_symbol (gfc_actual_arglist**, gfc_symbol*);
3630 bool gfc_check_operator_interface (gfc_symbol*, gfc_intrinsic_op, locus);
3631 bool gfc_has_vector_subscript (gfc_expr*);
3632 gfc_intrinsic_op gfc_equivalent_op (gfc_intrinsic_op);
3633 bool gfc_check_typebound_override (gfc_symtree*, gfc_symtree*);
3634 void gfc_check_dtio_interfaces (gfc_symbol*);
3635 gfc_symtree* gfc_find_typebound_dtio_proc (gfc_symbol *, bool, bool);
3636 gfc_symbol* gfc_find_specific_dtio_proc (gfc_symbol*, bool, bool);
3637 void gfc_get_formal_from_actual_arglist (gfc_symbol *, gfc_actual_arglist *);
3638 bool gfc_compare_actual_formal (gfc_actual_arglist **, gfc_formal_arglist *,
3639 int, int, bool, locus *);
3642 /* io.c */
3643 extern gfc_st_label format_asterisk;
3645 void gfc_free_open (gfc_open *);
3646 bool gfc_resolve_open (gfc_open *, locus *);
3647 void gfc_free_close (gfc_close *);
3648 bool gfc_resolve_close (gfc_close *, locus *);
3649 void gfc_free_filepos (gfc_filepos *);
3650 bool gfc_resolve_filepos (gfc_filepos *, locus *);
3651 void gfc_free_inquire (gfc_inquire *);
3652 bool gfc_resolve_inquire (gfc_inquire *);
3653 void gfc_free_dt (gfc_dt *);
3654 bool gfc_resolve_dt (gfc_code *, gfc_dt *, locus *);
3655 void gfc_free_wait (gfc_wait *);
3656 bool gfc_resolve_wait (gfc_wait *);
3658 /* module.c */
3659 void gfc_module_init_2 (void);
3660 void gfc_module_done_2 (void);
3661 void gfc_dump_module (const char *, int);
3662 bool gfc_check_symbol_access (gfc_symbol *);
3663 void gfc_free_use_stmts (gfc_use_list *);
3664 const char *gfc_dt_lower_string (const char *);
3665 const char *gfc_dt_upper_string (const char *);
3667 /* primary.c */
3668 symbol_attribute gfc_variable_attr (gfc_expr *, gfc_typespec *);
3669 symbol_attribute gfc_expr_attr (gfc_expr *);
3670 symbol_attribute gfc_caf_attr (gfc_expr *, bool i = false, bool *r = NULL);
3671 match gfc_match_rvalue (gfc_expr **);
3672 match gfc_match_varspec (gfc_expr*, int, bool, bool);
3673 int gfc_check_digit (char, int);
3674 bool gfc_is_function_return_value (gfc_symbol *, gfc_namespace *);
3675 bool gfc_convert_to_structure_constructor (gfc_expr *, gfc_symbol *,
3676 gfc_expr **,
3677 gfc_actual_arglist **, bool);
3679 /* trans.c */
3680 void gfc_generate_code (gfc_namespace *);
3681 void gfc_generate_module_code (gfc_namespace *);
3683 /* trans-intrinsic.c */
3684 bool gfc_inline_intrinsic_function_p (gfc_expr *);
3686 /* bbt.c */
3687 typedef int (*compare_fn) (void *, void *);
3688 void gfc_insert_bbt (void *, void *, compare_fn);
3689 void gfc_delete_bbt (void *, void *, compare_fn);
3691 /* dump-parse-tree.c */
3692 void gfc_dump_parse_tree (gfc_namespace *, FILE *);
3693 void gfc_dump_c_prototypes (gfc_namespace *, FILE *);
3694 void gfc_dump_external_c_prototypes (FILE *);
3695 void gfc_dump_global_symbols (FILE *);
3696 void debug (gfc_symbol *);
3697 void debug (gfc_expr *);
3699 /* parse.c */
3700 bool gfc_parse_file (void);
3701 void gfc_global_used (gfc_gsymbol *, locus *);
3702 gfc_namespace* gfc_build_block_ns (gfc_namespace *);
3704 /* dependency.c */
3705 int gfc_dep_compare_functions (gfc_expr *, gfc_expr *, bool);
3706 int gfc_dep_compare_expr (gfc_expr *, gfc_expr *);
3707 bool gfc_dep_difference (gfc_expr *, gfc_expr *, mpz_t *);
3709 /* check.c */
3710 bool gfc_check_same_strlen (const gfc_expr*, const gfc_expr*, const char*);
3711 bool gfc_calculate_transfer_sizes (gfc_expr*, gfc_expr*, gfc_expr*,
3712 size_t*, size_t*, size_t*);
3713 bool gfc_boz2int (gfc_expr *, int);
3714 bool gfc_boz2real (gfc_expr *, int);
3715 bool gfc_invalid_boz (const char *, locus *);
3716 bool gfc_invalid_null_arg (gfc_expr *);
3719 /* class.c */
3720 void gfc_fix_class_refs (gfc_expr *e);
3721 void gfc_add_component_ref (gfc_expr *, const char *);
3722 void gfc_add_class_array_ref (gfc_expr *);
3723 #define gfc_add_data_component(e) gfc_add_component_ref(e,"_data")
3724 #define gfc_add_vptr_component(e) gfc_add_component_ref(e,"_vptr")
3725 #define gfc_add_len_component(e) gfc_add_component_ref(e,"_len")
3726 #define gfc_add_hash_component(e) gfc_add_component_ref(e,"_hash")
3727 #define gfc_add_size_component(e) gfc_add_component_ref(e,"_size")
3728 #define gfc_add_def_init_component(e) gfc_add_component_ref(e,"_def_init")
3729 #define gfc_add_final_component(e) gfc_add_component_ref(e,"_final")
3730 bool gfc_is_class_array_ref (gfc_expr *, bool *);
3731 bool gfc_is_class_scalar_expr (gfc_expr *);
3732 bool gfc_is_class_container_ref (gfc_expr *e);
3733 gfc_expr *gfc_class_initializer (gfc_typespec *, gfc_expr *);
3734 unsigned int gfc_hash_value (gfc_symbol *);
3735 gfc_expr *gfc_get_len_component (gfc_expr *e, int);
3736 bool gfc_build_class_symbol (gfc_typespec *, symbol_attribute *,
3737 gfc_array_spec **);
3738 gfc_symbol *gfc_find_derived_vtab (gfc_symbol *);
3739 gfc_symbol *gfc_find_vtab (gfc_typespec *);
3740 gfc_symtree* gfc_find_typebound_proc (gfc_symbol*, bool*,
3741 const char*, bool, locus*);
3742 gfc_symtree* gfc_find_typebound_user_op (gfc_symbol*, bool*,
3743 const char*, bool, locus*);
3744 gfc_typebound_proc* gfc_find_typebound_intrinsic_op (gfc_symbol*, bool*,
3745 gfc_intrinsic_op, bool,
3746 locus*);
3747 gfc_symtree* gfc_get_tbp_symtree (gfc_symtree**, const char*);
3748 bool gfc_is_finalizable (gfc_symbol *, gfc_expr **);
3750 #define CLASS_DATA(sym) sym->ts.u.derived->components
3751 #define UNLIMITED_POLY(sym) \
3752 (sym != NULL && sym->ts.type == BT_CLASS \
3753 && CLASS_DATA (sym) \
3754 && CLASS_DATA (sym)->ts.u.derived \
3755 && CLASS_DATA (sym)->ts.u.derived->attr.unlimited_polymorphic)
3756 #define IS_CLASS_ARRAY(sym) \
3757 (sym->ts.type == BT_CLASS \
3758 && CLASS_DATA (sym) \
3759 && CLASS_DATA (sym)->attr.dimension \
3760 && !CLASS_DATA (sym)->attr.class_pointer)
3762 /* frontend-passes.c */
3764 void gfc_run_passes (gfc_namespace *);
3766 typedef int (*walk_code_fn_t) (gfc_code **, int *, void *);
3767 typedef int (*walk_expr_fn_t) (gfc_expr **, int *, void *);
3769 int gfc_dummy_code_callback (gfc_code **, int *, void *);
3770 int gfc_expr_walker (gfc_expr **, walk_expr_fn_t, void *);
3771 int gfc_code_walker (gfc_code **, walk_code_fn_t, walk_expr_fn_t, void *);
3772 bool gfc_has_dimen_vector_ref (gfc_expr *e);
3773 void gfc_check_externals (gfc_namespace *);
3774 bool gfc_fix_implicit_pure (gfc_namespace *);
3776 /* simplify.c */
3778 void gfc_convert_mpz_to_signed (mpz_t, int);
3779 gfc_expr *gfc_simplify_ieee_functions (gfc_expr *);
3780 bool gfc_is_size_zero_array (gfc_expr *);
3782 /* trans-array.c */
3784 bool gfc_is_reallocatable_lhs (gfc_expr *);
3786 /* trans-decl.c */
3788 void finish_oacc_declare (gfc_namespace *, gfc_symbol *, bool);
3789 void gfc_adjust_builtins (void);
3791 #endif /* GCC_GFORTRAN_H */