]>
Commit | Line | Data |
---|---|---|
6de9cd9a DN |
1 | /* Build up a list of intrinsic subroutines and functions for the |
2 | name-resolution stage. | |
ec378180 | 3 | Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, |
9fc4d79b | 4 | Inc. |
6de9cd9a DN |
5 | Contributed by Andy Vaught & Katherine Holcomb |
6 | ||
9fc4d79b | 7 | This file is part of GCC. |
6de9cd9a | 8 | |
9fc4d79b TS |
9 | GCC is free software; you can redistribute it and/or modify it under |
10 | the terms of the GNU General Public License as published by the Free | |
11 | Software Foundation; either version 2, or (at your option) any later | |
12 | version. | |
6de9cd9a | 13 | |
9fc4d79b TS |
14 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
17 | for more details. | |
6de9cd9a DN |
18 | |
19 | You should have received a copy of the GNU General Public License | |
9fc4d79b | 20 | along with GCC; see the file COPYING. If not, write to the Free |
ab57747b KC |
21 | Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA |
22 | 02110-1301, USA. */ | |
6de9cd9a DN |
23 | |
24 | ||
25 | #include "config.h" | |
26 | #include "system.h" | |
27 | #include "flags.h" | |
6de9cd9a DN |
28 | #include "gfortran.h" |
29 | #include "intrinsic.h" | |
30 | ||
31 | ||
1f2959f0 | 32 | /* Namespace to hold the resolved symbols for intrinsic subroutines. */ |
6de9cd9a DN |
33 | static gfc_namespace *gfc_intrinsic_namespace; |
34 | ||
35 | int gfc_init_expr = 0; | |
36 | ||
1270d633 | 37 | /* Pointers to an intrinsic function and its argument names that are being |
f7b529fa | 38 | checked. */ |
6de9cd9a | 39 | |
cb9e4f55 TS |
40 | const char *gfc_current_intrinsic; |
41 | const char *gfc_current_intrinsic_arg[MAX_INTRINSIC_ARGS]; | |
6de9cd9a DN |
42 | locus *gfc_current_intrinsic_where; |
43 | ||
44 | static gfc_intrinsic_sym *functions, *subroutines, *conversion, *next_sym; | |
45 | static gfc_intrinsic_arg *next_arg; | |
46 | ||
47 | static int nfunc, nsub, nargs, nconv; | |
48 | ||
49 | static enum | |
50 | { SZ_NOTHING = 0, SZ_SUBS, SZ_FUNCS, SZ_CONVS } | |
51 | sizing; | |
52 | ||
1270d633 SK |
53 | #define REQUIRED 0 |
54 | #define OPTIONAL 1 | |
6de9cd9a DN |
55 | |
56 | /* Return a letter based on the passed type. Used to construct the | |
57 | name of a type-dependent subroutine. */ | |
58 | ||
59 | char | |
60 | gfc_type_letter (bt type) | |
61 | { | |
62 | char c; | |
63 | ||
64 | switch (type) | |
65 | { | |
66 | case BT_LOGICAL: | |
67 | c = 'l'; | |
68 | break; | |
69 | case BT_CHARACTER: | |
70 | c = 's'; | |
71 | break; | |
72 | case BT_INTEGER: | |
73 | c = 'i'; | |
74 | break; | |
75 | case BT_REAL: | |
76 | c = 'r'; | |
77 | break; | |
78 | case BT_COMPLEX: | |
79 | c = 'c'; | |
80 | break; | |
81 | ||
d3642f89 FW |
82 | case BT_HOLLERITH: |
83 | c = 'h'; | |
84 | break; | |
85 | ||
6de9cd9a DN |
86 | default: |
87 | c = 'u'; | |
88 | break; | |
89 | } | |
90 | ||
91 | return c; | |
92 | } | |
93 | ||
94 | ||
95 | /* Get a symbol for a resolved name. */ | |
96 | ||
97 | gfc_symbol * | |
98 | gfc_get_intrinsic_sub_symbol (const char * name) | |
99 | { | |
100 | gfc_symbol *sym; | |
101 | ||
102 | gfc_get_symbol (name, gfc_intrinsic_namespace, &sym); | |
103 | sym->attr.always_explicit = 1; | |
104 | sym->attr.subroutine = 1; | |
105 | sym->attr.flavor = FL_PROCEDURE; | |
106 | sym->attr.proc = PROC_INTRINSIC; | |
107 | ||
108 | return sym; | |
109 | } | |
110 | ||
111 | ||
112 | /* Return a pointer to the name of a conversion function given two | |
113 | typespecs. */ | |
114 | ||
cb9e4f55 | 115 | static const char * |
6de9cd9a DN |
116 | conv_name (gfc_typespec * from, gfc_typespec * to) |
117 | { | |
118 | static char name[30]; | |
119 | ||
120 | sprintf (name, "__convert_%c%d_%c%d", gfc_type_letter (from->type), | |
121 | from->kind, gfc_type_letter (to->type), to->kind); | |
122 | ||
cb9e4f55 | 123 | return gfc_get_string (name); |
6de9cd9a DN |
124 | } |
125 | ||
126 | ||
127 | /* Given a pair of typespecs, find the gfc_intrinsic_sym node that | |
128 | corresponds to the conversion. Returns NULL if the conversion | |
129 | isn't found. */ | |
130 | ||
131 | static gfc_intrinsic_sym * | |
132 | find_conv (gfc_typespec * from, gfc_typespec * to) | |
133 | { | |
134 | gfc_intrinsic_sym *sym; | |
cb9e4f55 | 135 | const char *target; |
6de9cd9a DN |
136 | int i; |
137 | ||
138 | target = conv_name (from, to); | |
139 | sym = conversion; | |
140 | ||
141 | for (i = 0; i < nconv; i++, sym++) | |
142 | if (strcmp (target, sym->name) == 0) | |
143 | return sym; | |
144 | ||
145 | return NULL; | |
146 | } | |
147 | ||
148 | ||
149 | /* Interface to the check functions. We break apart an argument list | |
150 | and call the proper check function rather than forcing each | |
151 | function to manipulate the argument list. */ | |
152 | ||
153 | static try | |
154 | do_check (gfc_intrinsic_sym * specific, gfc_actual_arglist * arg) | |
155 | { | |
156 | gfc_expr *a1, *a2, *a3, *a4, *a5; | |
4c0c6b9f SK |
157 | |
158 | if (arg == NULL) | |
159 | return (*specific->check.f0) (); | |
6de9cd9a DN |
160 | |
161 | a1 = arg->expr; | |
162 | arg = arg->next; | |
4c0c6b9f SK |
163 | if (arg == NULL) |
164 | return (*specific->check.f1) (a1); | |
6de9cd9a | 165 | |
4c0c6b9f SK |
166 | a2 = arg->expr; |
167 | arg = arg->next; | |
6de9cd9a | 168 | if (arg == NULL) |
4c0c6b9f | 169 | return (*specific->check.f2) (a1, a2); |
6de9cd9a | 170 | |
4c0c6b9f SK |
171 | a3 = arg->expr; |
172 | arg = arg->next; | |
173 | if (arg == NULL) | |
174 | return (*specific->check.f3) (a1, a2, a3); | |
6de9cd9a | 175 | |
4c0c6b9f SK |
176 | a4 = arg->expr; |
177 | arg = arg->next; | |
178 | if (arg == NULL) | |
179 | return (*specific->check.f4) (a1, a2, a3, a4); | |
6de9cd9a | 180 | |
4c0c6b9f SK |
181 | a5 = arg->expr; |
182 | arg = arg->next; | |
183 | if (arg == NULL) | |
184 | return (*specific->check.f5) (a1, a2, a3, a4, a5); | |
185 | ||
186 | gfc_internal_error ("do_check(): too many args"); | |
6de9cd9a DN |
187 | } |
188 | ||
189 | ||
190 | /*********** Subroutines to build the intrinsic list ****************/ | |
191 | ||
192 | /* Add a single intrinsic symbol to the current list. | |
193 | ||
194 | Argument list: | |
195 | char * name of function | |
196 | int whether function is elemental | |
197 | int If the function can be used as an actual argument | |
198 | bt return type of function | |
199 | int kind of return type of function | |
b7892582 | 200 | int Fortran standard version |
6de9cd9a DN |
201 | check pointer to check function |
202 | simplify pointer to simplification function | |
203 | resolve pointer to resolution function | |
204 | ||
205 | Optional arguments come in multiples of four: | |
206 | char * name of argument | |
207 | bt type of argument | |
208 | int kind of argument | |
209 | int arg optional flag (1=optional, 0=required) | |
210 | ||
211 | The sequence is terminated by a NULL name. | |
212 | ||
213 | TODO: Are checks on actual_ok implemented elsewhere, or is that just | |
214 | missing here? */ | |
215 | ||
216 | static void | |
217 | add_sym (const char *name, int elemental, int actual_ok ATTRIBUTE_UNUSED, | |
b7892582 JB |
218 | bt type, int kind, int standard, gfc_check_f check, |
219 | gfc_simplify_f simplify, gfc_resolve_f resolve, ...) | |
6de9cd9a | 220 | { |
cb9e4f55 | 221 | char buf[GFC_MAX_SYMBOL_LEN + 11]; /* 10 for '_gfortran_', 1 for '\0' */ |
6de9cd9a DN |
222 | int optional, first_flag; |
223 | va_list argp; | |
224 | ||
b7892582 | 225 | /* First check that the intrinsic belongs to the selected standard. |
f7b529fa | 226 | If not, don't add it to the symbol list. */ |
b7892582 JB |
227 | if (!(gfc_option.allow_std & standard)) |
228 | return; | |
229 | ||
6de9cd9a DN |
230 | switch (sizing) |
231 | { | |
232 | case SZ_SUBS: | |
233 | nsub++; | |
234 | break; | |
235 | ||
236 | case SZ_FUNCS: | |
237 | nfunc++; | |
238 | break; | |
239 | ||
240 | case SZ_NOTHING: | |
cb9e4f55 | 241 | next_sym->name = gfc_get_string (name); |
6de9cd9a | 242 | |
cb9e4f55 TS |
243 | strcpy (buf, "_gfortran_"); |
244 | strcat (buf, name); | |
245 | next_sym->lib_name = gfc_get_string (buf); | |
6de9cd9a DN |
246 | |
247 | next_sym->elemental = elemental; | |
248 | next_sym->ts.type = type; | |
249 | next_sym->ts.kind = kind; | |
b7892582 | 250 | next_sym->standard = standard; |
6de9cd9a DN |
251 | next_sym->simplify = simplify; |
252 | next_sym->check = check; | |
253 | next_sym->resolve = resolve; | |
254 | next_sym->specific = 0; | |
255 | next_sym->generic = 0; | |
256 | break; | |
257 | ||
258 | default: | |
259 | gfc_internal_error ("add_sym(): Bad sizing mode"); | |
260 | } | |
261 | ||
262 | va_start (argp, resolve); | |
263 | ||
264 | first_flag = 1; | |
265 | ||
266 | for (;;) | |
267 | { | |
268 | name = va_arg (argp, char *); | |
269 | if (name == NULL) | |
270 | break; | |
271 | ||
272 | type = (bt) va_arg (argp, int); | |
273 | kind = va_arg (argp, int); | |
274 | optional = va_arg (argp, int); | |
275 | ||
276 | if (sizing != SZ_NOTHING) | |
277 | nargs++; | |
278 | else | |
279 | { | |
280 | next_arg++; | |
281 | ||
282 | if (first_flag) | |
283 | next_sym->formal = next_arg; | |
284 | else | |
285 | (next_arg - 1)->next = next_arg; | |
286 | ||
287 | first_flag = 0; | |
288 | ||
289 | strcpy (next_arg->name, name); | |
290 | next_arg->ts.type = type; | |
291 | next_arg->ts.kind = kind; | |
292 | next_arg->optional = optional; | |
293 | } | |
294 | } | |
295 | ||
296 | va_end (argp); | |
297 | ||
298 | next_sym++; | |
299 | } | |
300 | ||
301 | ||
1270d633 SK |
302 | /* Add a symbol to the function list where the function takes |
303 | 0 arguments. */ | |
304 | ||
305 | static void | |
306 | add_sym_0 (const char *name, int elemental, int actual_ok, bt type, | |
b7892582 | 307 | int kind, int standard, |
4c0c6b9f SK |
308 | try (*check)(void), |
309 | gfc_expr *(*simplify)(void), | |
1270d633 SK |
310 | void (*resolve)(gfc_expr *)) |
311 | { | |
6de9cd9a DN |
312 | gfc_simplify_f sf; |
313 | gfc_check_f cf; | |
314 | gfc_resolve_f rf; | |
315 | ||
4c0c6b9f SK |
316 | cf.f0 = check; |
317 | sf.f0 = simplify; | |
318 | rf.f0 = resolve; | |
6de9cd9a | 319 | |
b7892582 | 320 | add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf, |
6de9cd9a DN |
321 | (void*)0); |
322 | } | |
323 | ||
324 | ||
1270d633 SK |
325 | /* Add a symbol to the subroutine list where the subroutine takes |
326 | 0 arguments. */ | |
327 | ||
328 | static void | |
329 | add_sym_0s (const char * name, int actual_ok, int standard, | |
330 | void (*resolve)(gfc_code *)) | |
331 | { | |
6de9cd9a DN |
332 | gfc_check_f cf; |
333 | gfc_simplify_f sf; | |
334 | gfc_resolve_f rf; | |
335 | ||
1270d633 SK |
336 | cf.f1 = NULL; |
337 | sf.f1 = NULL; | |
338 | rf.s1 = resolve; | |
6de9cd9a | 339 | |
1270d633 | 340 | add_sym (name, 1, actual_ok, BT_UNKNOWN, 0, standard, cf, sf, rf, |
6de9cd9a DN |
341 | (void*)0); |
342 | } | |
343 | ||
344 | ||
1270d633 SK |
345 | /* Add a symbol to the function list where the function takes |
346 | 1 arguments. */ | |
347 | ||
6de9cd9a | 348 | static void |
1270d633 SK |
349 | add_sym_1 (const char *name, int elemental, int actual_ok, bt type, |
350 | int kind, int standard, | |
351 | try (*check)(gfc_expr *), | |
352 | gfc_expr *(*simplify)(gfc_expr *), | |
353 | void (*resolve)(gfc_expr *,gfc_expr *), | |
354 | const char* a1, bt type1, int kind1, int optional1) | |
6de9cd9a DN |
355 | { |
356 | gfc_check_f cf; | |
357 | gfc_simplify_f sf; | |
358 | gfc_resolve_f rf; | |
359 | ||
1270d633 SK |
360 | cf.f1 = check; |
361 | sf.f1 = simplify; | |
362 | rf.f1 = resolve; | |
6de9cd9a | 363 | |
1270d633 SK |
364 | add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf, |
365 | a1, type1, kind1, optional1, | |
6de9cd9a DN |
366 | (void*)0); |
367 | } | |
368 | ||
369 | ||
1270d633 SK |
370 | /* Add a symbol to the subroutine list where the subroutine takes |
371 | 1 arguments. */ | |
372 | ||
373 | static void | |
374 | add_sym_1s (const char *name, int elemental, int actual_ok, bt type, | |
b7892582 | 375 | int kind, int standard, |
6de9cd9a DN |
376 | try (*check)(gfc_expr *), |
377 | gfc_expr *(*simplify)(gfc_expr *), | |
378 | void (*resolve)(gfc_code *), | |
1270d633 SK |
379 | const char* a1, bt type1, int kind1, int optional1) |
380 | { | |
6de9cd9a DN |
381 | gfc_check_f cf; |
382 | gfc_simplify_f sf; | |
383 | gfc_resolve_f rf; | |
384 | ||
385 | cf.f1 = check; | |
386 | sf.f1 = simplify; | |
387 | rf.s1 = resolve; | |
388 | ||
b7892582 | 389 | add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf, |
6de9cd9a DN |
390 | a1, type1, kind1, optional1, |
391 | (void*)0); | |
392 | } | |
393 | ||
394 | ||
1270d633 SK |
395 | /* Add a symbol from the MAX/MIN family of intrinsic functions to the |
396 | function. MAX et al take 2 or more arguments. */ | |
397 | ||
398 | static void | |
399 | add_sym_1m (const char *name, int elemental, int actual_ok, bt type, | |
b7892582 | 400 | int kind, int standard, |
6de9cd9a DN |
401 | try (*check)(gfc_actual_arglist *), |
402 | gfc_expr *(*simplify)(gfc_expr *), | |
403 | void (*resolve)(gfc_expr *,gfc_actual_arglist *), | |
404 | const char* a1, bt type1, int kind1, int optional1, | |
1270d633 SK |
405 | const char* a2, bt type2, int kind2, int optional2) |
406 | { | |
6de9cd9a DN |
407 | gfc_check_f cf; |
408 | gfc_simplify_f sf; | |
409 | gfc_resolve_f rf; | |
410 | ||
411 | cf.f1m = check; | |
412 | sf.f1 = simplify; | |
413 | rf.f1m = resolve; | |
414 | ||
b7892582 | 415 | add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf, |
6de9cd9a DN |
416 | a1, type1, kind1, optional1, |
417 | a2, type2, kind2, optional2, | |
418 | (void*)0); | |
419 | } | |
420 | ||
421 | ||
1270d633 SK |
422 | /* Add a symbol to the function list where the function takes |
423 | 2 arguments. */ | |
424 | ||
425 | static void | |
426 | add_sym_2 (const char *name, int elemental, int actual_ok, bt type, | |
b7892582 | 427 | int kind, int standard, |
6de9cd9a DN |
428 | try (*check)(gfc_expr *,gfc_expr *), |
429 | gfc_expr *(*simplify)(gfc_expr *,gfc_expr *), | |
430 | void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *), | |
431 | const char* a1, bt type1, int kind1, int optional1, | |
1270d633 SK |
432 | const char* a2, bt type2, int kind2, int optional2) |
433 | { | |
6de9cd9a DN |
434 | gfc_check_f cf; |
435 | gfc_simplify_f sf; | |
436 | gfc_resolve_f rf; | |
437 | ||
438 | cf.f2 = check; | |
439 | sf.f2 = simplify; | |
440 | rf.f2 = resolve; | |
441 | ||
b7892582 | 442 | add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf, |
6de9cd9a DN |
443 | a1, type1, kind1, optional1, |
444 | a2, type2, kind2, optional2, | |
445 | (void*)0); | |
446 | } | |
447 | ||
448 | ||
1270d633 SK |
449 | /* Add a symbol to the subroutine list where the subroutine takes |
450 | 2 arguments. */ | |
2bd74949 | 451 | |
1270d633 SK |
452 | static void |
453 | add_sym_2s (const char *name, int elemental, int actual_ok, bt type, | |
b7892582 | 454 | int kind, int standard, |
6956a6f3 PB |
455 | try (*check)(gfc_expr *,gfc_expr *), |
456 | gfc_expr *(*simplify)(gfc_expr *,gfc_expr *), | |
2bd74949 SK |
457 | void (*resolve)(gfc_code *), |
458 | const char* a1, bt type1, int kind1, int optional1, | |
1270d633 SK |
459 | const char* a2, bt type2, int kind2, int optional2) |
460 | { | |
2bd74949 SK |
461 | gfc_check_f cf; |
462 | gfc_simplify_f sf; | |
463 | gfc_resolve_f rf; | |
464 | ||
6956a6f3 PB |
465 | cf.f2 = check; |
466 | sf.f2 = simplify; | |
2bd74949 SK |
467 | rf.s1 = resolve; |
468 | ||
b7892582 | 469 | add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf, |
2bd74949 SK |
470 | a1, type1, kind1, optional1, |
471 | a2, type2, kind2, optional2, | |
472 | (void*)0); | |
473 | } | |
474 | ||
475 | ||
1270d633 SK |
476 | /* Add a symbol to the function list where the function takes |
477 | 3 arguments. */ | |
478 | ||
479 | static void | |
480 | add_sym_3 (const char *name, int elemental, int actual_ok, bt type, | |
b7892582 | 481 | int kind, int standard, |
6de9cd9a DN |
482 | try (*check)(gfc_expr *,gfc_expr *,gfc_expr *), |
483 | gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *), | |
484 | void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *), | |
485 | const char* a1, bt type1, int kind1, int optional1, | |
486 | const char* a2, bt type2, int kind2, int optional2, | |
1270d633 SK |
487 | const char* a3, bt type3, int kind3, int optional3) |
488 | { | |
6de9cd9a DN |
489 | gfc_check_f cf; |
490 | gfc_simplify_f sf; | |
491 | gfc_resolve_f rf; | |
492 | ||
493 | cf.f3 = check; | |
494 | sf.f3 = simplify; | |
495 | rf.f3 = resolve; | |
496 | ||
b7892582 | 497 | add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf, |
6de9cd9a DN |
498 | a1, type1, kind1, optional1, |
499 | a2, type2, kind2, optional2, | |
500 | a3, type3, kind3, optional3, | |
501 | (void*)0); | |
502 | } | |
503 | ||
1270d633 | 504 | |
f3207b37 TS |
505 | /* MINLOC and MAXLOC get special treatment because their argument |
506 | might have to be reordered. */ | |
507 | ||
1270d633 SK |
508 | static void |
509 | add_sym_3ml (const char *name, int elemental, | |
b7892582 | 510 | int actual_ok, bt type, int kind, int standard, |
f3207b37 TS |
511 | try (*check)(gfc_actual_arglist *), |
512 | gfc_expr*(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *), | |
513 | void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *), | |
514 | const char* a1, bt type1, int kind1, int optional1, | |
515 | const char* a2, bt type2, int kind2, int optional2, | |
1270d633 SK |
516 | const char* a3, bt type3, int kind3, int optional3) |
517 | { | |
f3207b37 TS |
518 | gfc_check_f cf; |
519 | gfc_simplify_f sf; | |
520 | gfc_resolve_f rf; | |
521 | ||
522 | cf.f3ml = check; | |
523 | sf.f3 = simplify; | |
524 | rf.f3 = resolve; | |
525 | ||
b7892582 | 526 | add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf, |
f3207b37 TS |
527 | a1, type1, kind1, optional1, |
528 | a2, type2, kind2, optional2, | |
529 | a3, type3, kind3, optional3, | |
530 | (void*)0); | |
531 | } | |
532 | ||
1270d633 | 533 | |
7551270e ES |
534 | /* MINVAL, MAXVAL, PRODUCT, and SUM also get special treatment because |
535 | their argument also might have to be reordered. */ | |
536 | ||
1270d633 SK |
537 | static void |
538 | add_sym_3red (const char *name, int elemental, | |
b7892582 | 539 | int actual_ok, bt type, int kind, int standard, |
7551270e ES |
540 | try (*check)(gfc_actual_arglist *), |
541 | gfc_expr*(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *), | |
542 | void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *), | |
543 | const char* a1, bt type1, int kind1, int optional1, | |
544 | const char* a2, bt type2, int kind2, int optional2, | |
1270d633 SK |
545 | const char* a3, bt type3, int kind3, int optional3) |
546 | { | |
7551270e ES |
547 | gfc_check_f cf; |
548 | gfc_simplify_f sf; | |
549 | gfc_resolve_f rf; | |
550 | ||
551 | cf.f3red = check; | |
552 | sf.f3 = simplify; | |
553 | rf.f3 = resolve; | |
554 | ||
b7892582 | 555 | add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf, |
7551270e ES |
556 | a1, type1, kind1, optional1, |
557 | a2, type2, kind2, optional2, | |
558 | a3, type3, kind3, optional3, | |
559 | (void*)0); | |
560 | } | |
561 | ||
21fdfcc1 | 562 | |
1270d633 SK |
563 | /* Add a symbol to the subroutine list where the subroutine takes |
564 | 3 arguments. */ | |
565 | ||
566 | static void | |
567 | add_sym_3s (const char *name, int elemental, int actual_ok, bt type, | |
b7892582 | 568 | int kind, int standard, |
21fdfcc1 SK |
569 | try (*check)(gfc_expr *,gfc_expr *,gfc_expr *), |
570 | gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *), | |
571 | void (*resolve)(gfc_code *), | |
572 | const char* a1, bt type1, int kind1, int optional1, | |
573 | const char* a2, bt type2, int kind2, int optional2, | |
1270d633 SK |
574 | const char* a3, bt type3, int kind3, int optional3) |
575 | { | |
21fdfcc1 SK |
576 | gfc_check_f cf; |
577 | gfc_simplify_f sf; | |
578 | gfc_resolve_f rf; | |
579 | ||
580 | cf.f3 = check; | |
581 | sf.f3 = simplify; | |
582 | rf.s1 = resolve; | |
583 | ||
b7892582 | 584 | add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf, |
21fdfcc1 SK |
585 | a1, type1, kind1, optional1, |
586 | a2, type2, kind2, optional2, | |
587 | a3, type3, kind3, optional3, | |
588 | (void*)0); | |
589 | } | |
590 | ||
6de9cd9a | 591 | |
1270d633 SK |
592 | /* Add a symbol to the function list where the function takes |
593 | 4 arguments. */ | |
594 | ||
595 | static void | |
596 | add_sym_4 (const char *name, int elemental, int actual_ok, bt type, | |
b7892582 | 597 | int kind, int standard, |
6de9cd9a DN |
598 | try (*check)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *), |
599 | gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *), | |
600 | void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *), | |
601 | const char* a1, bt type1, int kind1, int optional1, | |
602 | const char* a2, bt type2, int kind2, int optional2, | |
603 | const char* a3, bt type3, int kind3, int optional3, | |
1270d633 SK |
604 | const char* a4, bt type4, int kind4, int optional4 ) |
605 | { | |
6de9cd9a DN |
606 | gfc_check_f cf; |
607 | gfc_simplify_f sf; | |
608 | gfc_resolve_f rf; | |
609 | ||
610 | cf.f4 = check; | |
611 | sf.f4 = simplify; | |
612 | rf.f4 = resolve; | |
613 | ||
b7892582 | 614 | add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf, |
6de9cd9a DN |
615 | a1, type1, kind1, optional1, |
616 | a2, type2, kind2, optional2, | |
617 | a3, type3, kind3, optional3, | |
618 | a4, type4, kind4, optional4, | |
619 | (void*)0); | |
620 | } | |
621 | ||
622 | ||
1270d633 SK |
623 | /* Add a symbol to the subroutine list where the subroutine takes |
624 | 4 arguments. */ | |
625 | ||
626 | static void | |
627 | add_sym_4s (const char *name, int elemental, int actual_ok, | |
b7892582 | 628 | bt type, int kind, int standard, |
60c9a35b PB |
629 | try (*check)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *), |
630 | gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *), | |
631 | void (*resolve)(gfc_code *), | |
632 | const char* a1, bt type1, int kind1, int optional1, | |
633 | const char* a2, bt type2, int kind2, int optional2, | |
634 | const char* a3, bt type3, int kind3, int optional3, | |
635 | const char* a4, bt type4, int kind4, int optional4) | |
636 | { | |
637 | gfc_check_f cf; | |
638 | gfc_simplify_f sf; | |
639 | gfc_resolve_f rf; | |
640 | ||
641 | cf.f4 = check; | |
642 | sf.f4 = simplify; | |
643 | rf.s1 = resolve; | |
644 | ||
b7892582 | 645 | add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf, |
60c9a35b PB |
646 | a1, type1, kind1, optional1, |
647 | a2, type2, kind2, optional2, | |
648 | a3, type3, kind3, optional3, | |
649 | a4, type4, kind4, optional4, | |
650 | (void*)0); | |
651 | } | |
652 | ||
653 | ||
1270d633 SK |
654 | /* Add a symbol to the subroutine list where the subroutine takes |
655 | 5 arguments. */ | |
656 | ||
657 | static void | |
658 | add_sym_5s (const char *name, int elemental, int actual_ok, | |
b7892582 | 659 | bt type, int kind, int standard, |
aa6fc635 JB |
660 | try (*check)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *), |
661 | gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *), | |
662 | void (*resolve)(gfc_code *), | |
663 | const char* a1, bt type1, int kind1, int optional1, | |
664 | const char* a2, bt type2, int kind2, int optional2, | |
665 | const char* a3, bt type3, int kind3, int optional3, | |
666 | const char* a4, bt type4, int kind4, int optional4, | |
667 | const char* a5, bt type5, int kind5, int optional5) | |
668 | { | |
669 | gfc_check_f cf; | |
670 | gfc_simplify_f sf; | |
671 | gfc_resolve_f rf; | |
672 | ||
673 | cf.f5 = check; | |
674 | sf.f5 = simplify; | |
675 | rf.s1 = resolve; | |
676 | ||
b7892582 | 677 | add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf, |
aa6fc635 JB |
678 | a1, type1, kind1, optional1, |
679 | a2, type2, kind2, optional2, | |
680 | a3, type3, kind3, optional3, | |
681 | a4, type4, kind4, optional4, | |
682 | a5, type5, kind5, optional5, | |
683 | (void*)0); | |
684 | } | |
685 | ||
686 | ||
6de9cd9a DN |
687 | /* Locate an intrinsic symbol given a base pointer, number of elements |
688 | in the table and a pointer to a name. Returns the NULL pointer if | |
689 | a name is not found. */ | |
690 | ||
691 | static gfc_intrinsic_sym * | |
692 | find_sym (gfc_intrinsic_sym * start, int n, const char *name) | |
693 | { | |
694 | ||
695 | while (n > 0) | |
696 | { | |
697 | if (strcmp (name, start->name) == 0) | |
698 | return start; | |
699 | ||
700 | start++; | |
701 | n--; | |
702 | } | |
703 | ||
704 | return NULL; | |
705 | } | |
706 | ||
707 | ||
708 | /* Given a name, find a function in the intrinsic function table. | |
709 | Returns NULL if not found. */ | |
710 | ||
711 | gfc_intrinsic_sym * | |
712 | gfc_find_function (const char *name) | |
713 | { | |
714 | ||
715 | return find_sym (functions, nfunc, name); | |
716 | } | |
717 | ||
718 | ||
719 | /* Given a name, find a function in the intrinsic subroutine table. | |
720 | Returns NULL if not found. */ | |
721 | ||
722 | static gfc_intrinsic_sym * | |
723 | find_subroutine (const char *name) | |
724 | { | |
725 | ||
726 | return find_sym (subroutines, nsub, name); | |
727 | } | |
728 | ||
729 | ||
730 | /* Given a string, figure out if it is the name of a generic intrinsic | |
731 | function or not. */ | |
732 | ||
733 | int | |
734 | gfc_generic_intrinsic (const char *name) | |
735 | { | |
736 | gfc_intrinsic_sym *sym; | |
737 | ||
738 | sym = gfc_find_function (name); | |
739 | return (sym == NULL) ? 0 : sym->generic; | |
740 | } | |
741 | ||
742 | ||
743 | /* Given a string, figure out if it is the name of a specific | |
744 | intrinsic function or not. */ | |
745 | ||
746 | int | |
747 | gfc_specific_intrinsic (const char *name) | |
748 | { | |
749 | gfc_intrinsic_sym *sym; | |
750 | ||
751 | sym = gfc_find_function (name); | |
752 | return (sym == NULL) ? 0 : sym->specific; | |
753 | } | |
754 | ||
755 | ||
756 | /* Given a string, figure out if it is the name of an intrinsic | |
757 | subroutine or function. There are no generic intrinsic | |
758 | subroutines, they are all specific. */ | |
759 | ||
760 | int | |
761 | gfc_intrinsic_name (const char *name, int subroutine_flag) | |
762 | { | |
763 | ||
764 | return subroutine_flag ? | |
765 | find_subroutine (name) != NULL : gfc_find_function (name) != NULL; | |
766 | } | |
767 | ||
768 | ||
769 | /* Collect a set of intrinsic functions into a generic collection. | |
770 | The first argument is the name of the generic function, which is | |
771 | also the name of a specific function. The rest of the specifics | |
772 | currently in the table are placed into the list of specific | |
773 | functions associated with that generic. */ | |
774 | ||
775 | static void | |
b7892582 | 776 | make_generic (const char *name, gfc_generic_isym_id generic_id, int standard) |
6de9cd9a DN |
777 | { |
778 | gfc_intrinsic_sym *g; | |
779 | ||
b7892582 JB |
780 | if (!(gfc_option.allow_std & standard)) |
781 | return; | |
782 | ||
6de9cd9a DN |
783 | if (sizing != SZ_NOTHING) |
784 | return; | |
785 | ||
786 | g = gfc_find_function (name); | |
787 | if (g == NULL) | |
788 | gfc_internal_error ("make_generic(): Can't find generic symbol '%s'", | |
789 | name); | |
790 | ||
791 | g->generic = 1; | |
792 | g->specific = 1; | |
793 | g->generic_id = generic_id; | |
cb9e4f55 | 794 | if ((g + 1)->name != NULL) |
6de9cd9a DN |
795 | g->specific_head = g + 1; |
796 | g++; | |
797 | ||
cb9e4f55 | 798 | while (g->name != NULL) |
6de9cd9a DN |
799 | { |
800 | g->next = g + 1; | |
801 | g->specific = 1; | |
802 | g->generic_id = generic_id; | |
803 | g++; | |
804 | } | |
805 | ||
806 | g--; | |
807 | g->next = NULL; | |
808 | } | |
809 | ||
810 | ||
811 | /* Create a duplicate intrinsic function entry for the current | |
812 | function, the only difference being the alternate name. Note that | |
813 | we use argument lists more than once, but all argument lists are | |
814 | freed as a single block. */ | |
815 | ||
816 | static void | |
19060788 | 817 | make_alias (const char *name, int standard) |
6de9cd9a DN |
818 | { |
819 | ||
19060788 SK |
820 | /* First check that the intrinsic belongs to the selected standard. |
821 | If not, don't add it to the symbol list. */ | |
822 | if (!(gfc_option.allow_std & standard)) | |
823 | return; | |
824 | ||
6de9cd9a DN |
825 | switch (sizing) |
826 | { | |
827 | case SZ_FUNCS: | |
828 | nfunc++; | |
829 | break; | |
830 | ||
831 | case SZ_SUBS: | |
832 | nsub++; | |
833 | break; | |
834 | ||
835 | case SZ_NOTHING: | |
836 | next_sym[0] = next_sym[-1]; | |
cb9e4f55 | 837 | next_sym->name = gfc_get_string (name); |
6de9cd9a DN |
838 | next_sym++; |
839 | break; | |
840 | ||
841 | default: | |
842 | break; | |
843 | } | |
844 | } | |
845 | ||
fe58e076 TK |
846 | /* Make the current subroutine noreturn. */ |
847 | ||
848 | static void | |
849 | make_noreturn(void) | |
850 | { | |
851 | if (sizing == SZ_NOTHING) | |
852 | next_sym[-1].noreturn = 1; | |
853 | } | |
6de9cd9a DN |
854 | |
855 | /* Add intrinsic functions. */ | |
856 | ||
857 | static void | |
858 | add_functions (void) | |
859 | { | |
860 | ||
861 | /* Argument names as in the standard (to be used as argument keywords). */ | |
862 | const char | |
863 | *a = "a", *f = "field", *pt = "pointer", *tg = "target", | |
864 | *b = "b", *m = "matrix", *ma = "matrix_a", *mb = "matrix_b", | |
865 | *c = "c", *n = "ncopies", *pos = "pos", *bck = "back", | |
866 | *i = "i", *v = "vector", *va = "vector_a", *vb = "vector_b", | |
867 | *j = "j", *a1 = "a1", *fs = "fsource", *ts = "tsource", | |
868 | *l = "l", *a2 = "a2", *mo = "mold", *ord = "order", | |
869 | *p = "p", *ar = "array", *shp = "shape", *src = "source", | |
870 | *r = "r", *bd = "boundary", *pad = "pad", *set = "set", | |
871 | *s = "s", *dm = "dim", *kind = "kind", *msk = "mask", | |
872 | *x = "x", *sh = "shift", *stg = "string", *ssg = "substring", | |
873 | *y = "y", *sz = "size", *sta = "string_a", *stb = "string_b", | |
185d7d97 | 874 | *z = "z", *ln = "len", *ut = "unit", *han = "handler", |
35059811 | 875 | *num = "number", *tm = "time"; |
6de9cd9a DN |
876 | |
877 | int di, dr, dd, dl, dc, dz, ii; | |
878 | ||
9d64df18 TS |
879 | di = gfc_default_integer_kind; |
880 | dr = gfc_default_real_kind; | |
881 | dd = gfc_default_double_kind; | |
882 | dl = gfc_default_logical_kind; | |
883 | dc = gfc_default_character_kind; | |
884 | dz = gfc_default_complex_kind; | |
6de9cd9a DN |
885 | ii = gfc_index_integer_kind; |
886 | ||
b7892582 | 887 | add_sym_1 ("abs", 1, 1, BT_REAL, dr, GFC_STD_F77, |
6de9cd9a | 888 | gfc_check_abs, gfc_simplify_abs, gfc_resolve_abs, |
1270d633 | 889 | a, BT_REAL, dr, REQUIRED); |
6de9cd9a | 890 | |
b7892582 | 891 | add_sym_1 ("iabs", 1, 1, BT_INTEGER, di, GFC_STD_F77, |
6de9cd9a | 892 | NULL, gfc_simplify_abs, gfc_resolve_abs, |
1270d633 | 893 | a, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 894 | |
b7892582 | 895 | add_sym_1 ("dabs", 1, 1, BT_REAL, dd, GFC_STD_F77, |
1270d633 SK |
896 | NULL, gfc_simplify_abs, gfc_resolve_abs, |
897 | a, BT_REAL, dd, REQUIRED); | |
6de9cd9a | 898 | |
b7892582 | 899 | add_sym_1 ("cabs", 1, 1, BT_REAL, dr, GFC_STD_F77, |
6de9cd9a | 900 | NULL, gfc_simplify_abs, gfc_resolve_abs, |
1270d633 | 901 | a, BT_COMPLEX, dz, REQUIRED); |
6de9cd9a | 902 | |
b7892582 JB |
903 | add_sym_1 ("zabs", 1, 1, BT_REAL, dd, GFC_STD_GNU, |
904 | NULL, gfc_simplify_abs, gfc_resolve_abs, | |
1270d633 | 905 | a, BT_COMPLEX, dd, REQUIRED); |
6de9cd9a | 906 | |
19060788 | 907 | make_alias ("cdabs", GFC_STD_GNU); |
6de9cd9a | 908 | |
b7892582 | 909 | make_generic ("abs", GFC_ISYM_ABS, GFC_STD_F77); |
6de9cd9a | 910 | |
b7892582 | 911 | add_sym_1 ("achar", 1, 1, BT_CHARACTER, dc, GFC_STD_F95, |
332e7efe | 912 | gfc_check_achar, gfc_simplify_achar, NULL, |
1270d633 | 913 | i, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 914 | |
b7892582 | 915 | make_generic ("achar", GFC_ISYM_ACHAR, GFC_STD_F95); |
6de9cd9a | 916 | |
b7892582 | 917 | add_sym_1 ("acos", 1, 1, BT_REAL, dr, GFC_STD_F77, |
985aff9c | 918 | gfc_check_fn_r, gfc_simplify_acos, gfc_resolve_acos, |
1270d633 | 919 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 920 | |
b7892582 | 921 | add_sym_1 ("dacos", 1, 1, BT_REAL, dd, GFC_STD_F77, |
6de9cd9a | 922 | NULL, gfc_simplify_acos, gfc_resolve_acos, |
1270d633 | 923 | x, BT_REAL, dd, REQUIRED); |
6de9cd9a | 924 | |
b7892582 | 925 | make_generic ("acos", GFC_ISYM_ACOS, GFC_STD_F77); |
6de9cd9a | 926 | |
1e399e23 JD |
927 | add_sym_1 ("acosh", 1, 1, BT_REAL, dr, GFC_STD_GNU, |
928 | gfc_check_fn_r, gfc_simplify_acosh, gfc_resolve_acosh, | |
929 | x, BT_REAL, dr, REQUIRED); | |
930 | ||
931 | add_sym_1 ("dacosh", 1, 1, BT_REAL, dd, GFC_STD_GNU, | |
932 | NULL, gfc_simplify_acosh, gfc_resolve_acosh, | |
933 | x, BT_REAL, dd, REQUIRED); | |
934 | ||
935 | make_generic ("acosh", GFC_ISYM_ACOSH, GFC_STD_GNU); | |
936 | ||
b7892582 | 937 | add_sym_1 ("adjustl", 1, 1, BT_CHARACTER, dc, GFC_STD_F95, |
1270d633 SK |
938 | NULL, gfc_simplify_adjustl, NULL, |
939 | stg, BT_CHARACTER, dc, REQUIRED); | |
6de9cd9a | 940 | |
b7892582 | 941 | make_generic ("adjustl", GFC_ISYM_ADJUSTL, GFC_STD_F95); |
6de9cd9a | 942 | |
b7892582 | 943 | add_sym_1 ("adjustr", 1, 1, BT_CHARACTER, dc, GFC_STD_F95, |
1270d633 SK |
944 | NULL, gfc_simplify_adjustr, NULL, |
945 | stg, BT_CHARACTER, dc, REQUIRED); | |
6de9cd9a | 946 | |
b7892582 | 947 | make_generic ("adjustr", GFC_ISYM_ADJUSTR, GFC_STD_F95); |
6de9cd9a | 948 | |
b7892582 | 949 | add_sym_1 ("aimag", 1, 1, BT_REAL, dr, GFC_STD_F77, |
985aff9c | 950 | gfc_check_fn_c, gfc_simplify_aimag, gfc_resolve_aimag, |
1270d633 | 951 | z, BT_COMPLEX, dz, REQUIRED); |
6de9cd9a | 952 | |
6970fcc8 SK |
953 | make_alias ("imag", GFC_STD_GNU); |
954 | make_alias ("imagpart", GFC_STD_GNU); | |
955 | ||
b7892582 JB |
956 | add_sym_1 ("dimag", 1, 1, BT_REAL, dd, GFC_STD_GNU, |
957 | NULL, gfc_simplify_aimag, gfc_resolve_aimag, | |
1270d633 | 958 | z, BT_COMPLEX, dd, REQUIRED); |
6de9cd9a | 959 | |
6970fcc8 | 960 | |
b7892582 | 961 | make_generic ("aimag", GFC_ISYM_AIMAG, GFC_STD_F77); |
6de9cd9a | 962 | |
b7892582 | 963 | add_sym_2 ("aint", 1, 1, BT_REAL, dr, GFC_STD_F77, |
6de9cd9a | 964 | gfc_check_a_xkind, gfc_simplify_aint, gfc_resolve_aint, |
1270d633 | 965 | a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL); |
6de9cd9a | 966 | |
b7892582 | 967 | add_sym_1 ("dint", 1, 1, BT_REAL, dd, GFC_STD_F77, |
6de9cd9a | 968 | NULL, gfc_simplify_dint, gfc_resolve_dint, |
1270d633 | 969 | a, BT_REAL, dd, REQUIRED); |
6de9cd9a | 970 | |
b7892582 | 971 | make_generic ("aint", GFC_ISYM_AINT, GFC_STD_F77); |
6de9cd9a | 972 | |
b7892582 | 973 | add_sym_2 ("all", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95, |
6de9cd9a | 974 | gfc_check_all_any, NULL, gfc_resolve_all, |
1270d633 | 975 | msk, BT_LOGICAL, dl, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL); |
6de9cd9a | 976 | |
b7892582 | 977 | make_generic ("all", GFC_ISYM_ALL, GFC_STD_F95); |
6de9cd9a | 978 | |
b7892582 | 979 | add_sym_1 ("allocated", 0, 1, BT_LOGICAL, dl, GFC_STD_F95, |
1270d633 SK |
980 | gfc_check_allocated, NULL, NULL, |
981 | ar, BT_UNKNOWN, 0, REQUIRED); | |
6de9cd9a | 982 | |
b7892582 | 983 | make_generic ("allocated", GFC_ISYM_ALLOCATED, GFC_STD_F95); |
6de9cd9a | 984 | |
b7892582 | 985 | add_sym_2 ("anint", 1, 1, BT_REAL, dr, GFC_STD_F77, |
6de9cd9a | 986 | gfc_check_a_xkind, gfc_simplify_anint, gfc_resolve_anint, |
1270d633 | 987 | a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL); |
6de9cd9a | 988 | |
b7892582 | 989 | add_sym_1 ("dnint", 1, 1, BT_REAL, dd, GFC_STD_F77, |
6de9cd9a | 990 | NULL, gfc_simplify_dnint, gfc_resolve_dnint, |
1270d633 | 991 | a, BT_REAL, dd, REQUIRED); |
6de9cd9a | 992 | |
b7892582 | 993 | make_generic ("anint", GFC_ISYM_ANINT, GFC_STD_F77); |
6de9cd9a | 994 | |
b7892582 | 995 | add_sym_2 ("any", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95, |
6de9cd9a | 996 | gfc_check_all_any, NULL, gfc_resolve_any, |
1270d633 | 997 | msk, BT_LOGICAL, dl, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL); |
6de9cd9a | 998 | |
b7892582 | 999 | make_generic ("any", GFC_ISYM_ANY, GFC_STD_F95); |
6de9cd9a | 1000 | |
b7892582 | 1001 | add_sym_1 ("asin", 1, 1, BT_REAL, dr, GFC_STD_F77, |
985aff9c | 1002 | gfc_check_fn_r, gfc_simplify_asin, gfc_resolve_asin, |
1270d633 | 1003 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1004 | |
b7892582 | 1005 | add_sym_1 ("dasin", 1, 1, BT_REAL, dd, GFC_STD_F77, |
6de9cd9a | 1006 | NULL, gfc_simplify_asin, gfc_resolve_asin, |
1270d633 | 1007 | x, BT_REAL, dd, REQUIRED); |
6de9cd9a | 1008 | |
b7892582 | 1009 | make_generic ("asin", GFC_ISYM_ASIN, GFC_STD_F77); |
1e399e23 JD |
1010 | |
1011 | add_sym_1 ("asinh", 1, 1, BT_REAL, dr, GFC_STD_GNU, | |
1012 | gfc_check_fn_r, gfc_simplify_asinh, gfc_resolve_asinh, | |
1013 | x, BT_REAL, dr, REQUIRED); | |
1014 | ||
1015 | add_sym_1 ("dasinh", 1, 1, BT_REAL, dd, GFC_STD_GNU, | |
1016 | NULL, gfc_simplify_asinh, gfc_resolve_asinh, | |
1017 | x, BT_REAL, dd, REQUIRED); | |
1018 | ||
1019 | make_generic ("asinh", GFC_ISYM_ASINH, GFC_STD_GNU); | |
6de9cd9a | 1020 | |
b7892582 | 1021 | add_sym_2 ("associated", 0, 1, BT_LOGICAL, dl, GFC_STD_F95, |
6de9cd9a | 1022 | gfc_check_associated, NULL, NULL, |
1270d633 | 1023 | pt, BT_UNKNOWN, 0, REQUIRED, tg, BT_UNKNOWN, 0, OPTIONAL); |
6de9cd9a | 1024 | |
b7892582 | 1025 | make_generic ("associated", GFC_ISYM_ASSOCIATED, GFC_STD_F95); |
6de9cd9a | 1026 | |
b7892582 | 1027 | add_sym_1 ("atan", 1, 1, BT_REAL, dr, GFC_STD_F77, |
985aff9c | 1028 | gfc_check_fn_r, gfc_simplify_atan, gfc_resolve_atan, |
1270d633 | 1029 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1030 | |
b7892582 | 1031 | add_sym_1 ("datan", 1, 1, BT_REAL, dd, GFC_STD_F77, |
6de9cd9a | 1032 | NULL, gfc_simplify_atan, gfc_resolve_atan, |
1270d633 | 1033 | x, BT_REAL, dd, REQUIRED); |
6de9cd9a | 1034 | |
b7892582 | 1035 | make_generic ("atan", GFC_ISYM_ATAN, GFC_STD_F77); |
1e399e23 JD |
1036 | |
1037 | add_sym_1 ("atanh", 1, 1, BT_REAL, dr, GFC_STD_GNU, | |
1038 | gfc_check_fn_r, gfc_simplify_atanh, gfc_resolve_atanh, | |
1039 | x, BT_REAL, dr, REQUIRED); | |
1040 | ||
1041 | add_sym_1 ("datanh", 1, 1, BT_REAL, dd, GFC_STD_GNU, | |
1042 | NULL, gfc_simplify_atanh, gfc_resolve_atanh, | |
1043 | x, BT_REAL, dd, REQUIRED); | |
1044 | ||
1045 | make_generic ("atanh", GFC_ISYM_ATANH, GFC_STD_GNU); | |
6de9cd9a | 1046 | |
b7892582 | 1047 | add_sym_2 ("atan2", 1, 1, BT_REAL, dr, GFC_STD_F77, |
a1bab9ea | 1048 | gfc_check_atan2, gfc_simplify_atan2, gfc_resolve_atan2, |
1270d633 | 1049 | y, BT_REAL, dr, REQUIRED, x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1050 | |
b7892582 | 1051 | add_sym_2 ("datan2", 1, 1, BT_REAL, dd, GFC_STD_F77, |
6de9cd9a | 1052 | NULL, gfc_simplify_atan2, gfc_resolve_atan2, |
1270d633 | 1053 | y, BT_REAL, dd, REQUIRED, x, BT_REAL, dd, REQUIRED); |
6de9cd9a | 1054 | |
b7892582 | 1055 | make_generic ("atan2", GFC_ISYM_ATAN2, GFC_STD_F77); |
1e399e23 | 1056 | |
e8525382 | 1057 | /* Bessel and Neumann functions for G77 compatibility. */ |
b7892582 | 1058 | add_sym_1 ("besj0", 1, 0, BT_REAL, dr, GFC_STD_GNU, |
e8525382 | 1059 | gfc_check_g77_math1, NULL, gfc_resolve_g77_math1, |
1270d633 | 1060 | x, BT_REAL, dr, REQUIRED); |
e8525382 | 1061 | |
b7892582 | 1062 | add_sym_1 ("dbesj0", 1, 0, BT_REAL, dd, GFC_STD_GNU, |
e8525382 | 1063 | gfc_check_g77_math1, NULL, gfc_resolve_g77_math1, |
1270d633 | 1064 | x, BT_REAL, dd, REQUIRED); |
e8525382 | 1065 | |
b7892582 | 1066 | make_generic ("besj0", GFC_ISYM_J0, GFC_STD_GNU); |
e8525382 | 1067 | |
b7892582 | 1068 | add_sym_1 ("besj1", 1, 0, BT_REAL, dr, GFC_STD_GNU, |
e8525382 | 1069 | gfc_check_g77_math1, NULL, gfc_resolve_g77_math1, |
1270d633 | 1070 | x, BT_REAL, dr, REQUIRED); |
e8525382 | 1071 | |
b7892582 | 1072 | add_sym_1 ("dbesj1", 1, 0, BT_REAL, dd, GFC_STD_GNU, |
e8525382 | 1073 | gfc_check_g77_math1, NULL, gfc_resolve_g77_math1, |
1270d633 | 1074 | x, BT_REAL, dd, REQUIRED); |
e8525382 | 1075 | |
b7892582 | 1076 | make_generic ("besj1", GFC_ISYM_J1, GFC_STD_GNU); |
e8525382 | 1077 | |
b7892582 | 1078 | add_sym_2 ("besjn", 1, 0, BT_REAL, dr, GFC_STD_GNU, |
1270d633 SK |
1079 | gfc_check_besn, NULL, gfc_resolve_besn, |
1080 | n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dr, REQUIRED); | |
e8525382 | 1081 | |
b7892582 | 1082 | add_sym_2 ("dbesjn", 1, 0, BT_REAL, dd, GFC_STD_GNU, |
1270d633 SK |
1083 | gfc_check_besn, NULL, gfc_resolve_besn, |
1084 | n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dd, REQUIRED); | |
e8525382 | 1085 | |
b7892582 | 1086 | make_generic ("besjn", GFC_ISYM_JN, GFC_STD_GNU); |
e8525382 | 1087 | |
b7892582 | 1088 | add_sym_1 ("besy0", 1, 0, BT_REAL, dr, GFC_STD_GNU, |
e8525382 | 1089 | gfc_check_g77_math1, NULL, gfc_resolve_g77_math1, |
1270d633 | 1090 | x, BT_REAL, dr, REQUIRED); |
e8525382 | 1091 | |
b7892582 | 1092 | add_sym_1 ("dbesy0", 1, 0, BT_REAL, dd, GFC_STD_GNU, |
e8525382 | 1093 | gfc_check_g77_math1, NULL, gfc_resolve_g77_math1, |
1270d633 | 1094 | x, BT_REAL, dd, REQUIRED); |
e8525382 | 1095 | |
b7892582 | 1096 | make_generic ("besy0", GFC_ISYM_Y0, GFC_STD_GNU); |
e8525382 | 1097 | |
b7892582 | 1098 | add_sym_1 ("besy1", 1, 0, BT_REAL, dr, GFC_STD_GNU, |
e8525382 | 1099 | gfc_check_g77_math1, NULL, gfc_resolve_g77_math1, |
1270d633 | 1100 | x, BT_REAL, dr, REQUIRED); |
e8525382 | 1101 | |
b7892582 | 1102 | add_sym_1 ("dbesy1", 1, 0, BT_REAL, dd, GFC_STD_GNU, |
e8525382 | 1103 | gfc_check_g77_math1, NULL, gfc_resolve_g77_math1, |
1270d633 | 1104 | x, BT_REAL, dd, REQUIRED); |
e8525382 | 1105 | |
b7892582 | 1106 | make_generic ("besy1", GFC_ISYM_Y1, GFC_STD_GNU); |
e8525382 | 1107 | |
b7892582 | 1108 | add_sym_2 ("besyn", 1, 0, BT_REAL, dr, GFC_STD_GNU, |
1270d633 SK |
1109 | gfc_check_besn, NULL, gfc_resolve_besn, |
1110 | n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dr, REQUIRED); | |
e8525382 | 1111 | |
b7892582 | 1112 | add_sym_2 ("dbesyn", 1, 0, BT_REAL, dd, GFC_STD_GNU, |
1270d633 SK |
1113 | gfc_check_besn, NULL, gfc_resolve_besn, |
1114 | n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dd, REQUIRED); | |
e8525382 | 1115 | |
b7892582 | 1116 | make_generic ("besyn", GFC_ISYM_YN, GFC_STD_GNU); |
e8525382 | 1117 | |
b7892582 | 1118 | add_sym_1 ("bit_size", 0, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1119 | gfc_check_i, gfc_simplify_bit_size, NULL, |
1270d633 | 1120 | i, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1121 | |
b7892582 | 1122 | make_generic ("bit_size", GFC_ISYM_NONE, GFC_STD_F95); |
6de9cd9a | 1123 | |
b7892582 | 1124 | add_sym_2 ("btest", 1, 1, BT_LOGICAL, dl, GFC_STD_F95, |
6de9cd9a | 1125 | gfc_check_btest, gfc_simplify_btest, gfc_resolve_btest, |
1270d633 | 1126 | i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1127 | |
b7892582 | 1128 | make_generic ("btest", GFC_ISYM_BTEST, GFC_STD_F95); |
6de9cd9a | 1129 | |
b7892582 | 1130 | add_sym_2 ("ceiling", 1, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1131 | gfc_check_a_ikind, gfc_simplify_ceiling, gfc_resolve_ceiling, |
1270d633 | 1132 | a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL); |
6de9cd9a | 1133 | |
b7892582 | 1134 | make_generic ("ceiling", GFC_ISYM_CEILING, GFC_STD_F95); |
6de9cd9a | 1135 | |
b7892582 | 1136 | add_sym_2 ("char", 1, 0, BT_CHARACTER, dc, GFC_STD_F77, |
6de9cd9a | 1137 | gfc_check_char, gfc_simplify_char, gfc_resolve_char, |
1270d633 | 1138 | i, BT_INTEGER, di, REQUIRED, kind, BT_INTEGER, di, OPTIONAL); |
6de9cd9a | 1139 | |
b7892582 | 1140 | make_generic ("char", GFC_ISYM_CHAR, GFC_STD_F77); |
6de9cd9a | 1141 | |
f77b6ca3 FXC |
1142 | add_sym_1 ("chdir", 0, 1, BT_INTEGER, di, GFC_STD_GNU, |
1143 | gfc_check_chdir, NULL, gfc_resolve_chdir, | |
1144 | a, BT_CHARACTER, dc, REQUIRED); | |
1145 | ||
1146 | make_generic ("chdir", GFC_ISYM_CHDIR, GFC_STD_GNU); | |
1147 | ||
b7892582 | 1148 | add_sym_3 ("cmplx", 1, 1, BT_COMPLEX, dz, GFC_STD_F77, |
6de9cd9a | 1149 | gfc_check_cmplx, gfc_simplify_cmplx, gfc_resolve_cmplx, |
1270d633 SK |
1150 | x, BT_UNKNOWN, dr, REQUIRED, y, BT_UNKNOWN, dr, OPTIONAL, |
1151 | kind, BT_INTEGER, di, OPTIONAL); | |
6de9cd9a | 1152 | |
b7892582 | 1153 | make_generic ("cmplx", GFC_ISYM_CMPLX, GFC_STD_F77); |
6de9cd9a DN |
1154 | |
1155 | /* Making dcmplx a specific of cmplx causes cmplx to return a double | |
1156 | complex instead of the default complex. */ | |
1157 | ||
b7892582 | 1158 | add_sym_2 ("dcmplx", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU, |
6de9cd9a | 1159 | gfc_check_dcmplx, gfc_simplify_dcmplx, gfc_resolve_dcmplx, |
1270d633 | 1160 | x, BT_REAL, dd, REQUIRED, y, BT_REAL, dd, OPTIONAL); |
6de9cd9a | 1161 | |
b7892582 | 1162 | make_generic ("dcmplx", GFC_ISYM_CMPLX, GFC_STD_GNU); |
6de9cd9a | 1163 | |
b7892582 | 1164 | add_sym_1 ("conjg", 1, 1, BT_COMPLEX, dz, GFC_STD_F77, |
985aff9c | 1165 | gfc_check_fn_c, gfc_simplify_conjg, gfc_resolve_conjg, |
1270d633 | 1166 | z, BT_COMPLEX, dz, REQUIRED); |
6de9cd9a | 1167 | |
b7892582 JB |
1168 | add_sym_1 ("dconjg", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU, |
1169 | NULL, gfc_simplify_conjg, gfc_resolve_conjg, | |
1270d633 | 1170 | z, BT_COMPLEX, dd, REQUIRED); |
6de9cd9a | 1171 | |
b7892582 | 1172 | make_generic ("conjg", GFC_ISYM_CONJG, GFC_STD_F77); |
6de9cd9a | 1173 | |
b7892582 | 1174 | add_sym_1 ("cos", 1, 1, BT_REAL, dr, GFC_STD_F77, |
985aff9c | 1175 | gfc_check_fn_rc, gfc_simplify_cos, gfc_resolve_cos, |
1270d633 | 1176 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1177 | |
b7892582 | 1178 | add_sym_1 ("dcos", 1, 1, BT_REAL, dd, GFC_STD_F77, |
985aff9c | 1179 | gfc_check_fn_rc, gfc_simplify_cos, gfc_resolve_cos, |
1270d633 | 1180 | x, BT_REAL, dd, REQUIRED); |
6de9cd9a | 1181 | |
b7892582 | 1182 | add_sym_1 ("ccos", 1, 1, BT_COMPLEX, dz, GFC_STD_F77, |
6de9cd9a | 1183 | NULL, gfc_simplify_cos, gfc_resolve_cos, |
1270d633 | 1184 | x, BT_COMPLEX, dz, REQUIRED); |
6de9cd9a | 1185 | |
b7892582 JB |
1186 | add_sym_1 ("zcos", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU, |
1187 | NULL, gfc_simplify_cos, gfc_resolve_cos, | |
1270d633 | 1188 | x, BT_COMPLEX, dd, REQUIRED); |
6de9cd9a | 1189 | |
19060788 | 1190 | make_alias ("cdcos", GFC_STD_GNU); |
6de9cd9a | 1191 | |
b7892582 | 1192 | make_generic ("cos", GFC_ISYM_COS, GFC_STD_F77); |
6de9cd9a | 1193 | |
b7892582 | 1194 | add_sym_1 ("cosh", 1, 1, BT_REAL, dr, GFC_STD_F77, |
985aff9c | 1195 | gfc_check_fn_r, gfc_simplify_cosh, gfc_resolve_cosh, |
1270d633 | 1196 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1197 | |
b7892582 | 1198 | add_sym_1 ("dcosh", 1, 1, BT_REAL, dd, GFC_STD_F77, |
6de9cd9a | 1199 | NULL, gfc_simplify_cosh, gfc_resolve_cosh, |
1270d633 | 1200 | x, BT_REAL, dd, REQUIRED); |
6de9cd9a | 1201 | |
b7892582 | 1202 | make_generic ("cosh", GFC_ISYM_COSH, GFC_STD_F77); |
6de9cd9a | 1203 | |
b7892582 | 1204 | add_sym_2 ("count", 0, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1205 | gfc_check_count, NULL, gfc_resolve_count, |
1270d633 | 1206 | msk, BT_LOGICAL, dl, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL); |
6de9cd9a | 1207 | |
b7892582 | 1208 | make_generic ("count", GFC_ISYM_COUNT, GFC_STD_F95); |
6de9cd9a | 1209 | |
b7892582 | 1210 | add_sym_3 ("cshift", 0, 1, BT_REAL, dr, GFC_STD_F95, |
6de9cd9a | 1211 | gfc_check_cshift, NULL, gfc_resolve_cshift, |
1270d633 SK |
1212 | ar, BT_REAL, dr, REQUIRED, sh, BT_INTEGER, di, REQUIRED, |
1213 | dm, BT_INTEGER, ii, OPTIONAL); | |
6de9cd9a | 1214 | |
b7892582 | 1215 | make_generic ("cshift", GFC_ISYM_CSHIFT, GFC_STD_F95); |
6de9cd9a | 1216 | |
35059811 FXC |
1217 | add_sym_1 ("ctime", 0, 1, BT_CHARACTER, 0, GFC_STD_GNU, |
1218 | gfc_check_ctime, NULL, gfc_resolve_ctime, | |
1219 | tm, BT_INTEGER, di, REQUIRED); | |
1220 | ||
1221 | make_generic ("ctime", GFC_ISYM_CTIME, GFC_STD_GNU); | |
1222 | ||
b7892582 | 1223 | add_sym_1 ("dble", 1, 1, BT_REAL, dd, GFC_STD_F77, |
6de9cd9a | 1224 | gfc_check_dble, gfc_simplify_dble, gfc_resolve_dble, |
1270d633 | 1225 | a, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1226 | |
19060788 | 1227 | make_alias ("dfloat", GFC_STD_GNU); |
3ec0f302 | 1228 | |
b7892582 | 1229 | make_generic ("dble", GFC_ISYM_DBLE, GFC_STD_F77); |
6de9cd9a | 1230 | |
b7892582 | 1231 | add_sym_1 ("digits", 0, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1232 | gfc_check_digits, gfc_simplify_digits, NULL, |
1270d633 | 1233 | x, BT_UNKNOWN, dr, REQUIRED); |
6de9cd9a | 1234 | |
b7892582 | 1235 | make_generic ("digits", GFC_ISYM_NONE, GFC_STD_F95); |
6de9cd9a | 1236 | |
b7892582 | 1237 | add_sym_2 ("dim", 1, 1, BT_REAL, dr, GFC_STD_F77, |
6de9cd9a | 1238 | gfc_check_a_p, gfc_simplify_dim, gfc_resolve_dim, |
1270d633 | 1239 | x, BT_UNKNOWN, dr, REQUIRED, y, BT_UNKNOWN, dr, REQUIRED); |
6de9cd9a | 1240 | |
b7892582 | 1241 | add_sym_2 ("idim", 1, 1, BT_INTEGER, di, GFC_STD_F77, |
6de9cd9a | 1242 | NULL, gfc_simplify_dim, gfc_resolve_dim, |
1270d633 | 1243 | x, BT_INTEGER, di, REQUIRED, y, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1244 | |
b7892582 | 1245 | add_sym_2 ("ddim", 1, 1, BT_REAL, dd, GFC_STD_F77, |
6de9cd9a | 1246 | NULL, gfc_simplify_dim, gfc_resolve_dim, |
1270d633 | 1247 | x, BT_REAL, dd, REQUIRED, y, BT_REAL, dd, REQUIRED); |
6de9cd9a | 1248 | |
b7892582 | 1249 | make_generic ("dim", GFC_ISYM_DIM, GFC_STD_F77); |
6de9cd9a | 1250 | |
b7892582 | 1251 | add_sym_2 ("dot_product", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95, |
6de9cd9a | 1252 | gfc_check_dot_product, NULL, gfc_resolve_dot_product, |
1270d633 | 1253 | va, BT_REAL, dr, REQUIRED, vb, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1254 | |
b7892582 | 1255 | make_generic ("dot_product", GFC_ISYM_DOT_PRODUCT, GFC_STD_F95); |
6de9cd9a | 1256 | |
b7892582 | 1257 | add_sym_2 ("dprod", 1, 1, BT_REAL, dd, GFC_STD_F77, |
6de9cd9a | 1258 | NULL, gfc_simplify_dprod, gfc_resolve_dprod, |
1270d633 | 1259 | x, BT_REAL, dr, REQUIRED, y, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1260 | |
b7892582 | 1261 | make_generic ("dprod", GFC_ISYM_DPROD, GFC_STD_F77); |
6de9cd9a | 1262 | |
b7892582 | 1263 | add_sym_1 ("dreal", 1, 0, BT_REAL, dd, GFC_STD_GNU, |
1270d633 SK |
1264 | NULL, NULL, NULL, |
1265 | a, BT_COMPLEX, dd, REQUIRED); | |
6de9cd9a | 1266 | |
b7892582 | 1267 | make_generic ("dreal", GFC_ISYM_REAL, GFC_STD_GNU); |
6de9cd9a | 1268 | |
b7892582 | 1269 | add_sym_4 ("eoshift", 0, 1, BT_REAL, dr, GFC_STD_F95, |
6de9cd9a | 1270 | gfc_check_eoshift, NULL, gfc_resolve_eoshift, |
1270d633 SK |
1271 | ar, BT_REAL, dr, 0, sh, BT_INTEGER, ii, REQUIRED, |
1272 | bd, BT_REAL, dr, 1, dm, BT_INTEGER, ii, OPTIONAL); | |
6de9cd9a | 1273 | |
b7892582 | 1274 | make_generic ("eoshift", GFC_ISYM_EOSHIFT, GFC_STD_F95); |
6de9cd9a | 1275 | |
b7892582 | 1276 | add_sym_1 ("epsilon", 0, 1, BT_REAL, dr, GFC_STD_F95, |
6de9cd9a | 1277 | gfc_check_x, gfc_simplify_epsilon, NULL, |
1270d633 | 1278 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1279 | |
b7892582 | 1280 | make_generic ("epsilon", GFC_ISYM_NONE, GFC_STD_F95); |
6de9cd9a | 1281 | |
e8525382 | 1282 | /* G77 compatibility for the ERF() and ERFC() functions. */ |
b7892582 | 1283 | add_sym_1 ("erf", 1, 0, BT_REAL, dr, GFC_STD_GNU, |
e8525382 | 1284 | gfc_check_g77_math1, NULL, gfc_resolve_g77_math1, |
1270d633 | 1285 | x, BT_REAL, dr, REQUIRED); |
e8525382 | 1286 | |
b7892582 | 1287 | add_sym_1 ("derf", 1, 0, BT_REAL, dd, GFC_STD_GNU, |
e8525382 | 1288 | gfc_check_g77_math1, NULL, gfc_resolve_g77_math1, |
1270d633 | 1289 | x, BT_REAL, dd, REQUIRED); |
e8525382 | 1290 | |
b7892582 | 1291 | make_generic ("erf", GFC_ISYM_ERF, GFC_STD_GNU); |
e8525382 | 1292 | |
b7892582 | 1293 | add_sym_1 ("erfc", 1, 0, BT_REAL, dr, GFC_STD_GNU, |
e8525382 | 1294 | gfc_check_g77_math1, NULL, gfc_resolve_g77_math1, |
1270d633 | 1295 | x, BT_REAL, dr, REQUIRED); |
e8525382 | 1296 | |
b7892582 | 1297 | add_sym_1 ("derfc", 1, 0, BT_REAL, dd, GFC_STD_GNU, |
e8525382 | 1298 | gfc_check_g77_math1, NULL, gfc_resolve_g77_math1, |
1270d633 | 1299 | x, BT_REAL, dd, REQUIRED); |
e8525382 | 1300 | |
b7892582 | 1301 | make_generic ("erfc", GFC_ISYM_ERFC, GFC_STD_GNU); |
e8525382 | 1302 | |
2bd74949 | 1303 | /* G77 compatibility */ |
b7892582 | 1304 | add_sym_1 ("etime", 0, 1, BT_REAL, 4, GFC_STD_GNU, |
2bd74949 | 1305 | gfc_check_etime, NULL, NULL, |
1270d633 | 1306 | x, BT_REAL, 4, REQUIRED); |
2bd74949 | 1307 | |
19060788 | 1308 | make_alias ("dtime", GFC_STD_GNU); |
2bd74949 | 1309 | |
b7892582 | 1310 | make_generic ("etime", GFC_ISYM_ETIME, GFC_STD_GNU); |
2bd74949 | 1311 | |
b7892582 | 1312 | add_sym_1 ("exp", 1, 1, BT_REAL, dr, GFC_STD_F77, |
985aff9c | 1313 | gfc_check_fn_rc, gfc_simplify_exp, gfc_resolve_exp, |
1270d633 | 1314 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1315 | |
b7892582 | 1316 | add_sym_1 ("dexp", 1, 1, BT_REAL, dd, GFC_STD_F77, |
1270d633 SK |
1317 | NULL, gfc_simplify_exp, gfc_resolve_exp, |
1318 | x, BT_REAL, dd, REQUIRED); | |
6de9cd9a | 1319 | |
b7892582 | 1320 | add_sym_1 ("cexp", 1, 1, BT_COMPLEX, dz, GFC_STD_F77, |
6de9cd9a | 1321 | NULL, gfc_simplify_exp, gfc_resolve_exp, |
1270d633 | 1322 | x, BT_COMPLEX, dz, REQUIRED); |
6de9cd9a | 1323 | |
b7892582 JB |
1324 | add_sym_1 ("zexp", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU, |
1325 | NULL, gfc_simplify_exp, gfc_resolve_exp, | |
1270d633 | 1326 | x, BT_COMPLEX, dd, REQUIRED); |
6de9cd9a | 1327 | |
19060788 | 1328 | make_alias ("cdexp", GFC_STD_GNU); |
6de9cd9a | 1329 | |
b7892582 | 1330 | make_generic ("exp", GFC_ISYM_EXP, GFC_STD_F77); |
6de9cd9a | 1331 | |
b7892582 | 1332 | add_sym_1 ("exponent", 1, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1333 | gfc_check_x, gfc_simplify_exponent, gfc_resolve_exponent, |
1270d633 | 1334 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1335 | |
b7892582 | 1336 | make_generic ("exponent", GFC_ISYM_EXPONENT, GFC_STD_F95); |
6de9cd9a | 1337 | |
35059811 FXC |
1338 | add_sym_0 ("fdate", 1, 0, BT_CHARACTER, dc, GFC_STD_GNU, |
1339 | NULL, NULL, gfc_resolve_fdate); | |
1340 | ||
1341 | make_generic ("fdate", GFC_ISYM_FDATE, GFC_STD_GNU); | |
1342 | ||
b7892582 | 1343 | add_sym_2 ("floor", 1, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1344 | gfc_check_a_ikind, gfc_simplify_floor, gfc_resolve_floor, |
1270d633 | 1345 | a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL); |
6de9cd9a | 1346 | |
b7892582 | 1347 | make_generic ("floor", GFC_ISYM_FLOOR, GFC_STD_F95); |
6de9cd9a | 1348 | |
df65f093 SK |
1349 | /* G77 compatible fnum */ |
1350 | add_sym_1 ("fnum", 0, 1, BT_INTEGER, di, GFC_STD_GNU, | |
1351 | gfc_check_fnum, NULL, gfc_resolve_fnum, | |
1352 | ut, BT_INTEGER, di, REQUIRED); | |
1353 | ||
1354 | make_generic ("fnum", GFC_ISYM_FNUM, GFC_STD_GNU); | |
1355 | ||
b7892582 | 1356 | add_sym_1 ("fraction", 1, 1, BT_REAL, dr, GFC_STD_F95, |
6de9cd9a | 1357 | gfc_check_x, gfc_simplify_fraction, gfc_resolve_fraction, |
1270d633 | 1358 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1359 | |
b7892582 | 1360 | make_generic ("fraction", GFC_ISYM_FRACTION, GFC_STD_F95); |
6de9cd9a | 1361 | |
df65f093 SK |
1362 | add_sym_2 ("fstat", 0, 1, BT_INTEGER, di, GFC_STD_GNU, |
1363 | gfc_check_fstat, NULL, gfc_resolve_fstat, | |
1364 | a, BT_INTEGER, di, REQUIRED, b, BT_INTEGER, di, REQUIRED); | |
1365 | ||
1366 | make_generic ("fstat", GFC_ISYM_FSTAT, GFC_STD_GNU); | |
1367 | ||
4c0c6b9f | 1368 | /* Unix IDs (g77 compatibility) */ |
b7892582 JB |
1369 | add_sym_1 ("getcwd", 0, 1, BT_INTEGER, di, GFC_STD_GNU, |
1370 | NULL, NULL, gfc_resolve_getcwd, | |
1270d633 SK |
1371 | c, BT_CHARACTER, dc, REQUIRED); |
1372 | ||
b7892582 | 1373 | make_generic ("getcwd", GFC_ISYM_GETCWD, GFC_STD_GNU); |
a8c60d7f | 1374 | |
b7892582 JB |
1375 | add_sym_0 ("getgid", 1, 0, BT_INTEGER, di, GFC_STD_GNU, |
1376 | NULL, NULL, gfc_resolve_getgid); | |
1270d633 | 1377 | |
b7892582 | 1378 | make_generic ("getgid", GFC_ISYM_GETGID, GFC_STD_GNU); |
4c0c6b9f | 1379 | |
b7892582 JB |
1380 | add_sym_0 ("getpid", 1, 0, BT_INTEGER, di, GFC_STD_GNU, |
1381 | NULL, NULL, gfc_resolve_getpid); | |
1270d633 | 1382 | |
b7892582 | 1383 | make_generic ("getpid", GFC_ISYM_GETPID, GFC_STD_GNU); |
4c0c6b9f | 1384 | |
b7892582 JB |
1385 | add_sym_0 ("getuid", 1, 0, BT_INTEGER, di, GFC_STD_GNU, |
1386 | NULL, NULL, gfc_resolve_getuid); | |
1270d633 | 1387 | |
b7892582 | 1388 | make_generic ("getuid", GFC_ISYM_GETUID, GFC_STD_GNU); |
4c0c6b9f | 1389 | |
f77b6ca3 FXC |
1390 | add_sym_1 ("hostnm", 0, 1, BT_INTEGER, di, GFC_STD_GNU, |
1391 | gfc_check_hostnm, NULL, gfc_resolve_hostnm, | |
1392 | a, BT_CHARACTER, dc, REQUIRED); | |
1393 | ||
1394 | make_generic ("hostnm", GFC_ISYM_HOSTNM, GFC_STD_GNU); | |
1395 | ||
b7892582 | 1396 | add_sym_1 ("huge", 0, 1, BT_REAL, dr, GFC_STD_F95, |
6de9cd9a | 1397 | gfc_check_huge, gfc_simplify_huge, NULL, |
1270d633 | 1398 | x, BT_UNKNOWN, dr, REQUIRED); |
6de9cd9a | 1399 | |
b7892582 | 1400 | make_generic ("huge", GFC_ISYM_NONE, GFC_STD_F95); |
6de9cd9a | 1401 | |
b7892582 | 1402 | add_sym_1 ("iachar", 1, 1, BT_INTEGER, di, GFC_STD_F95, |
860c8f3b | 1403 | gfc_check_ichar_iachar, gfc_simplify_iachar, NULL, |
1270d633 | 1404 | c, BT_CHARACTER, dc, REQUIRED); |
6de9cd9a | 1405 | |
b7892582 | 1406 | make_generic ("iachar", GFC_ISYM_IACHAR, GFC_STD_F95); |
6de9cd9a | 1407 | |
b7892582 | 1408 | add_sym_2 ("iand", 1, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1409 | gfc_check_iand, gfc_simplify_iand, gfc_resolve_iand, |
1270d633 | 1410 | i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1411 | |
b7892582 | 1412 | make_generic ("iand", GFC_ISYM_IAND, GFC_STD_F95); |
6de9cd9a | 1413 | |
1270d633 SK |
1414 | add_sym_0 ("iargc", 1, 1, BT_INTEGER, di, GFC_STD_GNU, |
1415 | NULL, NULL, NULL); | |
1416 | ||
b7892582 | 1417 | make_generic ("iargc", GFC_ISYM_IARGC, GFC_STD_GNU); |
b41b2534 | 1418 | |
1270d633 SK |
1419 | add_sym_0 ("command_argument_count", 1, 1, BT_INTEGER, di, GFC_STD_F2003, |
1420 | NULL, NULL, NULL); | |
1421 | ||
1422 | make_generic ("command_argument_count", GFC_ISYM_COMMAND_ARGUMENT_COUNT, | |
1423 | GFC_STD_F2003); | |
6de9cd9a | 1424 | |
b7892582 | 1425 | add_sym_2 ("ibclr", 1, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1426 | gfc_check_ibclr, gfc_simplify_ibclr, gfc_resolve_ibclr, |
1270d633 | 1427 | i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1428 | |
b7892582 | 1429 | make_generic ("ibclr", GFC_ISYM_IBCLR, GFC_STD_F95); |
6de9cd9a | 1430 | |
b7892582 | 1431 | add_sym_3 ("ibits", 1, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1432 | gfc_check_ibits, gfc_simplify_ibits, gfc_resolve_ibits, |
1270d633 SK |
1433 | i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED, |
1434 | ln, BT_INTEGER, di, REQUIRED); | |
6de9cd9a | 1435 | |
b7892582 | 1436 | make_generic ("ibits", GFC_ISYM_IBITS, GFC_STD_F95); |
6de9cd9a | 1437 | |
b7892582 | 1438 | add_sym_2 ("ibset", 1, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1439 | gfc_check_ibset, gfc_simplify_ibset, gfc_resolve_ibset, |
1270d633 | 1440 | i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1441 | |
b7892582 | 1442 | make_generic ("ibset", GFC_ISYM_IBSET, GFC_STD_F95); |
6de9cd9a | 1443 | |
b7892582 | 1444 | add_sym_1 ("ichar", 1, 0, BT_INTEGER, di, GFC_STD_F77, |
860c8f3b | 1445 | gfc_check_ichar_iachar, gfc_simplify_ichar, gfc_resolve_ichar, |
1270d633 | 1446 | c, BT_CHARACTER, dc, REQUIRED); |
6de9cd9a | 1447 | |
b7892582 | 1448 | make_generic ("ichar", GFC_ISYM_ICHAR, GFC_STD_F77); |
6de9cd9a | 1449 | |
c3d003d2 | 1450 | add_sym_2 ("ieor", 1, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1451 | gfc_check_ieor, gfc_simplify_ieor, gfc_resolve_ieor, |
1270d633 | 1452 | i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1453 | |
c3d003d2 | 1454 | make_generic ("ieor", GFC_ISYM_IEOR, GFC_STD_F95); |
6de9cd9a | 1455 | |
f77b6ca3 FXC |
1456 | add_sym_0 ("ierrno", 1, 0, BT_INTEGER, di, GFC_STD_GNU, |
1457 | NULL, NULL, gfc_resolve_ierrno); | |
1458 | ||
1459 | make_generic ("ierrno", GFC_ISYM_IERRNO, GFC_STD_GNU); | |
1460 | ||
b7892582 | 1461 | add_sym_3 ("index", 1, 1, BT_INTEGER, di, GFC_STD_F77, |
6de9cd9a | 1462 | gfc_check_index, gfc_simplify_index, NULL, |
1270d633 SK |
1463 | stg, BT_CHARACTER, dc, REQUIRED, ssg, BT_CHARACTER, dc, REQUIRED, |
1464 | bck, BT_LOGICAL, dl, OPTIONAL); | |
6de9cd9a | 1465 | |
b7892582 | 1466 | make_generic ("index", GFC_ISYM_INDEX, GFC_STD_F77); |
6de9cd9a | 1467 | |
b7892582 | 1468 | add_sym_2 ("int", 1, 1, BT_INTEGER, di, GFC_STD_F77, |
6de9cd9a | 1469 | gfc_check_int, gfc_simplify_int, gfc_resolve_int, |
1270d633 | 1470 | a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL); |
6de9cd9a | 1471 | |
b7892582 | 1472 | add_sym_1 ("ifix", 1, 0, BT_INTEGER, di, GFC_STD_F77, |
1270d633 SK |
1473 | NULL, gfc_simplify_ifix, NULL, |
1474 | a, BT_REAL, dr, REQUIRED); | |
6de9cd9a | 1475 | |
b7892582 | 1476 | add_sym_1 ("idint", 1, 0, BT_INTEGER, di, GFC_STD_F77, |
1270d633 SK |
1477 | NULL, gfc_simplify_idint, NULL, |
1478 | a, BT_REAL, dd, REQUIRED); | |
6de9cd9a | 1479 | |
b7892582 | 1480 | make_generic ("int", GFC_ISYM_INT, GFC_STD_F77); |
6de9cd9a | 1481 | |
b7892582 | 1482 | add_sym_2 ("ior", 1, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1483 | gfc_check_ior, gfc_simplify_ior, gfc_resolve_ior, |
1270d633 | 1484 | i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1485 | |
b7892582 | 1486 | make_generic ("ior", GFC_ISYM_IOR, GFC_STD_F95); |
6de9cd9a | 1487 | |
2bd74949 | 1488 | /* The following function is for G77 compatibility. */ |
b7892582 | 1489 | add_sym_1 ("irand", 0, 1, BT_INTEGER, 4, GFC_STD_GNU, |
2bd74949 | 1490 | gfc_check_irand, NULL, NULL, |
1270d633 | 1491 | i, BT_INTEGER, 4, OPTIONAL); |
2bd74949 | 1492 | |
b7892582 | 1493 | make_generic ("irand", GFC_ISYM_IRAND, GFC_STD_GNU); |
2bd74949 | 1494 | |
ae8b8789 FXC |
1495 | add_sym_1 ("isatty", 0, 0, BT_LOGICAL, dl, GFC_STD_GNU, |
1496 | gfc_check_isatty, NULL, gfc_resolve_isatty, | |
1497 | ut, BT_INTEGER, di, REQUIRED); | |
1498 | ||
1499 | make_generic ("isatty", GFC_ISYM_ISATTY, GFC_STD_GNU); | |
1500 | ||
b7892582 | 1501 | add_sym_2 ("ishft", 1, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1502 | gfc_check_ishft, gfc_simplify_ishft, gfc_resolve_ishft, |
1270d633 | 1503 | i, BT_INTEGER, di, REQUIRED, sh, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1504 | |
b7892582 | 1505 | make_generic ("ishft", GFC_ISYM_ISHFT, GFC_STD_F95); |
6de9cd9a | 1506 | |
b7892582 | 1507 | add_sym_3 ("ishftc", 1, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1508 | gfc_check_ishftc, gfc_simplify_ishftc, gfc_resolve_ishftc, |
1270d633 SK |
1509 | i, BT_INTEGER, di, REQUIRED, sh, BT_INTEGER, di, REQUIRED, |
1510 | sz, BT_INTEGER, di, OPTIONAL); | |
6de9cd9a | 1511 | |
b7892582 | 1512 | make_generic ("ishftc", GFC_ISYM_ISHFTC, GFC_STD_F95); |
6de9cd9a | 1513 | |
f77b6ca3 FXC |
1514 | add_sym_2 ("kill", 1, 1, BT_INTEGER, di, GFC_STD_GNU, |
1515 | gfc_check_kill, NULL, gfc_resolve_kill, | |
1516 | a, BT_INTEGER, di, REQUIRED, b, BT_INTEGER, di, REQUIRED); | |
1517 | ||
1518 | make_generic ("kill", GFC_ISYM_KILL, GFC_STD_GNU); | |
1519 | ||
b7892582 | 1520 | add_sym_1 ("kind", 0, 1, BT_INTEGER, di, GFC_STD_F95, |
1270d633 SK |
1521 | gfc_check_kind, gfc_simplify_kind, NULL, |
1522 | x, BT_REAL, dr, REQUIRED); | |
6de9cd9a | 1523 | |
b7892582 | 1524 | make_generic ("kind", GFC_ISYM_NONE, GFC_STD_F95); |
6de9cd9a | 1525 | |
b7892582 | 1526 | add_sym_2 ("lbound", 0, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1527 | gfc_check_lbound, gfc_simplify_lbound, gfc_resolve_lbound, |
1270d633 | 1528 | ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, di, OPTIONAL); |
6de9cd9a | 1529 | |
b7892582 | 1530 | make_generic ("lbound", GFC_ISYM_LBOUND, GFC_STD_F95); |
6de9cd9a | 1531 | |
b7892582 | 1532 | add_sym_1 ("len", 0, 1, BT_INTEGER, di, GFC_STD_F77, |
6de9cd9a | 1533 | NULL, gfc_simplify_len, gfc_resolve_len, |
1270d633 | 1534 | stg, BT_CHARACTER, dc, REQUIRED); |
6de9cd9a | 1535 | |
b7892582 | 1536 | make_generic ("len", GFC_ISYM_LEN, GFC_STD_F77); |
6de9cd9a | 1537 | |
b7892582 | 1538 | add_sym_1 ("len_trim", 1, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1539 | NULL, gfc_simplify_len_trim, gfc_resolve_len_trim, |
1270d633 | 1540 | stg, BT_CHARACTER, dc, REQUIRED); |
6de9cd9a | 1541 | |
f77b6ca3 FXC |
1542 | make_alias ("lnblnk", GFC_STD_GNU); |
1543 | ||
b7892582 | 1544 | make_generic ("len_trim", GFC_ISYM_LEN_TRIM, GFC_STD_F95); |
6de9cd9a | 1545 | |
b7892582 | 1546 | add_sym_2 ("lge", 1, 0, BT_LOGICAL, dl, GFC_STD_F77, |
6de9cd9a | 1547 | NULL, gfc_simplify_lge, NULL, |
1270d633 | 1548 | sta, BT_CHARACTER, dc, REQUIRED, stb, BT_CHARACTER, dc, REQUIRED); |
6de9cd9a | 1549 | |
b7892582 | 1550 | make_generic ("lge", GFC_ISYM_LGE, GFC_STD_F77); |
6de9cd9a | 1551 | |
b7892582 | 1552 | add_sym_2 ("lgt", 1, 0, BT_LOGICAL, dl, GFC_STD_F77, |
6de9cd9a | 1553 | NULL, gfc_simplify_lgt, NULL, |
1270d633 | 1554 | sta, BT_CHARACTER, dc, REQUIRED, stb, BT_CHARACTER, dc, REQUIRED); |
6de9cd9a | 1555 | |
b7892582 | 1556 | make_generic ("lgt", GFC_ISYM_LGT, GFC_STD_F77); |
6de9cd9a | 1557 | |
b7892582 | 1558 | add_sym_2 ("lle", 1, 0, BT_LOGICAL, dl, GFC_STD_F77, |
6de9cd9a | 1559 | NULL, gfc_simplify_lle, NULL, |
1270d633 | 1560 | sta, BT_CHARACTER, dc, REQUIRED, stb, BT_CHARACTER, dc, REQUIRED); |
6de9cd9a | 1561 | |
b7892582 | 1562 | make_generic ("lle", GFC_ISYM_LLE, GFC_STD_F77); |
6de9cd9a | 1563 | |
b7892582 | 1564 | add_sym_2 ("llt", 1, 0, BT_LOGICAL, dl, GFC_STD_F77, |
6de9cd9a | 1565 | NULL, gfc_simplify_llt, NULL, |
1270d633 | 1566 | sta, BT_CHARACTER, dc, REQUIRED, stb, BT_CHARACTER, dc, REQUIRED); |
6de9cd9a | 1567 | |
b7892582 | 1568 | make_generic ("llt", GFC_ISYM_LLT, GFC_STD_F77); |
6de9cd9a | 1569 | |
f77b6ca3 FXC |
1570 | add_sym_2 ("link", 0, 1, BT_INTEGER, di, GFC_STD_GNU, |
1571 | gfc_check_link, NULL, gfc_resolve_link, | |
1572 | a, BT_CHARACTER, dc, REQUIRED, b, BT_CHARACTER, dc, REQUIRED); | |
1573 | ||
1574 | make_generic ("link", GFC_ISYM_LINK, GFC_STD_GNU); | |
1575 | ||
b7892582 | 1576 | add_sym_1 ("log", 1, 1, BT_REAL, dr, GFC_STD_F77, |
985aff9c | 1577 | gfc_check_fn_rc, gfc_simplify_log, gfc_resolve_log, |
1270d633 | 1578 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1579 | |
b7892582 | 1580 | add_sym_1 ("alog", 1, 1, BT_REAL, dr, GFC_STD_F77, |
1270d633 SK |
1581 | NULL, gfc_simplify_log, gfc_resolve_log, |
1582 | x, BT_REAL, dr, REQUIRED); | |
6de9cd9a | 1583 | |
b7892582 | 1584 | add_sym_1 ("dlog", 1, 1, BT_REAL, dd, GFC_STD_F77, |
1270d633 SK |
1585 | NULL, gfc_simplify_log, gfc_resolve_log, |
1586 | x, BT_REAL, dd, REQUIRED); | |
6de9cd9a | 1587 | |
b7892582 | 1588 | add_sym_1 ("clog", 1, 1, BT_COMPLEX, dz, GFC_STD_F77, |
6de9cd9a | 1589 | NULL, gfc_simplify_log, gfc_resolve_log, |
1270d633 | 1590 | x, BT_COMPLEX, dz, REQUIRED); |
6de9cd9a | 1591 | |
b7892582 | 1592 | add_sym_1 ("zlog", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU, |
1270d633 SK |
1593 | NULL, gfc_simplify_log, gfc_resolve_log, |
1594 | x, BT_COMPLEX, dd, REQUIRED); | |
6de9cd9a | 1595 | |
19060788 | 1596 | make_alias ("cdlog", GFC_STD_GNU); |
6de9cd9a | 1597 | |
b7892582 | 1598 | make_generic ("log", GFC_ISYM_LOG, GFC_STD_F77); |
6de9cd9a | 1599 | |
b7892582 | 1600 | add_sym_1 ("log10", 1, 1, BT_REAL, dr, GFC_STD_F77, |
985aff9c | 1601 | gfc_check_fn_r, gfc_simplify_log10, gfc_resolve_log10, |
1270d633 | 1602 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1603 | |
b7892582 | 1604 | add_sym_1 ("alog10", 1, 1, BT_REAL, dr, GFC_STD_F77, |
6de9cd9a | 1605 | NULL, gfc_simplify_log10, gfc_resolve_log10, |
1270d633 | 1606 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1607 | |
b7892582 | 1608 | add_sym_1 ("dlog10", 1, 1, BT_REAL, dd, GFC_STD_F77, |
6de9cd9a | 1609 | NULL, gfc_simplify_log10, gfc_resolve_log10, |
1270d633 | 1610 | x, BT_REAL, dd, REQUIRED); |
6de9cd9a | 1611 | |
b7892582 | 1612 | make_generic ("log10", GFC_ISYM_LOG10, GFC_STD_F77); |
6de9cd9a | 1613 | |
b7892582 | 1614 | add_sym_2 ("logical", 0, 1, BT_LOGICAL, dl, GFC_STD_F95, |
6de9cd9a | 1615 | gfc_check_logical, gfc_simplify_logical, gfc_resolve_logical, |
1270d633 | 1616 | l, BT_LOGICAL, dl, REQUIRED, kind, BT_INTEGER, di, OPTIONAL); |
6de9cd9a | 1617 | |
b7892582 | 1618 | make_generic ("logical", GFC_ISYM_LOGICAL, GFC_STD_F95); |
6de9cd9a | 1619 | |
0d519038 FXC |
1620 | add_sym_1 ("malloc", 0, 1, BT_INTEGER, ii, GFC_STD_GNU, gfc_check_malloc, |
1621 | NULL, gfc_resolve_malloc, a, BT_INTEGER, di, REQUIRED); | |
1622 | ||
1623 | make_generic ("malloc", GFC_ISYM_MALLOC, GFC_STD_GNU); | |
1624 | ||
b7892582 | 1625 | add_sym_2 ("matmul", 0, 1, BT_REAL, dr, GFC_STD_F95, |
6de9cd9a | 1626 | gfc_check_matmul, NULL, gfc_resolve_matmul, |
1270d633 | 1627 | ma, BT_REAL, dr, REQUIRED, mb, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1628 | |
b7892582 | 1629 | make_generic ("matmul", GFC_ISYM_MATMUL, GFC_STD_F95); |
6de9cd9a DN |
1630 | |
1631 | /* Note: amax0 is equivalent to real(max), max1 is equivalent to | |
1632 | int(max). The max function must take at least two arguments. */ | |
1633 | ||
b7892582 | 1634 | add_sym_1m ("max", 1, 0, BT_UNKNOWN, 0, GFC_STD_F77, |
6de9cd9a | 1635 | gfc_check_min_max, gfc_simplify_max, gfc_resolve_max, |
1270d633 | 1636 | a1, BT_UNKNOWN, dr, REQUIRED, a2, BT_UNKNOWN, dr, REQUIRED); |
6de9cd9a | 1637 | |
b7892582 | 1638 | add_sym_1m ("max0", 1, 0, BT_INTEGER, di, GFC_STD_F77, |
6de9cd9a | 1639 | gfc_check_min_max_integer, gfc_simplify_max, NULL, |
1270d633 | 1640 | a1, BT_INTEGER, di, REQUIRED, a2, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1641 | |
b7892582 | 1642 | add_sym_1m ("amax0", 1, 0, BT_REAL, dr, GFC_STD_F77, |
6de9cd9a | 1643 | gfc_check_min_max_integer, gfc_simplify_max, NULL, |
1270d633 | 1644 | a1, BT_INTEGER, di, REQUIRED, a2, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1645 | |
b7892582 | 1646 | add_sym_1m ("amax1", 1, 0, BT_REAL, dr, GFC_STD_F77, |
6de9cd9a | 1647 | gfc_check_min_max_real, gfc_simplify_max, NULL, |
1270d633 | 1648 | a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1649 | |
b7892582 | 1650 | add_sym_1m ("max1", 1, 0, BT_INTEGER, di, GFC_STD_F77, |
6de9cd9a | 1651 | gfc_check_min_max_real, gfc_simplify_max, NULL, |
1270d633 | 1652 | a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1653 | |
b7892582 | 1654 | add_sym_1m ("dmax1", 1, 0, BT_REAL, dd, GFC_STD_F77, |
6de9cd9a | 1655 | gfc_check_min_max_double, gfc_simplify_max, NULL, |
1270d633 | 1656 | a1, BT_REAL, dd, REQUIRED, a2, BT_REAL, dd, REQUIRED); |
6de9cd9a | 1657 | |
b7892582 | 1658 | make_generic ("max", GFC_ISYM_MAX, GFC_STD_F77); |
6de9cd9a | 1659 | |
b7892582 | 1660 | add_sym_1 ("maxexponent", 0, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1661 | gfc_check_x, gfc_simplify_maxexponent, NULL, |
1270d633 | 1662 | x, BT_UNKNOWN, dr, REQUIRED); |
6de9cd9a | 1663 | |
b7892582 | 1664 | make_generic ("maxexponent", GFC_ISYM_NONE, GFC_STD_F95); |
6de9cd9a | 1665 | |
b7892582 | 1666 | add_sym_3ml ("maxloc", 0, 1, BT_INTEGER, di, GFC_STD_F95, |
f3207b37 | 1667 | gfc_check_minloc_maxloc, NULL, gfc_resolve_maxloc, |
1270d633 SK |
1668 | ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL, |
1669 | msk, BT_LOGICAL, dl, OPTIONAL); | |
6de9cd9a | 1670 | |
b7892582 | 1671 | make_generic ("maxloc", GFC_ISYM_MAXLOC, GFC_STD_F95); |
6de9cd9a | 1672 | |
b7892582 | 1673 | add_sym_3red ("maxval", 0, 1, BT_REAL, dr, GFC_STD_F95, |
617097a3 | 1674 | gfc_check_minval_maxval, NULL, gfc_resolve_maxval, |
1270d633 SK |
1675 | ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL, |
1676 | msk, BT_LOGICAL, dl, OPTIONAL); | |
6de9cd9a | 1677 | |
b7892582 | 1678 | make_generic ("maxval", GFC_ISYM_MAXVAL, GFC_STD_F95); |
6de9cd9a | 1679 | |
b7892582 | 1680 | add_sym_3 ("merge", 1, 1, BT_REAL, dr, GFC_STD_F95, |
6de9cd9a | 1681 | gfc_check_merge, NULL, gfc_resolve_merge, |
1270d633 SK |
1682 | ts, BT_REAL, dr, REQUIRED, fs, BT_REAL, dr, REQUIRED, |
1683 | msk, BT_LOGICAL, dl, REQUIRED); | |
6de9cd9a | 1684 | |
b7892582 | 1685 | make_generic ("merge", GFC_ISYM_MERGE, GFC_STD_F95); |
6de9cd9a | 1686 | |
1270d633 SK |
1687 | /* Note: amin0 is equivalent to real(min), min1 is equivalent to |
1688 | int(min). */ | |
6de9cd9a | 1689 | |
b7892582 | 1690 | add_sym_1m ("min", 1, 0, BT_UNKNOWN, 0, GFC_STD_F77, |
6de9cd9a | 1691 | gfc_check_min_max, gfc_simplify_min, gfc_resolve_min, |
1270d633 | 1692 | a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1693 | |
b7892582 | 1694 | add_sym_1m ("min0", 1, 0, BT_INTEGER, di, GFC_STD_F77, |
6de9cd9a | 1695 | gfc_check_min_max_integer, gfc_simplify_min, NULL, |
1270d633 | 1696 | a1, BT_INTEGER, di, REQUIRED, a2, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1697 | |
b7892582 | 1698 | add_sym_1m ("amin0", 1, 0, BT_REAL, dr, GFC_STD_F77, |
6de9cd9a | 1699 | gfc_check_min_max_integer, gfc_simplify_min, NULL, |
1270d633 | 1700 | a1, BT_INTEGER, di, REQUIRED, a2, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1701 | |
b7892582 | 1702 | add_sym_1m ("amin1", 1, 0, BT_REAL, dr, GFC_STD_F77, |
6de9cd9a | 1703 | gfc_check_min_max_real, gfc_simplify_min, NULL, |
1270d633 | 1704 | a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1705 | |
b7892582 | 1706 | add_sym_1m ("min1", 1, 0, BT_INTEGER, di, GFC_STD_F77, |
6de9cd9a | 1707 | gfc_check_min_max_real, gfc_simplify_min, NULL, |
1270d633 | 1708 | a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1709 | |
b7892582 | 1710 | add_sym_1m ("dmin1", 1, 0, BT_REAL, dd, GFC_STD_F77, |
6de9cd9a | 1711 | gfc_check_min_max_double, gfc_simplify_min, NULL, |
1270d633 | 1712 | a1, BT_REAL, dd, REQUIRED, a2, BT_REAL, dd, REQUIRED); |
6de9cd9a | 1713 | |
b7892582 | 1714 | make_generic ("min", GFC_ISYM_MIN, GFC_STD_F77); |
6de9cd9a | 1715 | |
b7892582 | 1716 | add_sym_1 ("minexponent", 0, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1717 | gfc_check_x, gfc_simplify_minexponent, NULL, |
1270d633 | 1718 | x, BT_UNKNOWN, dr, REQUIRED); |
6de9cd9a | 1719 | |
b7892582 | 1720 | make_generic ("minexponent", GFC_ISYM_NONE, GFC_STD_F95); |
6de9cd9a | 1721 | |
b7892582 | 1722 | add_sym_3ml ("minloc", 0, 1, BT_INTEGER, di, GFC_STD_F95, |
f3207b37 | 1723 | gfc_check_minloc_maxloc, NULL, gfc_resolve_minloc, |
1270d633 SK |
1724 | ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL, |
1725 | msk, BT_LOGICAL, dl, OPTIONAL); | |
6de9cd9a | 1726 | |
b7892582 | 1727 | make_generic ("minloc", GFC_ISYM_MINLOC, GFC_STD_F95); |
6de9cd9a | 1728 | |
b7892582 | 1729 | add_sym_3red ("minval", 0, 1, BT_REAL, dr, GFC_STD_F95, |
617097a3 | 1730 | gfc_check_minval_maxval, NULL, gfc_resolve_minval, |
1270d633 SK |
1731 | ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL, |
1732 | msk, BT_LOGICAL, dl, OPTIONAL); | |
6de9cd9a | 1733 | |
b7892582 | 1734 | make_generic ("minval", GFC_ISYM_MINVAL, GFC_STD_F95); |
6de9cd9a | 1735 | |
b7892582 | 1736 | add_sym_2 ("mod", 1, 1, BT_INTEGER, di, GFC_STD_F77, |
6de9cd9a | 1737 | gfc_check_a_p, gfc_simplify_mod, gfc_resolve_mod, |
1270d633 | 1738 | a, BT_INTEGER, di, REQUIRED, p, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1739 | |
b7892582 | 1740 | add_sym_2 ("amod", 1, 1, BT_REAL, dr, GFC_STD_F77, |
6de9cd9a | 1741 | NULL, gfc_simplify_mod, gfc_resolve_mod, |
1270d633 | 1742 | a, BT_REAL, dr, REQUIRED, p, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1743 | |
b7892582 | 1744 | add_sym_2 ("dmod", 1, 1, BT_REAL, dd, GFC_STD_F77, |
6de9cd9a | 1745 | NULL, gfc_simplify_mod, gfc_resolve_mod, |
1270d633 | 1746 | a, BT_REAL, dd, REQUIRED, p, BT_REAL, dd, REQUIRED); |
6de9cd9a | 1747 | |
b7892582 | 1748 | make_generic ("mod", GFC_ISYM_MOD, GFC_STD_F77); |
6de9cd9a | 1749 | |
b7892582 | 1750 | add_sym_2 ("modulo", 1, 1, BT_REAL, di, GFC_STD_F95, |
6de9cd9a | 1751 | gfc_check_a_p, gfc_simplify_modulo, gfc_resolve_modulo, |
1270d633 | 1752 | a, BT_REAL, di, REQUIRED, p, BT_REAL, di, REQUIRED); |
6de9cd9a | 1753 | |
b7892582 | 1754 | make_generic ("modulo", GFC_ISYM_MODULO, GFC_STD_F95); |
6de9cd9a | 1755 | |
b7892582 | 1756 | add_sym_2 ("nearest", 1, 1, BT_REAL, dr, GFC_STD_F95, |
8765339d | 1757 | gfc_check_nearest, gfc_simplify_nearest, gfc_resolve_nearest, |
1270d633 | 1758 | x, BT_REAL, dr, REQUIRED, s, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1759 | |
b7892582 | 1760 | make_generic ("nearest", GFC_ISYM_NEAREST, GFC_STD_F95); |
6de9cd9a | 1761 | |
b7892582 | 1762 | add_sym_2 ("nint", 1, 1, BT_INTEGER, di, GFC_STD_F77, |
6de9cd9a | 1763 | gfc_check_a_ikind, gfc_simplify_nint, gfc_resolve_nint, |
1270d633 | 1764 | a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL); |
6de9cd9a | 1765 | |
b7892582 | 1766 | add_sym_1 ("idnint", 1, 1, BT_INTEGER, di, GFC_STD_F77, |
6de9cd9a | 1767 | gfc_check_idnint, gfc_simplify_idnint, gfc_resolve_idnint, |
1270d633 | 1768 | a, BT_REAL, dd, REQUIRED); |
6de9cd9a | 1769 | |
b7892582 | 1770 | make_generic ("nint", GFC_ISYM_NINT, GFC_STD_F77); |
6de9cd9a | 1771 | |
b7892582 | 1772 | add_sym_1 ("not", 1, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1773 | gfc_check_i, gfc_simplify_not, gfc_resolve_not, |
1270d633 | 1774 | i, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1775 | |
b7892582 | 1776 | make_generic ("not", GFC_ISYM_NOT, GFC_STD_F95); |
6de9cd9a | 1777 | |
b7892582 | 1778 | add_sym_1 ("null", 0, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1779 | gfc_check_null, gfc_simplify_null, NULL, |
1270d633 | 1780 | mo, BT_INTEGER, di, OPTIONAL); |
6de9cd9a | 1781 | |
b7892582 | 1782 | make_generic ("null", GFC_ISYM_NONE, GFC_STD_F95); |
6de9cd9a | 1783 | |
b7892582 | 1784 | add_sym_3 ("pack", 0, 1, BT_REAL, dr, GFC_STD_F95, |
6de9cd9a | 1785 | gfc_check_pack, NULL, gfc_resolve_pack, |
1270d633 SK |
1786 | ar, BT_REAL, dr, REQUIRED, msk, BT_LOGICAL, dl, REQUIRED, |
1787 | v, BT_REAL, dr, OPTIONAL); | |
6de9cd9a | 1788 | |
b7892582 | 1789 | make_generic ("pack", GFC_ISYM_PACK, GFC_STD_F95); |
6de9cd9a | 1790 | |
b7892582 | 1791 | add_sym_1 ("precision", 0, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1792 | gfc_check_precision, gfc_simplify_precision, NULL, |
1270d633 | 1793 | x, BT_UNKNOWN, 0, REQUIRED); |
6de9cd9a | 1794 | |
b7892582 | 1795 | make_generic ("precision", GFC_ISYM_NONE, GFC_STD_F95); |
6de9cd9a | 1796 | |
b7892582 | 1797 | add_sym_1 ("present", 0, 1, BT_LOGICAL, dl, GFC_STD_F95, |
1270d633 SK |
1798 | gfc_check_present, NULL, NULL, |
1799 | a, BT_REAL, dr, REQUIRED); | |
6de9cd9a | 1800 | |
b7892582 | 1801 | make_generic ("present", GFC_ISYM_PRESENT, GFC_STD_F95); |
6de9cd9a | 1802 | |
b7892582 | 1803 | add_sym_3red ("product", 0, 1, BT_REAL, dr, GFC_STD_F95, |
617097a3 | 1804 | gfc_check_product_sum, NULL, gfc_resolve_product, |
1270d633 SK |
1805 | ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL, |
1806 | msk, BT_LOGICAL, dl, OPTIONAL); | |
6de9cd9a | 1807 | |
b7892582 | 1808 | make_generic ("product", GFC_ISYM_PRODUCT, GFC_STD_F95); |
6de9cd9a | 1809 | |
b7892582 | 1810 | add_sym_1 ("radix", 0, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1811 | gfc_check_radix, gfc_simplify_radix, NULL, |
1270d633 | 1812 | x, BT_UNKNOWN, 0, REQUIRED); |
6de9cd9a | 1813 | |
b7892582 | 1814 | make_generic ("radix", GFC_ISYM_NONE, GFC_STD_F95); |
6de9cd9a | 1815 | |
2bd74949 | 1816 | /* The following function is for G77 compatibility. */ |
b7892582 | 1817 | add_sym_1 ("rand", 0, 1, BT_REAL, 4, GFC_STD_GNU, |
2bd74949 | 1818 | gfc_check_rand, NULL, NULL, |
1270d633 | 1819 | i, BT_INTEGER, 4, OPTIONAL); |
2bd74949 | 1820 | |
1270d633 SK |
1821 | /* Compatibility with HP FORTRAN 77/iX Reference. Note, rand() and ran() |
1822 | use slightly different shoddy multiplicative congruential PRNG. */ | |
19060788 | 1823 | make_alias ("ran", GFC_STD_GNU); |
f8e566e5 | 1824 | |
b7892582 | 1825 | make_generic ("rand", GFC_ISYM_RAND, GFC_STD_GNU); |
2bd74949 | 1826 | |
b7892582 | 1827 | add_sym_1 ("range", 0, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1828 | gfc_check_range, gfc_simplify_range, NULL, |
1270d633 | 1829 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1830 | |
b7892582 | 1831 | make_generic ("range", GFC_ISYM_NONE, GFC_STD_F95); |
6de9cd9a | 1832 | |
b7892582 | 1833 | add_sym_2 ("real", 1, 0, BT_REAL, dr, GFC_STD_F77, |
6de9cd9a | 1834 | gfc_check_real, gfc_simplify_real, gfc_resolve_real, |
1270d633 | 1835 | a, BT_UNKNOWN, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL); |
6de9cd9a | 1836 | |
6970fcc8 SK |
1837 | /* This provides compatibility with g77. */ |
1838 | add_sym_1 ("realpart", 1, 0, BT_REAL, dr, GFC_STD_GNU, | |
1839 | gfc_check_fn_c, gfc_simplify_realpart, gfc_resolve_realpart, | |
1840 | a, BT_UNKNOWN, dr, REQUIRED); | |
1841 | ||
b7892582 | 1842 | add_sym_1 ("float", 1, 0, BT_REAL, dr, GFC_STD_F77, |
1270d633 SK |
1843 | NULL, gfc_simplify_float, NULL, |
1844 | a, BT_INTEGER, di, REQUIRED); | |
6de9cd9a | 1845 | |
b7892582 | 1846 | add_sym_1 ("sngl", 1, 0, BT_REAL, dr, GFC_STD_F77, |
1270d633 SK |
1847 | NULL, gfc_simplify_sngl, NULL, |
1848 | a, BT_REAL, dd, REQUIRED); | |
6de9cd9a | 1849 | |
b7892582 | 1850 | make_generic ("real", GFC_ISYM_REAL, GFC_STD_F77); |
6de9cd9a | 1851 | |
f77b6ca3 FXC |
1852 | add_sym_2 ("rename", 0, 1, BT_INTEGER, di, GFC_STD_GNU, |
1853 | gfc_check_rename, NULL, gfc_resolve_rename, | |
1854 | a, BT_CHARACTER, dc, REQUIRED, b, BT_CHARACTER, dc, REQUIRED); | |
1855 | ||
1856 | make_generic ("rename", GFC_ISYM_RENAME, GFC_STD_GNU); | |
1857 | ||
b7892582 | 1858 | add_sym_2 ("repeat", 0, 1, BT_CHARACTER, dc, GFC_STD_F95, |
6de9cd9a | 1859 | gfc_check_repeat, gfc_simplify_repeat, gfc_resolve_repeat, |
1270d633 | 1860 | stg, BT_CHARACTER, dc, REQUIRED, n, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1861 | |
b7892582 | 1862 | make_generic ("repeat", GFC_ISYM_REPEAT, GFC_STD_F95); |
6de9cd9a | 1863 | |
b7892582 | 1864 | add_sym_4 ("reshape", 0, 1, BT_REAL, dr, GFC_STD_F95, |
6de9cd9a | 1865 | gfc_check_reshape, gfc_simplify_reshape, gfc_resolve_reshape, |
1270d633 SK |
1866 | src, BT_REAL, dr, REQUIRED, shp, BT_INTEGER, ii, REQUIRED, |
1867 | pad, BT_REAL, dr, OPTIONAL, ord, BT_INTEGER, ii, OPTIONAL); | |
6de9cd9a | 1868 | |
b7892582 | 1869 | make_generic ("reshape", GFC_ISYM_RESHAPE, GFC_STD_F95); |
6de9cd9a | 1870 | |
b7892582 | 1871 | add_sym_1 ("rrspacing", 1, 1, BT_REAL, dr, GFC_STD_F95, |
6de9cd9a | 1872 | gfc_check_x, gfc_simplify_rrspacing, gfc_resolve_rrspacing, |
1270d633 | 1873 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1874 | |
b7892582 | 1875 | make_generic ("rrspacing", GFC_ISYM_RRSPACING, GFC_STD_F95); |
6de9cd9a | 1876 | |
b7892582 | 1877 | add_sym_2 ("scale", 1, 1, BT_REAL, dr, GFC_STD_F95, |
6de9cd9a | 1878 | gfc_check_scale, gfc_simplify_scale, gfc_resolve_scale, |
1270d633 | 1879 | x, BT_REAL, dr, REQUIRED, i, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1880 | |
b7892582 | 1881 | make_generic ("scale", GFC_ISYM_SCALE, GFC_STD_F95); |
6de9cd9a | 1882 | |
b7892582 | 1883 | add_sym_3 ("scan", 1, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1884 | gfc_check_scan, gfc_simplify_scan, gfc_resolve_scan, |
1270d633 SK |
1885 | stg, BT_CHARACTER, dc, REQUIRED, set, BT_CHARACTER, dc, REQUIRED, |
1886 | bck, BT_LOGICAL, dl, OPTIONAL); | |
6de9cd9a | 1887 | |
b7892582 | 1888 | make_generic ("scan", GFC_ISYM_SCAN, GFC_STD_F95); |
6de9cd9a | 1889 | |
f7b529fa | 1890 | /* Added for G77 compatibility garbage. */ |
1270d633 SK |
1891 | add_sym_0 ("second", 0, 1, BT_REAL, 4, GFC_STD_GNU, |
1892 | NULL, NULL, NULL); | |
2bd74949 | 1893 | |
b7892582 | 1894 | make_generic ("second", GFC_ISYM_SECOND, GFC_STD_GNU); |
2bd74949 | 1895 | |
53096259 PT |
1896 | /* Added for G77 compatibility. */ |
1897 | add_sym_1 ("secnds", 0, 1, BT_REAL, dr, GFC_STD_GNU, | |
1898 | gfc_check_secnds, NULL, gfc_resolve_secnds, | |
1899 | x, BT_REAL, dr, REQUIRED); | |
1900 | ||
1901 | make_generic ("secnds", GFC_ISYM_SECNDS, GFC_STD_GNU); | |
1902 | ||
b7892582 | 1903 | add_sym_1 ("selected_int_kind", 0, 1, BT_INTEGER, di, GFC_STD_F95, |
145cf79b | 1904 | gfc_check_selected_int_kind, gfc_simplify_selected_int_kind, NULL, |
1270d633 | 1905 | r, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1906 | |
b7892582 | 1907 | make_generic ("selected_int_kind", GFC_ISYM_SI_KIND, GFC_STD_F95); |
6de9cd9a | 1908 | |
b7892582 | 1909 | add_sym_2 ("selected_real_kind", 0, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1910 | gfc_check_selected_real_kind, gfc_simplify_selected_real_kind, |
1270d633 SK |
1911 | NULL, |
1912 | p, BT_INTEGER, di, OPTIONAL, r, BT_INTEGER, di, OPTIONAL); | |
6de9cd9a | 1913 | |
b7892582 | 1914 | make_generic ("selected_real_kind", GFC_ISYM_SR_KIND, GFC_STD_F95); |
6de9cd9a | 1915 | |
b7892582 | 1916 | add_sym_2 ("set_exponent", 1, 1, BT_REAL, dr, GFC_STD_F95, |
6de9cd9a DN |
1917 | gfc_check_set_exponent, gfc_simplify_set_exponent, |
1918 | gfc_resolve_set_exponent, | |
1270d633 | 1919 | x, BT_REAL, dr, REQUIRED, i, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1920 | |
b7892582 | 1921 | make_generic ("set_exponent", GFC_ISYM_SET_EXPONENT, GFC_STD_F95); |
6de9cd9a | 1922 | |
b7892582 | 1923 | add_sym_1 ("shape", 0, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1924 | gfc_check_shape, gfc_simplify_shape, gfc_resolve_shape, |
1270d633 | 1925 | src, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1926 | |
b7892582 | 1927 | make_generic ("shape", GFC_ISYM_SHAPE, GFC_STD_F95); |
6de9cd9a | 1928 | |
b7892582 | 1929 | add_sym_2 ("sign", 1, 1, BT_REAL, dr, GFC_STD_F77, |
6de9cd9a | 1930 | gfc_check_sign, gfc_simplify_sign, gfc_resolve_sign, |
1270d633 | 1931 | a, BT_REAL, dr, REQUIRED, b, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1932 | |
b7892582 | 1933 | add_sym_2 ("isign", 1, 1, BT_INTEGER, di, GFC_STD_F77, |
6de9cd9a | 1934 | NULL, gfc_simplify_sign, gfc_resolve_sign, |
1270d633 | 1935 | a, BT_INTEGER, di, REQUIRED, b, BT_INTEGER, di, REQUIRED); |
6de9cd9a | 1936 | |
b7892582 | 1937 | add_sym_2 ("dsign", 1, 1, BT_REAL, dd, GFC_STD_F77, |
6de9cd9a | 1938 | NULL, gfc_simplify_sign, gfc_resolve_sign, |
1270d633 | 1939 | a, BT_REAL, dd, REQUIRED, b, BT_REAL, dd, REQUIRED); |
6de9cd9a | 1940 | |
b7892582 | 1941 | make_generic ("sign", GFC_ISYM_SIGN, GFC_STD_F77); |
6de9cd9a | 1942 | |
185d7d97 FXC |
1943 | add_sym_2 ("signal", 1, 1, BT_INTEGER, di, GFC_STD_GNU, |
1944 | gfc_check_signal, NULL, gfc_resolve_signal, | |
1945 | num, BT_INTEGER, di, REQUIRED, han, BT_UNKNOWN, 0, REQUIRED); | |
1946 | ||
1947 | make_generic ("signal", GFC_ISYM_SIGNAL, GFC_STD_GNU); | |
1948 | ||
b7892582 | 1949 | add_sym_1 ("sin", 1, 1, BT_REAL, dr, GFC_STD_F77, |
985aff9c | 1950 | gfc_check_fn_rc, gfc_simplify_sin, gfc_resolve_sin, |
1270d633 | 1951 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1952 | |
b7892582 | 1953 | add_sym_1 ("dsin", 1, 1, BT_REAL, dd, GFC_STD_F77, |
1270d633 SK |
1954 | NULL, gfc_simplify_sin, gfc_resolve_sin, |
1955 | x, BT_REAL, dd, REQUIRED); | |
6de9cd9a | 1956 | |
b7892582 | 1957 | add_sym_1 ("csin", 1, 1, BT_COMPLEX, dz, GFC_STD_F77, |
6de9cd9a | 1958 | NULL, gfc_simplify_sin, gfc_resolve_sin, |
1270d633 | 1959 | x, BT_COMPLEX, dz, REQUIRED); |
6de9cd9a | 1960 | |
b7892582 | 1961 | add_sym_1 ("zsin", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU, |
1270d633 SK |
1962 | NULL, gfc_simplify_sin, gfc_resolve_sin, |
1963 | x, BT_COMPLEX, dd, REQUIRED); | |
6de9cd9a | 1964 | |
19060788 | 1965 | make_alias ("cdsin", GFC_STD_GNU); |
6de9cd9a | 1966 | |
b7892582 | 1967 | make_generic ("sin", GFC_ISYM_SIN, GFC_STD_F77); |
6de9cd9a | 1968 | |
b7892582 | 1969 | add_sym_1 ("sinh", 1, 1, BT_REAL, dr, GFC_STD_F77, |
985aff9c | 1970 | gfc_check_fn_r, gfc_simplify_sinh, gfc_resolve_sinh, |
1270d633 | 1971 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1972 | |
b7892582 | 1973 | add_sym_1 ("dsinh", 1, 1, BT_REAL, dd, GFC_STD_F77, |
6de9cd9a | 1974 | NULL, gfc_simplify_sinh, gfc_resolve_sinh, |
1270d633 | 1975 | x, BT_REAL, dd, REQUIRED); |
6de9cd9a | 1976 | |
b7892582 | 1977 | make_generic ("sinh", GFC_ISYM_SINH, GFC_STD_F77); |
6de9cd9a | 1978 | |
b7892582 | 1979 | add_sym_2 ("size", 0, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 1980 | gfc_check_size, gfc_simplify_size, NULL, |
1270d633 | 1981 | ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL); |
6de9cd9a | 1982 | |
b7892582 | 1983 | make_generic ("size", GFC_ISYM_SIZE, GFC_STD_F95); |
6de9cd9a | 1984 | |
b7892582 | 1985 | add_sym_1 ("spacing", 1, 1, BT_REAL, dr, GFC_STD_F95, |
6de9cd9a | 1986 | gfc_check_x, gfc_simplify_spacing, gfc_resolve_spacing, |
1270d633 | 1987 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 1988 | |
b7892582 | 1989 | make_generic ("spacing", GFC_ISYM_SPACING, GFC_STD_F95); |
6de9cd9a | 1990 | |
b7892582 | 1991 | add_sym_3 ("spread", 0, 1, BT_REAL, dr, GFC_STD_F95, |
6de9cd9a | 1992 | gfc_check_spread, NULL, gfc_resolve_spread, |
1270d633 SK |
1993 | src, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, REQUIRED, |
1994 | n, BT_INTEGER, di, REQUIRED); | |
6de9cd9a | 1995 | |
b7892582 | 1996 | make_generic ("spread", GFC_ISYM_SPREAD, GFC_STD_F95); |
6de9cd9a | 1997 | |
b7892582 | 1998 | add_sym_1 ("sqrt", 1, 1, BT_REAL, dr, GFC_STD_F77, |
985aff9c | 1999 | gfc_check_fn_rc, gfc_simplify_sqrt, gfc_resolve_sqrt, |
1270d633 | 2000 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 2001 | |
b7892582 | 2002 | add_sym_1 ("dsqrt", 1, 1, BT_REAL, dd, GFC_STD_F77, |
6de9cd9a | 2003 | NULL, gfc_simplify_sqrt, gfc_resolve_sqrt, |
1270d633 | 2004 | x, BT_REAL, dd, REQUIRED); |
6de9cd9a | 2005 | |
b7892582 | 2006 | add_sym_1 ("csqrt", 1, 1, BT_COMPLEX, dz, GFC_STD_F77, |
6de9cd9a | 2007 | NULL, gfc_simplify_sqrt, gfc_resolve_sqrt, |
1270d633 | 2008 | x, BT_COMPLEX, dz, REQUIRED); |
6de9cd9a | 2009 | |
b7892582 | 2010 | add_sym_1 ("zsqrt", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU, |
1270d633 SK |
2011 | NULL, gfc_simplify_sqrt, gfc_resolve_sqrt, |
2012 | x, BT_COMPLEX, dd, REQUIRED); | |
6de9cd9a | 2013 | |
19060788 | 2014 | make_alias ("cdsqrt", GFC_STD_GNU); |
6de9cd9a | 2015 | |
b7892582 | 2016 | make_generic ("sqrt", GFC_ISYM_SQRT, GFC_STD_F77); |
6de9cd9a | 2017 | |
df65f093 SK |
2018 | add_sym_2 ("stat", 0, 1, BT_INTEGER, di, GFC_STD_GNU, |
2019 | gfc_check_stat, NULL, gfc_resolve_stat, | |
2020 | a, BT_CHARACTER, dc, REQUIRED, b, BT_INTEGER, di, REQUIRED); | |
2021 | ||
2022 | make_generic ("stat", GFC_ISYM_STAT, GFC_STD_GNU); | |
2023 | ||
b7892582 | 2024 | add_sym_3red ("sum", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95, |
617097a3 | 2025 | gfc_check_product_sum, NULL, gfc_resolve_sum, |
1270d633 SK |
2026 | ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL, |
2027 | msk, BT_LOGICAL, dl, OPTIONAL); | |
6de9cd9a | 2028 | |
b7892582 | 2029 | make_generic ("sum", GFC_ISYM_SUM, GFC_STD_F95); |
6de9cd9a | 2030 | |
f77b6ca3 FXC |
2031 | add_sym_2 ("symlnk", 0, 1, BT_INTEGER, di, GFC_STD_GNU, |
2032 | gfc_check_symlnk, NULL, gfc_resolve_symlnk, | |
2033 | a, BT_CHARACTER, dc, REQUIRED, b, BT_CHARACTER, dc, REQUIRED); | |
2034 | ||
2035 | make_generic ("symlnk", GFC_ISYM_SYMLNK, GFC_STD_GNU); | |
2036 | ||
1270d633 SK |
2037 | add_sym_1 ("system", 1, 1, BT_INTEGER, di, GFC_STD_GNU, |
2038 | NULL, NULL, NULL, | |
2039 | c, BT_CHARACTER, dc, REQUIRED); | |
2040 | ||
b7892582 | 2041 | make_generic ("system", GFC_ISYM_SYSTEM, GFC_STD_GNU); |
5b1374e9 | 2042 | |
b7892582 | 2043 | add_sym_1 ("tan", 1, 1, BT_REAL, dr, GFC_STD_F77, |
985aff9c | 2044 | gfc_check_fn_r, gfc_simplify_tan, gfc_resolve_tan, |
1270d633 | 2045 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 2046 | |
b7892582 | 2047 | add_sym_1 ("dtan", 1, 1, BT_REAL, dd, GFC_STD_F77, |
1270d633 SK |
2048 | NULL, gfc_simplify_tan, gfc_resolve_tan, |
2049 | x, BT_REAL, dd, REQUIRED); | |
6de9cd9a | 2050 | |
b7892582 | 2051 | make_generic ("tan", GFC_ISYM_TAN, GFC_STD_F77); |
6de9cd9a | 2052 | |
b7892582 | 2053 | add_sym_1 ("tanh", 1, 1, BT_REAL, dr, GFC_STD_F77, |
985aff9c | 2054 | gfc_check_fn_r, gfc_simplify_tanh, gfc_resolve_tanh, |
1270d633 | 2055 | x, BT_REAL, dr, REQUIRED); |
6de9cd9a | 2056 | |
b7892582 | 2057 | add_sym_1 ("dtanh", 1, 1, BT_REAL, dd, GFC_STD_F77, |
6de9cd9a | 2058 | NULL, gfc_simplify_tanh, gfc_resolve_tanh, |
1270d633 | 2059 | x, BT_REAL, dd, REQUIRED); |
6de9cd9a | 2060 | |
b7892582 | 2061 | make_generic ("tanh", GFC_ISYM_TANH, GFC_STD_F77); |
6de9cd9a | 2062 | |
f77b6ca3 FXC |
2063 | add_sym_0 ("time", 1, 0, BT_INTEGER, di, GFC_STD_GNU, |
2064 | NULL, NULL, gfc_resolve_time); | |
2065 | ||
2066 | make_generic ("time", GFC_ISYM_TIME, GFC_STD_GNU); | |
2067 | ||
2068 | add_sym_0 ("time8", 1, 0, BT_INTEGER, di, GFC_STD_GNU, | |
2069 | NULL, NULL, gfc_resolve_time8); | |
2070 | ||
2071 | make_generic ("time8", GFC_ISYM_TIME8, GFC_STD_GNU); | |
2072 | ||
b7892582 | 2073 | add_sym_1 ("tiny", 0, 1, BT_REAL, dr, GFC_STD_F95, |
1270d633 SK |
2074 | gfc_check_x, gfc_simplify_tiny, NULL, |
2075 | x, BT_REAL, dr, REQUIRED); | |
6de9cd9a | 2076 | |
b7892582 | 2077 | make_generic ("tiny", GFC_ISYM_NONE, GFC_STD_F95); |
6de9cd9a | 2078 | |
b7892582 | 2079 | add_sym_3 ("transfer", 0, 1, BT_REAL, dr, GFC_STD_F95, |
6de9cd9a | 2080 | gfc_check_transfer, NULL, gfc_resolve_transfer, |
1270d633 SK |
2081 | src, BT_REAL, dr, REQUIRED, mo, BT_REAL, dr, REQUIRED, |
2082 | sz, BT_INTEGER, di, OPTIONAL); | |
6de9cd9a | 2083 | |
b7892582 | 2084 | make_generic ("transfer", GFC_ISYM_TRANSFER, GFC_STD_F95); |
6de9cd9a | 2085 | |
b7892582 | 2086 | add_sym_1 ("transpose", 0, 1, BT_REAL, dr, GFC_STD_F95, |
6de9cd9a | 2087 | gfc_check_transpose, NULL, gfc_resolve_transpose, |
1270d633 | 2088 | m, BT_REAL, dr, REQUIRED); |
6de9cd9a | 2089 | |
b7892582 | 2090 | make_generic ("transpose", GFC_ISYM_TRANSPOSE, GFC_STD_F95); |
6de9cd9a | 2091 | |
b7892582 | 2092 | add_sym_1 ("trim", 0, 1, BT_CHARACTER, dc, GFC_STD_F95, |
6de9cd9a | 2093 | gfc_check_trim, gfc_simplify_trim, gfc_resolve_trim, |
1270d633 | 2094 | stg, BT_CHARACTER, dc, REQUIRED); |
6de9cd9a | 2095 | |
b7892582 | 2096 | make_generic ("trim", GFC_ISYM_TRIM, GFC_STD_F95); |
6de9cd9a | 2097 | |
25fc05eb FXC |
2098 | add_sym_1 ("ttynam", 0, 1, BT_CHARACTER, 0, GFC_STD_GNU, |
2099 | gfc_check_ttynam, NULL, gfc_resolve_ttynam, | |
2100 | ut, BT_INTEGER, di, REQUIRED); | |
2101 | ||
2102 | make_generic ("ttynam", GFC_ISYM_TTYNAM, GFC_STD_GNU); | |
2103 | ||
b7892582 | 2104 | add_sym_2 ("ubound", 0, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 2105 | gfc_check_ubound, gfc_simplify_ubound, gfc_resolve_ubound, |
1270d633 | 2106 | ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL); |
6de9cd9a | 2107 | |
b7892582 | 2108 | make_generic ("ubound", GFC_ISYM_UBOUND, GFC_STD_F95); |
6de9cd9a | 2109 | |
d8fe26b2 SK |
2110 | /* g77 compatibility for UMASK. */ |
2111 | add_sym_1 ("umask", 0, 1, BT_INTEGER, di, GFC_STD_GNU, | |
2112 | gfc_check_umask, NULL, gfc_resolve_umask, | |
1270d633 | 2113 | a, BT_INTEGER, di, REQUIRED); |
d8fe26b2 SK |
2114 | |
2115 | make_generic ("umask", GFC_ISYM_UMASK, GFC_STD_GNU); | |
2116 | ||
2117 | /* g77 compatibility for UNLINK. */ | |
2118 | add_sym_1 ("unlink", 0, 1, BT_INTEGER, di, GFC_STD_GNU, | |
2119 | gfc_check_unlink, NULL, gfc_resolve_unlink, | |
1270d633 | 2120 | a, BT_CHARACTER, dc, REQUIRED); |
d8fe26b2 SK |
2121 | |
2122 | make_generic ("unlink", GFC_ISYM_UNLINK, GFC_STD_GNU); | |
2123 | ||
b7892582 | 2124 | add_sym_3 ("unpack", 0, 1, BT_REAL, dr, GFC_STD_F95, |
6de9cd9a | 2125 | gfc_check_unpack, NULL, gfc_resolve_unpack, |
1270d633 SK |
2126 | v, BT_REAL, dr, REQUIRED, msk, BT_LOGICAL, dl, REQUIRED, |
2127 | f, BT_REAL, dr, REQUIRED); | |
6de9cd9a | 2128 | |
b7892582 | 2129 | make_generic ("unpack", GFC_ISYM_UNPACK, GFC_STD_F95); |
6de9cd9a | 2130 | |
b7892582 | 2131 | add_sym_3 ("verify", 1, 1, BT_INTEGER, di, GFC_STD_F95, |
6de9cd9a | 2132 | gfc_check_verify, gfc_simplify_verify, gfc_resolve_verify, |
1270d633 SK |
2133 | stg, BT_CHARACTER, dc, REQUIRED, set, BT_CHARACTER, dc, REQUIRED, |
2134 | bck, BT_LOGICAL, dl, OPTIONAL); | |
6de9cd9a | 2135 | |
b7892582 | 2136 | make_generic ("verify", GFC_ISYM_VERIFY, GFC_STD_F95); |
83d890b9 AL |
2137 | |
2138 | add_sym_1 ("loc", 0, 1, BT_INTEGER, ii, GFC_STD_GNU, | |
2139 | gfc_check_loc, NULL, gfc_resolve_loc, | |
2140 | ar, BT_UNKNOWN, 0, REQUIRED); | |
2141 | ||
2142 | make_generic ("loc", GFC_ISYM_LOC, GFC_STD_GNU); | |
2143 | ||
6de9cd9a DN |
2144 | } |
2145 | ||
2146 | ||
6de9cd9a DN |
2147 | /* Add intrinsic subroutines. */ |
2148 | ||
2149 | static void | |
2150 | add_subroutines (void) | |
2151 | { | |
2152 | /* Argument names as in the standard (to be used as argument keywords). */ | |
2153 | const char | |
2154 | *h = "harvest", *dt = "date", *vl = "values", *pt = "put", | |
2155 | *c = "count", *tm = "time", *tp = "topos", *gt = "get", | |
2156 | *t = "to", *zn = "zone", *fp = "frompos", *cm = "count_max", | |
b41b2534 JB |
2157 | *f = "from", *sz = "size", *ln = "len", *cr = "count_rate", |
2158 | *com = "command", *length = "length", *st = "status", | |
aa6fc635 | 2159 | *val = "value", *num = "number", *name = "name", |
185d7d97 | 2160 | *trim_name = "trim_name", *ut = "unit", *han = "handler", |
35059811 | 2161 | *sec = "seconds", *res = "result"; |
6de9cd9a | 2162 | |
0d519038 | 2163 | int di, dr, dc, dl, ii; |
6de9cd9a | 2164 | |
9d64df18 TS |
2165 | di = gfc_default_integer_kind; |
2166 | dr = gfc_default_real_kind; | |
2167 | dc = gfc_default_character_kind; | |
2168 | dl = gfc_default_logical_kind; | |
0d519038 | 2169 | ii = gfc_index_integer_kind; |
6de9cd9a | 2170 | |
b7892582 | 2171 | add_sym_0s ("abort", 1, GFC_STD_GNU, NULL); |
6de9cd9a | 2172 | |
fe58e076 TK |
2173 | make_noreturn(); |
2174 | ||
b7892582 | 2175 | add_sym_1s ("cpu_time", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95, |
6de9cd9a | 2176 | gfc_check_cpu_time, NULL, gfc_resolve_cpu_time, |
1270d633 | 2177 | tm, BT_REAL, dr, REQUIRED); |
6de9cd9a | 2178 | |
f7b529fa | 2179 | /* More G77 compatibility garbage. */ |
35059811 FXC |
2180 | add_sym_2s ("ctime", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
2181 | gfc_check_ctime_sub, NULL, gfc_resolve_ctime_sub, | |
2182 | tm, BT_INTEGER, di, REQUIRED, res, BT_CHARACTER, dc, REQUIRED); | |
2183 | ||
b7892582 | 2184 | add_sym_1s ("second", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
2bd74949 | 2185 | gfc_check_second_sub, NULL, gfc_resolve_second_sub, |
1270d633 | 2186 | tm, BT_REAL, dr, REQUIRED); |
2bd74949 | 2187 | |
f77b6ca3 FXC |
2188 | add_sym_2s ("chdir", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
2189 | gfc_check_chdir_sub, NULL, gfc_resolve_chdir_sub, | |
2190 | name, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL); | |
2191 | ||
b7892582 | 2192 | add_sym_4s ("date_and_time", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95, |
60c9a35b | 2193 | gfc_check_date_and_time, NULL, NULL, |
1270d633 SK |
2194 | dt, BT_CHARACTER, dc, OPTIONAL, tm, BT_CHARACTER, dc, OPTIONAL, |
2195 | zn, BT_CHARACTER, dc, OPTIONAL, vl, BT_INTEGER, di, OPTIONAL); | |
6de9cd9a | 2196 | |
f7b529fa | 2197 | /* More G77 compatibility garbage. */ |
b7892582 | 2198 | add_sym_2s ("etime", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
2bd74949 | 2199 | gfc_check_etime_sub, NULL, gfc_resolve_etime_sub, |
1270d633 | 2200 | vl, BT_REAL, 4, REQUIRED, tm, BT_REAL, 4, REQUIRED); |
2bd74949 | 2201 | |
b7892582 | 2202 | add_sym_2s ("dtime", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
2bd74949 | 2203 | gfc_check_etime_sub, NULL, gfc_resolve_etime_sub, |
1270d633 | 2204 | vl, BT_REAL, 4, REQUIRED, tm, BT_REAL, 4, REQUIRED); |
2bd74949 | 2205 | |
35059811 FXC |
2206 | add_sym_1s ("fdate", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
2207 | gfc_check_fdate_sub, NULL, gfc_resolve_fdate_sub, | |
2208 | dt, BT_CHARACTER, dc, REQUIRED); | |
2209 | ||
f77b6ca3 FXC |
2210 | add_sym_1s ("gerror", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
2211 | gfc_check_gerror, NULL, gfc_resolve_gerror, c, BT_CHARACTER, | |
2212 | dc, REQUIRED); | |
2213 | ||
b7892582 | 2214 | add_sym_2s ("getcwd", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
a8c60d7f | 2215 | gfc_check_getcwd_sub, NULL, gfc_resolve_getcwd_sub, |
1270d633 | 2216 | c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL); |
a8c60d7f | 2217 | |
b7892582 | 2218 | add_sym_2s ("getenv", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
aa6fc635 | 2219 | NULL, NULL, NULL, |
1270d633 | 2220 | name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER, dc, REQUIRED); |
aa6fc635 | 2221 | |
b7892582 | 2222 | add_sym_2s ("getarg", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
60c9a35b | 2223 | NULL, NULL, gfc_resolve_getarg, |
1270d633 | 2224 | c, BT_INTEGER, di, REQUIRED, vl, BT_CHARACTER, dc, REQUIRED); |
a8c60d7f | 2225 | |
f77b6ca3 FXC |
2226 | add_sym_1s ("getlog", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
2227 | gfc_check_getlog, NULL, gfc_resolve_getlog, c, BT_CHARACTER, | |
2228 | dc, REQUIRED); | |
2229 | ||
b41b2534 JB |
2230 | /* F2003 commandline routines. */ |
2231 | ||
b7892582 | 2232 | add_sym_3s ("get_command", 0, 1, BT_UNKNOWN, 0, GFC_STD_F2003, |
60c9a35b | 2233 | NULL, NULL, gfc_resolve_get_command, |
1270d633 SK |
2234 | com, BT_CHARACTER, dc, OPTIONAL, length, BT_INTEGER, di, OPTIONAL, |
2235 | st, BT_INTEGER, di, OPTIONAL); | |
60c9a35b | 2236 | |
b7892582 | 2237 | add_sym_4s ("get_command_argument", 0, 1, BT_UNKNOWN, 0, GFC_STD_F2003, |
60c9a35b | 2238 | NULL, NULL, gfc_resolve_get_command_argument, |
1270d633 SK |
2239 | num, BT_INTEGER, di, REQUIRED, val, BT_CHARACTER, dc, OPTIONAL, |
2240 | length, BT_INTEGER, di, OPTIONAL, st, BT_INTEGER, di, OPTIONAL); | |
aa6fc635 | 2241 | |
f7b529fa | 2242 | /* F2003 subroutine to get environment variables. */ |
aa6fc635 | 2243 | |
b7892582 | 2244 | add_sym_5s ("get_environment_variable", 0, 1, BT_UNKNOWN, 0, GFC_STD_F2003, |
aa6fc635 | 2245 | NULL, NULL, gfc_resolve_get_environment_variable, |
1270d633 SK |
2246 | name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER, dc, OPTIONAL, |
2247 | length, BT_INTEGER, di, OPTIONAL, st, BT_INTEGER, di, OPTIONAL, | |
2248 | trim_name, BT_LOGICAL, dl, OPTIONAL); | |
6de9cd9a | 2249 | |
b7892582 | 2250 | add_sym_5s ("mvbits", 1, 1, BT_UNKNOWN, 0, GFC_STD_F95, |
ee569894 | 2251 | gfc_check_mvbits, gfc_simplify_mvbits, gfc_resolve_mvbits, |
1270d633 SK |
2252 | f, BT_INTEGER, di, REQUIRED, fp, BT_INTEGER, di, REQUIRED, |
2253 | ln, BT_INTEGER, di, REQUIRED, t, BT_INTEGER, di, REQUIRED, | |
2254 | tp, BT_INTEGER, di, REQUIRED); | |
6de9cd9a | 2255 | |
b7892582 | 2256 | add_sym_1s ("random_number", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95, |
6de9cd9a | 2257 | gfc_check_random_number, NULL, gfc_resolve_random_number, |
1270d633 | 2258 | h, BT_REAL, dr, REQUIRED); |
6de9cd9a | 2259 | |
b7892582 | 2260 | add_sym_3s ("random_seed", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95, |
6de9cd9a | 2261 | gfc_check_random_seed, NULL, NULL, |
1270d633 SK |
2262 | sz, BT_INTEGER, di, OPTIONAL, pt, BT_INTEGER, di, OPTIONAL, |
2263 | gt, BT_INTEGER, di, OPTIONAL); | |
6de9cd9a | 2264 | |
f7b529fa | 2265 | /* More G77 compatibility garbage. */ |
185d7d97 FXC |
2266 | add_sym_3s ("alarm", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
2267 | gfc_check_alarm_sub, NULL, gfc_resolve_alarm_sub, | |
2268 | sec, BT_INTEGER, di, REQUIRED, han, BT_UNKNOWN, 0, REQUIRED, | |
2269 | st, BT_INTEGER, di, OPTIONAL); | |
2270 | ||
b7892582 | 2271 | add_sym_1s ("srand", 0, 1, BT_UNKNOWN, di, GFC_STD_GNU, |
2bd74949 | 2272 | gfc_check_srand, NULL, gfc_resolve_srand, |
1270d633 | 2273 | c, BT_INTEGER, 4, REQUIRED); |
2bd74949 | 2274 | |
d8fe26b2 SK |
2275 | add_sym_1s ("exit", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
2276 | gfc_check_exit, NULL, gfc_resolve_exit, | |
1270d633 | 2277 | c, BT_INTEGER, di, OPTIONAL); |
d8fe26b2 | 2278 | |
fe58e076 TK |
2279 | make_noreturn(); |
2280 | ||
df65f093 SK |
2281 | add_sym_1s ("flush", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
2282 | gfc_check_flush, NULL, gfc_resolve_flush, | |
2283 | c, BT_INTEGER, di, OPTIONAL); | |
2284 | ||
0d519038 FXC |
2285 | add_sym_1s ("free", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, gfc_check_free, |
2286 | NULL, gfc_resolve_free, c, BT_INTEGER, ii, REQUIRED); | |
2287 | ||
f77b6ca3 FXC |
2288 | add_sym_2s ("hostnm", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
2289 | gfc_check_hostnm_sub, NULL, gfc_resolve_hostnm_sub, | |
2290 | c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL); | |
2291 | ||
2292 | add_sym_3s ("kill", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, gfc_check_kill_sub, | |
2293 | NULL, gfc_resolve_kill_sub, c, BT_INTEGER, di, REQUIRED, | |
2294 | val, BT_INTEGER, di, REQUIRED, st, BT_INTEGER, di, OPTIONAL); | |
2295 | ||
2296 | add_sym_3s ("link", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, | |
2297 | gfc_check_link_sub, NULL, gfc_resolve_link_sub, | |
2298 | name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER, | |
2299 | dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL); | |
2300 | ||
2301 | add_sym_1s ("perror", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, | |
2302 | gfc_check_perror, NULL, gfc_resolve_perror, | |
2303 | c, BT_CHARACTER, dc, REQUIRED); | |
2304 | ||
2305 | add_sym_3s ("rename", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, | |
2306 | gfc_check_rename_sub, NULL, gfc_resolve_rename_sub, | |
2307 | name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER, | |
2308 | dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL); | |
2309 | ||
2310 | add_sym_1s ("sleep", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, | |
2311 | gfc_check_sleep_sub, NULL, gfc_resolve_sleep_sub, | |
2312 | val, BT_CHARACTER, dc, REQUIRED); | |
2313 | ||
df65f093 SK |
2314 | add_sym_3s ("fstat", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
2315 | gfc_check_fstat_sub, NULL, gfc_resolve_fstat_sub, | |
2316 | ut, BT_INTEGER, di, REQUIRED, vl, BT_INTEGER, di, REQUIRED, | |
2317 | st, BT_INTEGER, di, OPTIONAL); | |
2318 | ||
2319 | add_sym_3s ("stat", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, | |
2320 | gfc_check_stat_sub, NULL, gfc_resolve_stat_sub, | |
2321 | name, BT_CHARACTER, dc, REQUIRED, vl, BT_INTEGER, di, REQUIRED, | |
2322 | st, BT_INTEGER, di, OPTIONAL); | |
2323 | ||
185d7d97 FXC |
2324 | add_sym_3s ("signal", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
2325 | gfc_check_signal_sub, NULL, gfc_resolve_signal_sub, | |
2326 | num, BT_INTEGER, di, REQUIRED, han, BT_UNKNOWN, 0, REQUIRED, | |
2327 | st, BT_INTEGER, di, OPTIONAL); | |
2328 | ||
f77b6ca3 FXC |
2329 | add_sym_3s ("symlnk", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
2330 | gfc_check_symlnk_sub, NULL, gfc_resolve_symlnk_sub, | |
2331 | name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER, | |
2332 | dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL); | |
2333 | ||
b7892582 | 2334 | add_sym_2s ("system", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
5b1374e9 | 2335 | NULL, NULL, gfc_resolve_system_sub, |
1270d633 | 2336 | c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL); |
5b1374e9 | 2337 | |
b7892582 | 2338 | add_sym_3s ("system_clock", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95, |
21fdfcc1 | 2339 | gfc_check_system_clock, NULL, gfc_resolve_system_clock, |
1270d633 SK |
2340 | c, BT_INTEGER, di, OPTIONAL, cr, BT_INTEGER, di, OPTIONAL, |
2341 | cm, BT_INTEGER, di, OPTIONAL); | |
d8fe26b2 | 2342 | |
ae8b8789 FXC |
2343 | add_sym_2s ("ttynam", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
2344 | gfc_check_ttynam_sub, NULL, gfc_resolve_ttynam_sub, | |
2345 | ut, BT_INTEGER, di, REQUIRED, c, BT_CHARACTER, dc, REQUIRED); | |
2346 | ||
d8fe26b2 SK |
2347 | add_sym_2s ("umask", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, |
2348 | gfc_check_umask_sub, NULL, gfc_resolve_umask_sub, | |
1270d633 | 2349 | val, BT_INTEGER, di, REQUIRED, num, BT_INTEGER, di, OPTIONAL); |
d8fe26b2 SK |
2350 | |
2351 | add_sym_2s ("unlink", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, | |
2352 | gfc_check_unlink_sub, NULL, gfc_resolve_unlink_sub, | |
1270d633 | 2353 | c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL); |
d8fe26b2 | 2354 | |
6de9cd9a DN |
2355 | } |
2356 | ||
2357 | ||
2358 | /* Add a function to the list of conversion symbols. */ | |
2359 | ||
2360 | static void | |
c3a29423 | 2361 | add_conv (bt from_type, int from_kind, bt to_type, int to_kind, int standard) |
6de9cd9a DN |
2362 | { |
2363 | ||
2364 | gfc_typespec from, to; | |
2365 | gfc_intrinsic_sym *sym; | |
2366 | ||
2367 | if (sizing == SZ_CONVS) | |
2368 | { | |
2369 | nconv++; | |
2370 | return; | |
2371 | } | |
2372 | ||
2373 | gfc_clear_ts (&from); | |
2374 | from.type = from_type; | |
2375 | from.kind = from_kind; | |
2376 | ||
2377 | gfc_clear_ts (&to); | |
2378 | to.type = to_type; | |
2379 | to.kind = to_kind; | |
2380 | ||
2381 | sym = conversion + nconv; | |
2382 | ||
c3a29423 | 2383 | sym->name = conv_name (&from, &to); |
cb9e4f55 | 2384 | sym->lib_name = sym->name; |
c3a29423 RS |
2385 | sym->simplify.cc = gfc_convert_constant; |
2386 | sym->standard = standard; | |
6de9cd9a DN |
2387 | sym->elemental = 1; |
2388 | sym->ts = to; | |
2389 | sym->generic_id = GFC_ISYM_CONVERSION; | |
2390 | ||
2391 | nconv++; | |
2392 | } | |
2393 | ||
2394 | ||
2395 | /* Create gfc_intrinsic_sym nodes for all intrinsic conversion | |
2396 | functions by looping over the kind tables. */ | |
2397 | ||
2398 | static void | |
2399 | add_conversions (void) | |
2400 | { | |
2401 | int i, j; | |
2402 | ||
2403 | /* Integer-Integer conversions. */ | |
2404 | for (i = 0; gfc_integer_kinds[i].kind != 0; i++) | |
2405 | for (j = 0; gfc_integer_kinds[j].kind != 0; j++) | |
2406 | { | |
2407 | if (i == j) | |
2408 | continue; | |
2409 | ||
2410 | add_conv (BT_INTEGER, gfc_integer_kinds[i].kind, | |
c3a29423 | 2411 | BT_INTEGER, gfc_integer_kinds[j].kind, GFC_STD_F77); |
6de9cd9a DN |
2412 | } |
2413 | ||
2414 | /* Integer-Real/Complex conversions. */ | |
2415 | for (i = 0; gfc_integer_kinds[i].kind != 0; i++) | |
2416 | for (j = 0; gfc_real_kinds[j].kind != 0; j++) | |
2417 | { | |
2418 | add_conv (BT_INTEGER, gfc_integer_kinds[i].kind, | |
c3a29423 | 2419 | BT_REAL, gfc_real_kinds[j].kind, GFC_STD_F77); |
6de9cd9a DN |
2420 | |
2421 | add_conv (BT_REAL, gfc_real_kinds[j].kind, | |
c3a29423 | 2422 | BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_F77); |
6de9cd9a DN |
2423 | |
2424 | add_conv (BT_INTEGER, gfc_integer_kinds[i].kind, | |
c3a29423 | 2425 | BT_COMPLEX, gfc_real_kinds[j].kind, GFC_STD_F77); |
6de9cd9a DN |
2426 | |
2427 | add_conv (BT_COMPLEX, gfc_real_kinds[j].kind, | |
c3a29423 | 2428 | BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_F77); |
6de9cd9a DN |
2429 | } |
2430 | ||
d3642f89 FW |
2431 | if ((gfc_option.allow_std & GFC_STD_LEGACY) != 0) |
2432 | { | |
2433 | /* Hollerith-Integer conversions. */ | |
2434 | for (i = 0; gfc_integer_kinds[i].kind != 0; i++) | |
2435 | add_conv (BT_HOLLERITH, gfc_default_character_kind, | |
2436 | BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_LEGACY); | |
2437 | /* Hollerith-Real conversions. */ | |
2438 | for (i = 0; gfc_real_kinds[i].kind != 0; i++) | |
2439 | add_conv (BT_HOLLERITH, gfc_default_character_kind, | |
2440 | BT_REAL, gfc_real_kinds[i].kind, GFC_STD_LEGACY); | |
2441 | /* Hollerith-Complex conversions. */ | |
2442 | for (i = 0; gfc_real_kinds[i].kind != 0; i++) | |
2443 | add_conv (BT_HOLLERITH, gfc_default_character_kind, | |
2444 | BT_COMPLEX, gfc_real_kinds[i].kind, GFC_STD_LEGACY); | |
2445 | ||
2446 | /* Hollerith-Character conversions. */ | |
2447 | add_conv (BT_HOLLERITH, gfc_default_character_kind, BT_CHARACTER, | |
2448 | gfc_default_character_kind, GFC_STD_LEGACY); | |
2449 | ||
2450 | /* Hollerith-Logical conversions. */ | |
2451 | for (i = 0; gfc_logical_kinds[i].kind != 0; i++) | |
2452 | add_conv (BT_HOLLERITH, gfc_default_character_kind, | |
2453 | BT_LOGICAL, gfc_logical_kinds[i].kind, GFC_STD_LEGACY); | |
2454 | } | |
2455 | ||
6de9cd9a DN |
2456 | /* Real/Complex - Real/Complex conversions. */ |
2457 | for (i = 0; gfc_real_kinds[i].kind != 0; i++) | |
2458 | for (j = 0; gfc_real_kinds[j].kind != 0; j++) | |
2459 | { | |
2460 | if (i != j) | |
2461 | { | |
2462 | add_conv (BT_REAL, gfc_real_kinds[i].kind, | |
c3a29423 | 2463 | BT_REAL, gfc_real_kinds[j].kind, GFC_STD_F77); |
6de9cd9a DN |
2464 | |
2465 | add_conv (BT_COMPLEX, gfc_real_kinds[i].kind, | |
c3a29423 | 2466 | BT_COMPLEX, gfc_real_kinds[j].kind, GFC_STD_F77); |
6de9cd9a DN |
2467 | } |
2468 | ||
2469 | add_conv (BT_REAL, gfc_real_kinds[i].kind, | |
c3a29423 | 2470 | BT_COMPLEX, gfc_real_kinds[j].kind, GFC_STD_F77); |
6de9cd9a DN |
2471 | |
2472 | add_conv (BT_COMPLEX, gfc_real_kinds[i].kind, | |
c3a29423 | 2473 | BT_REAL, gfc_real_kinds[j].kind, GFC_STD_F77); |
6de9cd9a DN |
2474 | } |
2475 | ||
2476 | /* Logical/Logical kind conversion. */ | |
2477 | for (i = 0; gfc_logical_kinds[i].kind; i++) | |
2478 | for (j = 0; gfc_logical_kinds[j].kind; j++) | |
2479 | { | |
2480 | if (i == j) | |
2481 | continue; | |
2482 | ||
2483 | add_conv (BT_LOGICAL, gfc_logical_kinds[i].kind, | |
c3a29423 | 2484 | BT_LOGICAL, gfc_logical_kinds[j].kind, GFC_STD_F77); |
6de9cd9a | 2485 | } |
c3a29423 RS |
2486 | |
2487 | /* Integer-Logical and Logical-Integer conversions. */ | |
2488 | if ((gfc_option.allow_std & GFC_STD_LEGACY) != 0) | |
2489 | for (i=0; gfc_integer_kinds[i].kind; i++) | |
2490 | for (j=0; gfc_logical_kinds[j].kind; j++) | |
2491 | { | |
2492 | add_conv (BT_INTEGER, gfc_integer_kinds[i].kind, | |
2493 | BT_LOGICAL, gfc_logical_kinds[j].kind, GFC_STD_LEGACY); | |
2494 | add_conv (BT_LOGICAL, gfc_logical_kinds[j].kind, | |
2495 | BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_LEGACY); | |
2496 | } | |
6de9cd9a DN |
2497 | } |
2498 | ||
2499 | ||
2500 | /* Initialize the table of intrinsics. */ | |
2501 | void | |
2502 | gfc_intrinsic_init_1 (void) | |
2503 | { | |
2504 | int i; | |
2505 | ||
2506 | nargs = nfunc = nsub = nconv = 0; | |
2507 | ||
2508 | /* Create a namespace to hold the resolved intrinsic symbols. */ | |
0366dfe9 | 2509 | gfc_intrinsic_namespace = gfc_get_namespace (NULL, 0); |
6de9cd9a DN |
2510 | |
2511 | sizing = SZ_FUNCS; | |
2512 | add_functions (); | |
2513 | sizing = SZ_SUBS; | |
2514 | add_subroutines (); | |
2515 | sizing = SZ_CONVS; | |
2516 | add_conversions (); | |
2517 | ||
2518 | functions = gfc_getmem (sizeof (gfc_intrinsic_sym) * (nfunc + nsub) | |
2519 | + sizeof (gfc_intrinsic_arg) * nargs); | |
2520 | ||
2521 | next_sym = functions; | |
2522 | subroutines = functions + nfunc; | |
2523 | ||
2524 | conversion = gfc_getmem (sizeof (gfc_intrinsic_sym) * nconv); | |
2525 | ||
2526 | next_arg = ((gfc_intrinsic_arg *) (subroutines + nsub)) - 1; | |
2527 | ||
2528 | sizing = SZ_NOTHING; | |
2529 | nconv = 0; | |
2530 | ||
2531 | add_functions (); | |
2532 | add_subroutines (); | |
2533 | add_conversions (); | |
2534 | ||
2535 | /* Set the pure flag. All intrinsic functions are pure, and | |
f7b529fa | 2536 | intrinsic subroutines are pure if they are elemental. */ |
6de9cd9a DN |
2537 | |
2538 | for (i = 0; i < nfunc; i++) | |
2539 | functions[i].pure = 1; | |
2540 | ||
2541 | for (i = 0; i < nsub; i++) | |
2542 | subroutines[i].pure = subroutines[i].elemental; | |
2543 | } | |
2544 | ||
2545 | ||
2546 | void | |
2547 | gfc_intrinsic_done_1 (void) | |
2548 | { | |
2549 | gfc_free (functions); | |
2550 | gfc_free (conversion); | |
2551 | gfc_free_namespace (gfc_intrinsic_namespace); | |
2552 | } | |
2553 | ||
2554 | ||
2555 | /******** Subroutines to check intrinsic interfaces ***********/ | |
2556 | ||
2557 | /* Given a formal argument list, remove any NULL arguments that may | |
2558 | have been left behind by a sort against some formal argument list. */ | |
2559 | ||
2560 | static void | |
2561 | remove_nullargs (gfc_actual_arglist ** ap) | |
2562 | { | |
2563 | gfc_actual_arglist *head, *tail, *next; | |
2564 | ||
2565 | tail = NULL; | |
2566 | ||
2567 | for (head = *ap; head; head = next) | |
2568 | { | |
2569 | next = head->next; | |
2570 | ||
2571 | if (head->expr == NULL) | |
2572 | { | |
2573 | head->next = NULL; | |
2574 | gfc_free_actual_arglist (head); | |
2575 | } | |
2576 | else | |
2577 | { | |
2578 | if (tail == NULL) | |
2579 | *ap = head; | |
2580 | else | |
2581 | tail->next = head; | |
2582 | ||
2583 | tail = head; | |
2584 | tail->next = NULL; | |
2585 | } | |
2586 | } | |
2587 | ||
2588 | if (tail == NULL) | |
2589 | *ap = NULL; | |
2590 | } | |
2591 | ||
2592 | ||
2593 | /* Given an actual arglist and a formal arglist, sort the actual | |
2594 | arglist so that its arguments are in a one-to-one correspondence | |
2595 | with the format arglist. Arguments that are not present are given | |
2596 | a blank gfc_actual_arglist structure. If something is obviously | |
2597 | wrong (say, a missing required argument) we abort sorting and | |
2598 | return FAILURE. */ | |
2599 | ||
2600 | static try | |
2601 | sort_actual (const char *name, gfc_actual_arglist ** ap, | |
2602 | gfc_intrinsic_arg * formal, locus * where) | |
2603 | { | |
2604 | ||
2605 | gfc_actual_arglist *actual, *a; | |
2606 | gfc_intrinsic_arg *f; | |
2607 | ||
2608 | remove_nullargs (ap); | |
2609 | actual = *ap; | |
2610 | ||
2611 | for (f = formal; f; f = f->next) | |
2612 | f->actual = NULL; | |
2613 | ||
2614 | f = formal; | |
2615 | a = actual; | |
2616 | ||
2617 | if (f == NULL && a == NULL) /* No arguments */ | |
2618 | return SUCCESS; | |
2619 | ||
2620 | for (;;) | |
2621 | { /* Put the nonkeyword arguments in a 1:1 correspondence */ | |
2622 | if (f == NULL) | |
2623 | break; | |
2624 | if (a == NULL) | |
2625 | goto optional; | |
2626 | ||
cb9e4f55 | 2627 | if (a->name != NULL) |
6de9cd9a DN |
2628 | goto keywords; |
2629 | ||
2630 | f->actual = a; | |
2631 | ||
2632 | f = f->next; | |
2633 | a = a->next; | |
2634 | } | |
2635 | ||
2636 | if (a == NULL) | |
2637 | goto do_sort; | |
2638 | ||
2639 | gfc_error ("Too many arguments in call to '%s' at %L", name, where); | |
2640 | return FAILURE; | |
2641 | ||
2642 | keywords: | |
2643 | /* Associate the remaining actual arguments, all of which have | |
2644 | to be keyword arguments. */ | |
2645 | for (; a; a = a->next) | |
2646 | { | |
2647 | for (f = formal; f; f = f->next) | |
2648 | if (strcmp (a->name, f->name) == 0) | |
2649 | break; | |
2650 | ||
2651 | if (f == NULL) | |
2652 | { | |
2653 | gfc_error ("Can't find keyword named '%s' in call to '%s' at %L", | |
2654 | a->name, name, where); | |
2655 | return FAILURE; | |
2656 | } | |
2657 | ||
2658 | if (f->actual != NULL) | |
2659 | { | |
2660 | gfc_error ("Argument '%s' is appears twice in call to '%s' at %L", | |
2661 | f->name, name, where); | |
2662 | return FAILURE; | |
2663 | } | |
2664 | ||
2665 | f->actual = a; | |
2666 | } | |
2667 | ||
2668 | optional: | |
2669 | /* At this point, all unmatched formal args must be optional. */ | |
2670 | for (f = formal; f; f = f->next) | |
2671 | { | |
2672 | if (f->actual == NULL && f->optional == 0) | |
2673 | { | |
2674 | gfc_error ("Missing actual argument '%s' in call to '%s' at %L", | |
2675 | f->name, name, where); | |
2676 | return FAILURE; | |
2677 | } | |
2678 | } | |
2679 | ||
2680 | do_sort: | |
2681 | /* Using the formal argument list, string the actual argument list | |
2682 | together in a way that corresponds with the formal list. */ | |
2683 | actual = NULL; | |
2684 | ||
2685 | for (f = formal; f; f = f->next) | |
2686 | { | |
f9fed73b TS |
2687 | if (f->actual == NULL) |
2688 | { | |
2689 | a = gfc_get_actual_arglist (); | |
2690 | a->missing_arg_type = f->ts.type; | |
2691 | } | |
2692 | else | |
2693 | a = f->actual; | |
6de9cd9a DN |
2694 | |
2695 | if (actual == NULL) | |
2696 | *ap = a; | |
2697 | else | |
2698 | actual->next = a; | |
2699 | ||
2700 | actual = a; | |
2701 | } | |
f7b529fa | 2702 | actual->next = NULL; /* End the sorted argument list. */ |
6de9cd9a DN |
2703 | |
2704 | return SUCCESS; | |
2705 | } | |
2706 | ||
2707 | ||
2708 | /* Compare an actual argument list with an intrinsic's formal argument | |
2709 | list. The lists are checked for agreement of type. We don't check | |
2710 | for arrayness here. */ | |
2711 | ||
2712 | static try | |
2713 | check_arglist (gfc_actual_arglist ** ap, gfc_intrinsic_sym * sym, | |
2714 | int error_flag) | |
2715 | { | |
2716 | gfc_actual_arglist *actual; | |
2717 | gfc_intrinsic_arg *formal; | |
2718 | int i; | |
2719 | ||
2720 | formal = sym->formal; | |
2721 | actual = *ap; | |
2722 | ||
2723 | i = 0; | |
2724 | for (; formal; formal = formal->next, actual = actual->next, i++) | |
2725 | { | |
2726 | if (actual->expr == NULL) | |
2727 | continue; | |
2728 | ||
2729 | if (!gfc_compare_types (&formal->ts, &actual->expr->ts)) | |
2730 | { | |
2731 | if (error_flag) | |
2732 | gfc_error | |
2733 | ("Type of argument '%s' in call to '%s' at %L should be " | |
2734 | "%s, not %s", gfc_current_intrinsic_arg[i], | |
2735 | gfc_current_intrinsic, &actual->expr->where, | |
2736 | gfc_typename (&formal->ts), gfc_typename (&actual->expr->ts)); | |
2737 | return FAILURE; | |
2738 | } | |
2739 | } | |
2740 | ||
2741 | return SUCCESS; | |
2742 | } | |
2743 | ||
2744 | ||
2745 | /* Given a pointer to an intrinsic symbol and an expression node that | |
2746 | represent the function call to that subroutine, figure out the type | |
2747 | of the result. This may involve calling a resolution subroutine. */ | |
2748 | ||
2749 | static void | |
2750 | resolve_intrinsic (gfc_intrinsic_sym * specific, gfc_expr * e) | |
2751 | { | |
2752 | gfc_expr *a1, *a2, *a3, *a4, *a5; | |
2753 | gfc_actual_arglist *arg; | |
2754 | ||
2755 | if (specific->resolve.f1 == NULL) | |
2756 | { | |
2757 | if (e->value.function.name == NULL) | |
2758 | e->value.function.name = specific->lib_name; | |
2759 | ||
2760 | if (e->ts.type == BT_UNKNOWN) | |
2761 | e->ts = specific->ts; | |
2762 | return; | |
2763 | } | |
2764 | ||
2765 | arg = e->value.function.actual; | |
2766 | ||
6de9cd9a DN |
2767 | /* Special case hacks for MIN and MAX. */ |
2768 | if (specific->resolve.f1m == gfc_resolve_max | |
2769 | || specific->resolve.f1m == gfc_resolve_min) | |
2770 | { | |
2771 | (*specific->resolve.f1m) (e, arg); | |
2772 | return; | |
2773 | } | |
2774 | ||
4c0c6b9f SK |
2775 | if (arg == NULL) |
2776 | { | |
2777 | (*specific->resolve.f0) (e); | |
2778 | return; | |
2779 | } | |
2780 | ||
6de9cd9a DN |
2781 | a1 = arg->expr; |
2782 | arg = arg->next; | |
2783 | ||
2784 | if (arg == NULL) | |
2785 | { | |
2786 | (*specific->resolve.f1) (e, a1); | |
2787 | return; | |
2788 | } | |
2789 | ||
2790 | a2 = arg->expr; | |
2791 | arg = arg->next; | |
2792 | ||
2793 | if (arg == NULL) | |
2794 | { | |
2795 | (*specific->resolve.f2) (e, a1, a2); | |
2796 | return; | |
2797 | } | |
2798 | ||
2799 | a3 = arg->expr; | |
2800 | arg = arg->next; | |
2801 | ||
2802 | if (arg == NULL) | |
2803 | { | |
2804 | (*specific->resolve.f3) (e, a1, a2, a3); | |
2805 | return; | |
2806 | } | |
2807 | ||
2808 | a4 = arg->expr; | |
2809 | arg = arg->next; | |
2810 | ||
2811 | if (arg == NULL) | |
2812 | { | |
2813 | (*specific->resolve.f4) (e, a1, a2, a3, a4); | |
2814 | return; | |
2815 | } | |
2816 | ||
2817 | a5 = arg->expr; | |
2818 | arg = arg->next; | |
2819 | ||
2820 | if (arg == NULL) | |
2821 | { | |
2822 | (*specific->resolve.f5) (e, a1, a2, a3, a4, a5); | |
2823 | return; | |
2824 | } | |
2825 | ||
2826 | gfc_internal_error ("resolve_intrinsic(): Too many args for intrinsic"); | |
2827 | } | |
2828 | ||
2829 | ||
2830 | /* Given an intrinsic symbol node and an expression node, call the | |
2831 | simplification function (if there is one), perhaps replacing the | |
2832 | expression with something simpler. We return FAILURE on an error | |
2833 | of the simplification, SUCCESS if the simplification worked, even | |
2834 | if nothing has changed in the expression itself. */ | |
2835 | ||
2836 | static try | |
2837 | do_simplify (gfc_intrinsic_sym * specific, gfc_expr * e) | |
2838 | { | |
2839 | gfc_expr *result, *a1, *a2, *a3, *a4, *a5; | |
2840 | gfc_actual_arglist *arg; | |
2841 | ||
d3642f89 FW |
2842 | /* Check the arguments if there are Hollerith constants. We deal with |
2843 | them at run-time. */ | |
2844 | for (arg = e->value.function.actual; arg != NULL; arg = arg->next) | |
2845 | { | |
2846 | if (arg->expr && arg->expr->from_H) | |
2847 | { | |
2848 | result = NULL; | |
2849 | goto finish; | |
2850 | } | |
2851 | } | |
6de9cd9a DN |
2852 | /* Max and min require special handling due to the variable number |
2853 | of args. */ | |
2854 | if (specific->simplify.f1 == gfc_simplify_min) | |
2855 | { | |
2856 | result = gfc_simplify_min (e); | |
2857 | goto finish; | |
2858 | } | |
2859 | ||
2860 | if (specific->simplify.f1 == gfc_simplify_max) | |
2861 | { | |
2862 | result = gfc_simplify_max (e); | |
2863 | goto finish; | |
2864 | } | |
2865 | ||
2866 | if (specific->simplify.f1 == NULL) | |
2867 | { | |
2868 | result = NULL; | |
2869 | goto finish; | |
2870 | } | |
2871 | ||
2872 | arg = e->value.function.actual; | |
2873 | ||
4c0c6b9f SK |
2874 | if (arg == NULL) |
2875 | { | |
2876 | result = (*specific->simplify.f0) (); | |
2877 | goto finish; | |
2878 | } | |
2879 | ||
6de9cd9a DN |
2880 | a1 = arg->expr; |
2881 | arg = arg->next; | |
2882 | ||
2883 | if (specific->simplify.cc == gfc_convert_constant) | |
2884 | { | |
2885 | result = gfc_convert_constant (a1, specific->ts.type, specific->ts.kind); | |
2886 | goto finish; | |
2887 | } | |
2888 | ||
2889 | /* TODO: Warn if -pedantic and initialization expression and arg | |
2890 | types not integer or character */ | |
2891 | ||
2892 | if (arg == NULL) | |
2893 | result = (*specific->simplify.f1) (a1); | |
2894 | else | |
2895 | { | |
2896 | a2 = arg->expr; | |
2897 | arg = arg->next; | |
2898 | ||
2899 | if (arg == NULL) | |
2900 | result = (*specific->simplify.f2) (a1, a2); | |
2901 | else | |
2902 | { | |
2903 | a3 = arg->expr; | |
2904 | arg = arg->next; | |
2905 | ||
2906 | if (arg == NULL) | |
2907 | result = (*specific->simplify.f3) (a1, a2, a3); | |
2908 | else | |
2909 | { | |
2910 | a4 = arg->expr; | |
2911 | arg = arg->next; | |
2912 | ||
2913 | if (arg == NULL) | |
2914 | result = (*specific->simplify.f4) (a1, a2, a3, a4); | |
2915 | else | |
2916 | { | |
2917 | a5 = arg->expr; | |
2918 | arg = arg->next; | |
2919 | ||
2920 | if (arg == NULL) | |
2921 | result = (*specific->simplify.f5) (a1, a2, a3, a4, a5); | |
2922 | else | |
2923 | gfc_internal_error | |
2924 | ("do_simplify(): Too many args for intrinsic"); | |
2925 | } | |
2926 | } | |
2927 | } | |
2928 | } | |
2929 | ||
2930 | finish: | |
2931 | if (result == &gfc_bad_expr) | |
2932 | return FAILURE; | |
2933 | ||
2934 | if (result == NULL) | |
2935 | resolve_intrinsic (specific, e); /* Must call at run-time */ | |
2936 | else | |
2937 | { | |
2938 | result->where = e->where; | |
2939 | gfc_replace_expr (e, result); | |
2940 | } | |
2941 | ||
2942 | return SUCCESS; | |
2943 | } | |
2944 | ||
2945 | ||
2946 | /* Initialize the gfc_current_intrinsic_arg[] array for the benefit of | |
2947 | error messages. This subroutine returns FAILURE if a subroutine | |
2948 | has more than MAX_INTRINSIC_ARGS, in which case the actual argument | |
2949 | list cannot match any intrinsic. */ | |
2950 | ||
2951 | static void | |
2952 | init_arglist (gfc_intrinsic_sym * isym) | |
2953 | { | |
2954 | gfc_intrinsic_arg *formal; | |
2955 | int i; | |
2956 | ||
2957 | gfc_current_intrinsic = isym->name; | |
2958 | ||
2959 | i = 0; | |
2960 | for (formal = isym->formal; formal; formal = formal->next) | |
2961 | { | |
2962 | if (i >= MAX_INTRINSIC_ARGS) | |
2963 | gfc_internal_error ("init_arglist(): too many arguments"); | |
2964 | gfc_current_intrinsic_arg[i++] = formal->name; | |
2965 | } | |
2966 | } | |
2967 | ||
2968 | ||
2969 | /* Given a pointer to an intrinsic symbol and an expression consisting | |
2970 | of a function call, see if the function call is consistent with the | |
2971 | intrinsic's formal argument list. Return SUCCESS if the expression | |
2972 | and intrinsic match, FAILURE otherwise. */ | |
2973 | ||
2974 | static try | |
2975 | check_specific (gfc_intrinsic_sym * specific, gfc_expr * expr, int error_flag) | |
2976 | { | |
2977 | gfc_actual_arglist *arg, **ap; | |
2978 | int r; | |
2979 | try t; | |
2980 | ||
2981 | ap = &expr->value.function.actual; | |
2982 | ||
2983 | init_arglist (specific); | |
2984 | ||
2985 | /* Don't attempt to sort the argument list for min or max. */ | |
2986 | if (specific->check.f1m == gfc_check_min_max | |
2987 | || specific->check.f1m == gfc_check_min_max_integer | |
2988 | || specific->check.f1m == gfc_check_min_max_real | |
2989 | || specific->check.f1m == gfc_check_min_max_double) | |
2990 | return (*specific->check.f1m) (*ap); | |
2991 | ||
2992 | if (sort_actual (specific->name, ap, specific->formal, | |
2993 | &expr->where) == FAILURE) | |
2994 | return FAILURE; | |
2995 | ||
7551270e ES |
2996 | if (specific->check.f3ml == gfc_check_minloc_maxloc) |
2997 | /* This is special because we might have to reorder the argument | |
2998 | list. */ | |
2999 | t = gfc_check_minloc_maxloc (*ap); | |
617097a3 | 3000 | else if (specific->check.f3red == gfc_check_minval_maxval) |
7551270e ES |
3001 | /* This is also special because we also might have to reorder the |
3002 | argument list. */ | |
617097a3 TS |
3003 | t = gfc_check_minval_maxval (*ap); |
3004 | else if (specific->check.f3red == gfc_check_product_sum) | |
3005 | /* Same here. The difference to the previous case is that we allow a | |
3006 | general numeric type. */ | |
3007 | t = gfc_check_product_sum (*ap); | |
7551270e | 3008 | else |
f3207b37 TS |
3009 | { |
3010 | if (specific->check.f1 == NULL) | |
3011 | { | |
3012 | t = check_arglist (ap, specific, error_flag); | |
3013 | if (t == SUCCESS) | |
3014 | expr->ts = specific->ts; | |
3015 | } | |
3016 | else | |
3017 | t = do_check (specific, *ap); | |
3018 | } | |
6de9cd9a DN |
3019 | |
3020 | /* Check ranks for elemental intrinsics. */ | |
3021 | if (t == SUCCESS && specific->elemental) | |
3022 | { | |
3023 | r = 0; | |
3024 | for (arg = expr->value.function.actual; arg; arg = arg->next) | |
3025 | { | |
3026 | if (arg->expr == NULL || arg->expr->rank == 0) | |
3027 | continue; | |
3028 | if (r == 0) | |
3029 | { | |
3030 | r = arg->expr->rank; | |
3031 | continue; | |
3032 | } | |
3033 | ||
3034 | if (arg->expr->rank != r) | |
3035 | { | |
3036 | gfc_error | |
3037 | ("Ranks of arguments to elemental intrinsic '%s' differ " | |
3038 | "at %L", specific->name, &arg->expr->where); | |
3039 | return FAILURE; | |
3040 | } | |
3041 | } | |
3042 | } | |
3043 | ||
3044 | if (t == FAILURE) | |
3045 | remove_nullargs (ap); | |
3046 | ||
3047 | return t; | |
3048 | } | |
3049 | ||
3050 | ||
3051 | /* See if an intrinsic is one of the intrinsics we evaluate | |
3052 | as an extension. */ | |
3053 | ||
3054 | static int | |
3055 | gfc_init_expr_extensions (gfc_intrinsic_sym *isym) | |
3056 | { | |
3057 | /* FIXME: This should be moved into the intrinsic definitions. */ | |
3058 | static const char * const init_expr_extensions[] = { | |
3059 | "digits", "epsilon", "huge", "kind", "maxexponent", "minexponent", | |
3060 | "precision", "present", "radix", "range", "selected_real_kind", | |
3061 | "tiny", NULL | |
3062 | }; | |
3063 | ||
3064 | int i; | |
3065 | ||
3066 | for (i = 0; init_expr_extensions[i]; i++) | |
3067 | if (strcmp (init_expr_extensions[i], isym->name) == 0) | |
3068 | return 0; | |
3069 | ||
3070 | return 1; | |
3071 | } | |
3072 | ||
3073 | ||
b7892582 JB |
3074 | /* Check whether an intrinsic belongs to whatever standard the user |
3075 | has chosen. */ | |
3076 | ||
3077 | static void | |
9e660c49 | 3078 | check_intrinsic_standard (const char *name, int standard, locus * where) |
b7892582 | 3079 | { |
b7892582 JB |
3080 | if (!gfc_option.warn_nonstd_intrinsics) |
3081 | return; | |
3082 | ||
b376133b | 3083 | gfc_notify_std (standard, "Intrinsic '%s' at %L is not included " |
9e660c49 | 3084 | "in the selected standard", name, where); |
b7892582 JB |
3085 | } |
3086 | ||
3087 | ||
6de9cd9a DN |
3088 | /* See if a function call corresponds to an intrinsic function call. |
3089 | We return: | |
3090 | ||
3091 | MATCH_YES if the call corresponds to an intrinsic, simplification | |
3092 | is done if possible. | |
3093 | ||
3094 | MATCH_NO if the call does not correspond to an intrinsic | |
3095 | ||
3096 | MATCH_ERROR if the call corresponds to an intrinsic but there was an | |
3097 | error during the simplification process. | |
3098 | ||
3099 | The error_flag parameter enables an error reporting. */ | |
3100 | ||
3101 | match | |
3102 | gfc_intrinsic_func_interface (gfc_expr * expr, int error_flag) | |
3103 | { | |
3104 | gfc_intrinsic_sym *isym, *specific; | |
3105 | gfc_actual_arglist *actual; | |
3106 | const char *name; | |
3107 | int flag; | |
3108 | ||
3109 | if (expr->value.function.isym != NULL) | |
3110 | return (do_simplify (expr->value.function.isym, expr) == FAILURE) | |
3111 | ? MATCH_ERROR : MATCH_YES; | |
3112 | ||
3113 | gfc_suppress_error = !error_flag; | |
3114 | flag = 0; | |
3115 | ||
3116 | for (actual = expr->value.function.actual; actual; actual = actual->next) | |
3117 | if (actual->expr != NULL) | |
3118 | flag |= (actual->expr->ts.type != BT_INTEGER | |
3119 | && actual->expr->ts.type != BT_CHARACTER); | |
3120 | ||
3121 | name = expr->symtree->n.sym->name; | |
3122 | ||
3123 | isym = specific = gfc_find_function (name); | |
3124 | if (isym == NULL) | |
3125 | { | |
3126 | gfc_suppress_error = 0; | |
3127 | return MATCH_NO; | |
3128 | } | |
3129 | ||
3130 | gfc_current_intrinsic_where = &expr->where; | |
3131 | ||
3132 | /* Bypass the generic list for min and max. */ | |
3133 | if (isym->check.f1m == gfc_check_min_max) | |
3134 | { | |
3135 | init_arglist (isym); | |
3136 | ||
3137 | if (gfc_check_min_max (expr->value.function.actual) == SUCCESS) | |
3138 | goto got_specific; | |
3139 | ||
3140 | gfc_suppress_error = 0; | |
3141 | return MATCH_NO; | |
3142 | } | |
3143 | ||
3144 | /* If the function is generic, check all of its specific | |
3145 | incarnations. If the generic name is also a specific, we check | |
3146 | that name last, so that any error message will correspond to the | |
3147 | specific. */ | |
3148 | gfc_suppress_error = 1; | |
3149 | ||
3150 | if (isym->generic) | |
3151 | { | |
3152 | for (specific = isym->specific_head; specific; | |
3153 | specific = specific->next) | |
3154 | { | |
3155 | if (specific == isym) | |
3156 | continue; | |
3157 | if (check_specific (specific, expr, 0) == SUCCESS) | |
3158 | goto got_specific; | |
3159 | } | |
3160 | } | |
3161 | ||
3162 | gfc_suppress_error = !error_flag; | |
3163 | ||
3164 | if (check_specific (isym, expr, error_flag) == FAILURE) | |
3165 | { | |
3166 | gfc_suppress_error = 0; | |
3167 | return MATCH_NO; | |
3168 | } | |
3169 | ||
3170 | specific = isym; | |
3171 | ||
3172 | got_specific: | |
3173 | expr->value.function.isym = specific; | |
3174 | gfc_intrinsic_symbol (expr->symtree->n.sym); | |
3175 | ||
14ceeb32 | 3176 | gfc_suppress_error = 0; |
6de9cd9a | 3177 | if (do_simplify (specific, expr) == FAILURE) |
14ceeb32 | 3178 | return MATCH_ERROR; |
6de9cd9a DN |
3179 | |
3180 | /* TODO: We should probably only allow elemental functions here. */ | |
3181 | flag |= (expr->ts.type != BT_INTEGER && expr->ts.type != BT_CHARACTER); | |
3182 | ||
6de9cd9a DN |
3183 | if (pedantic && gfc_init_expr |
3184 | && flag && gfc_init_expr_extensions (specific)) | |
3185 | { | |
3186 | if (gfc_notify_std (GFC_STD_GNU, "Extension: Evaluation of " | |
3187 | "nonstandard initialization expression at %L", &expr->where) | |
3188 | == FAILURE) | |
3189 | { | |
3190 | return MATCH_ERROR; | |
3191 | } | |
3192 | } | |
3193 | ||
9e660c49 | 3194 | check_intrinsic_standard (name, isym->standard, &expr->where); |
b7892582 | 3195 | |
6de9cd9a DN |
3196 | return MATCH_YES; |
3197 | } | |
3198 | ||
3199 | ||
3200 | /* See if a CALL statement corresponds to an intrinsic subroutine. | |
3201 | Returns MATCH_YES if the subroutine corresponds to an intrinsic, | |
3202 | MATCH_NO if not, and MATCH_ERROR if there was an error (but did | |
3203 | correspond). */ | |
3204 | ||
3205 | match | |
3206 | gfc_intrinsic_sub_interface (gfc_code * c, int error_flag) | |
3207 | { | |
3208 | gfc_intrinsic_sym *isym; | |
3209 | const char *name; | |
3210 | ||
3211 | name = c->symtree->n.sym->name; | |
3212 | ||
3213 | isym = find_subroutine (name); | |
3214 | if (isym == NULL) | |
3215 | return MATCH_NO; | |
3216 | ||
3217 | gfc_suppress_error = !error_flag; | |
3218 | ||
3219 | init_arglist (isym); | |
3220 | ||
3221 | if (sort_actual (name, &c->ext.actual, isym->formal, &c->loc) == FAILURE) | |
3222 | goto fail; | |
3223 | ||
3224 | if (isym->check.f1 != NULL) | |
3225 | { | |
3226 | if (do_check (isym, c->ext.actual) == FAILURE) | |
3227 | goto fail; | |
3228 | } | |
3229 | else | |
3230 | { | |
3231 | if (check_arglist (&c->ext.actual, isym, 1) == FAILURE) | |
3232 | goto fail; | |
3233 | } | |
3234 | ||
3235 | /* The subroutine corresponds to an intrinsic. Allow errors to be | |
f7b529fa | 3236 | seen at this point. */ |
6de9cd9a DN |
3237 | gfc_suppress_error = 0; |
3238 | ||
3239 | if (isym->resolve.s1 != NULL) | |
3240 | isym->resolve.s1 (c); | |
3241 | else | |
3242 | c->resolved_sym = gfc_get_intrinsic_sub_symbol (isym->lib_name); | |
3243 | ||
3244 | if (gfc_pure (NULL) && !isym->elemental) | |
3245 | { | |
3246 | gfc_error ("Subroutine call to intrinsic '%s' at %L is not PURE", name, | |
3247 | &c->loc); | |
3248 | return MATCH_ERROR; | |
3249 | } | |
3250 | ||
fe58e076 | 3251 | c->resolved_sym->attr.noreturn = isym->noreturn; |
9e660c49 | 3252 | check_intrinsic_standard (name, isym->standard, &c->loc); |
b7892582 | 3253 | |
6de9cd9a DN |
3254 | return MATCH_YES; |
3255 | ||
3256 | fail: | |
3257 | gfc_suppress_error = 0; | |
3258 | return MATCH_NO; | |
3259 | } | |
3260 | ||
3261 | ||
3262 | /* Call gfc_convert_type() with warning enabled. */ | |
3263 | ||
3264 | try | |
3265 | gfc_convert_type (gfc_expr * expr, gfc_typespec * ts, int eflag) | |
3266 | { | |
3267 | return gfc_convert_type_warn (expr, ts, eflag, 1); | |
3268 | } | |
3269 | ||
3270 | ||
3271 | /* Try to convert an expression (in place) from one type to another. | |
3272 | 'eflag' controls the behavior on error. | |
3273 | ||
3274 | The possible values are: | |
3275 | ||
3276 | 1 Generate a gfc_error() | |
3277 | 2 Generate a gfc_internal_error(). | |
3278 | ||
3279 | 'wflag' controls the warning related to conversion. */ | |
3280 | ||
3281 | try | |
3282 | gfc_convert_type_warn (gfc_expr * expr, gfc_typespec * ts, int eflag, | |
3283 | int wflag) | |
3284 | { | |
3285 | gfc_intrinsic_sym *sym; | |
3286 | gfc_typespec from_ts; | |
3287 | locus old_where; | |
3288 | gfc_expr *new; | |
3289 | int rank; | |
323c74da | 3290 | mpz_t *shape; |
6de9cd9a DN |
3291 | |
3292 | from_ts = expr->ts; /* expr->ts gets clobbered */ | |
3293 | ||
3294 | if (ts->type == BT_UNKNOWN) | |
3295 | goto bad; | |
3296 | ||
3297 | /* NULL and zero size arrays get their type here. */ | |
3298 | if (expr->expr_type == EXPR_NULL | |
3299 | || (expr->expr_type == EXPR_ARRAY | |
3300 | && expr->value.constructor == NULL)) | |
3301 | { | |
3302 | /* Sometimes the RHS acquire the type. */ | |
3303 | expr->ts = *ts; | |
3304 | return SUCCESS; | |
3305 | } | |
3306 | ||
3307 | if (expr->ts.type == BT_UNKNOWN) | |
3308 | goto bad; | |
3309 | ||
3310 | if (expr->ts.type == BT_DERIVED | |
3311 | && ts->type == BT_DERIVED | |
3312 | && gfc_compare_types (&expr->ts, ts)) | |
3313 | return SUCCESS; | |
3314 | ||
3315 | sym = find_conv (&expr->ts, ts); | |
3316 | if (sym == NULL) | |
3317 | goto bad; | |
3318 | ||
3319 | /* At this point, a conversion is necessary. A warning may be needed. */ | |
c3a29423 RS |
3320 | if ((gfc_option.warn_std & sym->standard) != 0) |
3321 | gfc_warning_now ("Extension: Conversion from %s to %s at %L", | |
3322 | gfc_typename (&from_ts), gfc_typename (ts), &expr->where); | |
3323 | else if (wflag && gfc_option.warn_conversion) | |
6de9cd9a DN |
3324 | gfc_warning_now ("Conversion from %s to %s at %L", |
3325 | gfc_typename (&from_ts), gfc_typename (ts), &expr->where); | |
3326 | ||
3327 | /* Insert a pre-resolved function call to the right function. */ | |
3328 | old_where = expr->where; | |
3329 | rank = expr->rank; | |
323c74da RH |
3330 | shape = expr->shape; |
3331 | ||
6de9cd9a DN |
3332 | new = gfc_get_expr (); |
3333 | *new = *expr; | |
3334 | ||
3335 | new = gfc_build_conversion (new); | |
3336 | new->value.function.name = sym->lib_name; | |
3337 | new->value.function.isym = sym; | |
3338 | new->where = old_where; | |
3339 | new->rank = rank; | |
323c74da | 3340 | new->shape = gfc_copy_shape (shape, rank); |
6de9cd9a DN |
3341 | |
3342 | *expr = *new; | |
3343 | ||
3344 | gfc_free (new); | |
3345 | expr->ts = *ts; | |
3346 | ||
3347 | if (gfc_is_constant_expr (expr->value.function.actual->expr) | |
3348 | && do_simplify (sym, expr) == FAILURE) | |
3349 | { | |
3350 | ||
3351 | if (eflag == 2) | |
3352 | goto bad; | |
3353 | return FAILURE; /* Error already generated in do_simplify() */ | |
3354 | } | |
3355 | ||
3356 | return SUCCESS; | |
3357 | ||
3358 | bad: | |
3359 | if (eflag == 1) | |
3360 | { | |
3361 | gfc_error ("Can't convert %s to %s at %L", | |
3362 | gfc_typename (&from_ts), gfc_typename (ts), &expr->where); | |
3363 | return FAILURE; | |
3364 | } | |
3365 | ||
3366 | gfc_internal_error ("Can't convert %s to %s at %L", | |
3367 | gfc_typename (&from_ts), gfc_typename (ts), | |
3368 | &expr->where); | |
3369 | /* Not reached */ | |
3370 | } |