]>
Commit | Line | Data |
---|---|---|
6de9cd9a | 1 | /* gfortran header file |
ec378180 | 2 | Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, |
9fc4d79b | 3 | Inc. |
6de9cd9a DN |
4 | Contributed by Andy Vaught |
5 | ||
9fc4d79b | 6 | This file is part of GCC. |
6de9cd9a | 7 | |
9fc4d79b TS |
8 | GCC is free software; you can redistribute it and/or modify it under |
9 | the terms of the GNU General Public License as published by the Free | |
10 | Software Foundation; either version 2, or (at your option) any later | |
11 | version. | |
6de9cd9a | 12 | |
9fc4d79b TS |
13 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
14 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 | for more details. | |
6de9cd9a DN |
17 | |
18 | You should have received a copy of the GNU General Public License | |
9fc4d79b | 19 | along with GCC; see the file COPYING. If not, write to the Free |
ab57747b KC |
20 | Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA |
21 | 02110-1301, USA. */ | |
6de9cd9a DN |
22 | |
23 | #ifndef GCC_GFORTRAN_H | |
24 | #define GCC_GFORTRAN_H | |
25 | ||
26 | /* It's probably insane to have this large of a header file, but it | |
27 | seemed like everything had to be recompiled anyway when a change | |
28 | was made to a header file, and there were ordering issues with | |
29 | multiple header files. Besides, Microsoft's winnt.h was 250k last | |
30 | time I looked, so by comparison this is perfectly reasonable. */ | |
31 | ||
6de9cd9a DN |
32 | #include "system.h" |
33 | #include "coretypes.h" | |
c8cc8542 | 34 | #include "input.h" |
6de9cd9a DN |
35 | |
36 | /* The following ifdefs are recommended by the autoconf documentation | |
37 | for any code using alloca. */ | |
38 | ||
39 | /* AIX requires this to be the first thing in the file. */ | |
40 | #ifdef __GNUC__ | |
41 | #else /* not __GNUC__ */ | |
42 | #ifdef HAVE_ALLOCA_H | |
43 | #include <alloca.h> | |
44 | #else /* do not HAVE_ALLOCA_H */ | |
45 | #ifdef _AIX | |
46 | #pragma alloca | |
47 | #else | |
48 | #ifndef alloca /* predefined by HP cc +Olibcalls */ | |
49 | char *alloca (); | |
50 | #endif /* not predefined */ | |
51 | #endif /* not _AIX */ | |
52 | #endif /* do not HAVE_ALLOCA_H */ | |
53 | #endif /* not __GNUC__ */ | |
54 | ||
6de9cd9a DN |
55 | /* Major control parameters. */ |
56 | ||
6de9cd9a | 57 | #define GFC_MAX_SYMBOL_LEN 63 |
6de9cd9a DN |
58 | #define GFC_MAX_LINE 132 /* Characters beyond this are not seen. */ |
59 | #define GFC_MAX_DIMENSIONS 7 /* Maximum dimensions in an array. */ | |
60 | #define GFC_LETTERS 26 /* Number of letters in the alphabet. */ | |
6de9cd9a DN |
61 | |
62 | #define free(x) Use_gfc_free_instead_of_free() | |
63 | #define gfc_is_whitespace(c) ((c==' ') || (c=='\t')) | |
64 | ||
65 | #ifndef NULL | |
66 | #define NULL ((void *) 0) | |
67 | #endif | |
68 | ||
69 | /* Stringization. */ | |
70 | #define stringize(x) expand_macro(x) | |
71 | #define expand_macro(x) # x | |
72 | ||
73 | /* For a the runtime library, a standard prefix is a requirement to | |
74 | avoid cluttering the namespace with things nobody asked for. It's | |
75 | ugly to look at and a pain to type when you add the prefix by hand, | |
76 | so we hide it behind a macro. */ | |
77 | #define PREFIX(x) "_gfortran_" x | |
5b200ac2 | 78 | #define PREFIX_LEN 10 |
6de9cd9a DN |
79 | |
80 | /* Macro to initialize an mstring structure. */ | |
81 | #define minit(s, t) { s, NULL, t } | |
82 | ||
83 | /* Structure for storing strings to be matched by gfc_match_string. */ | |
84 | typedef struct | |
85 | { | |
86 | const char *string; | |
87 | const char *mp; | |
88 | int tag; | |
89 | } | |
90 | mstring; | |
91 | ||
92 | ||
902c2ed4 | 93 | /* Flags to specify which standard/extension contains a feature. */ |
c0309c74 RS |
94 | #define GFC_STD_LEGACY (1<<6) /* Backward compatibility. */ |
95 | #define GFC_STD_GNU (1<<5) /* GNU Fortran extension. */ | |
96 | #define GFC_STD_F2003 (1<<4) /* New in F2003. */ | |
f7b529fa | 97 | /* Note that no features were obsoleted nor deleted in F2003. */ |
c0309c74 RS |
98 | #define GFC_STD_F95 (1<<3) /* New in F95. */ |
99 | #define GFC_STD_F95_DEL (1<<2) /* Deleted in F95. */ | |
100 | #define GFC_STD_F95_OBS (1<<1) /* Obsoleted in F95. */ | |
101 | #define GFC_STD_F77 (1<<0) /* Up to and including F77. */ | |
6de9cd9a DN |
102 | |
103 | /*************************** Enums *****************************/ | |
104 | ||
105 | /* The author remains confused to this day about the convention of | |
106 | returning '0' for 'SUCCESS'... or was it the other way around? The | |
107 | following enum makes things much more readable. We also start | |
108 | values off at one instead of zero. */ | |
109 | ||
110 | typedef enum | |
111 | { SUCCESS = 1, FAILURE } | |
112 | try; | |
113 | ||
114 | /* Matchers return one of these three values. The difference between | |
115 | MATCH_NO and MATCH_ERROR is that MATCH_ERROR means that a match was | |
116 | successful, but that something non-syntactic is wrong and an error | |
117 | has already been issued. */ | |
118 | ||
119 | typedef enum | |
120 | { MATCH_NO = 1, MATCH_YES, MATCH_ERROR } | |
121 | match; | |
122 | ||
123 | typedef enum | |
124 | { FORM_FREE, FORM_FIXED, FORM_UNKNOWN } | |
125 | gfc_source_form; | |
126 | ||
127 | typedef enum | |
128 | { BT_UNKNOWN = 1, BT_INTEGER, BT_REAL, BT_COMPLEX, | |
d3642f89 | 129 | BT_LOGICAL, BT_CHARACTER, BT_DERIVED, BT_PROCEDURE, BT_HOLLERITH |
6de9cd9a DN |
130 | } |
131 | bt; | |
132 | ||
133 | /* Expression node types. */ | |
134 | typedef enum | |
135 | { EXPR_OP = 1, EXPR_FUNCTION, EXPR_CONSTANT, EXPR_VARIABLE, | |
136 | EXPR_SUBSTRING, EXPR_STRUCTURE, EXPR_ARRAY, EXPR_NULL | |
137 | } | |
138 | expr_t; | |
139 | ||
140 | /* Array types. */ | |
141 | typedef enum | |
142 | { AS_EXPLICIT = 1, AS_ASSUMED_SHAPE, AS_DEFERRED, | |
143 | AS_ASSUMED_SIZE, AS_UNKNOWN | |
144 | } | |
145 | array_type; | |
146 | ||
147 | typedef enum | |
148 | { AR_FULL = 1, AR_ELEMENT, AR_SECTION, AR_UNKNOWN } | |
149 | ar_type; | |
150 | ||
151 | /* Statement label types. */ | |
152 | typedef enum | |
153 | { ST_LABEL_UNKNOWN = 1, ST_LABEL_TARGET, | |
154 | ST_LABEL_BAD_TARGET, ST_LABEL_FORMAT | |
155 | } | |
156 | gfc_sl_type; | |
157 | ||
158 | /* Intrinsic operators. */ | |
159 | typedef enum | |
160 | { GFC_INTRINSIC_BEGIN = 0, | |
161 | INTRINSIC_NONE = -1, INTRINSIC_UPLUS = GFC_INTRINSIC_BEGIN, | |
162 | INTRINSIC_UMINUS, INTRINSIC_PLUS, INTRINSIC_MINUS, INTRINSIC_TIMES, | |
163 | INTRINSIC_DIVIDE, INTRINSIC_POWER, INTRINSIC_CONCAT, | |
164 | INTRINSIC_AND, INTRINSIC_OR, INTRINSIC_EQV, INTRINSIC_NEQV, | |
165 | INTRINSIC_EQ, INTRINSIC_NE, INTRINSIC_GT, INTRINSIC_GE, | |
166 | INTRINSIC_LT, INTRINSIC_LE, INTRINSIC_NOT, INTRINSIC_USER, | |
167 | INTRINSIC_ASSIGN, | |
168 | GFC_INTRINSIC_END /* Sentinel */ | |
169 | } | |
170 | gfc_intrinsic_op; | |
171 | ||
172 | ||
173 | /* Strings for all intrinsic operators. */ | |
174 | extern mstring intrinsic_operators[]; | |
175 | ||
176 | ||
177 | /* This macro is the number of intrinsic operators that exist. | |
178 | Assumptions are made about the numbering of the interface_op enums. */ | |
179 | #define GFC_INTRINSIC_OPS GFC_INTRINSIC_END | |
180 | ||
181 | /* Arithmetic results. */ | |
182 | typedef enum | |
f8e566e5 | 183 | { ARITH_OK = 1, ARITH_OVERFLOW, ARITH_UNDERFLOW, ARITH_NAN, |
0de27aac | 184 | ARITH_DIV0, ARITH_INCOMMENSURATE, ARITH_ASYMMETRIC |
6de9cd9a DN |
185 | } |
186 | arith; | |
187 | ||
188 | /* Statements. */ | |
189 | typedef enum | |
190 | { | |
191 | ST_ARITHMETIC_IF, ST_ALLOCATE, ST_ATTR_DECL, ST_BACKSPACE, ST_BLOCK_DATA, | |
192 | ST_CALL, ST_CASE, ST_CLOSE, ST_COMMON, ST_CONTINUE, ST_CONTAINS, ST_CYCLE, | |
193 | ST_DATA, ST_DATA_DECL, ST_DEALLOCATE, ST_DO, ST_ELSE, ST_ELSEIF, | |
194 | ST_ELSEWHERE, ST_END_BLOCK_DATA, ST_ENDDO, ST_IMPLIED_ENDDO, | |
6403ec5f JB |
195 | ST_END_FILE, ST_FLUSH, ST_END_FORALL, ST_END_FUNCTION, ST_ENDIF, |
196 | ST_END_INTERFACE, ST_END_MODULE, ST_END_PROGRAM, ST_END_SELECT, | |
197 | ST_END_SUBROUTINE, ST_END_WHERE, ST_END_TYPE, ST_ENTRY, ST_EQUIVALENCE, | |
198 | ST_EXIT, ST_FORALL, ST_FORALL_BLOCK, ST_FORMAT, ST_FUNCTION, ST_GOTO, | |
199 | ST_IF_BLOCK, ST_IMPLICIT, ST_IMPLICIT_NONE, ST_INQUIRE, ST_INTERFACE, | |
200 | ST_PARAMETER, ST_MODULE, ST_MODULE_PROC, ST_NAMELIST, ST_NULLIFY, ST_OPEN, | |
201 | ST_PAUSE, ST_PRIVATE, ST_PROGRAM, ST_PUBLIC, ST_READ, ST_RETURN, ST_REWIND, | |
202 | ST_STOP, ST_SUBROUTINE, ST_TYPE, ST_USE, ST_WHERE_BLOCK, ST_WHERE, ST_WRITE, | |
203 | ST_ASSIGNMENT, ST_POINTER_ASSIGNMENT, ST_SELECT_CASE, ST_SEQUENCE, | |
204 | ST_SIMPLE_IF, ST_STATEMENT_FUNCTION, ST_DERIVED_DECL, ST_LABEL_ASSIGNMENT, | |
205 | ST_NONE | |
6de9cd9a DN |
206 | } |
207 | gfc_statement; | |
208 | ||
209 | ||
210 | /* Types of interfaces that we can have. Assignment interfaces are | |
211 | considered to be intrinsic operators. */ | |
212 | typedef enum | |
213 | { | |
214 | INTERFACE_NAMELESS = 1, INTERFACE_GENERIC, | |
215 | INTERFACE_INTRINSIC_OP, INTERFACE_USER_OP | |
216 | } | |
217 | interface_type; | |
218 | ||
219 | /* Symbol flavors: these are all mutually exclusive. | |
220 | 10 elements = 4 bits. */ | |
5f42ddb0 | 221 | typedef enum sym_flavor |
6de9cd9a DN |
222 | { |
223 | FL_UNKNOWN = 0, FL_PROGRAM, FL_BLOCK_DATA, FL_MODULE, FL_VARIABLE, | |
224 | FL_PARAMETER, FL_LABEL, FL_PROCEDURE, FL_DERIVED, FL_NAMELIST | |
225 | } | |
226 | sym_flavor; | |
227 | ||
228 | /* Procedure types. 7 elements = 3 bits. */ | |
5f42ddb0 | 229 | typedef enum procedure_type |
6de9cd9a DN |
230 | { PROC_UNKNOWN, PROC_MODULE, PROC_INTERNAL, PROC_DUMMY, |
231 | PROC_INTRINSIC, PROC_ST_FUNCTION, PROC_EXTERNAL | |
232 | } | |
233 | procedure_type; | |
234 | ||
235 | /* Intent types. */ | |
5f42ddb0 | 236 | typedef enum sym_intent |
6de9cd9a DN |
237 | { INTENT_UNKNOWN = 0, INTENT_IN, INTENT_OUT, INTENT_INOUT |
238 | } | |
239 | sym_intent; | |
240 | ||
241 | /* Access types. */ | |
5f42ddb0 KG |
242 | typedef enum gfc_access |
243 | { ACCESS_UNKNOWN = 0, ACCESS_PUBLIC, ACCESS_PRIVATE | |
6de9cd9a DN |
244 | } |
245 | gfc_access; | |
246 | ||
247 | /* Flags to keep track of where an interface came from. | |
248 | 4 elements = 2 bits. */ | |
5f42ddb0 | 249 | typedef enum ifsrc |
6de9cd9a DN |
250 | { IFSRC_UNKNOWN = 0, IFSRC_DECL, IFSRC_IFBODY, IFSRC_USAGE |
251 | } | |
252 | ifsrc; | |
253 | ||
254 | /* Strings for all symbol attributes. We use these for dumping the | |
255 | parse tree, in error messages, and also when reading and writing | |
256 | modules. In symbol.c. */ | |
257 | extern const mstring flavors[]; | |
258 | extern const mstring procedures[]; | |
259 | extern const mstring intents[]; | |
260 | extern const mstring access_types[]; | |
261 | extern const mstring ifsrc_types[]; | |
262 | ||
263 | /* Enumeration of all the generic intrinsic functions. Used by the | |
264 | backend for identification of a function. */ | |
265 | ||
266 | enum gfc_generic_isym_id | |
267 | { | |
268 | /* GFC_ISYM_NONE is used for intrinsics which will never be seen by | |
269 | the backend (eg. KIND). */ | |
270 | GFC_ISYM_NONE = 0, | |
271 | GFC_ISYM_ABS, | |
272 | GFC_ISYM_ACHAR, | |
273 | GFC_ISYM_ACOS, | |
1e399e23 | 274 | GFC_ISYM_ACOSH, |
6de9cd9a DN |
275 | GFC_ISYM_ADJUSTL, |
276 | GFC_ISYM_ADJUSTR, | |
277 | GFC_ISYM_AIMAG, | |
278 | GFC_ISYM_AINT, | |
279 | GFC_ISYM_ALL, | |
280 | GFC_ISYM_ALLOCATED, | |
281 | GFC_ISYM_ANINT, | |
282 | GFC_ISYM_ANY, | |
283 | GFC_ISYM_ASIN, | |
1e399e23 | 284 | GFC_ISYM_ASINH, |
6de9cd9a DN |
285 | GFC_ISYM_ASSOCIATED, |
286 | GFC_ISYM_ATAN, | |
1e399e23 | 287 | GFC_ISYM_ATANH, |
6de9cd9a | 288 | GFC_ISYM_ATAN2, |
e8525382 SK |
289 | GFC_ISYM_J0, |
290 | GFC_ISYM_J1, | |
291 | GFC_ISYM_JN, | |
292 | GFC_ISYM_Y0, | |
293 | GFC_ISYM_Y1, | |
294 | GFC_ISYM_YN, | |
6de9cd9a DN |
295 | GFC_ISYM_BTEST, |
296 | GFC_ISYM_CEILING, | |
297 | GFC_ISYM_CHAR, | |
f77b6ca3 | 298 | GFC_ISYM_CHDIR, |
6de9cd9a | 299 | GFC_ISYM_CMPLX, |
b41b2534 | 300 | GFC_ISYM_COMMAND_ARGUMENT_COUNT, |
6de9cd9a DN |
301 | GFC_ISYM_CONJG, |
302 | GFC_ISYM_COS, | |
303 | GFC_ISYM_COSH, | |
304 | GFC_ISYM_COUNT, | |
305 | GFC_ISYM_CSHIFT, | |
306 | GFC_ISYM_DBLE, | |
307 | GFC_ISYM_DIM, | |
308 | GFC_ISYM_DOT_PRODUCT, | |
309 | GFC_ISYM_DPROD, | |
310 | GFC_ISYM_EOSHIFT, | |
e8525382 SK |
311 | GFC_ISYM_ERF, |
312 | GFC_ISYM_ERFC, | |
2bd74949 | 313 | GFC_ISYM_ETIME, |
6de9cd9a DN |
314 | GFC_ISYM_EXP, |
315 | GFC_ISYM_EXPONENT, | |
316 | GFC_ISYM_FLOOR, | |
df65f093 | 317 | GFC_ISYM_FNUM, |
6de9cd9a | 318 | GFC_ISYM_FRACTION, |
df65f093 | 319 | GFC_ISYM_FSTAT, |
a8c60d7f | 320 | GFC_ISYM_GETCWD, |
4c0c6b9f SK |
321 | GFC_ISYM_GETGID, |
322 | GFC_ISYM_GETPID, | |
323 | GFC_ISYM_GETUID, | |
f77b6ca3 | 324 | GFC_ISYM_HOSTNM, |
6de9cd9a DN |
325 | GFC_ISYM_IACHAR, |
326 | GFC_ISYM_IAND, | |
b41b2534 | 327 | GFC_ISYM_IARGC, |
6de9cd9a DN |
328 | GFC_ISYM_IBCLR, |
329 | GFC_ISYM_IBITS, | |
330 | GFC_ISYM_IBSET, | |
331 | GFC_ISYM_ICHAR, | |
332 | GFC_ISYM_IEOR, | |
f77b6ca3 | 333 | GFC_ISYM_IERRNO, |
6de9cd9a DN |
334 | GFC_ISYM_INDEX, |
335 | GFC_ISYM_INT, | |
336 | GFC_ISYM_IOR, | |
2bd74949 | 337 | GFC_ISYM_IRAND, |
ae8b8789 | 338 | GFC_ISYM_ISATTY, |
6de9cd9a DN |
339 | GFC_ISYM_ISHFT, |
340 | GFC_ISYM_ISHFTC, | |
f77b6ca3 | 341 | GFC_ISYM_KILL, |
6de9cd9a DN |
342 | GFC_ISYM_LBOUND, |
343 | GFC_ISYM_LEN, | |
344 | GFC_ISYM_LEN_TRIM, | |
f77b6ca3 | 345 | GFC_ISYM_LINK, |
6de9cd9a DN |
346 | GFC_ISYM_LGE, |
347 | GFC_ISYM_LGT, | |
348 | GFC_ISYM_LLE, | |
349 | GFC_ISYM_LLT, | |
350 | GFC_ISYM_LOG, | |
351 | GFC_ISYM_LOG10, | |
352 | GFC_ISYM_LOGICAL, | |
353 | GFC_ISYM_MATMUL, | |
354 | GFC_ISYM_MAX, | |
355 | GFC_ISYM_MAXLOC, | |
356 | GFC_ISYM_MAXVAL, | |
357 | GFC_ISYM_MERGE, | |
358 | GFC_ISYM_MIN, | |
359 | GFC_ISYM_MINLOC, | |
360 | GFC_ISYM_MINVAL, | |
361 | GFC_ISYM_MOD, | |
362 | GFC_ISYM_MODULO, | |
363 | GFC_ISYM_NEAREST, | |
364 | GFC_ISYM_NINT, | |
365 | GFC_ISYM_NOT, | |
366 | GFC_ISYM_PACK, | |
367 | GFC_ISYM_PRESENT, | |
368 | GFC_ISYM_PRODUCT, | |
2bd74949 | 369 | GFC_ISYM_RAND, |
6de9cd9a | 370 | GFC_ISYM_REAL, |
f77b6ca3 | 371 | GFC_ISYM_RENAME, |
6de9cd9a DN |
372 | GFC_ISYM_REPEAT, |
373 | GFC_ISYM_RESHAPE, | |
374 | GFC_ISYM_RRSPACING, | |
375 | GFC_ISYM_SCALE, | |
376 | GFC_ISYM_SCAN, | |
2bd74949 | 377 | GFC_ISYM_SECOND, |
6de9cd9a DN |
378 | GFC_ISYM_SET_EXPONENT, |
379 | GFC_ISYM_SHAPE, | |
380 | GFC_ISYM_SI_KIND, | |
381 | GFC_ISYM_SIGN, | |
382 | GFC_ISYM_SIN, | |
383 | GFC_ISYM_SINH, | |
384 | GFC_ISYM_SIZE, | |
385 | GFC_ISYM_SPACING, | |
386 | GFC_ISYM_SPREAD, | |
387 | GFC_ISYM_SQRT, | |
388 | GFC_ISYM_SR_KIND, | |
df65f093 | 389 | GFC_ISYM_STAT, |
6de9cd9a | 390 | GFC_ISYM_SUM, |
f77b6ca3 | 391 | GFC_ISYM_SYMLNK, |
5b1374e9 | 392 | GFC_ISYM_SYSTEM, |
6de9cd9a DN |
393 | GFC_ISYM_TAN, |
394 | GFC_ISYM_TANH, | |
f77b6ca3 FXC |
395 | GFC_ISYM_TIME, |
396 | GFC_ISYM_TIME8, | |
6de9cd9a DN |
397 | GFC_ISYM_TRANSFER, |
398 | GFC_ISYM_TRANSPOSE, | |
399 | GFC_ISYM_TRIM, | |
400 | GFC_ISYM_UBOUND, | |
d8fe26b2 SK |
401 | GFC_ISYM_UMASK, |
402 | GFC_ISYM_UNLINK, | |
6de9cd9a DN |
403 | GFC_ISYM_UNPACK, |
404 | GFC_ISYM_VERIFY, | |
405 | GFC_ISYM_CONVERSION | |
406 | }; | |
407 | typedef enum gfc_generic_isym_id gfc_generic_isym_id; | |
408 | ||
409 | /************************* Structures *****************************/ | |
410 | ||
411 | /* Symbol attribute structure. */ | |
412 | typedef struct | |
413 | { | |
414 | /* Variable attributes. */ | |
415 | unsigned allocatable:1, dimension:1, external:1, intrinsic:1, | |
416 | optional:1, pointer:1, save:1, target:1, | |
3d79abbd | 417 | dummy:1, result:1, assign:1; |
6de9cd9a DN |
418 | |
419 | unsigned data:1, /* Symbol is named in a DATA statement. */ | |
420 | use_assoc:1; /* Symbol has been use-associated. */ | |
421 | ||
9056bd70 | 422 | unsigned in_namelist:1, in_common:1; |
6de9cd9a | 423 | unsigned function:1, subroutine:1, generic:1; |
d1303acd TS |
424 | unsigned implicit_type:1; /* Type defined via implicit rules. */ |
425 | unsigned untyped:1; /* No implicit type could be found. */ | |
6de9cd9a DN |
426 | |
427 | /* Function/subroutine attributes */ | |
428 | unsigned sequence:1, elemental:1, pure:1, recursive:1; | |
429 | unsigned unmaskable:1, masked:1, contained:1; | |
430 | ||
fe58e076 TK |
431 | /* This is set if the subroutine doesn't return. Currently, this |
432 | is only possible for intrinsic subroutines. */ | |
433 | unsigned noreturn:1; | |
434 | ||
3d79abbd PB |
435 | /* Set if this procedure is an alternate entry point. These procedures |
436 | don't have any code associated, and the backend will turn them into | |
437 | thunks to the master function. */ | |
438 | unsigned entry:1; | |
8b67b708 | 439 | |
3d79abbd PB |
440 | /* Set if this is the master function for a procedure with multiple |
441 | entry points. */ | |
442 | unsigned entry_master:1; | |
8b67b708 | 443 | |
d198b59a JJ |
444 | /* Set if this is the master function for a function with multiple |
445 | entry points where characteristics of the entry points differ. */ | |
446 | unsigned mixed_entry_master:1; | |
3d79abbd | 447 | |
6de9cd9a DN |
448 | /* Set if a function must always be referenced by an explicit interface. */ |
449 | unsigned always_explicit:1; | |
450 | ||
451 | /* Set if the symbol has been referenced in an expression. No further | |
452 | modification of type or type parameters is permitted. */ | |
453 | unsigned referenced:1; | |
454 | ||
8b67b708 FXC |
455 | /* Set if the is the symbol for the main program. This is the least |
456 | cumbersome way to communicate this function property without | |
457 | strcmp'ing with __MAIN everywhere. */ | |
458 | unsigned is_main_program:1; | |
459 | ||
6de9cd9a | 460 | /* Mutually exclusive multibit attributes. */ |
5f42ddb0 KG |
461 | ENUM_BITFIELD (gfc_access) access:2; |
462 | ENUM_BITFIELD (sym_intent) intent:2; | |
463 | ENUM_BITFIELD (sym_flavor) flavor:4; | |
464 | ENUM_BITFIELD (ifsrc) if_source:2; | |
6de9cd9a | 465 | |
5f42ddb0 | 466 | ENUM_BITFIELD (procedure_type) proc:3; |
6de9cd9a DN |
467 | |
468 | } | |
469 | symbol_attribute; | |
470 | ||
471 | ||
d4fa05b9 TS |
472 | /* The following three structures are used to identify a location in |
473 | the sources. | |
474 | ||
475 | gfc_file is used to maintain a tree of the source files and how | |
476 | they include each other | |
6de9cd9a | 477 | |
d4fa05b9 TS |
478 | gfc_linebuf holds a single line of source code and information |
479 | which file it resides in | |
6de9cd9a | 480 | |
d4fa05b9 TS |
481 | locus point to the sourceline and the character in the source |
482 | line. | |
483 | */ | |
6de9cd9a | 484 | |
d4fa05b9 | 485 | typedef struct gfc_file |
6de9cd9a | 486 | { |
d4fa05b9 TS |
487 | struct gfc_file *included_by, *next, *up; |
488 | int inclusion_line, line; | |
489 | char *filename; | |
490 | } gfc_file; | |
491 | ||
492 | typedef struct gfc_linebuf | |
493 | { | |
c8cc8542 PB |
494 | #ifdef USE_MAPPED_LOCATION |
495 | source_location location; | |
496 | #else | |
d4fa05b9 | 497 | int linenum; |
c8cc8542 | 498 | #endif |
d4fa05b9 TS |
499 | struct gfc_file *file; |
500 | struct gfc_linebuf *next; | |
501 | ||
ba1defa5 RG |
502 | int truncated; |
503 | ||
4cdf7223 | 504 | char line[1]; |
d4fa05b9 | 505 | } gfc_linebuf; |
4cdf7223 PB |
506 | |
507 | #define gfc_linebuf_header_size (offsetof (gfc_linebuf, line)) | |
508 | ||
d4fa05b9 TS |
509 | typedef struct |
510 | { | |
511 | char *nextc; | |
512 | gfc_linebuf *lb; | |
513 | } locus; | |
6de9cd9a | 514 | |
0ce0154c KG |
515 | /* In order for the "gfc" format checking to work correctly, you must |
516 | have declared a typedef locus first. */ | |
517 | #if GCC_VERSION >= 4001 | |
518 | #define ATTRIBUTE_GCC_GFC(m, n) __attribute__ ((__format__ (__gcc_gfc__, m, n))) ATTRIBUTE_NONNULL(m) | |
519 | #else | |
520 | #define ATTRIBUTE_GCC_GFC(m, n) ATTRIBUTE_NONNULL(m) | |
521 | #endif | |
522 | ||
6de9cd9a | 523 | |
6de9cd9a DN |
524 | extern int gfc_suppress_error; |
525 | ||
526 | ||
527 | /* Character length structures hold the expression that gives the | |
528 | length of a character variable. We avoid putting these into | |
529 | gfc_typespec because doing so prevents us from doing structure | |
530 | copies and forces us to deallocate any typespecs we create, as well | |
531 | as structures that contain typespecs. They also can have multiple | |
532 | character typespecs pointing to them. | |
533 | ||
534 | These structures form a singly linked list within the current | |
535 | namespace and are deallocated with the namespace. It is possible to | |
536 | end up with gfc_charlen structures that have nothing pointing to them. */ | |
537 | ||
538 | typedef struct gfc_charlen | |
539 | { | |
540 | struct gfc_expr *length; | |
541 | struct gfc_charlen *next; | |
542 | tree backend_decl; | |
543 | } | |
544 | gfc_charlen; | |
545 | ||
546 | #define gfc_get_charlen() gfc_getmem(sizeof(gfc_charlen)) | |
547 | ||
548 | /* Type specification structure. FIXME: derived and cl could be union??? */ | |
549 | typedef struct | |
550 | { | |
551 | bt type; | |
552 | int kind; | |
553 | struct gfc_symbol *derived; | |
554 | gfc_charlen *cl; /* For character types only. */ | |
555 | } | |
556 | gfc_typespec; | |
557 | ||
558 | /* Array specification. */ | |
559 | typedef struct | |
560 | { | |
561 | int rank; /* A rank of zero means that a variable is a scalar. */ | |
562 | array_type type; | |
563 | struct gfc_expr *lower[GFC_MAX_DIMENSIONS], *upper[GFC_MAX_DIMENSIONS]; | |
564 | } | |
565 | gfc_array_spec; | |
566 | ||
567 | #define gfc_get_array_spec() gfc_getmem(sizeof(gfc_array_spec)) | |
568 | ||
569 | ||
570 | /* Components of derived types. */ | |
571 | typedef struct gfc_component | |
572 | { | |
cb9e4f55 | 573 | const char *name; |
6de9cd9a DN |
574 | gfc_typespec ts; |
575 | ||
576 | int pointer, dimension; | |
577 | gfc_array_spec *as; | |
578 | ||
579 | tree backend_decl; | |
580 | locus loc; | |
581 | struct gfc_expr *initializer; | |
582 | struct gfc_component *next; | |
583 | } | |
584 | gfc_component; | |
585 | ||
586 | #define gfc_get_component() gfc_getmem(sizeof(gfc_component)) | |
587 | ||
588 | /* Formal argument lists are lists of symbols. */ | |
589 | typedef struct gfc_formal_arglist | |
590 | { | |
4f613946 | 591 | /* Symbol representing the argument at this position in the arglist. */ |
6de9cd9a | 592 | struct gfc_symbol *sym; |
4f613946 | 593 | /* Points to the next formal argument. */ |
6de9cd9a DN |
594 | struct gfc_formal_arglist *next; |
595 | } | |
596 | gfc_formal_arglist; | |
597 | ||
598 | #define gfc_get_formal_arglist() gfc_getmem(sizeof(gfc_formal_arglist)) | |
599 | ||
600 | ||
601 | /* The gfc_actual_arglist structure is for actual arguments. */ | |
602 | typedef struct gfc_actual_arglist | |
603 | { | |
cb9e4f55 | 604 | const char *name; |
6de9cd9a DN |
605 | /* Alternate return label when the expr member is null. */ |
606 | struct gfc_st_label *label; | |
607 | ||
1600fe22 TS |
608 | /* This is set to the type of an eventual omitted optional |
609 | argument. This is used to determine if a hidden string length | |
610 | argument has to be added to a function call. */ | |
611 | bt missing_arg_type; | |
612 | ||
6de9cd9a DN |
613 | struct gfc_expr *expr; |
614 | struct gfc_actual_arglist *next; | |
615 | } | |
616 | gfc_actual_arglist; | |
617 | ||
618 | #define gfc_get_actual_arglist() gfc_getmem(sizeof(gfc_actual_arglist)) | |
619 | ||
620 | ||
621 | /* Because a symbol can belong to multiple namelists, they must be | |
622 | linked externally to the symbol itself. */ | |
623 | typedef struct gfc_namelist | |
624 | { | |
625 | struct gfc_symbol *sym; | |
626 | struct gfc_namelist *next; | |
627 | } | |
628 | gfc_namelist; | |
629 | ||
630 | #define gfc_get_namelist() gfc_getmem(sizeof(gfc_namelist)) | |
631 | ||
632 | ||
633 | /* The gfc_st_label structure is a doubly linked list attached to a | |
634 | namespace that records the usage of statement labels within that | |
635 | space. */ | |
636 | /* TODO: Make format/statement specifics a union. */ | |
637 | typedef struct gfc_st_label | |
638 | { | |
639 | int value; | |
640 | ||
641 | gfc_sl_type defined, referenced; | |
642 | ||
643 | struct gfc_expr *format; | |
644 | ||
645 | tree backend_decl; | |
646 | ||
647 | locus where; | |
648 | ||
649 | struct gfc_st_label *prev, *next; | |
650 | } | |
651 | gfc_st_label; | |
652 | ||
653 | ||
654 | /* gfc_interface()-- Interfaces are lists of symbols strung together. */ | |
655 | typedef struct gfc_interface | |
656 | { | |
657 | struct gfc_symbol *sym; | |
658 | locus where; | |
659 | struct gfc_interface *next; | |
660 | } | |
661 | gfc_interface; | |
662 | ||
663 | #define gfc_get_interface() gfc_getmem(sizeof(gfc_interface)) | |
664 | ||
665 | ||
666 | /* User operator nodes. These are like stripped down symbols. */ | |
667 | typedef struct | |
668 | { | |
cb9e4f55 | 669 | const char *name; |
6de9cd9a DN |
670 | |
671 | gfc_interface *operator; | |
672 | struct gfc_namespace *ns; | |
673 | gfc_access access; | |
674 | } | |
675 | gfc_user_op; | |
676 | ||
677 | /* Symbol nodes. These are important things. They are what the | |
678 | standard refers to as "entities". The possibly multiple names that | |
679 | refer to the same entity are accomplished by a binary tree of | |
680 | symtree structures that is balanced by the red-black method-- more | |
681 | than one symtree node can point to any given symbol. */ | |
682 | ||
683 | typedef struct gfc_symbol | |
684 | { | |
cb9e4f55 TS |
685 | const char *name; /* Primary name, before renaming */ |
686 | const char *module; /* Module this symbol came from */ | |
6de9cd9a DN |
687 | locus declared_at; |
688 | ||
689 | gfc_typespec ts; | |
690 | symbol_attribute attr; | |
691 | ||
692 | /* The interface member points to the formal argument list if the | |
693 | symbol is a function or subroutine name. If the symbol is a | |
694 | generic name, the generic member points to the list of | |
695 | interfaces. */ | |
696 | ||
697 | gfc_interface *generic; | |
698 | gfc_access component_access; | |
699 | ||
700 | gfc_formal_arglist *formal; | |
701 | struct gfc_namespace *formal_ns; | |
702 | ||
703 | struct gfc_expr *value; /* Parameter/Initializer value */ | |
704 | gfc_array_spec *as; | |
705 | struct gfc_symbol *result; /* function result symbol */ | |
706 | gfc_component *components; /* Derived type components */ | |
707 | ||
9056bd70 | 708 | struct gfc_symbol *common_next; /* Links for COMMON syms */ |
6de9cd9a DN |
709 | /* Make sure setup code for dummy arguments is generated in the correct |
710 | order. */ | |
711 | int dummy_order; | |
712 | ||
713 | gfc_namelist *namelist, *namelist_tail; | |
714 | ||
715 | /* Change management fields. Symbols that might be modified by the | |
716 | current statement have the mark member nonzero and are kept in a | |
717 | singly linked list through the tlink field. Of these symbols, | |
718 | symbols with old_symbol equal to NULL are symbols created within | |
719 | the current statement. Otherwise, old_symbol points to a copy of | |
720 | the old symbol. */ | |
721 | ||
722 | struct gfc_symbol *old_symbol, *tlink; | |
723 | unsigned mark:1, new:1; | |
5291e69a PB |
724 | /* Nonzero if all equivalences associated with this symbol have been |
725 | processed. */ | |
726 | unsigned equiv_built:1; | |
6de9cd9a DN |
727 | int refs; |
728 | struct gfc_namespace *ns; /* namespace containing this symbol */ | |
729 | ||
730 | tree backend_decl; | |
6de9cd9a DN |
731 | } |
732 | gfc_symbol; | |
733 | ||
734 | ||
9056bd70 TS |
735 | /* This structure is used to keep track of symbols in common blocks. */ |
736 | ||
737 | typedef struct | |
738 | { | |
739 | locus where; | |
740 | int use_assoc, saved; | |
53814b8f | 741 | char name[GFC_MAX_SYMBOL_LEN + 1]; |
9056bd70 TS |
742 | gfc_symbol *head; |
743 | } | |
744 | gfc_common_head; | |
745 | ||
746 | #define gfc_get_common_head() gfc_getmem(sizeof(gfc_common_head)) | |
747 | ||
748 | ||
3d79abbd PB |
749 | /* A list of all the alternate entry points for a procedure. */ |
750 | ||
751 | typedef struct gfc_entry_list | |
752 | { | |
753 | /* The symbol for this entry point. */ | |
754 | gfc_symbol *sym; | |
755 | /* The zero-based id of this entry point. */ | |
756 | int id; | |
757 | /* The LABEL_EXPR marking this entry point. */ | |
758 | tree label; | |
759 | /* The nest item in the list. */ | |
760 | struct gfc_entry_list *next; | |
761 | } | |
762 | gfc_entry_list; | |
763 | ||
764 | #define gfc_get_entry_list() \ | |
765 | (gfc_entry_list *) gfc_getmem(sizeof(gfc_entry_list)) | |
9056bd70 | 766 | |
6de9cd9a DN |
767 | /* Within a namespace, symbols are pointed to by symtree nodes that |
768 | are linked together in a balanced binary tree. There can be | |
769 | several symtrees pointing to the same symbol node via USE | |
770 | statements. */ | |
771 | ||
772 | #define BBT_HEADER(self) int priority; struct self *left, *right | |
773 | ||
774 | typedef struct gfc_symtree | |
775 | { | |
776 | BBT_HEADER (gfc_symtree); | |
cb9e4f55 | 777 | const char *name; |
6de9cd9a DN |
778 | int ambiguous; |
779 | union | |
780 | { | |
781 | gfc_symbol *sym; /* Symbol associated with this node */ | |
782 | gfc_user_op *uop; | |
9056bd70 | 783 | gfc_common_head *common; |
6de9cd9a DN |
784 | } |
785 | n; | |
786 | ||
787 | } | |
788 | gfc_symtree; | |
789 | ||
790 | ||
3d79abbd PB |
791 | /* A namespace describes the contents of procedure, module or |
792 | interface block. */ | |
793 | /* ??? Anything else use these? */ | |
794 | ||
6de9cd9a DN |
795 | typedef struct gfc_namespace |
796 | { | |
4f613946 TS |
797 | /* Tree containing all the symbols in this namespace. */ |
798 | gfc_symtree *sym_root; | |
799 | /* Tree containing all the user-defined operators in the namespace. */ | |
800 | gfc_symtree *uop_root; | |
801 | /* Tree containing all the common blocks. */ | |
802 | gfc_symtree *common_root; | |
6de9cd9a | 803 | |
4f613946 | 804 | /* If set_flag[letter] is set, an implicit type has been set for letter. */ |
6de9cd9a | 805 | int set_flag[GFC_LETTERS]; |
4f613946 TS |
806 | /* Keeps track of the implicit types associated with the letters. */ |
807 | gfc_typespec default_type[GFC_LETTERS]; | |
6de9cd9a | 808 | |
4f613946 | 809 | /* If this is a namespace of a procedure, this points to the procedure. */ |
6de9cd9a | 810 | struct gfc_symbol *proc_name; |
4f613946 TS |
811 | /* If this is the namespace of a unit which contains executable |
812 | code, this points to it. */ | |
6de9cd9a | 813 | struct gfc_code *code; |
4f613946 TS |
814 | |
815 | /* Points to the equivalences set up in this namespace. */ | |
6de9cd9a | 816 | struct gfc_equiv *equiv; |
4f613946 TS |
817 | gfc_interface *operator[GFC_INTRINSIC_OPS]; |
818 | ||
819 | /* Points to the parent namespace, i.e. the namespace of a module or | |
820 | procedure in which the procedure belonging to this namespace is | |
821 | contained. The parent namespace points to this namespace either | |
822 | directly via CONTAINED, or indirectly via the chain built by | |
823 | SIBLING. */ | |
824 | struct gfc_namespace *parent; | |
825 | /* CONTAINED points to the first contained namespace. Sibling | |
826 | namespaces are chained via SIBLING. */ | |
827 | struct gfc_namespace *contained, *sibling; | |
828 | ||
829 | gfc_common_head blank_common; | |
6de9cd9a DN |
830 | gfc_access default_access, operator_access[GFC_INTRINSIC_OPS]; |
831 | ||
832 | gfc_st_label *st_labels; | |
294fbfc8 TS |
833 | /* This list holds information about all the data initializers in |
834 | this namespace. */ | |
6de9cd9a DN |
835 | struct gfc_data *data; |
836 | ||
837 | gfc_charlen *cl_list; | |
838 | ||
4c1f4f52 | 839 | int save_all, seen_save, seen_implicit_none; |
3d79abbd PB |
840 | |
841 | /* Normally we don't need to refcount namespaces. However when we read | |
842 | a module containing a function with multiple entry points, this | |
843 | will appear as several functions with the same formal namespace. */ | |
844 | int refs; | |
845 | ||
846 | /* A list of all alternate entry points to this procedure (or NULL). */ | |
847 | gfc_entry_list *entries; | |
0de4325e TS |
848 | |
849 | /* Set to 1 if namespace is a BLOCK DATA program unit. */ | |
850 | int is_block_data; | |
6de9cd9a DN |
851 | } |
852 | gfc_namespace; | |
853 | ||
854 | extern gfc_namespace *gfc_current_ns; | |
855 | ||
c9543002 TS |
856 | /* Global symbols are symbols of global scope. Currently we only use |
857 | this to detect collisions already when parsing. | |
858 | TODO: Extend to verify procedure calls. */ | |
859 | ||
860 | typedef struct gfc_gsymbol | |
861 | { | |
862 | BBT_HEADER(gfc_gsymbol); | |
863 | ||
973a384d | 864 | const char *name; |
c9543002 TS |
865 | enum { GSYM_UNKNOWN=1, GSYM_PROGRAM, GSYM_FUNCTION, GSYM_SUBROUTINE, |
866 | GSYM_MODULE, GSYM_COMMON, GSYM_BLOCK_DATA } type; | |
867 | ||
868 | int defined, used; | |
869 | locus where; | |
870 | } | |
871 | gfc_gsymbol; | |
872 | ||
873 | extern gfc_gsymbol *gfc_gsym_root; | |
6de9cd9a DN |
874 | |
875 | /* Information on interfaces being built. */ | |
876 | typedef struct | |
877 | { | |
878 | interface_type type; | |
879 | gfc_symbol *sym; | |
880 | gfc_namespace *ns; | |
881 | gfc_user_op *uop; | |
882 | gfc_intrinsic_op op; | |
883 | } | |
884 | gfc_interface_info; | |
885 | ||
886 | extern gfc_interface_info current_interface; | |
887 | ||
888 | ||
889 | /* Array reference. */ | |
890 | typedef struct gfc_array_ref | |
891 | { | |
892 | ar_type type; | |
893 | int dimen; /* # of components in the reference */ | |
894 | locus where; | |
895 | gfc_array_spec *as; | |
896 | ||
897 | locus c_where[GFC_MAX_DIMENSIONS]; /* All expressions can be NULL */ | |
898 | struct gfc_expr *start[GFC_MAX_DIMENSIONS], *end[GFC_MAX_DIMENSIONS], | |
899 | *stride[GFC_MAX_DIMENSIONS]; | |
900 | ||
901 | enum | |
902 | { DIMEN_ELEMENT = 1, DIMEN_RANGE, DIMEN_VECTOR, DIMEN_UNKNOWN } | |
903 | dimen_type[GFC_MAX_DIMENSIONS]; | |
904 | ||
905 | struct gfc_expr *offset; | |
906 | } | |
907 | gfc_array_ref; | |
908 | ||
909 | #define gfc_get_array_ref() gfc_getmem(sizeof(gfc_array_ref)) | |
910 | ||
911 | ||
912 | /* Component reference nodes. A variable is stored as an expression | |
913 | node that points to the base symbol. After that, a singly linked | |
914 | list of component reference nodes gives the variable's complete | |
915 | resolution. The array_ref component may be present and comes | |
916 | before the component component. */ | |
917 | ||
918 | typedef enum | |
919 | { REF_ARRAY, REF_COMPONENT, REF_SUBSTRING } | |
920 | ref_type; | |
921 | ||
922 | typedef struct gfc_ref | |
923 | { | |
924 | ref_type type; | |
925 | ||
926 | union | |
927 | { | |
928 | struct gfc_array_ref ar; | |
929 | ||
930 | struct | |
931 | { | |
932 | gfc_component *component; | |
933 | gfc_symbol *sym; | |
934 | } | |
935 | c; | |
936 | ||
937 | struct | |
938 | { | |
939 | struct gfc_expr *start, *end; /* Substring */ | |
940 | gfc_charlen *length; | |
941 | } | |
942 | ss; | |
943 | ||
944 | } | |
945 | u; | |
946 | ||
947 | struct gfc_ref *next; | |
948 | } | |
949 | gfc_ref; | |
950 | ||
951 | #define gfc_get_ref() gfc_getmem(sizeof(gfc_ref)) | |
952 | ||
953 | ||
954 | /* Structures representing intrinsic symbols and their arguments lists. */ | |
955 | typedef struct gfc_intrinsic_arg | |
956 | { | |
957 | char name[GFC_MAX_SYMBOL_LEN + 1]; | |
958 | ||
959 | gfc_typespec ts; | |
960 | int optional; | |
961 | gfc_actual_arglist *actual; | |
962 | ||
963 | struct gfc_intrinsic_arg *next; | |
964 | ||
965 | } | |
966 | gfc_intrinsic_arg; | |
967 | ||
968 | ||
4f613946 TS |
969 | /* Specifies the various kinds of check functions used to verify the |
970 | argument lists of intrinsic functions. fX with X an integer refer | |
971 | to check functions of intrinsics with X arguments. f1m is used for | |
972 | the MAX and MIN intrinsics which can have an arbitrary number of | |
973 | arguments, f3ml is used for the MINLOC and MAXLOC intrinsics as | |
974 | these have special semantics. */ | |
975 | ||
6de9cd9a DN |
976 | typedef union |
977 | { | |
4c0c6b9f | 978 | try (*f0)(void); |
6de9cd9a DN |
979 | try (*f1)(struct gfc_expr *); |
980 | try (*f1m)(gfc_actual_arglist *); | |
981 | try (*f2)(struct gfc_expr *, struct gfc_expr *); | |
982 | try (*f3)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *); | |
f3207b37 | 983 | try (*f3ml)(gfc_actual_arglist *); |
7551270e | 984 | try (*f3red)(gfc_actual_arglist *); |
6de9cd9a DN |
985 | try (*f4)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *, |
986 | struct gfc_expr *); | |
987 | try (*f5)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *, | |
988 | struct gfc_expr *, struct gfc_expr *); | |
989 | } | |
990 | gfc_check_f; | |
991 | ||
4f613946 TS |
992 | /* Like gfc_check_f, these specify the type of the simplification |
993 | function associated with an intrinsic. The fX are just like in | |
994 | gfc_check_f. cc is used for type conversion functions. */ | |
6de9cd9a DN |
995 | |
996 | typedef union | |
997 | { | |
4c0c6b9f | 998 | struct gfc_expr *(*f0)(void); |
6de9cd9a DN |
999 | struct gfc_expr *(*f1)(struct gfc_expr *); |
1000 | struct gfc_expr *(*f2)(struct gfc_expr *, struct gfc_expr *); | |
1001 | struct gfc_expr *(*f3)(struct gfc_expr *, struct gfc_expr *, | |
1002 | struct gfc_expr *); | |
1003 | struct gfc_expr *(*f4)(struct gfc_expr *, struct gfc_expr *, | |
1004 | struct gfc_expr *, struct gfc_expr *); | |
1005 | struct gfc_expr *(*f5)(struct gfc_expr *, struct gfc_expr *, | |
1006 | struct gfc_expr *, struct gfc_expr *, | |
1007 | struct gfc_expr *); | |
1008 | struct gfc_expr *(*cc)(struct gfc_expr *, bt, int); | |
1009 | } | |
1010 | gfc_simplify_f; | |
1011 | ||
4f613946 | 1012 | /* Again like gfc_check_f, these specify the type of the resolution |
13795658 | 1013 | function associated with an intrinsic. The fX are just like in |
4f613946 TS |
1014 | gfc_check_f. f1m is used for MIN and MAX, s1 is used for abort(). |
1015 | */ | |
6de9cd9a DN |
1016 | |
1017 | typedef union | |
1018 | { | |
1019 | void (*f0)(struct gfc_expr *); | |
1020 | void (*f1)(struct gfc_expr *, struct gfc_expr *); | |
1021 | void (*f1m)(struct gfc_expr *, struct gfc_actual_arglist *); | |
1022 | void (*f2)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *); | |
1023 | void (*f3)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *, | |
1024 | struct gfc_expr *); | |
1025 | void (*f4)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *, | |
1026 | struct gfc_expr *, struct gfc_expr *); | |
1027 | void (*f5)(struct gfc_expr *, struct gfc_expr *, struct gfc_expr *, | |
1028 | struct gfc_expr *, struct gfc_expr *, struct gfc_expr *); | |
1029 | void (*s1)(struct gfc_code *); | |
1030 | } | |
1031 | gfc_resolve_f; | |
1032 | ||
1033 | ||
1034 | typedef struct gfc_intrinsic_sym | |
1035 | { | |
cb9e4f55 | 1036 | const char *name, *lib_name; |
6de9cd9a DN |
1037 | gfc_intrinsic_arg *formal; |
1038 | gfc_typespec ts; | |
fe58e076 | 1039 | int elemental, pure, generic, specific, actual_ok, standard, noreturn; |
6de9cd9a DN |
1040 | |
1041 | gfc_simplify_f simplify; | |
1042 | gfc_check_f check; | |
1043 | gfc_resolve_f resolve; | |
1044 | struct gfc_intrinsic_sym *specific_head, *next; | |
1045 | gfc_generic_isym_id generic_id; | |
1046 | ||
1047 | } | |
1048 | gfc_intrinsic_sym; | |
1049 | ||
1050 | ||
1051 | /* Expression nodes. The expression node types deserve explanations, | |
1052 | since the last couple can be easily misconstrued: | |
1053 | ||
1054 | EXPR_OP Operator node pointing to one or two other nodes | |
1055 | EXPR_FUNCTION Function call, symbol points to function's name | |
1056 | EXPR_CONSTANT A scalar constant: Logical, String, Real, Int or Complex | |
1057 | EXPR_VARIABLE An Lvalue with a root symbol and possible reference list | |
1058 | which expresses structure, array and substring refs. | |
1059 | EXPR_NULL The NULL pointer value (which also has a basic type). | |
1060 | EXPR_SUBSTRING A substring of a constant string | |
1061 | EXPR_STRUCTURE A structure constructor | |
1062 | EXPR_ARRAY An array constructor. */ | |
1063 | ||
1064 | #include <gmp.h> | |
f8e566e5 SK |
1065 | #include <mpfr.h> |
1066 | #define GFC_RND_MODE GMP_RNDN | |
6de9cd9a DN |
1067 | |
1068 | typedef struct gfc_expr | |
1069 | { | |
1070 | expr_t expr_type; | |
1071 | ||
1072 | gfc_typespec ts; /* These two refer to the overall expression */ | |
1073 | ||
1074 | int rank; | |
1075 | mpz_t *shape; /* Can be NULL if shape is unknown at compile time */ | |
1076 | ||
6de9cd9a DN |
1077 | /* Nonnull for functions and structure constructors */ |
1078 | gfc_symtree *symtree; | |
1079 | ||
6de9cd9a DN |
1080 | gfc_ref *ref; |
1081 | ||
6de9cd9a DN |
1082 | locus where; |
1083 | ||
d3642f89 FW |
1084 | /* True if it is converted from Hollerith constant. */ |
1085 | unsigned int from_H : 1; | |
1086 | ||
6de9cd9a DN |
1087 | union |
1088 | { | |
6de9cd9a | 1089 | int logical; |
f8e566e5 SK |
1090 | mpz_t integer; |
1091 | ||
1092 | mpfr_t real; | |
6de9cd9a DN |
1093 | |
1094 | struct | |
1095 | { | |
f8e566e5 | 1096 | mpfr_t r, i; |
6de9cd9a DN |
1097 | } |
1098 | complex; | |
1099 | ||
58b03ab2 TS |
1100 | struct |
1101 | { | |
1102 | gfc_intrinsic_op operator; | |
1103 | gfc_user_op *uop; | |
1104 | struct gfc_expr *op1, *op2; | |
1105 | } | |
1106 | op; | |
1107 | ||
6de9cd9a DN |
1108 | struct |
1109 | { | |
1110 | gfc_actual_arglist *actual; | |
6b25a558 | 1111 | const char *name; /* Points to the ultimate name of the function */ |
6de9cd9a DN |
1112 | gfc_intrinsic_sym *isym; |
1113 | gfc_symbol *esym; | |
1114 | } | |
1115 | function; | |
1116 | ||
1117 | struct | |
1118 | { | |
1119 | int length; | |
1120 | char *string; | |
1121 | } | |
1122 | character; | |
1123 | ||
1124 | struct gfc_constructor *constructor; | |
1125 | } | |
1126 | value; | |
1127 | ||
1128 | } | |
1129 | gfc_expr; | |
1130 | ||
1131 | ||
94538bd1 | 1132 | #define gfc_get_shape(rank) ((mpz_t *) gfc_getmem((rank)*sizeof(mpz_t))) |
6de9cd9a DN |
1133 | |
1134 | /* Structures for information associated with different kinds of | |
1135 | numbers. The first set of integer parameters define all there is | |
1136 | to know about a particular kind. The rest of the elements are | |
1137 | computed from the first elements. */ | |
1138 | ||
1139 | typedef struct | |
1140 | { | |
e2cad04b | 1141 | /* Values really representable by the target. */ |
14df5747 | 1142 | mpz_t huge, pedantic_min_int, min_int, max_int; |
e2cad04b RH |
1143 | |
1144 | int kind, radix, digits, bit_size, range; | |
1145 | ||
1146 | /* True if the C type of the given name maps to this precision. | |
1147 | Note that more than one bit can be set. */ | |
1148 | unsigned int c_char : 1; | |
1149 | unsigned int c_short : 1; | |
1150 | unsigned int c_int : 1; | |
1151 | unsigned int c_long : 1; | |
1152 | unsigned int c_long_long : 1; | |
6de9cd9a DN |
1153 | } |
1154 | gfc_integer_info; | |
1155 | ||
1156 | extern gfc_integer_info gfc_integer_kinds[]; | |
1157 | ||
1158 | ||
1159 | typedef struct | |
1160 | { | |
1161 | int kind, bit_size; | |
1162 | ||
e2cad04b RH |
1163 | /* True if the C++ type bool, C99 type _Bool, maps to this precision. */ |
1164 | unsigned int c_bool : 1; | |
6de9cd9a DN |
1165 | } |
1166 | gfc_logical_info; | |
1167 | ||
1168 | extern gfc_logical_info gfc_logical_kinds[]; | |
1169 | ||
1170 | ||
1171 | typedef struct | |
1172 | { | |
2d0aa65f | 1173 | mpfr_t epsilon, huge, tiny, subnormal; |
6de9cd9a | 1174 | int kind, radix, digits, min_exponent, max_exponent; |
6de9cd9a | 1175 | int range, precision; |
e2cad04b RH |
1176 | |
1177 | /* The precision of the type as reported by GET_MODE_PRECISION. */ | |
1178 | int mode_precision; | |
1179 | ||
1180 | /* True if the C type of the given name maps to this precision. | |
1181 | Note that more than one bit can be set. */ | |
1182 | unsigned int c_float : 1; | |
1183 | unsigned int c_double : 1; | |
1184 | unsigned int c_long_double : 1; | |
6de9cd9a DN |
1185 | } |
1186 | gfc_real_info; | |
1187 | ||
1188 | extern gfc_real_info gfc_real_kinds[]; | |
1189 | ||
1190 | ||
1191 | /* Equivalence structures. Equivalent lvalues are linked along the | |
1192 | *eq pointer, equivalence sets are strung along the *next node. */ | |
1193 | typedef struct gfc_equiv | |
1194 | { | |
1195 | struct gfc_equiv *next, *eq; | |
1196 | gfc_expr *expr; | |
1197 | int used; | |
1198 | } | |
1199 | gfc_equiv; | |
1200 | ||
1201 | #define gfc_get_equiv() gfc_getmem(sizeof(gfc_equiv)) | |
1202 | ||
1203 | ||
1204 | /* gfc_case stores the selector list of a case statement. The *low | |
1205 | and *high pointers can point to the same expression in the case of | |
1206 | a single value. If *high is NULL, the selection is from *low | |
1207 | upwards, if *low is NULL the selection is *high downwards. | |
1208 | ||
410d1a45 SK |
1209 | This structure has separate fields to allow single and double linked |
1210 | lists of CASEs at the same time. The singe linked list along the NEXT | |
6de9cd9a DN |
1211 | field is a list of cases for a single CASE label. The double linked |
1212 | list along the LEFT/RIGHT fields is used to detect overlap and to | |
1213 | build a table of the cases for SELECT constructs with a CHARACTER | |
1214 | case expression. */ | |
1215 | ||
1216 | typedef struct gfc_case | |
1217 | { | |
1218 | /* Where we saw this case. */ | |
1219 | locus where; | |
1220 | int n; | |
1221 | ||
1222 | /* Case range values. If (low == high), it's a single value. If one of | |
1223 | the labels is NULL, it's an unbounded case. If both are NULL, this | |
1224 | represents the default case. */ | |
1225 | gfc_expr *low, *high; | |
1226 | ||
1227 | /* Next case label in the list of cases for a single CASE label. */ | |
1228 | struct gfc_case *next; | |
1229 | ||
1230 | /* Used for detecting overlap, and for code generation. */ | |
1231 | struct gfc_case *left, *right; | |
1232 | ||
1233 | /* True if this case label can never be matched. */ | |
1234 | int unreachable; | |
1235 | } | |
1236 | gfc_case; | |
1237 | ||
1238 | #define gfc_get_case() gfc_getmem(sizeof(gfc_case)) | |
1239 | ||
1240 | ||
1241 | typedef struct | |
1242 | { | |
1243 | gfc_expr *var, *start, *end, *step; | |
1244 | } | |
1245 | gfc_iterator; | |
1246 | ||
1247 | #define gfc_get_iterator() gfc_getmem(sizeof(gfc_iterator)) | |
1248 | ||
1249 | ||
f7b529fa | 1250 | /* Allocation structure for ALLOCATE, DEALLOCATE and NULLIFY statements. */ |
6de9cd9a DN |
1251 | |
1252 | typedef struct gfc_alloc | |
1253 | { | |
1254 | gfc_expr *expr; | |
1255 | struct gfc_alloc *next; | |
1256 | } | |
1257 | gfc_alloc; | |
1258 | ||
1259 | #define gfc_get_alloc() gfc_getmem(sizeof(gfc_alloc)) | |
1260 | ||
1261 | ||
1262 | typedef struct | |
1263 | { | |
1264 | gfc_expr *unit, *file, *status, *access, *form, *recl, | |
1265 | *blank, *position, *action, *delim, *pad, *iostat; | |
1266 | gfc_st_label *err; | |
1267 | } | |
1268 | gfc_open; | |
1269 | ||
1270 | ||
1271 | typedef struct | |
1272 | { | |
1273 | gfc_expr *unit, *status, *iostat; | |
1274 | gfc_st_label *err; | |
1275 | } | |
1276 | gfc_close; | |
1277 | ||
1278 | ||
1279 | typedef struct | |
1280 | { | |
1281 | gfc_expr *unit, *iostat; | |
1282 | gfc_st_label *err; | |
1283 | } | |
1284 | gfc_filepos; | |
1285 | ||
1286 | ||
1287 | typedef struct | |
1288 | { | |
1289 | gfc_expr *unit, *file, *iostat, *exist, *opened, *number, *named, | |
1290 | *name, *access, *sequential, *direct, *form, *formatted, | |
1291 | *unformatted, *recl, *nextrec, *blank, *position, *action, *read, | |
1292 | *write, *readwrite, *delim, *pad, *iolength; | |
1293 | ||
1294 | gfc_st_label *err; | |
1295 | ||
1296 | } | |
1297 | gfc_inquire; | |
1298 | ||
1299 | ||
1300 | typedef struct | |
1301 | { | |
1302 | gfc_expr *io_unit, *format_expr, *rec, *advance, *iostat, *size; | |
1303 | ||
1304 | gfc_symbol *namelist; | |
1305 | /* A format_label of `format_asterisk' indicates the "*" format */ | |
1306 | gfc_st_label *format_label; | |
1307 | gfc_st_label *err, *end, *eor; | |
1308 | ||
1309 | locus eor_where, end_where; | |
1310 | } | |
1311 | gfc_dt; | |
1312 | ||
1313 | ||
1314 | typedef struct gfc_forall_iterator | |
1315 | { | |
1316 | gfc_expr *var, *start, *end, *stride; | |
1317 | struct gfc_forall_iterator *next; | |
1318 | } | |
1319 | gfc_forall_iterator; | |
1320 | ||
1321 | ||
1322 | /* Executable statements that fill gfc_code structures. */ | |
1323 | typedef enum | |
1324 | { | |
1325 | EXEC_NOP = 1, EXEC_ASSIGN, EXEC_LABEL_ASSIGN, EXEC_POINTER_ASSIGN, | |
3d79abbd PB |
1326 | EXEC_GOTO, EXEC_CALL, EXEC_RETURN, EXEC_ENTRY, |
1327 | EXEC_PAUSE, EXEC_STOP, EXEC_CONTINUE, | |
6de9cd9a DN |
1328 | EXEC_IF, EXEC_ARITHMETIC_IF, EXEC_DO, EXEC_DO_WHILE, EXEC_SELECT, |
1329 | EXEC_FORALL, EXEC_WHERE, EXEC_CYCLE, EXEC_EXIT, | |
1330 | EXEC_ALLOCATE, EXEC_DEALLOCATE, | |
1331 | EXEC_OPEN, EXEC_CLOSE, | |
1332 | EXEC_READ, EXEC_WRITE, EXEC_IOLENGTH, EXEC_TRANSFER, EXEC_DT_END, | |
6403ec5f | 1333 | EXEC_BACKSPACE, EXEC_ENDFILE, EXEC_INQUIRE, EXEC_REWIND, EXEC_FLUSH |
6de9cd9a DN |
1334 | } |
1335 | gfc_exec_op; | |
1336 | ||
1337 | typedef struct gfc_code | |
1338 | { | |
1339 | gfc_exec_op op; | |
1340 | ||
1341 | struct gfc_code *block, *next; | |
1342 | locus loc; | |
1343 | ||
1344 | gfc_st_label *here, *label, *label2, *label3; | |
1345 | gfc_symtree *symtree; | |
1346 | gfc_expr *expr, *expr2; | |
1347 | /* A name isn't sufficient to identify a subroutine, we need the actual | |
1348 | symbol for the interface definition. | |
1349 | const char *sub_name; */ | |
1350 | gfc_symbol *resolved_sym; | |
1351 | ||
1352 | union | |
1353 | { | |
1354 | gfc_actual_arglist *actual; | |
1355 | gfc_case *case_list; | |
1356 | gfc_iterator *iterator; | |
1357 | gfc_alloc *alloc_list; | |
1358 | gfc_open *open; | |
1359 | gfc_close *close; | |
1360 | gfc_filepos *filepos; | |
1361 | gfc_inquire *inquire; | |
1362 | gfc_dt *dt; | |
1363 | gfc_forall_iterator *forall_iterator; | |
1364 | struct gfc_code *whichloop; | |
1365 | int stop_code; | |
3d79abbd | 1366 | gfc_entry_list *entry; |
6de9cd9a DN |
1367 | } |
1368 | ext; /* Points to additional structures required by statement */ | |
1369 | ||
1370 | /* Backend_decl is used for cycle and break labels in do loops, and | |
1371 | * probably for other constructs as well, once we translate them. */ | |
1372 | tree backend_decl; | |
1373 | } | |
1374 | gfc_code; | |
1375 | ||
1376 | ||
1377 | /* Storage for DATA statements. */ | |
1378 | typedef struct gfc_data_variable | |
1379 | { | |
1380 | gfc_expr *expr; | |
1381 | gfc_iterator iter; | |
1382 | struct gfc_data_variable *list, *next; | |
1383 | } | |
1384 | gfc_data_variable; | |
1385 | ||
1386 | ||
1387 | typedef struct gfc_data_value | |
1388 | { | |
b8502435 | 1389 | unsigned int repeat; |
6de9cd9a | 1390 | gfc_expr *expr; |
6de9cd9a DN |
1391 | struct gfc_data_value *next; |
1392 | } | |
1393 | gfc_data_value; | |
1394 | ||
1395 | ||
1396 | typedef struct gfc_data | |
1397 | { | |
1398 | gfc_data_variable *var; | |
1399 | gfc_data_value *value; | |
1400 | locus where; | |
1401 | ||
1402 | struct gfc_data *next; | |
1403 | } | |
1404 | gfc_data; | |
1405 | ||
1406 | #define gfc_get_data_variable() gfc_getmem(sizeof(gfc_data_variable)) | |
1407 | #define gfc_get_data_value() gfc_getmem(sizeof(gfc_data_value)) | |
1408 | #define gfc_get_data() gfc_getmem(sizeof(gfc_data)) | |
1409 | ||
1410 | ||
1411 | /* Structure for holding compile options */ | |
1412 | typedef struct | |
1413 | { | |
6de9cd9a DN |
1414 | char *module_dir; |
1415 | gfc_source_form source_form; | |
1416 | int fixed_line_length; | |
1417 | int max_identifier_length; | |
1418 | int verbose; | |
1419 | ||
1420 | int warn_aliasing; | |
1421 | int warn_conversion; | |
1422 | int warn_implicit_interface; | |
1423 | int warn_line_truncation; | |
2d8b59df | 1424 | int warn_underflow; |
6de9cd9a DN |
1425 | int warn_surprising; |
1426 | int warn_unused_labels; | |
1427 | ||
3ae9eb27 SK |
1428 | int flag_default_double; |
1429 | int flag_default_integer; | |
1430 | int flag_default_real; | |
6de9cd9a DN |
1431 | int flag_dollar_ok; |
1432 | int flag_underscoring; | |
1433 | int flag_second_underscore; | |
1434 | int flag_implicit_none; | |
1435 | int flag_max_stack_var_size; | |
1436 | int flag_module_access_private; | |
1437 | int flag_no_backend; | |
1438 | int flag_pack_derived; | |
1439 | int flag_repack_arrays; | |
973ff4c0 | 1440 | int flag_f2c; |
ee5426a4 | 1441 | int flag_automatic; |
131c66cd | 1442 | int flag_backslash; |
e0bcf78c | 1443 | int flag_d_lines; |
6de9cd9a DN |
1444 | |
1445 | int q_kind; | |
3ae9eb27 | 1446 | |
6de9cd9a DN |
1447 | int warn_std; |
1448 | int allow_std; | |
b7892582 | 1449 | int warn_nonstd_intrinsics; |
6de9cd9a DN |
1450 | } |
1451 | gfc_option_t; | |
1452 | ||
1453 | extern gfc_option_t gfc_option; | |
1454 | ||
1455 | ||
1456 | /* Constructor nodes for array and structure constructors. */ | |
1457 | typedef struct gfc_constructor | |
1458 | { | |
1459 | gfc_expr *expr; | |
1460 | gfc_iterator *iterator; | |
1461 | locus where; | |
1462 | struct gfc_constructor *next; | |
1463 | struct | |
1464 | { | |
1465 | mpz_t offset; /* Record the offset of array element which appears in | |
1466 | data statement like "data a(5)/4/". */ | |
1467 | gfc_component *component; /* Record the component being initialized. */ | |
1468 | } | |
1469 | n; | |
1470 | mpz_t repeat; /* Record the repeat number of initial values in data | |
1471 | statement like "data a/5*10/". */ | |
1472 | } | |
1473 | gfc_constructor; | |
1474 | ||
1475 | ||
1476 | typedef struct iterator_stack | |
1477 | { | |
1478 | gfc_symtree *variable; | |
1479 | mpz_t value; | |
1480 | struct iterator_stack *prev; | |
1481 | } | |
1482 | iterator_stack; | |
1483 | extern iterator_stack *iter_stack; | |
1484 | ||
1485 | /************************ Function prototypes *************************/ | |
1486 | ||
1487 | /* data.c */ | |
1488 | void gfc_formalize_init_value (gfc_symbol *); | |
1489 | void gfc_get_section_index (gfc_array_ref *, mpz_t *, mpz_t *); | |
1490 | void gfc_assign_data_value (gfc_expr *, gfc_expr *, mpz_t); | |
b8502435 | 1491 | void gfc_assign_data_value_range (gfc_expr *, gfc_expr *, mpz_t, mpz_t); |
6de9cd9a DN |
1492 | void gfc_advance_section (mpz_t *, gfc_array_ref *, mpz_t *); |
1493 | ||
1494 | /* scanner.c */ | |
1495 | void gfc_scanner_done_1 (void); | |
1496 | void gfc_scanner_init_1 (void); | |
1497 | ||
1498 | void gfc_add_include_path (const char *); | |
1499 | void gfc_release_include_path (void); | |
1500 | FILE *gfc_open_included_file (const char *); | |
1501 | ||
6de9cd9a DN |
1502 | int gfc_at_end (void); |
1503 | int gfc_at_eof (void); | |
1504 | int gfc_at_bol (void); | |
1505 | int gfc_at_eol (void); | |
1506 | void gfc_advance_line (void); | |
1507 | int gfc_check_include (void); | |
1508 | ||
1509 | void gfc_skip_comments (void); | |
1510 | int gfc_next_char_literal (int); | |
1511 | int gfc_next_char (void); | |
1512 | int gfc_peek_char (void); | |
1513 | void gfc_error_recovery (void); | |
1514 | void gfc_gobble_whitespace (void); | |
e0bcf78c | 1515 | try gfc_new_file (void); |
6de9cd9a | 1516 | |
d4fa05b9 | 1517 | extern gfc_source_form gfc_current_form; |
e0bcf78c | 1518 | extern const char *gfc_source_file; |
63645982 | 1519 | extern locus gfc_current_locus; |
6de9cd9a DN |
1520 | |
1521 | /* misc.c */ | |
1522 | void *gfc_getmem (size_t) ATTRIBUTE_MALLOC; | |
1523 | void gfc_free (void *); | |
1524 | int gfc_terminal_width(void); | |
1525 | void gfc_clear_ts (gfc_typespec *); | |
1526 | FILE *gfc_open_file (const char *); | |
1527 | const char *gfc_article (const char *); | |
1528 | const char *gfc_basic_typename (bt); | |
1529 | const char *gfc_typename (gfc_typespec *); | |
1530 | ||
1531 | #define gfc_op2string(OP) (OP == INTRINSIC_ASSIGN ? \ | |
1532 | "=" : gfc_code2string (intrinsic_operators, OP)) | |
1533 | ||
1534 | const char *gfc_code2string (const mstring *, int); | |
1535 | int gfc_string2code (const mstring *, const char *); | |
1536 | const char *gfc_intent_string (sym_intent); | |
1537 | ||
1538 | void gfc_init_1 (void); | |
1539 | void gfc_init_2 (void); | |
1540 | void gfc_done_1 (void); | |
1541 | void gfc_done_2 (void); | |
1542 | ||
1543 | /* options.c */ | |
1544 | unsigned int gfc_init_options (unsigned int, const char **); | |
1545 | int gfc_handle_option (size_t, const char *, int); | |
1546 | bool gfc_post_options (const char **); | |
1547 | ||
1548 | /* iresolve.c */ | |
6b25a558 | 1549 | const char * gfc_get_string (const char *, ...) ATTRIBUTE_PRINTF_1; |
6de9cd9a DN |
1550 | |
1551 | /* error.c */ | |
1552 | ||
1553 | typedef struct gfc_error_buf | |
1554 | { | |
1555 | int flag; | |
d71b89ca JJ |
1556 | size_t allocated, index; |
1557 | char *message; | |
6de9cd9a DN |
1558 | } gfc_error_buf; |
1559 | ||
1560 | void gfc_error_init_1 (void); | |
1561 | void gfc_buffer_error (int); | |
1562 | ||
0ce0154c KG |
1563 | void gfc_warning (const char *, ...) ATTRIBUTE_GCC_GFC(1,2); |
1564 | void gfc_warning_now (const char *, ...) ATTRIBUTE_GCC_GFC(1,2); | |
6de9cd9a DN |
1565 | void gfc_clear_warning (void); |
1566 | void gfc_warning_check (void); | |
1567 | ||
0ce0154c KG |
1568 | void gfc_error (const char *, ...) ATTRIBUTE_GCC_GFC(1,2); |
1569 | void gfc_error_now (const char *, ...) ATTRIBUTE_GCC_GFC(1,2); | |
1570 | void gfc_fatal_error (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_GCC_GFC(1,2); | |
1571 | void gfc_internal_error (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_GCC_GFC(1,2); | |
6de9cd9a DN |
1572 | void gfc_clear_error (void); |
1573 | int gfc_error_check (void); | |
1574 | ||
0ce0154c | 1575 | try gfc_notify_std (int, const char *, ...) ATTRIBUTE_GCC_GFC(2,3); |
6de9cd9a DN |
1576 | |
1577 | /* A general purpose syntax error. */ | |
1578 | #define gfc_syntax_error(ST) \ | |
1579 | gfc_error ("Syntax error in %s statement at %C", gfc_ascii_statement (ST)); | |
1580 | ||
1581 | void gfc_push_error (gfc_error_buf *); | |
1582 | void gfc_pop_error (gfc_error_buf *); | |
d71b89ca | 1583 | void gfc_free_error (gfc_error_buf *); |
6de9cd9a DN |
1584 | |
1585 | void gfc_status (const char *, ...) ATTRIBUTE_PRINTF_1; | |
1586 | void gfc_status_char (char); | |
1587 | ||
1588 | void gfc_get_errors (int *, int *); | |
1589 | ||
1590 | /* arith.c */ | |
1591 | void gfc_arith_init_1 (void); | |
1592 | void gfc_arith_done_1 (void); | |
1593 | ||
5e8e542f | 1594 | /* trans-types.c */ |
e7a2d5fb | 1595 | int gfc_validate_kind (bt, int, bool); |
6de9cd9a | 1596 | extern int gfc_index_integer_kind; |
9d64df18 | 1597 | extern int gfc_default_integer_kind; |
f4e7375a | 1598 | extern int gfc_max_integer_kind; |
9d64df18 TS |
1599 | extern int gfc_default_real_kind; |
1600 | extern int gfc_default_double_kind; | |
1601 | extern int gfc_default_character_kind; | |
1602 | extern int gfc_default_logical_kind; | |
1603 | extern int gfc_default_complex_kind; | |
e8525382 | 1604 | extern int gfc_c_int_kind; |
6de9cd9a DN |
1605 | |
1606 | /* symbol.c */ | |
1607 | void gfc_clear_new_implicit (void); | |
1107b970 PB |
1608 | try gfc_add_new_implicit_range (int, int); |
1609 | try gfc_merge_new_implicit (gfc_typespec *); | |
6de9cd9a | 1610 | void gfc_set_implicit_none (void); |
6de9cd9a DN |
1611 | |
1612 | gfc_typespec *gfc_get_default_type (gfc_symbol *, gfc_namespace *); | |
1613 | try gfc_set_default_type (gfc_symbol *, int, gfc_namespace *); | |
1614 | ||
1615 | void gfc_set_component_attr (gfc_component *, symbol_attribute *); | |
1616 | void gfc_get_component_attr (symbol_attribute *, gfc_component *); | |
1617 | ||
1618 | void gfc_set_sym_referenced (gfc_symbol * sym); | |
1619 | ||
1620 | try gfc_add_allocatable (symbol_attribute *, locus *); | |
231b2fcc | 1621 | try gfc_add_dimension (symbol_attribute *, const char *, locus *); |
6de9cd9a DN |
1622 | try gfc_add_external (symbol_attribute *, locus *); |
1623 | try gfc_add_intrinsic (symbol_attribute *, locus *); | |
1624 | try gfc_add_optional (symbol_attribute *, locus *); | |
1625 | try gfc_add_pointer (symbol_attribute *, locus *); | |
231b2fcc TS |
1626 | try gfc_add_result (symbol_attribute *, const char *, locus *); |
1627 | try gfc_add_save (symbol_attribute *, const char *, locus *); | |
6de9cd9a DN |
1628 | try gfc_add_saved_common (symbol_attribute *, locus *); |
1629 | try gfc_add_target (symbol_attribute *, locus *); | |
231b2fcc TS |
1630 | try gfc_add_dummy (symbol_attribute *, const char *, locus *); |
1631 | try gfc_add_generic (symbol_attribute *, const char *, locus *); | |
6de9cd9a | 1632 | try gfc_add_common (symbol_attribute *, locus *); |
231b2fcc TS |
1633 | try gfc_add_in_common (symbol_attribute *, const char *, locus *); |
1634 | try gfc_add_data (symbol_attribute *, const char *, locus *); | |
1635 | try gfc_add_in_namelist (symbol_attribute *, const char *, locus *); | |
1636 | try gfc_add_sequence (symbol_attribute *, const char *, locus *); | |
6de9cd9a DN |
1637 | try gfc_add_elemental (symbol_attribute *, locus *); |
1638 | try gfc_add_pure (symbol_attribute *, locus *); | |
1639 | try gfc_add_recursive (symbol_attribute *, locus *); | |
231b2fcc TS |
1640 | try gfc_add_function (symbol_attribute *, const char *, locus *); |
1641 | try gfc_add_subroutine (symbol_attribute *, const char *, locus *); | |
1642 | ||
1643 | try gfc_add_access (symbol_attribute *, gfc_access, const char *, locus *); | |
1644 | try gfc_add_flavor (symbol_attribute *, sym_flavor, const char *, locus *); | |
1645 | try gfc_add_entry (symbol_attribute *, const char *, locus *); | |
1646 | try gfc_add_procedure (symbol_attribute *, procedure_type, | |
1647 | const char *, locus *); | |
6de9cd9a DN |
1648 | try gfc_add_intent (symbol_attribute *, sym_intent, locus *); |
1649 | try gfc_add_explicit_interface (gfc_symbol *, ifsrc, | |
1650 | gfc_formal_arglist *, locus *); | |
1651 | try gfc_add_type (gfc_symbol *, gfc_typespec *, locus *); | |
1652 | ||
1653 | void gfc_clear_attr (symbol_attribute *); | |
1654 | try gfc_missing_attr (symbol_attribute *, locus *); | |
1655 | try gfc_copy_attr (symbol_attribute *, symbol_attribute *, locus *); | |
1656 | ||
1657 | try gfc_add_component (gfc_symbol *, const char *, gfc_component **); | |
1658 | gfc_symbol *gfc_use_derived (gfc_symbol *); | |
1659 | gfc_symtree *gfc_use_derived_tree (gfc_symtree *); | |
1660 | gfc_component *gfc_find_component (gfc_symbol *, const char *); | |
1661 | ||
1662 | gfc_st_label *gfc_get_st_label (int); | |
1663 | void gfc_free_st_label (gfc_st_label *); | |
1664 | void gfc_define_st_label (gfc_st_label *, gfc_sl_type, locus *); | |
1665 | try gfc_reference_st_label (gfc_st_label *, gfc_sl_type); | |
1666 | ||
0366dfe9 | 1667 | gfc_namespace *gfc_get_namespace (gfc_namespace *, int); |
6de9cd9a DN |
1668 | gfc_symtree *gfc_new_symtree (gfc_symtree **, const char *); |
1669 | gfc_symtree *gfc_find_symtree (gfc_symtree *, const char *); | |
1670 | gfc_user_op *gfc_get_uop (const char *); | |
1671 | gfc_user_op *gfc_find_uop (const char *, gfc_namespace *); | |
1672 | void gfc_free_symbol (gfc_symbol *); | |
1673 | gfc_symbol *gfc_new_symbol (const char *, gfc_namespace *); | |
1674 | int gfc_find_symbol (const char *, gfc_namespace *, int, gfc_symbol **); | |
1675 | int gfc_find_sym_tree (const char *, gfc_namespace *, int, gfc_symtree **); | |
1676 | int gfc_get_symbol (const char *, gfc_namespace *, gfc_symbol **); | |
1677 | int gfc_get_sym_tree (const char *, gfc_namespace *, gfc_symtree **); | |
1678 | int gfc_get_ha_symbol (const char *, gfc_symbol **); | |
1679 | int gfc_get_ha_sym_tree (const char *, gfc_symtree **); | |
1680 | ||
1681 | int gfc_symbols_could_alias (gfc_symbol *, gfc_symbol *); | |
1682 | ||
1683 | void gfc_undo_symbols (void); | |
1684 | void gfc_commit_symbols (void); | |
1685 | void gfc_free_namespace (gfc_namespace *); | |
1686 | ||
1687 | void gfc_symbol_init_2 (void); | |
1688 | void gfc_symbol_done_2 (void); | |
1689 | ||
9056bd70 | 1690 | void gfc_traverse_symtree (gfc_symtree *, void (*)(gfc_symtree *)); |
6de9cd9a DN |
1691 | void gfc_traverse_ns (gfc_namespace *, void (*)(gfc_symbol *)); |
1692 | void gfc_traverse_user_op (gfc_namespace *, void (*)(gfc_user_op *)); | |
1693 | void gfc_save_all (gfc_namespace *); | |
1694 | ||
1695 | void gfc_symbol_state (void); | |
1696 | ||
cb9e4f55 TS |
1697 | gfc_gsymbol *gfc_get_gsymbol (const char *); |
1698 | gfc_gsymbol *gfc_find_gsymbol (gfc_gsymbol *, const char *); | |
c9543002 | 1699 | |
6de9cd9a DN |
1700 | /* intrinsic.c */ |
1701 | extern int gfc_init_expr; | |
1702 | ||
1703 | /* Given a symbol that we have decided is intrinsic, mark it as such | |
1704 | by placing it into a special module that is otherwise impossible to | |
1705 | read or write. */ | |
1706 | ||
cb9e4f55 | 1707 | #define gfc_intrinsic_symbol(SYM) SYM->module = gfc_get_string ("(intrinsic)") |
6de9cd9a DN |
1708 | |
1709 | void gfc_intrinsic_init_1 (void); | |
1710 | void gfc_intrinsic_done_1 (void); | |
1711 | ||
1712 | char gfc_type_letter (bt); | |
1713 | gfc_symbol * gfc_get_intrinsic_sub_symbol (const char *); | |
1714 | try gfc_convert_type (gfc_expr *, gfc_typespec *, int); | |
1715 | try gfc_convert_type_warn (gfc_expr *, gfc_typespec *, int, int); | |
1716 | int gfc_generic_intrinsic (const char *); | |
1717 | int gfc_specific_intrinsic (const char *); | |
1718 | int gfc_intrinsic_name (const char *, int); | |
1719 | gfc_intrinsic_sym *gfc_find_function (const char *); | |
1720 | ||
1721 | match gfc_intrinsic_func_interface (gfc_expr *, int); | |
1722 | match gfc_intrinsic_sub_interface (gfc_code *, int); | |
1723 | ||
1724 | /* simplify.c */ | |
1725 | void gfc_simplify_init_1 (void); | |
6de9cd9a DN |
1726 | |
1727 | /* match.c -- FIXME */ | |
1728 | void gfc_free_iterator (gfc_iterator *, int); | |
1729 | void gfc_free_forall_iterator (gfc_forall_iterator *); | |
1730 | void gfc_free_alloc_list (gfc_alloc *); | |
1731 | void gfc_free_namelist (gfc_namelist *); | |
1732 | void gfc_free_equiv (gfc_equiv *); | |
1733 | void gfc_free_data (gfc_data *); | |
1734 | void gfc_free_case_list (gfc_case *); | |
1735 | ||
1736 | /* expr.c */ | |
1737 | void gfc_free_actual_arglist (gfc_actual_arglist *); | |
1738 | gfc_actual_arglist *gfc_copy_actual_arglist (gfc_actual_arglist *); | |
1739 | const char *gfc_extract_int (gfc_expr *, int *); | |
1740 | ||
1741 | gfc_expr *gfc_build_conversion (gfc_expr *); | |
1742 | void gfc_free_ref_list (gfc_ref *); | |
1743 | void gfc_type_convert_binary (gfc_expr *); | |
1744 | int gfc_is_constant_expr (gfc_expr *); | |
1745 | try gfc_simplify_expr (gfc_expr *, int); | |
1746 | ||
1747 | gfc_expr *gfc_get_expr (void); | |
1748 | void gfc_free_expr (gfc_expr *); | |
1749 | void gfc_replace_expr (gfc_expr *, gfc_expr *); | |
1750 | gfc_expr *gfc_int_expr (int); | |
1751 | gfc_expr *gfc_logical_expr (int, locus *); | |
1752 | mpz_t *gfc_copy_shape (mpz_t *, int); | |
94538bd1 | 1753 | mpz_t *gfc_copy_shape_excluding (mpz_t *, int, gfc_expr *); |
6de9cd9a DN |
1754 | gfc_expr *gfc_copy_expr (gfc_expr *); |
1755 | ||
1756 | try gfc_specification_expr (gfc_expr *); | |
1757 | ||
1758 | int gfc_numeric_ts (gfc_typespec *); | |
1759 | int gfc_kind_max (gfc_expr *, gfc_expr *); | |
1760 | ||
1761 | try gfc_check_conformance (const char *, gfc_expr *, gfc_expr *); | |
1762 | try gfc_check_assign (gfc_expr *, gfc_expr *, int); | |
1763 | try gfc_check_pointer_assign (gfc_expr *, gfc_expr *); | |
1764 | try gfc_check_assign_symbol (gfc_symbol *, gfc_expr *); | |
1765 | ||
54b4ba60 | 1766 | gfc_expr *gfc_default_initializer (gfc_typespec *); |
294fbfc8 TS |
1767 | gfc_expr *gfc_get_variable_expr (gfc_symtree *); |
1768 | ||
54b4ba60 | 1769 | |
6de9cd9a DN |
1770 | /* st.c */ |
1771 | extern gfc_code new_st; | |
1772 | ||
1773 | void gfc_clear_new_st (void); | |
1774 | gfc_code *gfc_get_code (void); | |
1775 | gfc_code *gfc_append_code (gfc_code *, gfc_code *); | |
1776 | void gfc_free_statement (gfc_code *); | |
1777 | void gfc_free_statements (gfc_code *); | |
1778 | ||
1779 | /* resolve.c */ | |
1780 | try gfc_resolve_expr (gfc_expr *); | |
1781 | void gfc_resolve (gfc_namespace *); | |
1782 | int gfc_impure_variable (gfc_symbol *); | |
1783 | int gfc_pure (gfc_symbol *); | |
1784 | int gfc_elemental (gfc_symbol *); | |
8d5cfa27 | 1785 | try gfc_resolve_iterator (gfc_iterator *, bool); |
6de9cd9a | 1786 | try gfc_resolve_index (gfc_expr *, int); |
bf302220 | 1787 | try gfc_resolve_dim_arg (gfc_expr *); |
6de9cd9a DN |
1788 | |
1789 | /* array.c */ | |
1790 | void gfc_free_array_spec (gfc_array_spec *); | |
1791 | gfc_array_ref *gfc_copy_array_ref (gfc_array_ref *); | |
1792 | ||
1793 | try gfc_set_array_spec (gfc_symbol *, gfc_array_spec *, locus *); | |
1794 | gfc_array_spec *gfc_copy_array_spec (gfc_array_spec *); | |
1795 | try gfc_resolve_array_spec (gfc_array_spec *, int); | |
1796 | ||
1797 | int gfc_compare_array_spec (gfc_array_spec *, gfc_array_spec *); | |
1798 | ||
1799 | gfc_expr *gfc_start_constructor (bt, int, locus *); | |
1800 | void gfc_append_constructor (gfc_expr *, gfc_expr *); | |
1801 | void gfc_free_constructor (gfc_constructor *); | |
1802 | void gfc_simplify_iterator_var (gfc_expr *); | |
1803 | try gfc_expand_constructor (gfc_expr *); | |
1804 | int gfc_constant_ac (gfc_expr *); | |
1805 | int gfc_expanded_ac (gfc_expr *); | |
1806 | try gfc_resolve_array_constructor (gfc_expr *); | |
1807 | try gfc_check_constructor_type (gfc_expr *); | |
1808 | try gfc_check_iter_variable (gfc_expr *); | |
1809 | try gfc_check_constructor (gfc_expr *, try (*)(gfc_expr *)); | |
1810 | gfc_constructor *gfc_copy_constructor (gfc_constructor * src); | |
1811 | gfc_expr *gfc_get_array_element (gfc_expr *, int); | |
1812 | try gfc_array_size (gfc_expr *, mpz_t *); | |
1813 | try gfc_array_dimen_size (gfc_expr *, int, mpz_t *); | |
1814 | try gfc_array_ref_shape (gfc_array_ref *, mpz_t *); | |
1815 | gfc_array_ref *gfc_find_array_ref (gfc_expr *); | |
1816 | void gfc_insert_constructor (gfc_expr *, gfc_constructor *); | |
1817 | gfc_constructor *gfc_get_constructor (void); | |
1818 | tree gfc_conv_array_initializer (tree type, gfc_expr * expr); | |
1819 | try spec_size (gfc_array_spec *, mpz_t *); | |
4077d207 | 1820 | int gfc_is_compile_time_shape (gfc_array_spec *); |
6de9cd9a DN |
1821 | |
1822 | /* interface.c -- FIXME: some of these should be in symbol.c */ | |
1823 | void gfc_free_interface (gfc_interface *); | |
1824 | int gfc_compare_types (gfc_typespec *, gfc_typespec *); | |
1825 | void gfc_check_interfaces (gfc_namespace *); | |
1826 | void gfc_procedure_use (gfc_symbol *, gfc_actual_arglist **, locus *); | |
1827 | gfc_symbol *gfc_search_interface (gfc_interface *, int, | |
1828 | gfc_actual_arglist **); | |
1829 | try gfc_extend_expr (gfc_expr *); | |
1830 | void gfc_free_formal_arglist (gfc_formal_arglist *); | |
1831 | try gfc_extend_assign (gfc_code *, gfc_namespace *); | |
1832 | try gfc_add_interface (gfc_symbol * sym); | |
1833 | ||
1834 | /* io.c */ | |
1835 | extern gfc_st_label format_asterisk; | |
1836 | ||
1837 | void gfc_free_open (gfc_open *); | |
1838 | try gfc_resolve_open (gfc_open *); | |
1839 | void gfc_free_close (gfc_close *); | |
1840 | try gfc_resolve_close (gfc_close *); | |
1841 | void gfc_free_filepos (gfc_filepos *); | |
1842 | try gfc_resolve_filepos (gfc_filepos *); | |
1843 | void gfc_free_inquire (gfc_inquire *); | |
1844 | try gfc_resolve_inquire (gfc_inquire *); | |
1845 | void gfc_free_dt (gfc_dt *); | |
1846 | try gfc_resolve_dt (gfc_dt *); | |
1847 | ||
1848 | /* module.c */ | |
1849 | void gfc_module_init_2 (void); | |
1850 | void gfc_module_done_2 (void); | |
1851 | void gfc_dump_module (const char *, int); | |
af30f793 | 1852 | bool gfc_check_access (gfc_access, gfc_access); |
6de9cd9a DN |
1853 | |
1854 | /* primary.c */ | |
1855 | symbol_attribute gfc_variable_attr (gfc_expr *, gfc_typespec *); | |
1856 | symbol_attribute gfc_expr_attr (gfc_expr *); | |
1857 | ||
1858 | /* trans.c */ | |
1859 | void gfc_generate_code (gfc_namespace *); | |
1860 | void gfc_generate_module_code (gfc_namespace *); | |
1861 | ||
1862 | /* bbt.c */ | |
1863 | typedef int (*compare_fn) (void *, void *); | |
1864 | void gfc_insert_bbt (void *, void *, compare_fn); | |
1865 | void gfc_delete_bbt (void *, void *, compare_fn); | |
1866 | ||
1867 | /* dump-parse-tree.c */ | |
1868 | void gfc_show_namespace (gfc_namespace *); | |
1869 | ||
1870 | /* parse.c */ | |
1871 | try gfc_parse_file (void); | |
1872 | ||
53814b8f | 1873 | #endif /* GCC_GFORTRAN_H */ |