Daily bump.
[official-gcc.git] / gcc / fortran / intrinsic.c
bloba958f8ec9d12e07a954c4b642dbf2eee0f75c58d
1 /* Build up a list of intrinsic subroutines and functions for the
2 name-resolution stage.
3 Copyright (C) 2000-2015 Free Software Foundation, Inc.
4 Contributed by Andy Vaught & Katherine Holcomb
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "flags.h"
26 #include "gfortran.h"
27 #include "intrinsic.h"
29 /* Namespace to hold the resolved symbols for intrinsic subroutines. */
30 static gfc_namespace *gfc_intrinsic_namespace;
32 bool gfc_init_expr_flag = false;
34 /* Pointers to an intrinsic function and its argument names that are being
35 checked. */
37 const char *gfc_current_intrinsic;
38 gfc_intrinsic_arg *gfc_current_intrinsic_arg[MAX_INTRINSIC_ARGS];
39 locus *gfc_current_intrinsic_where;
41 static gfc_intrinsic_sym *functions, *subroutines, *conversion, *next_sym;
42 static gfc_intrinsic_sym *char_conversions;
43 static gfc_intrinsic_arg *next_arg;
45 static int nfunc, nsub, nargs, nconv, ncharconv;
47 static enum
48 { SZ_NOTHING = 0, SZ_SUBS, SZ_FUNCS, SZ_CONVS }
49 sizing;
51 enum klass
52 { CLASS_IMPURE = 0, CLASS_PURE, CLASS_ELEMENTAL,
53 CLASS_INQUIRY, CLASS_TRANSFORMATIONAL, CLASS_ATOMIC };
55 #define ACTUAL_NO 0
56 #define ACTUAL_YES 1
58 #define REQUIRED 0
59 #define OPTIONAL 1
62 /* Return a letter based on the passed type. Used to construct the
63 name of a type-dependent subroutine. */
65 char
66 gfc_type_letter (bt type)
68 char c;
70 switch (type)
72 case BT_LOGICAL:
73 c = 'l';
74 break;
75 case BT_CHARACTER:
76 c = 's';
77 break;
78 case BT_INTEGER:
79 c = 'i';
80 break;
81 case BT_REAL:
82 c = 'r';
83 break;
84 case BT_COMPLEX:
85 c = 'c';
86 break;
88 case BT_HOLLERITH:
89 c = 'h';
90 break;
92 default:
93 c = 'u';
94 break;
97 return c;
101 /* Get a symbol for a resolved name. Note, if needed be, the elemental
102 attribute has be added afterwards. */
104 gfc_symbol *
105 gfc_get_intrinsic_sub_symbol (const char *name)
107 gfc_symbol *sym;
109 gfc_get_symbol (name, gfc_intrinsic_namespace, &sym);
110 sym->attr.always_explicit = 1;
111 sym->attr.subroutine = 1;
112 sym->attr.flavor = FL_PROCEDURE;
113 sym->attr.proc = PROC_INTRINSIC;
115 gfc_commit_symbol (sym);
117 return sym;
121 /* Return a pointer to the name of a conversion function given two
122 typespecs. */
124 static const char *
125 conv_name (gfc_typespec *from, gfc_typespec *to)
127 return gfc_get_string ("__convert_%c%d_%c%d",
128 gfc_type_letter (from->type), from->kind,
129 gfc_type_letter (to->type), to->kind);
133 /* Given a pair of typespecs, find the gfc_intrinsic_sym node that
134 corresponds to the conversion. Returns NULL if the conversion
135 isn't found. */
137 static gfc_intrinsic_sym *
138 find_conv (gfc_typespec *from, gfc_typespec *to)
140 gfc_intrinsic_sym *sym;
141 const char *target;
142 int i;
144 target = conv_name (from, to);
145 sym = conversion;
147 for (i = 0; i < nconv; i++, sym++)
148 if (target == sym->name)
149 return sym;
151 return NULL;
155 /* Given a pair of CHARACTER typespecs, find the gfc_intrinsic_sym node
156 that corresponds to the conversion. Returns NULL if the conversion
157 isn't found. */
159 static gfc_intrinsic_sym *
160 find_char_conv (gfc_typespec *from, gfc_typespec *to)
162 gfc_intrinsic_sym *sym;
163 const char *target;
164 int i;
166 target = conv_name (from, to);
167 sym = char_conversions;
169 for (i = 0; i < ncharconv; i++, sym++)
170 if (target == sym->name)
171 return sym;
173 return NULL;
177 /* Check TS29113, C407b for assumed type and C535b for assumed-rank,
178 and a likewise check for NO_ARG_CHECK. */
180 static bool
181 do_ts29113_check (gfc_intrinsic_sym *specific, gfc_actual_arglist *arg)
183 gfc_actual_arglist *a;
185 for (a = arg; a; a = a->next)
187 if (!a->expr)
188 continue;
190 if (a->expr->expr_type == EXPR_VARIABLE
191 && (a->expr->symtree->n.sym->attr.ext_attr
192 & (1 << EXT_ATTR_NO_ARG_CHECK))
193 && specific->id != GFC_ISYM_C_LOC
194 && specific->id != GFC_ISYM_PRESENT)
196 gfc_error ("Variable with NO_ARG_CHECK attribute at %L is only "
197 "permitted as argument to the intrinsic functions "
198 "C_LOC and PRESENT", &a->expr->where);
199 return false;
201 else if (a->expr->ts.type == BT_ASSUMED
202 && specific->id != GFC_ISYM_LBOUND
203 && specific->id != GFC_ISYM_PRESENT
204 && specific->id != GFC_ISYM_RANK
205 && specific->id != GFC_ISYM_SHAPE
206 && specific->id != GFC_ISYM_SIZE
207 && specific->id != GFC_ISYM_SIZEOF
208 && specific->id != GFC_ISYM_UBOUND
209 && specific->id != GFC_ISYM_C_LOC)
211 gfc_error ("Assumed-type argument at %L is not permitted as actual"
212 " argument to the intrinsic %s", &a->expr->where,
213 gfc_current_intrinsic);
214 return false;
216 else if (a->expr->ts.type == BT_ASSUMED && a != arg)
218 gfc_error ("Assumed-type argument at %L is only permitted as "
219 "first actual argument to the intrinsic %s",
220 &a->expr->where, gfc_current_intrinsic);
221 return false;
223 if (a->expr->rank == -1 && !specific->inquiry)
225 gfc_error ("Assumed-rank argument at %L is only permitted as actual "
226 "argument to intrinsic inquiry functions",
227 &a->expr->where);
228 return false;
230 if (a->expr->rank == -1 && arg != a)
232 gfc_error ("Assumed-rank argument at %L is only permitted as first "
233 "actual argument to the intrinsic inquiry function %s",
234 &a->expr->where, gfc_current_intrinsic);
235 return false;
239 return true;
243 /* Interface to the check functions. We break apart an argument list
244 and call the proper check function rather than forcing each
245 function to manipulate the argument list. */
247 static bool
248 do_check (gfc_intrinsic_sym *specific, gfc_actual_arglist *arg)
250 gfc_expr *a1, *a2, *a3, *a4, *a5;
252 if (arg == NULL)
253 return (*specific->check.f0) ();
255 a1 = arg->expr;
256 arg = arg->next;
257 if (arg == NULL)
258 return (*specific->check.f1) (a1);
260 a2 = arg->expr;
261 arg = arg->next;
262 if (arg == NULL)
263 return (*specific->check.f2) (a1, a2);
265 a3 = arg->expr;
266 arg = arg->next;
267 if (arg == NULL)
268 return (*specific->check.f3) (a1, a2, a3);
270 a4 = arg->expr;
271 arg = arg->next;
272 if (arg == NULL)
273 return (*specific->check.f4) (a1, a2, a3, a4);
275 a5 = arg->expr;
276 arg = arg->next;
277 if (arg == NULL)
278 return (*specific->check.f5) (a1, a2, a3, a4, a5);
280 gfc_internal_error ("do_check(): too many args");
284 /*********** Subroutines to build the intrinsic list ****************/
286 /* Add a single intrinsic symbol to the current list.
288 Argument list:
289 char * name of function
290 int whether function is elemental
291 int If the function can be used as an actual argument [1]
292 bt return type of function
293 int kind of return type of function
294 int Fortran standard version
295 check pointer to check function
296 simplify pointer to simplification function
297 resolve pointer to resolution function
299 Optional arguments come in multiples of five:
300 char * name of argument
301 bt type of argument
302 int kind of argument
303 int arg optional flag (1=optional, 0=required)
304 sym_intent intent of argument
306 The sequence is terminated by a NULL name.
309 [1] Whether a function can or cannot be used as an actual argument is
310 determined by its presence on the 13.6 list in Fortran 2003. The
311 following intrinsics, which are GNU extensions, are considered allowed
312 as actual arguments: ACOSH ATANH DACOSH DASINH DATANH DCONJG DIMAG
313 ZABS ZCOS ZEXP ZLOG ZSIN ZSQRT. */
315 static void
316 add_sym (const char *name, gfc_isym_id id, enum klass cl, int actual_ok, bt type, int kind,
317 int standard, gfc_check_f check, gfc_simplify_f simplify,
318 gfc_resolve_f resolve, ...)
320 char buf[GFC_MAX_SYMBOL_LEN + 11]; /* 10 for '_gfortran_', 1 for '\0' */
321 int optional, first_flag;
322 sym_intent intent;
323 va_list argp;
325 switch (sizing)
327 case SZ_SUBS:
328 nsub++;
329 break;
331 case SZ_FUNCS:
332 nfunc++;
333 break;
335 case SZ_NOTHING:
336 next_sym->name = gfc_get_string (name);
338 strcpy (buf, "_gfortran_");
339 strcat (buf, name);
340 next_sym->lib_name = gfc_get_string (buf);
342 next_sym->pure = (cl != CLASS_IMPURE);
343 next_sym->elemental = (cl == CLASS_ELEMENTAL);
344 next_sym->inquiry = (cl == CLASS_INQUIRY);
345 next_sym->transformational = (cl == CLASS_TRANSFORMATIONAL);
346 next_sym->actual_ok = actual_ok;
347 next_sym->ts.type = type;
348 next_sym->ts.kind = kind;
349 next_sym->standard = standard;
350 next_sym->simplify = simplify;
351 next_sym->check = check;
352 next_sym->resolve = resolve;
353 next_sym->specific = 0;
354 next_sym->generic = 0;
355 next_sym->conversion = 0;
356 next_sym->id = id;
357 break;
359 default:
360 gfc_internal_error ("add_sym(): Bad sizing mode");
363 va_start (argp, resolve);
365 first_flag = 1;
367 for (;;)
369 name = va_arg (argp, char *);
370 if (name == NULL)
371 break;
373 type = (bt) va_arg (argp, int);
374 kind = va_arg (argp, int);
375 optional = va_arg (argp, int);
376 intent = (sym_intent) va_arg (argp, int);
378 if (sizing != SZ_NOTHING)
379 nargs++;
380 else
382 next_arg++;
384 if (first_flag)
385 next_sym->formal = next_arg;
386 else
387 (next_arg - 1)->next = next_arg;
389 first_flag = 0;
391 strcpy (next_arg->name, name);
392 next_arg->ts.type = type;
393 next_arg->ts.kind = kind;
394 next_arg->optional = optional;
395 next_arg->value = 0;
396 next_arg->intent = intent;
400 va_end (argp);
402 next_sym++;
406 /* Add a symbol to the function list where the function takes
407 0 arguments. */
409 static void
410 add_sym_0 (const char *name, gfc_isym_id id, enum klass cl, int actual_ok, bt type,
411 int kind, int standard,
412 bool (*check) (void),
413 gfc_expr *(*simplify) (void),
414 void (*resolve) (gfc_expr *))
416 gfc_simplify_f sf;
417 gfc_check_f cf;
418 gfc_resolve_f rf;
420 cf.f0 = check;
421 sf.f0 = simplify;
422 rf.f0 = resolve;
424 add_sym (name, id, cl, actual_ok, type, kind, standard, cf, sf, rf,
425 (void *) 0);
429 /* Add a symbol to the subroutine list where the subroutine takes
430 0 arguments. */
432 static void
433 add_sym_0s (const char *name, gfc_isym_id id, int standard,
434 void (*resolve) (gfc_code *))
436 gfc_check_f cf;
437 gfc_simplify_f sf;
438 gfc_resolve_f rf;
440 cf.f1 = NULL;
441 sf.f1 = NULL;
442 rf.s1 = resolve;
444 add_sym (name, id, CLASS_IMPURE, ACTUAL_NO, BT_UNKNOWN, 0, standard, cf, sf,
445 rf, (void *) 0);
449 /* Add a symbol to the function list where the function takes
450 1 arguments. */
452 static void
453 add_sym_1 (const char *name, gfc_isym_id id, enum klass cl, int actual_ok, bt type,
454 int kind, int standard,
455 bool (*check) (gfc_expr *),
456 gfc_expr *(*simplify) (gfc_expr *),
457 void (*resolve) (gfc_expr *, gfc_expr *),
458 const char *a1, bt type1, int kind1, int optional1)
460 gfc_check_f cf;
461 gfc_simplify_f sf;
462 gfc_resolve_f rf;
464 cf.f1 = check;
465 sf.f1 = simplify;
466 rf.f1 = resolve;
468 add_sym (name, id, cl, actual_ok, type, kind, standard, cf, sf, rf,
469 a1, type1, kind1, optional1, INTENT_IN,
470 (void *) 0);
474 /* Add a symbol to the function list where the function takes
475 1 arguments, specifying the intent of the argument. */
477 static void
478 add_sym_1_intent (const char *name, gfc_isym_id id, enum klass cl,
479 int actual_ok, bt type, int kind, int standard,
480 bool (*check) (gfc_expr *),
481 gfc_expr *(*simplify) (gfc_expr *),
482 void (*resolve) (gfc_expr *, gfc_expr *),
483 const char *a1, bt type1, int kind1, int optional1,
484 sym_intent intent1)
486 gfc_check_f cf;
487 gfc_simplify_f sf;
488 gfc_resolve_f rf;
490 cf.f1 = check;
491 sf.f1 = simplify;
492 rf.f1 = resolve;
494 add_sym (name, id, cl, actual_ok, type, kind, standard, cf, sf, rf,
495 a1, type1, kind1, optional1, intent1,
496 (void *) 0);
500 /* Add a symbol to the subroutine list where the subroutine takes
501 1 arguments, specifying the intent of the argument. */
503 static void
504 add_sym_1s (const char *name, gfc_isym_id id, enum klass cl, bt type, int kind,
505 int standard, bool (*check) (gfc_expr *),
506 gfc_expr *(*simplify) (gfc_expr *), void (*resolve) (gfc_code *),
507 const char *a1, bt type1, int kind1, int optional1,
508 sym_intent intent1)
510 gfc_check_f cf;
511 gfc_simplify_f sf;
512 gfc_resolve_f rf;
514 cf.f1 = check;
515 sf.f1 = simplify;
516 rf.s1 = resolve;
518 add_sym (name, id, cl, ACTUAL_NO, type, kind, standard, cf, sf, rf,
519 a1, type1, kind1, optional1, intent1,
520 (void *) 0);
524 /* Add a symbol from the MAX/MIN family of intrinsic functions to the
525 function. MAX et al take 2 or more arguments. */
527 static void
528 add_sym_1m (const char *name, gfc_isym_id id, enum klass cl, int actual_ok, bt type,
529 int kind, int standard,
530 bool (*check) (gfc_actual_arglist *),
531 gfc_expr *(*simplify) (gfc_expr *),
532 void (*resolve) (gfc_expr *, gfc_actual_arglist *),
533 const char *a1, bt type1, int kind1, int optional1,
534 const char *a2, bt type2, int kind2, int optional2)
536 gfc_check_f cf;
537 gfc_simplify_f sf;
538 gfc_resolve_f rf;
540 cf.f1m = check;
541 sf.f1 = simplify;
542 rf.f1m = resolve;
544 add_sym (name, id, cl, actual_ok, type, kind, standard, cf, sf, rf,
545 a1, type1, kind1, optional1, INTENT_IN,
546 a2, type2, kind2, optional2, INTENT_IN,
547 (void *) 0);
551 /* Add a symbol to the function list where the function takes
552 2 arguments. */
554 static void
555 add_sym_2 (const char *name, gfc_isym_id id, enum klass cl, int actual_ok, bt type,
556 int kind, int standard,
557 bool (*check) (gfc_expr *, gfc_expr *),
558 gfc_expr *(*simplify) (gfc_expr *, gfc_expr *),
559 void (*resolve) (gfc_expr *, gfc_expr *, gfc_expr *),
560 const char *a1, bt type1, int kind1, int optional1,
561 const char *a2, bt type2, int kind2, int optional2)
563 gfc_check_f cf;
564 gfc_simplify_f sf;
565 gfc_resolve_f rf;
567 cf.f2 = check;
568 sf.f2 = simplify;
569 rf.f2 = resolve;
571 add_sym (name, id, cl, actual_ok, type, kind, standard, cf, sf, rf,
572 a1, type1, kind1, optional1, INTENT_IN,
573 a2, type2, kind2, optional2, INTENT_IN,
574 (void *) 0);
578 /* Add a symbol to the function list where the function takes
579 2 arguments; same as add_sym_2 - but allows to specify the intent. */
581 static void
582 add_sym_2_intent (const char *name, gfc_isym_id id, enum klass cl,
583 int actual_ok, bt type, int kind, int standard,
584 bool (*check) (gfc_expr *, gfc_expr *),
585 gfc_expr *(*simplify) (gfc_expr *, gfc_expr *),
586 void (*resolve) (gfc_expr *, gfc_expr *, gfc_expr *),
587 const char *a1, bt type1, int kind1, int optional1,
588 sym_intent intent1, const char *a2, bt type2, int kind2,
589 int optional2, sym_intent intent2)
591 gfc_check_f cf;
592 gfc_simplify_f sf;
593 gfc_resolve_f rf;
595 cf.f2 = check;
596 sf.f2 = simplify;
597 rf.f2 = resolve;
599 add_sym (name, id, cl, actual_ok, type, kind, standard, cf, sf, rf,
600 a1, type1, kind1, optional1, intent1,
601 a2, type2, kind2, optional2, intent2,
602 (void *) 0);
606 /* Add a symbol to the subroutine list where the subroutine takes
607 2 arguments, specifying the intent of the arguments. */
609 static void
610 add_sym_2s (const char *name, gfc_isym_id id, enum klass cl, bt type,
611 int kind, int standard,
612 bool (*check) (gfc_expr *, gfc_expr *),
613 gfc_expr *(*simplify) (gfc_expr *, gfc_expr *),
614 void (*resolve) (gfc_code *),
615 const char *a1, bt type1, int kind1, int optional1,
616 sym_intent intent1, const char *a2, bt type2, int kind2,
617 int optional2, sym_intent intent2)
619 gfc_check_f cf;
620 gfc_simplify_f sf;
621 gfc_resolve_f rf;
623 cf.f2 = check;
624 sf.f2 = simplify;
625 rf.s1 = resolve;
627 add_sym (name, id, cl, ACTUAL_NO, type, kind, standard, cf, sf, rf,
628 a1, type1, kind1, optional1, intent1,
629 a2, type2, kind2, optional2, intent2,
630 (void *) 0);
634 /* Add a symbol to the function list where the function takes
635 3 arguments. */
637 static void
638 add_sym_3 (const char *name, gfc_isym_id id, enum klass cl, int actual_ok, bt type,
639 int kind, int standard,
640 bool (*check) (gfc_expr *, gfc_expr *, gfc_expr *),
641 gfc_expr *(*simplify) (gfc_expr *, gfc_expr *, gfc_expr *),
642 void (*resolve) (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *),
643 const char *a1, bt type1, int kind1, int optional1,
644 const char *a2, bt type2, int kind2, int optional2,
645 const char *a3, bt type3, int kind3, int optional3)
647 gfc_check_f cf;
648 gfc_simplify_f sf;
649 gfc_resolve_f rf;
651 cf.f3 = check;
652 sf.f3 = simplify;
653 rf.f3 = resolve;
655 add_sym (name, id, cl, actual_ok, type, kind, standard, cf, sf, rf,
656 a1, type1, kind1, optional1, INTENT_IN,
657 a2, type2, kind2, optional2, INTENT_IN,
658 a3, type3, kind3, optional3, INTENT_IN,
659 (void *) 0);
663 /* MINLOC and MAXLOC get special treatment because their argument
664 might have to be reordered. */
666 static void
667 add_sym_3ml (const char *name, gfc_isym_id id, enum klass cl, int actual_ok, bt type,
668 int kind, int standard,
669 bool (*check) (gfc_actual_arglist *),
670 gfc_expr *(*simplify) (gfc_expr *, gfc_expr *, gfc_expr *),
671 void (*resolve) (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *),
672 const char *a1, bt type1, int kind1, int optional1,
673 const char *a2, bt type2, int kind2, int optional2,
674 const char *a3, bt type3, int kind3, int optional3)
676 gfc_check_f cf;
677 gfc_simplify_f sf;
678 gfc_resolve_f rf;
680 cf.f3ml = check;
681 sf.f3 = simplify;
682 rf.f3 = resolve;
684 add_sym (name, id, cl, actual_ok, type, kind, standard, cf, sf, rf,
685 a1, type1, kind1, optional1, INTENT_IN,
686 a2, type2, kind2, optional2, INTENT_IN,
687 a3, type3, kind3, optional3, INTENT_IN,
688 (void *) 0);
692 /* MINVAL, MAXVAL, PRODUCT, and SUM also get special treatment because
693 their argument also might have to be reordered. */
695 static void
696 add_sym_3red (const char *name, gfc_isym_id id, enum klass cl, int actual_ok, bt type,
697 int kind, int standard,
698 bool (*check) (gfc_actual_arglist *),
699 gfc_expr *(*simplify) (gfc_expr *, gfc_expr *, gfc_expr *),
700 void (*resolve) (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *),
701 const char *a1, bt type1, int kind1, int optional1,
702 const char *a2, bt type2, int kind2, int optional2,
703 const char *a3, bt type3, int kind3, int optional3)
705 gfc_check_f cf;
706 gfc_simplify_f sf;
707 gfc_resolve_f rf;
709 cf.f3red = check;
710 sf.f3 = simplify;
711 rf.f3 = resolve;
713 add_sym (name, id, cl, actual_ok, type, kind, standard, cf, sf, rf,
714 a1, type1, kind1, optional1, INTENT_IN,
715 a2, type2, kind2, optional2, INTENT_IN,
716 a3, type3, kind3, optional3, INTENT_IN,
717 (void *) 0);
721 /* Add a symbol to the subroutine list where the subroutine takes
722 3 arguments, specifying the intent of the arguments. */
724 static void
725 add_sym_3s (const char *name, gfc_isym_id id, enum klass cl, bt type,
726 int kind, int standard,
727 bool (*check) (gfc_expr *, gfc_expr *, gfc_expr *),
728 gfc_expr *(*simplify) (gfc_expr *, gfc_expr *, gfc_expr *),
729 void (*resolve) (gfc_code *),
730 const char *a1, bt type1, int kind1, int optional1,
731 sym_intent intent1, const char *a2, bt type2, int kind2,
732 int optional2, sym_intent intent2, const char *a3, bt type3,
733 int kind3, int optional3, sym_intent intent3)
735 gfc_check_f cf;
736 gfc_simplify_f sf;
737 gfc_resolve_f rf;
739 cf.f3 = check;
740 sf.f3 = simplify;
741 rf.s1 = resolve;
743 add_sym (name, id, cl, ACTUAL_NO, type, kind, standard, cf, sf, rf,
744 a1, type1, kind1, optional1, intent1,
745 a2, type2, kind2, optional2, intent2,
746 a3, type3, kind3, optional3, intent3,
747 (void *) 0);
751 /* Add a symbol to the function list where the function takes
752 4 arguments. */
754 static void
755 add_sym_4 (const char *name, gfc_isym_id id, enum klass cl, int actual_ok, bt type,
756 int kind, int standard,
757 bool (*check) (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *),
758 gfc_expr *(*simplify) (gfc_expr *, gfc_expr *, gfc_expr *,
759 gfc_expr *),
760 void (*resolve) (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *,
761 gfc_expr *),
762 const char *a1, bt type1, int kind1, int optional1,
763 const char *a2, bt type2, int kind2, int optional2,
764 const char *a3, bt type3, int kind3, int optional3,
765 const char *a4, bt type4, int kind4, int optional4 )
767 gfc_check_f cf;
768 gfc_simplify_f sf;
769 gfc_resolve_f rf;
771 cf.f4 = check;
772 sf.f4 = simplify;
773 rf.f4 = resolve;
775 add_sym (name, id, cl, actual_ok, type, kind, standard, cf, sf, rf,
776 a1, type1, kind1, optional1, INTENT_IN,
777 a2, type2, kind2, optional2, INTENT_IN,
778 a3, type3, kind3, optional3, INTENT_IN,
779 a4, type4, kind4, optional4, INTENT_IN,
780 (void *) 0);
784 /* Add a symbol to the subroutine list where the subroutine takes
785 4 arguments. */
787 static void
788 add_sym_4s (const char *name, gfc_isym_id id, enum klass cl, bt type, int kind,
789 int standard,
790 bool (*check) (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *),
791 gfc_expr *(*simplify) (gfc_expr *, gfc_expr *, gfc_expr *,
792 gfc_expr *),
793 void (*resolve) (gfc_code *),
794 const char *a1, bt type1, int kind1, int optional1,
795 sym_intent intent1, const char *a2, bt type2, int kind2,
796 int optional2, sym_intent intent2, const char *a3, bt type3,
797 int kind3, int optional3, sym_intent intent3, const char *a4,
798 bt type4, int kind4, int optional4, sym_intent intent4)
800 gfc_check_f cf;
801 gfc_simplify_f sf;
802 gfc_resolve_f rf;
804 cf.f4 = check;
805 sf.f4 = simplify;
806 rf.s1 = resolve;
808 add_sym (name, id, cl, ACTUAL_NO, type, kind, standard, cf, sf, rf,
809 a1, type1, kind1, optional1, intent1,
810 a2, type2, kind2, optional2, intent2,
811 a3, type3, kind3, optional3, intent3,
812 a4, type4, kind4, optional4, intent4,
813 (void *) 0);
817 /* Add a symbol to the subroutine list where the subroutine takes
818 5 arguments. */
820 static void
821 add_sym_5s (const char *name, gfc_isym_id id, enum klass cl, bt type, int kind,
822 int standard,
823 bool (*check) (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *,
824 gfc_expr *),
825 gfc_expr *(*simplify) (gfc_expr *, gfc_expr *, gfc_expr *,
826 gfc_expr *, gfc_expr *),
827 void (*resolve) (gfc_code *),
828 const char *a1, bt type1, int kind1, int optional1,
829 sym_intent intent1, const char *a2, bt type2, int kind2,
830 int optional2, sym_intent intent2, const char *a3, bt type3,
831 int kind3, int optional3, sym_intent intent3, const char *a4,
832 bt type4, int kind4, int optional4, sym_intent intent4,
833 const char *a5, bt type5, int kind5, int optional5,
834 sym_intent intent5)
836 gfc_check_f cf;
837 gfc_simplify_f sf;
838 gfc_resolve_f rf;
840 cf.f5 = check;
841 sf.f5 = simplify;
842 rf.s1 = resolve;
844 add_sym (name, id, cl, ACTUAL_NO, type, kind, standard, cf, sf, rf,
845 a1, type1, kind1, optional1, intent1,
846 a2, type2, kind2, optional2, intent2,
847 a3, type3, kind3, optional3, intent3,
848 a4, type4, kind4, optional4, intent4,
849 a5, type5, kind5, optional5, intent5,
850 (void *) 0);
854 /* Locate an intrinsic symbol given a base pointer, number of elements
855 in the table and a pointer to a name. Returns the NULL pointer if
856 a name is not found. */
858 static gfc_intrinsic_sym *
859 find_sym (gfc_intrinsic_sym *start, int n, const char *name)
861 /* name may be a user-supplied string, so we must first make sure
862 that we're comparing against a pointer into the global string
863 table. */
864 const char *p = gfc_get_string (name);
866 while (n > 0)
868 if (p == start->name)
869 return start;
871 start++;
872 n--;
875 return NULL;
879 gfc_isym_id
880 gfc_isym_id_by_intmod (intmod_id from_intmod, int intmod_sym_id)
882 if (from_intmod == INTMOD_NONE)
883 return (gfc_isym_id) intmod_sym_id;
884 else if (from_intmod == INTMOD_ISO_C_BINDING)
885 return (gfc_isym_id) c_interop_kinds_table[intmod_sym_id].value;
886 else if (from_intmod == INTMOD_ISO_FORTRAN_ENV)
887 switch (intmod_sym_id)
889 #define NAMED_SUBROUTINE(a,b,c,d) \
890 case a: \
891 return (gfc_isym_id) c;
892 #define NAMED_FUNCTION(a,b,c,d) \
893 case a: \
894 return (gfc_isym_id) c;
895 #include "iso-fortran-env.def"
896 default:
897 gcc_unreachable ();
899 else
900 gcc_unreachable ();
901 return (gfc_isym_id) 0;
905 gfc_isym_id
906 gfc_isym_id_by_intmod_sym (gfc_symbol *sym)
908 return gfc_isym_id_by_intmod (sym->from_intmod, sym->intmod_sym_id);
912 gfc_intrinsic_sym *
913 gfc_intrinsic_subroutine_by_id (gfc_isym_id id)
915 gfc_intrinsic_sym *start = subroutines;
916 int n = nsub;
918 while (true)
920 gcc_assert (n > 0);
921 if (id == start->id)
922 return start;
924 start++;
925 n--;
930 gfc_intrinsic_sym *
931 gfc_intrinsic_function_by_id (gfc_isym_id id)
933 gfc_intrinsic_sym *start = functions;
934 int n = nfunc;
936 while (true)
938 gcc_assert (n > 0);
939 if (id == start->id)
940 return start;
942 start++;
943 n--;
948 /* Given a name, find a function in the intrinsic function table.
949 Returns NULL if not found. */
951 gfc_intrinsic_sym *
952 gfc_find_function (const char *name)
954 gfc_intrinsic_sym *sym;
956 sym = find_sym (functions, nfunc, name);
957 if (!sym || sym->from_module)
958 sym = find_sym (conversion, nconv, name);
960 return (!sym || sym->from_module) ? NULL : sym;
964 /* Given a name, find a function in the intrinsic subroutine table.
965 Returns NULL if not found. */
967 gfc_intrinsic_sym *
968 gfc_find_subroutine (const char *name)
970 gfc_intrinsic_sym *sym;
971 sym = find_sym (subroutines, nsub, name);
972 return (!sym || sym->from_module) ? NULL : sym;
976 /* Given a string, figure out if it is the name of a generic intrinsic
977 function or not. */
980 gfc_generic_intrinsic (const char *name)
982 gfc_intrinsic_sym *sym;
984 sym = gfc_find_function (name);
985 return (!sym || sym->from_module) ? 0 : sym->generic;
989 /* Given a string, figure out if it is the name of a specific
990 intrinsic function or not. */
993 gfc_specific_intrinsic (const char *name)
995 gfc_intrinsic_sym *sym;
997 sym = gfc_find_function (name);
998 return (!sym || sym->from_module) ? 0 : sym->specific;
1002 /* Given a string, figure out if it is the name of an intrinsic function
1003 or subroutine allowed as an actual argument or not. */
1005 gfc_intrinsic_actual_ok (const char *name, const bool subroutine_flag)
1007 gfc_intrinsic_sym *sym;
1009 /* Intrinsic subroutines are not allowed as actual arguments. */
1010 if (subroutine_flag)
1011 return 0;
1012 else
1014 sym = gfc_find_function (name);
1015 return (sym == NULL) ? 0 : sym->actual_ok;
1020 /* Given a symbol, find out if it is (and is to be treated as) an intrinsic.
1021 If its name refers to an intrinsic, but this intrinsic is not included in
1022 the selected standard, this returns FALSE and sets the symbol's external
1023 attribute. */
1025 bool
1026 gfc_is_intrinsic (gfc_symbol* sym, int subroutine_flag, locus loc)
1028 gfc_intrinsic_sym* isym;
1029 const char* symstd;
1031 /* If INTRINSIC attribute is already known, return. */
1032 if (sym->attr.intrinsic)
1033 return true;
1035 /* Check for attributes which prevent the symbol from being INTRINSIC. */
1036 if (sym->attr.external || sym->attr.contained
1037 || sym->attr.if_source == IFSRC_IFBODY)
1038 return false;
1040 if (subroutine_flag)
1041 isym = gfc_find_subroutine (sym->name);
1042 else
1043 isym = gfc_find_function (sym->name);
1045 /* No such intrinsic available at all? */
1046 if (!isym)
1047 return false;
1049 /* See if this intrinsic is allowed in the current standard. */
1050 if (!gfc_check_intrinsic_standard (isym, &symstd, false, loc)
1051 && !sym->attr.artificial)
1053 if (sym->attr.proc == PROC_UNKNOWN && warn_intrinsics_std)
1054 gfc_warning_now (OPT_Wintrinsics_std, "The intrinsic %qs at %L is not "
1055 "included in the selected standard but %s and %qs will"
1056 " be treated as if declared EXTERNAL. Use an"
1057 " appropriate -std=* option or define"
1058 " -fall-intrinsics to allow this intrinsic.",
1059 sym->name, &loc, symstd, sym->name);
1061 return false;
1064 return true;
1068 /* Collect a set of intrinsic functions into a generic collection.
1069 The first argument is the name of the generic function, which is
1070 also the name of a specific function. The rest of the specifics
1071 currently in the table are placed into the list of specific
1072 functions associated with that generic.
1074 PR fortran/32778
1075 FIXME: Remove the argument STANDARD if no regressions are
1076 encountered. Change all callers (approx. 360).
1079 static void
1080 make_generic (const char *name, gfc_isym_id id, int standard ATTRIBUTE_UNUSED)
1082 gfc_intrinsic_sym *g;
1084 if (sizing != SZ_NOTHING)
1085 return;
1087 g = gfc_find_function (name);
1088 if (g == NULL)
1089 gfc_internal_error ("make_generic(): Can't find generic symbol %qs",
1090 name);
1092 gcc_assert (g->id == id);
1094 g->generic = 1;
1095 g->specific = 1;
1096 if ((g + 1)->name != NULL)
1097 g->specific_head = g + 1;
1098 g++;
1100 while (g->name != NULL)
1102 g->next = g + 1;
1103 g->specific = 1;
1104 g++;
1107 g--;
1108 g->next = NULL;
1112 /* Create a duplicate intrinsic function entry for the current
1113 function, the only differences being the alternate name and
1114 a different standard if necessary. Note that we use argument
1115 lists more than once, but all argument lists are freed as a
1116 single block. */
1118 static void
1119 make_alias (const char *name, int standard)
1121 switch (sizing)
1123 case SZ_FUNCS:
1124 nfunc++;
1125 break;
1127 case SZ_SUBS:
1128 nsub++;
1129 break;
1131 case SZ_NOTHING:
1132 next_sym[0] = next_sym[-1];
1133 next_sym->name = gfc_get_string (name);
1134 next_sym->standard = standard;
1135 next_sym++;
1136 break;
1138 default:
1139 break;
1144 /* Make the current subroutine noreturn. */
1146 static void
1147 make_noreturn (void)
1149 if (sizing == SZ_NOTHING)
1150 next_sym[-1].noreturn = 1;
1154 /* Mark current intrinsic as module intrinsic. */
1155 static void
1156 make_from_module (void)
1158 if (sizing == SZ_NOTHING)
1159 next_sym[-1].from_module = 1;
1162 /* Set the attr.value of the current procedure. */
1164 static void
1165 set_attr_value (int n, ...)
1167 gfc_intrinsic_arg *arg;
1168 va_list argp;
1169 int i;
1171 if (sizing != SZ_NOTHING)
1172 return;
1174 va_start (argp, n);
1175 arg = next_sym[-1].formal;
1177 for (i = 0; i < n; i++)
1179 gcc_assert (arg != NULL);
1180 arg->value = va_arg (argp, int);
1181 arg = arg->next;
1183 va_end (argp);
1187 /* Add intrinsic functions. */
1189 static void
1190 add_functions (void)
1192 /* Argument names as in the standard (to be used as argument keywords). */
1193 const char
1194 *a = "a", *f = "field", *pt = "pointer", *tg = "target",
1195 *b = "b", *m = "matrix", *ma = "matrix_a", *mb = "matrix_b",
1196 *c = "c", *n = "n", *ncopies= "ncopies", *pos = "pos", *bck = "back",
1197 *i = "i", *v = "vector", *va = "vector_a", *vb = "vector_b",
1198 *j = "j", *a1 = "a1", *fs = "fsource", *ts = "tsource",
1199 *l = "l", *a2 = "a2", *mo = "mold", *ord = "order",
1200 *p = "p", *ar = "array", *shp = "shape", *src = "source",
1201 *r = "r", *bd = "boundary", *pad = "pad", *set = "set",
1202 *s = "s", *dm = "dim", *kind = "kind", *msk = "mask",
1203 *x = "x", *sh = "shift", *stg = "string", *ssg = "substring",
1204 *y = "y", *sz = "size", *sta = "string_a", *stb = "string_b",
1205 *z = "z", *ln = "len", *ut = "unit", *han = "handler",
1206 *num = "number", *tm = "time", *nm = "name", *md = "mode",
1207 *vl = "values", *p1 = "path1", *p2 = "path2", *com = "command",
1208 *ca = "coarray", *sub = "sub", *dist = "distance", *failed="failed";
1210 int di, dr, dd, dl, dc, dz, ii;
1212 di = gfc_default_integer_kind;
1213 dr = gfc_default_real_kind;
1214 dd = gfc_default_double_kind;
1215 dl = gfc_default_logical_kind;
1216 dc = gfc_default_character_kind;
1217 dz = gfc_default_complex_kind;
1218 ii = gfc_index_integer_kind;
1220 add_sym_1 ("abs", GFC_ISYM_ABS, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1221 gfc_check_abs, gfc_simplify_abs, gfc_resolve_abs,
1222 a, BT_REAL, dr, REQUIRED);
1224 add_sym_1 ("iabs", GFC_ISYM_ABS, CLASS_ELEMENTAL, ACTUAL_YES, BT_INTEGER, di, GFC_STD_F77,
1225 NULL, gfc_simplify_abs, gfc_resolve_abs,
1226 a, BT_INTEGER, di, REQUIRED);
1228 add_sym_1 ("dabs", GFC_ISYM_ABS, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1229 gfc_check_fn_d, gfc_simplify_abs, gfc_resolve_abs,
1230 a, BT_REAL, dd, REQUIRED);
1232 add_sym_1 ("cabs", GFC_ISYM_ABS, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1233 NULL, gfc_simplify_abs, gfc_resolve_abs,
1234 a, BT_COMPLEX, dz, REQUIRED);
1236 add_sym_1 ("zabs", GFC_ISYM_ABS, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_GNU,
1237 NULL, gfc_simplify_abs, gfc_resolve_abs,
1238 a, BT_COMPLEX, dd, REQUIRED);
1240 make_alias ("cdabs", GFC_STD_GNU);
1242 make_generic ("abs", GFC_ISYM_ABS, GFC_STD_F77);
1244 /* The checking function for ACCESS is called gfc_check_access_func
1245 because the name gfc_check_access is already used in module.c. */
1246 add_sym_2 ("access", GFC_ISYM_ACCESS, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
1247 di, GFC_STD_GNU, gfc_check_access_func, NULL, gfc_resolve_access,
1248 nm, BT_CHARACTER, dc, REQUIRED, md, BT_CHARACTER, dc, REQUIRED);
1250 make_generic ("access", GFC_ISYM_ACCESS, GFC_STD_GNU);
1252 add_sym_2 ("achar", GFC_ISYM_ACHAR, CLASS_ELEMENTAL, ACTUAL_NO,
1253 BT_CHARACTER, dc, GFC_STD_F95,
1254 gfc_check_achar, gfc_simplify_achar, gfc_resolve_achar,
1255 i, BT_INTEGER, di, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1257 make_generic ("achar", GFC_ISYM_ACHAR, GFC_STD_F95);
1259 add_sym_1 ("acos", GFC_ISYM_ACOS, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1260 gfc_check_fn_rc2008, gfc_simplify_acos, gfc_resolve_acos,
1261 x, BT_REAL, dr, REQUIRED);
1263 add_sym_1 ("dacos", GFC_ISYM_ACOS, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1264 gfc_check_fn_d, gfc_simplify_acos, gfc_resolve_acos,
1265 x, BT_REAL, dd, REQUIRED);
1267 make_generic ("acos", GFC_ISYM_ACOS, GFC_STD_F77);
1269 add_sym_1 ("acosh", GFC_ISYM_ACOSH, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr,
1270 GFC_STD_F2008, gfc_check_fn_rc2008, gfc_simplify_acosh,
1271 gfc_resolve_acosh, x, BT_REAL, dr, REQUIRED);
1273 add_sym_1 ("dacosh", GFC_ISYM_ACOSH, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_GNU,
1274 gfc_check_fn_d, gfc_simplify_acosh, gfc_resolve_acosh,
1275 x, BT_REAL, dd, REQUIRED);
1277 make_generic ("acosh", GFC_ISYM_ACOSH, GFC_STD_F2008);
1279 add_sym_1 ("adjustl", GFC_ISYM_ADJUSTL, CLASS_ELEMENTAL, ACTUAL_NO,
1280 BT_CHARACTER, dc, GFC_STD_F95, NULL, gfc_simplify_adjustl,
1281 gfc_resolve_adjustl, stg, BT_CHARACTER, 0, REQUIRED);
1283 make_generic ("adjustl", GFC_ISYM_ADJUSTL, GFC_STD_F95);
1285 add_sym_1 ("adjustr", GFC_ISYM_ADJUSTR, CLASS_ELEMENTAL, ACTUAL_NO,
1286 BT_CHARACTER, dc, GFC_STD_F95, NULL, gfc_simplify_adjustr,
1287 gfc_resolve_adjustr, stg, BT_CHARACTER, 0, REQUIRED);
1289 make_generic ("adjustr", GFC_ISYM_ADJUSTR, GFC_STD_F95);
1291 add_sym_1 ("aimag", GFC_ISYM_AIMAG, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1292 gfc_check_fn_c, gfc_simplify_aimag, gfc_resolve_aimag,
1293 z, BT_COMPLEX, dz, REQUIRED);
1295 make_alias ("imag", GFC_STD_GNU);
1296 make_alias ("imagpart", GFC_STD_GNU);
1298 add_sym_1 ("dimag", GFC_ISYM_AIMAG, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_GNU,
1299 NULL, gfc_simplify_aimag, gfc_resolve_aimag,
1300 z, BT_COMPLEX, dd, REQUIRED);
1302 make_generic ("aimag", GFC_ISYM_AIMAG, GFC_STD_F77);
1304 add_sym_2 ("aint", GFC_ISYM_AINT, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1305 gfc_check_a_xkind, gfc_simplify_aint, gfc_resolve_aint,
1306 a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1308 add_sym_1 ("dint", GFC_ISYM_AINT, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1309 NULL, gfc_simplify_dint, gfc_resolve_dint,
1310 a, BT_REAL, dd, REQUIRED);
1312 make_generic ("aint", GFC_ISYM_AINT, GFC_STD_F77);
1314 add_sym_2 ("all", GFC_ISYM_ALL, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_F95,
1315 gfc_check_all_any, gfc_simplify_all, gfc_resolve_all,
1316 msk, BT_LOGICAL, dl, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL);
1318 make_generic ("all", GFC_ISYM_ALL, GFC_STD_F95);
1320 add_sym_1 ("allocated", GFC_ISYM_ALLOCATED, CLASS_INQUIRY, ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_F95,
1321 gfc_check_allocated, NULL, NULL,
1322 ar, BT_UNKNOWN, 0, REQUIRED);
1324 make_generic ("allocated", GFC_ISYM_ALLOCATED, GFC_STD_F95);
1326 add_sym_2 ("anint", GFC_ISYM_ANINT, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1327 gfc_check_a_xkind, gfc_simplify_anint, gfc_resolve_anint,
1328 a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1330 add_sym_1 ("dnint", GFC_ISYM_ANINT, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1331 NULL, gfc_simplify_dnint, gfc_resolve_dnint,
1332 a, BT_REAL, dd, REQUIRED);
1334 make_generic ("anint", GFC_ISYM_ANINT, GFC_STD_F77);
1336 add_sym_2 ("any", GFC_ISYM_ANY, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_F95,
1337 gfc_check_all_any, gfc_simplify_any, gfc_resolve_any,
1338 msk, BT_LOGICAL, dl, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL);
1340 make_generic ("any", GFC_ISYM_ANY, GFC_STD_F95);
1342 add_sym_1 ("asin", GFC_ISYM_ASIN, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1343 gfc_check_fn_rc2008, gfc_simplify_asin, gfc_resolve_asin,
1344 x, BT_REAL, dr, REQUIRED);
1346 add_sym_1 ("dasin", GFC_ISYM_ASIN, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1347 gfc_check_fn_d, gfc_simplify_asin, gfc_resolve_asin,
1348 x, BT_REAL, dd, REQUIRED);
1350 make_generic ("asin", GFC_ISYM_ASIN, GFC_STD_F77);
1352 add_sym_1 ("asinh", GFC_ISYM_ASINH, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr,
1353 GFC_STD_F2008, gfc_check_fn_rc2008, gfc_simplify_asinh,
1354 gfc_resolve_asinh, x, BT_REAL, dr, REQUIRED);
1356 add_sym_1 ("dasinh", GFC_ISYM_ASINH, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_GNU,
1357 gfc_check_fn_d, gfc_simplify_asinh, gfc_resolve_asinh,
1358 x, BT_REAL, dd, REQUIRED);
1360 make_generic ("asinh", GFC_ISYM_ASINH, GFC_STD_F2008);
1362 add_sym_2 ("associated", GFC_ISYM_ASSOCIATED, CLASS_INQUIRY, ACTUAL_NO, BT_LOGICAL, dl,
1363 GFC_STD_F95, gfc_check_associated, NULL, NULL,
1364 pt, BT_UNKNOWN, 0, REQUIRED, tg, BT_UNKNOWN, 0, OPTIONAL);
1366 make_generic ("associated", GFC_ISYM_ASSOCIATED, GFC_STD_F95);
1368 add_sym_1 ("atan", GFC_ISYM_ATAN, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1369 gfc_check_fn_rc2008, gfc_simplify_atan, gfc_resolve_atan,
1370 x, BT_REAL, dr, REQUIRED);
1372 add_sym_1 ("datan", GFC_ISYM_ATAN, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1373 gfc_check_fn_d, gfc_simplify_atan, gfc_resolve_atan,
1374 x, BT_REAL, dd, REQUIRED);
1376 /* Two-argument version of atan, equivalent to atan2. */
1377 add_sym_2 ("atan", GFC_ISYM_ATAN2, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F2008,
1378 gfc_check_atan_2, gfc_simplify_atan2, gfc_resolve_atan2,
1379 y, BT_REAL, dr, REQUIRED, x, BT_REAL, dr, REQUIRED);
1381 make_generic ("atan", GFC_ISYM_ATAN, GFC_STD_F77);
1383 add_sym_1 ("atanh", GFC_ISYM_ATANH, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr,
1384 GFC_STD_F2008, gfc_check_fn_rc2008, gfc_simplify_atanh,
1385 gfc_resolve_atanh, x, BT_REAL, dr, REQUIRED);
1387 add_sym_1 ("datanh", GFC_ISYM_ATANH, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_GNU,
1388 gfc_check_fn_d, gfc_simplify_atanh, gfc_resolve_atanh,
1389 x, BT_REAL, dd, REQUIRED);
1391 make_generic ("atanh", GFC_ISYM_ATANH, GFC_STD_F2008);
1393 add_sym_2 ("atan2", GFC_ISYM_ATAN2, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1394 gfc_check_atan2, gfc_simplify_atan2, gfc_resolve_atan2,
1395 y, BT_REAL, dr, REQUIRED, x, BT_REAL, dr, REQUIRED);
1397 add_sym_2 ("datan2", GFC_ISYM_ATAN2, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1398 gfc_check_datan2, gfc_simplify_atan2, gfc_resolve_atan2,
1399 y, BT_REAL, dd, REQUIRED, x, BT_REAL, dd, REQUIRED);
1401 make_generic ("atan2", GFC_ISYM_ATAN2, GFC_STD_F77);
1403 /* Bessel and Neumann functions for G77 compatibility. */
1404 add_sym_1 ("besj0", GFC_ISYM_J0, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
1405 gfc_check_fn_r, gfc_simplify_bessel_j0, gfc_resolve_g77_math1,
1406 x, BT_REAL, dr, REQUIRED);
1408 make_alias ("bessel_j0", GFC_STD_F2008);
1410 add_sym_1 ("dbesj0", GFC_ISYM_J0, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
1411 gfc_check_fn_d, gfc_simplify_bessel_j0, gfc_resolve_g77_math1,
1412 x, BT_REAL, dd, REQUIRED);
1414 make_generic ("bessel_j0", GFC_ISYM_J0, GFC_STD_F2008);
1416 add_sym_1 ("besj1", GFC_ISYM_J1, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
1417 gfc_check_fn_r, gfc_simplify_bessel_j1, gfc_resolve_g77_math1,
1418 x, BT_REAL, dr, REQUIRED);
1420 make_alias ("bessel_j1", GFC_STD_F2008);
1422 add_sym_1 ("dbesj1", GFC_ISYM_J1, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
1423 gfc_check_fn_d, gfc_simplify_bessel_j1, gfc_resolve_g77_math1,
1424 x, BT_REAL, dd, REQUIRED);
1426 make_generic ("bessel_j1", GFC_ISYM_J1, GFC_STD_F2008);
1428 add_sym_2 ("besjn", GFC_ISYM_JN, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
1429 gfc_check_besn, gfc_simplify_bessel_jn, gfc_resolve_besn,
1430 n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dr, REQUIRED);
1432 make_alias ("bessel_jn", GFC_STD_F2008);
1434 add_sym_2 ("dbesjn", GFC_ISYM_JN, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
1435 gfc_check_besn, gfc_simplify_bessel_jn, gfc_resolve_besn,
1436 n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dd, REQUIRED);
1438 add_sym_3 ("bessel_jn", GFC_ISYM_JN2, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F2008,
1439 gfc_check_bessel_n2, gfc_simplify_bessel_jn2, gfc_resolve_bessel_n2,
1440 "n1", BT_INTEGER, di, REQUIRED,"n2", BT_INTEGER, di, REQUIRED,
1441 x, BT_REAL, dr, REQUIRED);
1442 set_attr_value (3, true, true, true);
1444 make_generic ("bessel_jn", GFC_ISYM_JN, GFC_STD_F2008);
1446 add_sym_1 ("besy0", GFC_ISYM_Y0, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
1447 gfc_check_fn_r, gfc_simplify_bessel_y0, gfc_resolve_g77_math1,
1448 x, BT_REAL, dr, REQUIRED);
1450 make_alias ("bessel_y0", GFC_STD_F2008);
1452 add_sym_1 ("dbesy0", GFC_ISYM_Y0, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
1453 gfc_check_fn_d, gfc_simplify_bessel_y0, gfc_resolve_g77_math1,
1454 x, BT_REAL, dd, REQUIRED);
1456 make_generic ("bessel_y0", GFC_ISYM_Y0, GFC_STD_F2008);
1458 add_sym_1 ("besy1", GFC_ISYM_Y1, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
1459 gfc_check_fn_r, gfc_simplify_bessel_y1, gfc_resolve_g77_math1,
1460 x, BT_REAL, dr, REQUIRED);
1462 make_alias ("bessel_y1", GFC_STD_F2008);
1464 add_sym_1 ("dbesy1", GFC_ISYM_Y1, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
1465 gfc_check_fn_d, gfc_simplify_bessel_y1, gfc_resolve_g77_math1,
1466 x, BT_REAL, dd, REQUIRED);
1468 make_generic ("bessel_y1", GFC_ISYM_Y1, GFC_STD_F2008);
1470 add_sym_2 ("besyn", GFC_ISYM_YN, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
1471 gfc_check_besn, gfc_simplify_bessel_yn, gfc_resolve_besn,
1472 n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dr, REQUIRED);
1474 make_alias ("bessel_yn", GFC_STD_F2008);
1476 add_sym_2 ("dbesyn", GFC_ISYM_YN, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
1477 gfc_check_besn, gfc_simplify_bessel_yn, gfc_resolve_besn,
1478 n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dd, REQUIRED);
1480 add_sym_3 ("bessel_yn", GFC_ISYM_YN2, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F2008,
1481 gfc_check_bessel_n2, gfc_simplify_bessel_yn2, gfc_resolve_bessel_n2,
1482 "n1", BT_INTEGER, di, REQUIRED,"n2", BT_INTEGER, di, REQUIRED,
1483 x, BT_REAL, dr, REQUIRED);
1484 set_attr_value (3, true, true, true);
1486 make_generic ("bessel_yn", GFC_ISYM_YN, GFC_STD_F2008);
1488 add_sym_2 ("bge", GFC_ISYM_BGE, CLASS_ELEMENTAL, ACTUAL_NO,
1489 BT_LOGICAL, dl, GFC_STD_F2008,
1490 gfc_check_bge_bgt_ble_blt, gfc_simplify_bge, NULL,
1491 i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED);
1493 make_generic ("bge", GFC_ISYM_BGE, GFC_STD_F2008);
1495 add_sym_2 ("bgt", GFC_ISYM_BGT, CLASS_ELEMENTAL, ACTUAL_NO,
1496 BT_LOGICAL, dl, GFC_STD_F2008,
1497 gfc_check_bge_bgt_ble_blt, gfc_simplify_bgt, NULL,
1498 i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED);
1500 make_generic ("bgt", GFC_ISYM_BGT, GFC_STD_F2008);
1502 add_sym_1 ("bit_size", GFC_ISYM_BIT_SIZE, CLASS_INQUIRY, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1503 gfc_check_i, gfc_simplify_bit_size, NULL,
1504 i, BT_INTEGER, di, REQUIRED);
1506 make_generic ("bit_size", GFC_ISYM_BIT_SIZE, GFC_STD_F95);
1508 add_sym_2 ("ble", GFC_ISYM_BLE, CLASS_ELEMENTAL, ACTUAL_NO,
1509 BT_LOGICAL, dl, GFC_STD_F2008,
1510 gfc_check_bge_bgt_ble_blt, gfc_simplify_ble, NULL,
1511 i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED);
1513 make_generic ("ble", GFC_ISYM_BLE, GFC_STD_F2008);
1515 add_sym_2 ("blt", GFC_ISYM_BLT, CLASS_ELEMENTAL, ACTUAL_NO,
1516 BT_LOGICAL, dl, GFC_STD_F2008,
1517 gfc_check_bge_bgt_ble_blt, gfc_simplify_blt, NULL,
1518 i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED);
1520 make_generic ("blt", GFC_ISYM_BLT, GFC_STD_F2008);
1522 add_sym_2 ("btest", GFC_ISYM_BTEST, CLASS_ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_F95,
1523 gfc_check_bitfcn, gfc_simplify_btest, gfc_resolve_btest,
1524 i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED);
1526 make_generic ("btest", GFC_ISYM_BTEST, GFC_STD_F95);
1528 add_sym_2 ("ceiling", GFC_ISYM_CEILING, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1529 gfc_check_a_ikind, gfc_simplify_ceiling, gfc_resolve_ceiling,
1530 a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1532 make_generic ("ceiling", GFC_ISYM_CEILING, GFC_STD_F95);
1534 add_sym_2 ("char", GFC_ISYM_CHAR, CLASS_ELEMENTAL, ACTUAL_NO, BT_CHARACTER, dc, GFC_STD_F77,
1535 gfc_check_char, gfc_simplify_char, gfc_resolve_char,
1536 i, BT_INTEGER, di, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1538 make_generic ("char", GFC_ISYM_CHAR, GFC_STD_F77);
1540 add_sym_1 ("chdir", GFC_ISYM_CHDIR, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER, di,
1541 GFC_STD_GNU, gfc_check_chdir, NULL, gfc_resolve_chdir,
1542 nm, BT_CHARACTER, dc, REQUIRED);
1544 make_generic ("chdir", GFC_ISYM_CHDIR, GFC_STD_GNU);
1546 add_sym_2 ("chmod", GFC_ISYM_CHMOD, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
1547 di, GFC_STD_GNU, gfc_check_chmod, NULL, gfc_resolve_chmod,
1548 nm, BT_CHARACTER, dc, REQUIRED, md, BT_CHARACTER, dc, REQUIRED);
1550 make_generic ("chmod", GFC_ISYM_CHMOD, GFC_STD_GNU);
1552 add_sym_3 ("cmplx", GFC_ISYM_CMPLX, CLASS_ELEMENTAL, ACTUAL_NO, BT_COMPLEX, dz, GFC_STD_F77,
1553 gfc_check_cmplx, gfc_simplify_cmplx, gfc_resolve_cmplx,
1554 x, BT_UNKNOWN, dr, REQUIRED, y, BT_UNKNOWN, dr, OPTIONAL,
1555 kind, BT_INTEGER, di, OPTIONAL);
1557 make_generic ("cmplx", GFC_ISYM_CMPLX, GFC_STD_F77);
1559 add_sym_0 ("command_argument_count", GFC_ISYM_COMMAND_ARGUMENT_COUNT, CLASS_INQUIRY,
1560 ACTUAL_NO, BT_INTEGER, di, GFC_STD_F2003, NULL, NULL, NULL);
1562 make_generic ("command_argument_count", GFC_ISYM_COMMAND_ARGUMENT_COUNT,
1563 GFC_STD_F2003);
1565 add_sym_2 ("complex", GFC_ISYM_COMPLEX, CLASS_ELEMENTAL, ACTUAL_NO, BT_COMPLEX, dz, GFC_STD_GNU,
1566 gfc_check_complex, gfc_simplify_complex, gfc_resolve_complex,
1567 x, BT_UNKNOWN, dr, REQUIRED, y, BT_UNKNOWN, dr, REQUIRED);
1569 make_generic ("complex", GFC_ISYM_COMPLEX, GFC_STD_GNU);
1571 /* Making dcmplx a specific of cmplx causes cmplx to return a double
1572 complex instead of the default complex. */
1574 add_sym_2 ("dcmplx", GFC_ISYM_CMPLX, CLASS_ELEMENTAL, ACTUAL_NO, BT_COMPLEX, dd, GFC_STD_GNU,
1575 gfc_check_dcmplx, gfc_simplify_dcmplx, gfc_resolve_dcmplx,
1576 x, BT_REAL, dd, REQUIRED, y, BT_REAL, dd, OPTIONAL);
1578 make_generic ("dcmplx", GFC_ISYM_CMPLX, GFC_STD_GNU);
1580 add_sym_1 ("conjg", GFC_ISYM_CONJG, CLASS_ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dz, GFC_STD_F77,
1581 gfc_check_fn_c, gfc_simplify_conjg, gfc_resolve_conjg,
1582 z, BT_COMPLEX, dz, REQUIRED);
1584 add_sym_1 ("dconjg", GFC_ISYM_CONJG, CLASS_ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dd, GFC_STD_GNU,
1585 NULL, gfc_simplify_conjg, gfc_resolve_conjg,
1586 z, BT_COMPLEX, dd, REQUIRED);
1588 make_generic ("conjg", GFC_ISYM_CONJG, GFC_STD_F77);
1590 add_sym_1 ("cos", GFC_ISYM_COS, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1591 gfc_check_fn_rc, gfc_simplify_cos, gfc_resolve_cos,
1592 x, BT_REAL, dr, REQUIRED);
1594 add_sym_1 ("dcos", GFC_ISYM_COS, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1595 gfc_check_fn_d, gfc_simplify_cos, gfc_resolve_cos,
1596 x, BT_REAL, dd, REQUIRED);
1598 add_sym_1 ("ccos", GFC_ISYM_COS, CLASS_ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dz, GFC_STD_F77,
1599 NULL, gfc_simplify_cos, gfc_resolve_cos,
1600 x, BT_COMPLEX, dz, REQUIRED);
1602 add_sym_1 ("zcos", GFC_ISYM_COS, CLASS_ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dd, GFC_STD_GNU,
1603 NULL, gfc_simplify_cos, gfc_resolve_cos,
1604 x, BT_COMPLEX, dd, REQUIRED);
1606 make_alias ("cdcos", GFC_STD_GNU);
1608 make_generic ("cos", GFC_ISYM_COS, GFC_STD_F77);
1610 add_sym_1 ("cosh", GFC_ISYM_COSH, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1611 gfc_check_fn_rc2008, gfc_simplify_cosh, gfc_resolve_cosh,
1612 x, BT_REAL, dr, REQUIRED);
1614 add_sym_1 ("dcosh", GFC_ISYM_COSH, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1615 gfc_check_fn_d, gfc_simplify_cosh, gfc_resolve_cosh,
1616 x, BT_REAL, dd, REQUIRED);
1618 make_generic ("cosh", GFC_ISYM_COSH, GFC_STD_F77);
1620 add_sym_3 ("count", GFC_ISYM_COUNT, CLASS_TRANSFORMATIONAL, ACTUAL_NO,
1621 BT_INTEGER, di, GFC_STD_F95,
1622 gfc_check_count, gfc_simplify_count, gfc_resolve_count,
1623 msk, BT_LOGICAL, dl, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
1624 kind, BT_INTEGER, di, OPTIONAL);
1626 make_generic ("count", GFC_ISYM_COUNT, GFC_STD_F95);
1628 add_sym_3 ("cshift", GFC_ISYM_CSHIFT, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
1629 gfc_check_cshift, NULL, gfc_resolve_cshift,
1630 ar, BT_REAL, dr, REQUIRED, sh, BT_INTEGER, di, REQUIRED,
1631 dm, BT_INTEGER, ii, OPTIONAL);
1633 make_generic ("cshift", GFC_ISYM_CSHIFT, GFC_STD_F95);
1635 add_sym_1 ("ctime", GFC_ISYM_CTIME, CLASS_IMPURE, ACTUAL_NO, BT_CHARACTER,
1636 0, GFC_STD_GNU, gfc_check_ctime, NULL, gfc_resolve_ctime,
1637 tm, BT_INTEGER, di, REQUIRED);
1639 make_generic ("ctime", GFC_ISYM_CTIME, GFC_STD_GNU);
1641 add_sym_1 ("dble", GFC_ISYM_DBLE, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_F77,
1642 gfc_check_dble, gfc_simplify_dble, gfc_resolve_dble,
1643 a, BT_REAL, dr, REQUIRED);
1645 make_generic ("dble", GFC_ISYM_DBLE, GFC_STD_F77);
1647 add_sym_1 ("digits", GFC_ISYM_DIGITS, CLASS_INQUIRY, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1648 gfc_check_digits, gfc_simplify_digits, NULL,
1649 x, BT_UNKNOWN, dr, REQUIRED);
1651 make_generic ("digits", GFC_ISYM_DIGITS, GFC_STD_F95);
1653 add_sym_2 ("dim", GFC_ISYM_DIM, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1654 gfc_check_a_p, gfc_simplify_dim, gfc_resolve_dim,
1655 x, BT_REAL, dr, REQUIRED, y, BT_REAL, dr, REQUIRED);
1657 add_sym_2 ("idim", GFC_ISYM_DIM, CLASS_ELEMENTAL, ACTUAL_YES, BT_INTEGER, di, GFC_STD_F77,
1658 NULL, gfc_simplify_dim, gfc_resolve_dim,
1659 x, BT_INTEGER, di, REQUIRED, y, BT_INTEGER, di, REQUIRED);
1661 add_sym_2 ("ddim", GFC_ISYM_DIM, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1662 gfc_check_x_yd, gfc_simplify_dim, gfc_resolve_dim,
1663 x, BT_REAL, dd, REQUIRED, y, BT_REAL, dd, REQUIRED);
1665 make_generic ("dim", GFC_ISYM_DIM, GFC_STD_F77);
1667 add_sym_2 ("dot_product", GFC_ISYM_DOT_PRODUCT, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr,
1668 GFC_STD_F95, gfc_check_dot_product, gfc_simplify_dot_product, gfc_resolve_dot_product,
1669 va, BT_REAL, dr, REQUIRED, vb, BT_REAL, dr, REQUIRED);
1671 make_generic ("dot_product", GFC_ISYM_DOT_PRODUCT, GFC_STD_F95);
1673 add_sym_2 ("dprod", GFC_ISYM_DPROD,CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1674 gfc_check_dprod, gfc_simplify_dprod, gfc_resolve_dprod,
1675 x, BT_REAL, dr, REQUIRED, y, BT_REAL, dr, REQUIRED);
1677 make_generic ("dprod", GFC_ISYM_DPROD, GFC_STD_F77);
1679 add_sym_1 ("dreal", GFC_ISYM_REAL, CLASS_ELEMENTAL, ACTUAL_NO,
1680 BT_REAL, dd, GFC_STD_GNU, NULL, gfc_simplify_dreal, NULL,
1681 a, BT_COMPLEX, dd, REQUIRED);
1683 make_generic ("dreal", GFC_ISYM_REAL, GFC_STD_GNU);
1685 add_sym_3 ("dshiftl", GFC_ISYM_DSHIFTL, CLASS_ELEMENTAL, ACTUAL_NO,
1686 BT_INTEGER, di, GFC_STD_F2008,
1687 gfc_check_dshift, gfc_simplify_dshiftl, gfc_resolve_dshift,
1688 i, BT_INTEGER, di, REQUIRED,
1689 j, BT_INTEGER, di, REQUIRED,
1690 sh, BT_INTEGER, di, REQUIRED);
1692 make_generic ("dshiftl", GFC_ISYM_DSHIFTL, GFC_STD_F2008);
1694 add_sym_3 ("dshiftr", GFC_ISYM_DSHIFTR, CLASS_ELEMENTAL, ACTUAL_NO,
1695 BT_INTEGER, di, GFC_STD_F2008,
1696 gfc_check_dshift, gfc_simplify_dshiftr, gfc_resolve_dshift,
1697 i, BT_INTEGER, di, REQUIRED,
1698 j, BT_INTEGER, di, REQUIRED,
1699 sh, BT_INTEGER, di, REQUIRED);
1701 make_generic ("dshiftr", GFC_ISYM_DSHIFTR, GFC_STD_F2008);
1703 add_sym_4 ("eoshift", GFC_ISYM_EOSHIFT, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
1704 gfc_check_eoshift, NULL, gfc_resolve_eoshift,
1705 ar, BT_REAL, dr, REQUIRED, sh, BT_INTEGER, ii, REQUIRED,
1706 bd, BT_REAL, dr, OPTIONAL, dm, BT_INTEGER, ii, OPTIONAL);
1708 make_generic ("eoshift", GFC_ISYM_EOSHIFT, GFC_STD_F95);
1710 add_sym_1 ("epsilon", GFC_ISYM_EPSILON, CLASS_INQUIRY, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
1711 gfc_check_x, gfc_simplify_epsilon, NULL,
1712 x, BT_REAL, dr, REQUIRED);
1714 make_generic ("epsilon", GFC_ISYM_EPSILON, GFC_STD_F95);
1716 /* G77 compatibility for the ERF() and ERFC() functions. */
1717 add_sym_1 ("erf", GFC_ISYM_ERF, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr,
1718 GFC_STD_F2008, gfc_check_fn_r, gfc_simplify_erf,
1719 gfc_resolve_g77_math1, x, BT_REAL, dr, REQUIRED);
1721 add_sym_1 ("derf", GFC_ISYM_ERF, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dd,
1722 GFC_STD_GNU, gfc_check_fn_d, gfc_simplify_erf,
1723 gfc_resolve_g77_math1, x, BT_REAL, dd, REQUIRED);
1725 make_generic ("erf", GFC_ISYM_ERF, GFC_STD_F2008);
1727 add_sym_1 ("erfc", GFC_ISYM_ERFC, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr,
1728 GFC_STD_F2008, gfc_check_fn_r, gfc_simplify_erfc,
1729 gfc_resolve_g77_math1, x, BT_REAL, dr, REQUIRED);
1731 add_sym_1 ("derfc", GFC_ISYM_ERFC, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dd,
1732 GFC_STD_GNU, gfc_check_fn_d, gfc_simplify_erfc,
1733 gfc_resolve_g77_math1, x, BT_REAL, dd, REQUIRED);
1735 make_generic ("erfc", GFC_ISYM_ERFC, GFC_STD_F2008);
1737 add_sym_1 ("erfc_scaled", GFC_ISYM_ERFC_SCALED, CLASS_ELEMENTAL, ACTUAL_NO,
1738 BT_REAL, dr, GFC_STD_F2008, gfc_check_fn_r,
1739 gfc_simplify_erfc_scaled, gfc_resolve_g77_math1, x, BT_REAL,
1740 dr, REQUIRED);
1742 make_generic ("erfc_scaled", GFC_ISYM_ERFC_SCALED, GFC_STD_F2008);
1744 /* G77 compatibility */
1745 add_sym_1 ("dtime", GFC_ISYM_DTIME, CLASS_IMPURE, ACTUAL_NO, BT_REAL,
1746 4, GFC_STD_GNU, gfc_check_dtime_etime, NULL, NULL,
1747 x, BT_REAL, 4, REQUIRED);
1749 make_generic ("dtime", GFC_ISYM_DTIME, GFC_STD_GNU);
1751 add_sym_1 ("etime", GFC_ISYM_ETIME, CLASS_IMPURE, ACTUAL_NO, BT_REAL,
1752 4, GFC_STD_GNU, gfc_check_dtime_etime, NULL, NULL,
1753 x, BT_REAL, 4, REQUIRED);
1755 make_generic ("etime", GFC_ISYM_ETIME, GFC_STD_GNU);
1757 add_sym_1 ("exp", GFC_ISYM_EXP, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1758 gfc_check_fn_rc, gfc_simplify_exp, gfc_resolve_exp,
1759 x, BT_REAL, dr, REQUIRED);
1761 add_sym_1 ("dexp", GFC_ISYM_EXP, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1762 gfc_check_fn_d, gfc_simplify_exp, gfc_resolve_exp,
1763 x, BT_REAL, dd, REQUIRED);
1765 add_sym_1 ("cexp", GFC_ISYM_EXP, CLASS_ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dz, GFC_STD_F77,
1766 NULL, gfc_simplify_exp, gfc_resolve_exp,
1767 x, BT_COMPLEX, dz, REQUIRED);
1769 add_sym_1 ("zexp", GFC_ISYM_EXP, CLASS_ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dd, GFC_STD_GNU,
1770 NULL, gfc_simplify_exp, gfc_resolve_exp,
1771 x, BT_COMPLEX, dd, REQUIRED);
1773 make_alias ("cdexp", GFC_STD_GNU);
1775 make_generic ("exp", GFC_ISYM_EXP, GFC_STD_F77);
1777 add_sym_1 ("exponent", GFC_ISYM_EXPONENT, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1778 gfc_check_x, gfc_simplify_exponent, gfc_resolve_exponent,
1779 x, BT_REAL, dr, REQUIRED);
1781 make_generic ("exponent", GFC_ISYM_EXPONENT, GFC_STD_F95);
1783 add_sym_2 ("extends_type_of", GFC_ISYM_EXTENDS_TYPE_OF, CLASS_INQUIRY,
1784 ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_F2003,
1785 gfc_check_same_type_as, gfc_simplify_extends_type_of,
1786 gfc_resolve_extends_type_of,
1787 a, BT_UNKNOWN, 0, REQUIRED,
1788 mo, BT_UNKNOWN, 0, REQUIRED);
1790 add_sym_0 ("fdate", GFC_ISYM_FDATE, CLASS_IMPURE, ACTUAL_NO, BT_CHARACTER,
1791 dc, GFC_STD_GNU, NULL, NULL, gfc_resolve_fdate);
1793 make_generic ("fdate", GFC_ISYM_FDATE, GFC_STD_GNU);
1795 add_sym_2 ("floor", GFC_ISYM_FLOOR, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1796 gfc_check_a_ikind, gfc_simplify_floor, gfc_resolve_floor,
1797 a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1799 make_generic ("floor", GFC_ISYM_FLOOR, GFC_STD_F95);
1801 /* G77 compatible fnum */
1802 add_sym_1 ("fnum", GFC_ISYM_FNUM, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
1803 di, GFC_STD_GNU, gfc_check_fnum, NULL, gfc_resolve_fnum,
1804 ut, BT_INTEGER, di, REQUIRED);
1806 make_generic ("fnum", GFC_ISYM_FNUM, GFC_STD_GNU);
1808 add_sym_1 ("fraction", GFC_ISYM_FRACTION, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
1809 gfc_check_x, gfc_simplify_fraction, gfc_resolve_fraction,
1810 x, BT_REAL, dr, REQUIRED);
1812 make_generic ("fraction", GFC_ISYM_FRACTION, GFC_STD_F95);
1814 add_sym_2_intent ("fstat", GFC_ISYM_FSTAT, CLASS_IMPURE, ACTUAL_NO,
1815 BT_INTEGER, di, GFC_STD_GNU,
1816 gfc_check_fstat, NULL, gfc_resolve_fstat,
1817 ut, BT_INTEGER, di, REQUIRED, INTENT_IN,
1818 vl, BT_INTEGER, di, REQUIRED, INTENT_OUT);
1820 make_generic ("fstat", GFC_ISYM_FSTAT, GFC_STD_GNU);
1822 add_sym_1 ("ftell", GFC_ISYM_FTELL, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
1823 ii, GFC_STD_GNU, gfc_check_ftell, NULL, gfc_resolve_ftell,
1824 ut, BT_INTEGER, di, REQUIRED);
1826 make_generic ("ftell", GFC_ISYM_FTELL, GFC_STD_GNU);
1828 add_sym_2_intent ("fgetc", GFC_ISYM_FGETC, CLASS_IMPURE, ACTUAL_NO,
1829 BT_INTEGER, di, GFC_STD_GNU,
1830 gfc_check_fgetputc, NULL, gfc_resolve_fgetc,
1831 ut, BT_INTEGER, di, REQUIRED, INTENT_IN,
1832 c, BT_CHARACTER, dc, REQUIRED, INTENT_OUT);
1834 make_generic ("fgetc", GFC_ISYM_FGETC, GFC_STD_GNU);
1836 add_sym_1_intent ("fget", GFC_ISYM_FGET, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
1837 di, GFC_STD_GNU, gfc_check_fgetput, NULL, gfc_resolve_fget,
1838 c, BT_CHARACTER, dc, REQUIRED, INTENT_OUT);
1840 make_generic ("fget", GFC_ISYM_FGET, GFC_STD_GNU);
1842 add_sym_2 ("fputc", GFC_ISYM_FPUTC, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
1843 di, GFC_STD_GNU, gfc_check_fgetputc, NULL, gfc_resolve_fputc,
1844 ut, BT_INTEGER, di, REQUIRED, c, BT_CHARACTER, dc, REQUIRED);
1846 make_generic ("fputc", GFC_ISYM_FPUTC, GFC_STD_GNU);
1848 add_sym_1 ("fput", GFC_ISYM_FPUT, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
1849 di, GFC_STD_GNU, gfc_check_fgetput, NULL, gfc_resolve_fput,
1850 c, BT_CHARACTER, dc, REQUIRED);
1852 make_generic ("fput", GFC_ISYM_FPUT, GFC_STD_GNU);
1854 add_sym_1 ("gamma", GFC_ISYM_TGAMMA, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr,
1855 GFC_STD_F2008, gfc_check_fn_r, gfc_simplify_gamma,
1856 gfc_resolve_gamma, x, BT_REAL, dr, REQUIRED);
1858 add_sym_1 ("dgamma", GFC_ISYM_TGAMMA, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
1859 gfc_check_fn_d, gfc_simplify_gamma, gfc_resolve_gamma,
1860 x, BT_REAL, dr, REQUIRED);
1862 make_generic ("gamma", GFC_ISYM_TGAMMA, GFC_STD_F2008);
1864 /* Unix IDs (g77 compatibility) */
1865 add_sym_1 ("getcwd", GFC_ISYM_GETCWD, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
1866 di, GFC_STD_GNU, NULL, NULL, gfc_resolve_getcwd,
1867 c, BT_CHARACTER, dc, REQUIRED);
1869 make_generic ("getcwd", GFC_ISYM_GETCWD, GFC_STD_GNU);
1871 add_sym_0 ("getgid", GFC_ISYM_GETGID, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
1872 di, GFC_STD_GNU, NULL, NULL, gfc_resolve_getgid);
1874 make_generic ("getgid", GFC_ISYM_GETGID, GFC_STD_GNU);
1876 add_sym_0 ("getpid", GFC_ISYM_GETPID, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
1877 di, GFC_STD_GNU, NULL, NULL, gfc_resolve_getpid);
1879 make_generic ("getpid", GFC_ISYM_GETPID, GFC_STD_GNU);
1881 add_sym_0 ("getuid", GFC_ISYM_GETUID, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
1882 di, GFC_STD_GNU, NULL, NULL, gfc_resolve_getuid);
1884 make_generic ("getuid", GFC_ISYM_GETUID, GFC_STD_GNU);
1886 add_sym_1_intent ("hostnm", GFC_ISYM_HOSTNM, CLASS_IMPURE, ACTUAL_NO,
1887 BT_INTEGER, di, GFC_STD_GNU,
1888 gfc_check_hostnm, NULL, gfc_resolve_hostnm,
1889 c, BT_CHARACTER, dc, REQUIRED, INTENT_OUT);
1891 make_generic ("hostnm", GFC_ISYM_HOSTNM, GFC_STD_GNU);
1893 add_sym_1 ("huge", GFC_ISYM_HUGE, CLASS_INQUIRY, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
1894 gfc_check_huge, gfc_simplify_huge, NULL,
1895 x, BT_UNKNOWN, dr, REQUIRED);
1897 make_generic ("huge", GFC_ISYM_HUGE, GFC_STD_F95);
1899 add_sym_2 ("hypot", GFC_ISYM_HYPOT, CLASS_ELEMENTAL, ACTUAL_NO,
1900 BT_REAL, dr, GFC_STD_F2008,
1901 gfc_check_hypot, gfc_simplify_hypot, gfc_resolve_hypot,
1902 x, BT_REAL, dr, REQUIRED, y, BT_REAL, dr, REQUIRED);
1904 make_generic ("hypot", GFC_ISYM_HYPOT, GFC_STD_F2008);
1906 add_sym_2 ("iachar", GFC_ISYM_IACHAR, CLASS_ELEMENTAL, ACTUAL_NO,
1907 BT_INTEGER, di, GFC_STD_F95,
1908 gfc_check_ichar_iachar, gfc_simplify_iachar, gfc_resolve_iachar,
1909 c, BT_CHARACTER, dc, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1911 make_generic ("iachar", GFC_ISYM_IACHAR, GFC_STD_F95);
1913 add_sym_2 ("iand", GFC_ISYM_IAND, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1914 gfc_check_iand, gfc_simplify_iand, gfc_resolve_iand,
1915 i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED);
1917 make_generic ("iand", GFC_ISYM_IAND, GFC_STD_F95);
1919 add_sym_2 ("and", GFC_ISYM_AND, CLASS_IMPURE, ACTUAL_NO, BT_LOGICAL,
1920 dl, GFC_STD_GNU, gfc_check_and, gfc_simplify_and, gfc_resolve_and,
1921 i, BT_UNKNOWN, 0, REQUIRED, j, BT_UNKNOWN, 0, REQUIRED);
1923 make_generic ("and", GFC_ISYM_AND, GFC_STD_GNU);
1925 add_sym_3red ("iall", GFC_ISYM_IALL, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F2008,
1926 gfc_check_transf_bit_intrins, gfc_simplify_iall, gfc_resolve_iall,
1927 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
1928 msk, BT_LOGICAL, dl, OPTIONAL);
1930 make_generic ("iall", GFC_ISYM_IALL, GFC_STD_F2008);
1932 add_sym_3red ("iany", GFC_ISYM_IANY, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F2008,
1933 gfc_check_transf_bit_intrins, gfc_simplify_iany, gfc_resolve_iany,
1934 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
1935 msk, BT_LOGICAL, dl, OPTIONAL);
1937 make_generic ("iany", GFC_ISYM_IANY, GFC_STD_F2008);
1939 add_sym_0 ("iargc", GFC_ISYM_IARGC, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
1940 di, GFC_STD_GNU, NULL, NULL, NULL);
1942 make_generic ("iargc", GFC_ISYM_IARGC, GFC_STD_GNU);
1944 add_sym_2 ("ibclr", GFC_ISYM_IBCLR, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1945 gfc_check_bitfcn, gfc_simplify_ibclr, gfc_resolve_ibclr,
1946 i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED);
1948 make_generic ("ibclr", GFC_ISYM_IBCLR, GFC_STD_F95);
1950 add_sym_3 ("ibits", GFC_ISYM_IBITS, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1951 gfc_check_ibits, gfc_simplify_ibits, gfc_resolve_ibits,
1952 i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED,
1953 ln, BT_INTEGER, di, REQUIRED);
1955 make_generic ("ibits", GFC_ISYM_IBITS, GFC_STD_F95);
1957 add_sym_2 ("ibset", GFC_ISYM_IBSET, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1958 gfc_check_bitfcn, gfc_simplify_ibset, gfc_resolve_ibset,
1959 i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED);
1961 make_generic ("ibset", GFC_ISYM_IBSET, GFC_STD_F95);
1963 add_sym_2 ("ichar", GFC_ISYM_ICHAR, CLASS_ELEMENTAL, ACTUAL_NO,
1964 BT_INTEGER, di, GFC_STD_F77,
1965 gfc_check_ichar_iachar, gfc_simplify_ichar, gfc_resolve_ichar,
1966 c, BT_CHARACTER, dc, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1968 make_generic ("ichar", GFC_ISYM_ICHAR, GFC_STD_F77);
1970 add_sym_2 ("ieor", GFC_ISYM_IEOR, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1971 gfc_check_ieor, gfc_simplify_ieor, gfc_resolve_ieor,
1972 i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED);
1974 make_generic ("ieor", GFC_ISYM_IEOR, GFC_STD_F95);
1976 add_sym_2 ("xor", GFC_ISYM_XOR, CLASS_IMPURE, ACTUAL_NO, BT_LOGICAL,
1977 dl, GFC_STD_GNU, gfc_check_and, gfc_simplify_xor, gfc_resolve_xor,
1978 i, BT_UNKNOWN, 0, REQUIRED, j, BT_UNKNOWN, 0, REQUIRED);
1980 make_generic ("xor", GFC_ISYM_XOR, GFC_STD_GNU);
1982 add_sym_0 ("ierrno", GFC_ISYM_IERRNO, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
1983 di, GFC_STD_GNU, NULL, NULL, gfc_resolve_ierrno);
1985 make_generic ("ierrno", GFC_ISYM_IERRNO, GFC_STD_GNU);
1987 add_sym_2 ("image_index", GFC_ISYM_IMAGE_INDEX, CLASS_INQUIRY, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F2008,
1988 gfc_check_image_index, gfc_simplify_image_index, gfc_resolve_image_index,
1989 ca, BT_REAL, dr, REQUIRED, sub, BT_INTEGER, ii, REQUIRED);
1991 /* The resolution function for INDEX is called gfc_resolve_index_func
1992 because the name gfc_resolve_index is already used in resolve.c. */
1993 add_sym_4 ("index", GFC_ISYM_INDEX, CLASS_ELEMENTAL, ACTUAL_YES,
1994 BT_INTEGER, di, GFC_STD_F77,
1995 gfc_check_index, gfc_simplify_index, gfc_resolve_index_func,
1996 stg, BT_CHARACTER, dc, REQUIRED, ssg, BT_CHARACTER, dc, REQUIRED,
1997 bck, BT_LOGICAL, dl, OPTIONAL, kind, BT_INTEGER, di, OPTIONAL);
1999 make_generic ("index", GFC_ISYM_INDEX, GFC_STD_F77);
2001 add_sym_2 ("int", GFC_ISYM_INT, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F77,
2002 gfc_check_int, gfc_simplify_int, gfc_resolve_int,
2003 a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
2005 add_sym_1 ("ifix", GFC_ISYM_INT, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F77,
2006 NULL, gfc_simplify_ifix, NULL,
2007 a, BT_REAL, dr, REQUIRED);
2009 add_sym_1 ("idint", GFC_ISYM_INT, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F77,
2010 NULL, gfc_simplify_idint, NULL,
2011 a, BT_REAL, dd, REQUIRED);
2013 make_generic ("int", GFC_ISYM_INT, GFC_STD_F77);
2015 add_sym_1 ("int2", GFC_ISYM_INT2, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
2016 gfc_check_intconv, gfc_simplify_int2, gfc_resolve_int2,
2017 a, BT_REAL, dr, REQUIRED);
2019 make_alias ("short", GFC_STD_GNU);
2021 make_generic ("int2", GFC_ISYM_INT2, GFC_STD_GNU);
2023 add_sym_1 ("int8", GFC_ISYM_INT8, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
2024 gfc_check_intconv, gfc_simplify_int8, gfc_resolve_int8,
2025 a, BT_REAL, dr, REQUIRED);
2027 make_generic ("int8", GFC_ISYM_INT8, GFC_STD_GNU);
2029 add_sym_1 ("long", GFC_ISYM_LONG, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
2030 gfc_check_intconv, gfc_simplify_long, gfc_resolve_long,
2031 a, BT_REAL, dr, REQUIRED);
2033 make_generic ("long", GFC_ISYM_LONG, GFC_STD_GNU);
2035 add_sym_2 ("ior", GFC_ISYM_IOR, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
2036 gfc_check_ior, gfc_simplify_ior, gfc_resolve_ior,
2037 i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED);
2039 make_generic ("ior", GFC_ISYM_IOR, GFC_STD_F95);
2041 add_sym_2 ("or", GFC_ISYM_OR, CLASS_IMPURE, ACTUAL_NO, BT_LOGICAL,
2042 dl, GFC_STD_GNU, gfc_check_and, gfc_simplify_or, gfc_resolve_or,
2043 i, BT_UNKNOWN, 0, REQUIRED, j, BT_UNKNOWN, 0, REQUIRED);
2045 make_generic ("or", GFC_ISYM_OR, GFC_STD_GNU);
2047 add_sym_3red ("iparity", GFC_ISYM_IPARITY, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F2008,
2048 gfc_check_transf_bit_intrins, gfc_simplify_iparity, gfc_resolve_iparity,
2049 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
2050 msk, BT_LOGICAL, dl, OPTIONAL);
2052 make_generic ("iparity", GFC_ISYM_IPARITY, GFC_STD_F2008);
2054 /* The following function is for G77 compatibility. */
2055 add_sym_1 ("irand", GFC_ISYM_IRAND, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
2056 4, GFC_STD_GNU, gfc_check_irand, NULL, NULL,
2057 i, BT_INTEGER, 4, OPTIONAL);
2059 make_generic ("irand", GFC_ISYM_IRAND, GFC_STD_GNU);
2061 add_sym_1 ("isatty", GFC_ISYM_ISATTY, CLASS_IMPURE, ACTUAL_NO, BT_LOGICAL,
2062 dl, GFC_STD_GNU, gfc_check_isatty, NULL, gfc_resolve_isatty,
2063 ut, BT_INTEGER, di, REQUIRED);
2065 make_generic ("isatty", GFC_ISYM_ISATTY, GFC_STD_GNU);
2067 add_sym_1 ("is_iostat_end", GFC_ISYM_IS_IOSTAT_END,
2068 CLASS_ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_F2003,
2069 gfc_check_i, gfc_simplify_is_iostat_end, NULL,
2070 i, BT_INTEGER, 0, REQUIRED);
2072 make_generic ("is_iostat_end", GFC_ISYM_IS_IOSTAT_END, GFC_STD_F2003);
2074 add_sym_1 ("is_iostat_eor", GFC_ISYM_IS_IOSTAT_EOR,
2075 CLASS_ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_F2003,
2076 gfc_check_i, gfc_simplify_is_iostat_eor, NULL,
2077 i, BT_INTEGER, 0, REQUIRED);
2079 make_generic ("is_iostat_eor", GFC_ISYM_IS_IOSTAT_EOR, GFC_STD_F2003);
2081 add_sym_1 ("isnan", GFC_ISYM_ISNAN, CLASS_ELEMENTAL, ACTUAL_NO,
2082 BT_LOGICAL, dl, GFC_STD_GNU,
2083 gfc_check_isnan, gfc_simplify_isnan, NULL,
2084 x, BT_REAL, 0, REQUIRED);
2086 make_generic ("isnan", GFC_ISYM_ISNAN, GFC_STD_GNU);
2088 add_sym_2 ("rshift", GFC_ISYM_RSHIFT, CLASS_ELEMENTAL, ACTUAL_NO,
2089 BT_INTEGER, di, GFC_STD_GNU,
2090 gfc_check_ishft, gfc_simplify_rshift, gfc_resolve_rshift,
2091 i, BT_INTEGER, di, REQUIRED, sh, BT_INTEGER, di, REQUIRED);
2093 make_generic ("rshift", GFC_ISYM_RSHIFT, GFC_STD_GNU);
2095 add_sym_2 ("lshift", GFC_ISYM_LSHIFT, CLASS_ELEMENTAL, ACTUAL_NO,
2096 BT_INTEGER, di, GFC_STD_GNU,
2097 gfc_check_ishft, gfc_simplify_lshift, gfc_resolve_lshift,
2098 i, BT_INTEGER, di, REQUIRED, sh, BT_INTEGER, di, REQUIRED);
2100 make_generic ("lshift", GFC_ISYM_LSHIFT, GFC_STD_GNU);
2102 add_sym_2 ("ishft", GFC_ISYM_ISHFT, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
2103 gfc_check_ishft, gfc_simplify_ishft, gfc_resolve_ishft,
2104 i, BT_INTEGER, di, REQUIRED, sh, BT_INTEGER, di, REQUIRED);
2106 make_generic ("ishft", GFC_ISYM_ISHFT, GFC_STD_F95);
2108 add_sym_3 ("ishftc", GFC_ISYM_ISHFTC, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
2109 gfc_check_ishftc, gfc_simplify_ishftc, gfc_resolve_ishftc,
2110 i, BT_INTEGER, di, REQUIRED, sh, BT_INTEGER, di, REQUIRED,
2111 sz, BT_INTEGER, di, OPTIONAL);
2113 make_generic ("ishftc", GFC_ISYM_ISHFTC, GFC_STD_F95);
2115 add_sym_2 ("kill", GFC_ISYM_KILL, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
2116 di, GFC_STD_GNU, gfc_check_kill, NULL, gfc_resolve_kill,
2117 a, BT_INTEGER, di, REQUIRED, b, BT_INTEGER, di, REQUIRED);
2119 make_generic ("kill", GFC_ISYM_KILL, GFC_STD_GNU);
2121 add_sym_1 ("kind", GFC_ISYM_KIND, CLASS_INQUIRY, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
2122 gfc_check_kind, gfc_simplify_kind, NULL,
2123 x, BT_REAL, dr, REQUIRED);
2125 make_generic ("kind", GFC_ISYM_KIND, GFC_STD_F95);
2127 add_sym_3 ("lbound", GFC_ISYM_LBOUND, CLASS_INQUIRY, ACTUAL_NO,
2128 BT_INTEGER, di, GFC_STD_F95,
2129 gfc_check_lbound, gfc_simplify_lbound, gfc_resolve_lbound,
2130 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, di, OPTIONAL,
2131 kind, BT_INTEGER, di, OPTIONAL);
2133 make_generic ("lbound", GFC_ISYM_LBOUND, GFC_STD_F95);
2135 add_sym_3 ("lcobound", GFC_ISYM_LCOBOUND, CLASS_INQUIRY, ACTUAL_NO,
2136 BT_INTEGER, di, GFC_STD_F2008,
2137 gfc_check_lcobound, gfc_simplify_lcobound, gfc_resolve_lcobound,
2138 ca, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
2139 kind, BT_INTEGER, di, OPTIONAL);
2141 make_generic ("lcobound", GFC_ISYM_LCOBOUND, GFC_STD_F2008);
2143 add_sym_1 ("leadz", GFC_ISYM_LEADZ, CLASS_ELEMENTAL, ACTUAL_NO,
2144 BT_INTEGER, di, GFC_STD_F2008,
2145 gfc_check_i, gfc_simplify_leadz, NULL,
2146 i, BT_INTEGER, di, REQUIRED);
2148 make_generic ("leadz", GFC_ISYM_LEADZ, GFC_STD_F2008);
2150 add_sym_2 ("len", GFC_ISYM_LEN, CLASS_INQUIRY, ACTUAL_YES,
2151 BT_INTEGER, di, GFC_STD_F77,
2152 gfc_check_len_lentrim, gfc_simplify_len, gfc_resolve_len,
2153 stg, BT_CHARACTER, dc, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
2155 make_generic ("len", GFC_ISYM_LEN, GFC_STD_F77);
2157 add_sym_2 ("len_trim", GFC_ISYM_LEN_TRIM, CLASS_ELEMENTAL, ACTUAL_NO,
2158 BT_INTEGER, di, GFC_STD_F95,
2159 gfc_check_len_lentrim, gfc_simplify_len_trim, gfc_resolve_len_trim,
2160 stg, BT_CHARACTER, dc, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
2162 make_alias ("lnblnk", GFC_STD_GNU);
2164 make_generic ("len_trim", GFC_ISYM_LEN_TRIM, GFC_STD_F95);
2166 add_sym_1 ("lgamma", GFC_ISYM_LGAMMA, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL,
2167 dr, GFC_STD_GNU,
2168 gfc_check_fn_r, gfc_simplify_lgamma, gfc_resolve_lgamma,
2169 x, BT_REAL, dr, REQUIRED);
2171 make_alias ("log_gamma", GFC_STD_F2008);
2173 add_sym_1 ("algama", GFC_ISYM_LGAMMA, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
2174 gfc_check_fn_r, gfc_simplify_lgamma, gfc_resolve_lgamma,
2175 x, BT_REAL, dr, REQUIRED);
2177 add_sym_1 ("dlgama", GFC_ISYM_LGAMMA, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
2178 gfc_check_fn_d, gfc_simplify_lgamma, gfc_resolve_lgamma,
2179 x, BT_REAL, dr, REQUIRED);
2181 make_generic ("log_gamma", GFC_ISYM_LGAMMA, GFC_STD_F2008);
2184 add_sym_2 ("lge", GFC_ISYM_LGE, CLASS_ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl,
2185 GFC_STD_F77, gfc_check_lge_lgt_lle_llt, gfc_simplify_lge, NULL,
2186 sta, BT_CHARACTER, dc, REQUIRED, stb, BT_CHARACTER, dc, REQUIRED);
2188 make_generic ("lge", GFC_ISYM_LGE, GFC_STD_F77);
2190 add_sym_2 ("lgt", GFC_ISYM_LGT, CLASS_ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl,
2191 GFC_STD_F77, gfc_check_lge_lgt_lle_llt, gfc_simplify_lgt, NULL,
2192 sta, BT_CHARACTER, dc, REQUIRED, stb, BT_CHARACTER, dc, REQUIRED);
2194 make_generic ("lgt", GFC_ISYM_LGT, GFC_STD_F77);
2196 add_sym_2 ("lle",GFC_ISYM_LLE, CLASS_ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl,
2197 GFC_STD_F77, gfc_check_lge_lgt_lle_llt, gfc_simplify_lle, NULL,
2198 sta, BT_CHARACTER, dc, REQUIRED, stb, BT_CHARACTER, dc, REQUIRED);
2200 make_generic ("lle", GFC_ISYM_LLE, GFC_STD_F77);
2202 add_sym_2 ("llt", GFC_ISYM_LLT, CLASS_ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl,
2203 GFC_STD_F77, gfc_check_lge_lgt_lle_llt, gfc_simplify_llt, NULL,
2204 sta, BT_CHARACTER, dc, REQUIRED, stb, BT_CHARACTER, dc, REQUIRED);
2206 make_generic ("llt", GFC_ISYM_LLT, GFC_STD_F77);
2208 add_sym_2 ("link", GFC_ISYM_LINK, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER, di,
2209 GFC_STD_GNU, gfc_check_link, NULL, gfc_resolve_link,
2210 p1, BT_CHARACTER, dc, REQUIRED, p2, BT_CHARACTER, dc, REQUIRED);
2212 make_generic ("link", GFC_ISYM_LINK, GFC_STD_GNU);
2214 add_sym_1 ("log", GFC_ISYM_LOG, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
2215 gfc_check_fn_rc, gfc_simplify_log, gfc_resolve_log,
2216 x, BT_REAL, dr, REQUIRED);
2218 add_sym_1 ("alog", GFC_ISYM_LOG, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
2219 NULL, gfc_simplify_log, gfc_resolve_log,
2220 x, BT_REAL, dr, REQUIRED);
2222 add_sym_1 ("dlog", GFC_ISYM_LOG, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
2223 gfc_check_fn_d, gfc_simplify_log, gfc_resolve_log,
2224 x, BT_REAL, dd, REQUIRED);
2226 add_sym_1 ("clog", GFC_ISYM_LOG, CLASS_ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dz, GFC_STD_F77,
2227 NULL, gfc_simplify_log, gfc_resolve_log,
2228 x, BT_COMPLEX, dz, REQUIRED);
2230 add_sym_1 ("zlog", GFC_ISYM_LOG, CLASS_ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dd, GFC_STD_GNU,
2231 NULL, gfc_simplify_log, gfc_resolve_log,
2232 x, BT_COMPLEX, dd, REQUIRED);
2234 make_alias ("cdlog", GFC_STD_GNU);
2236 make_generic ("log", GFC_ISYM_LOG, GFC_STD_F77);
2238 add_sym_1 ("log10", GFC_ISYM_LOG10, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
2239 gfc_check_fn_r, gfc_simplify_log10, gfc_resolve_log10,
2240 x, BT_REAL, dr, REQUIRED);
2242 add_sym_1 ("alog10", GFC_ISYM_LOG10, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
2243 NULL, gfc_simplify_log10, gfc_resolve_log10,
2244 x, BT_REAL, dr, REQUIRED);
2246 add_sym_1 ("dlog10", GFC_ISYM_LOG10, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
2247 gfc_check_fn_d, gfc_simplify_log10, gfc_resolve_log10,
2248 x, BT_REAL, dd, REQUIRED);
2250 make_generic ("log10", GFC_ISYM_LOG10, GFC_STD_F77);
2252 add_sym_2 ("logical", GFC_ISYM_LOGICAL, CLASS_ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_F95,
2253 gfc_check_logical, gfc_simplify_logical, gfc_resolve_logical,
2254 l, BT_LOGICAL, dl, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
2256 make_generic ("logical", GFC_ISYM_LOGICAL, GFC_STD_F95);
2258 add_sym_2_intent ("lstat", GFC_ISYM_LSTAT, CLASS_IMPURE, ACTUAL_NO,
2259 BT_INTEGER, di, GFC_STD_GNU,
2260 gfc_check_stat, NULL, gfc_resolve_lstat,
2261 nm, BT_CHARACTER, dc, REQUIRED, INTENT_IN,
2262 vl, BT_INTEGER, di, REQUIRED, INTENT_OUT);
2264 make_generic ("lstat", GFC_ISYM_LSTAT, GFC_STD_GNU);
2266 add_sym_1 ("malloc", GFC_ISYM_MALLOC, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER, ii,
2267 GFC_STD_GNU, gfc_check_malloc, NULL, gfc_resolve_malloc,
2268 sz, BT_INTEGER, di, REQUIRED);
2270 make_generic ("malloc", GFC_ISYM_MALLOC, GFC_STD_GNU);
2272 add_sym_2 ("maskl", GFC_ISYM_MASKL, CLASS_ELEMENTAL, ACTUAL_NO,
2273 BT_INTEGER, di, GFC_STD_F2008,
2274 gfc_check_mask, gfc_simplify_maskl, gfc_resolve_mask,
2275 i, BT_INTEGER, di, REQUIRED,
2276 kind, BT_INTEGER, di, OPTIONAL);
2278 make_generic ("maskl", GFC_ISYM_MASKL, GFC_STD_F2008);
2280 add_sym_2 ("maskr", GFC_ISYM_MASKR, CLASS_ELEMENTAL, ACTUAL_NO,
2281 BT_INTEGER, di, GFC_STD_F2008,
2282 gfc_check_mask, gfc_simplify_maskr, gfc_resolve_mask,
2283 i, BT_INTEGER, di, REQUIRED,
2284 kind, BT_INTEGER, di, OPTIONAL);
2286 make_generic ("maskr", GFC_ISYM_MASKR, GFC_STD_F2008);
2288 add_sym_2 ("matmul", GFC_ISYM_MATMUL, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2289 gfc_check_matmul, gfc_simplify_matmul, gfc_resolve_matmul,
2290 ma, BT_REAL, dr, REQUIRED, mb, BT_REAL, dr, REQUIRED);
2292 make_generic ("matmul", GFC_ISYM_MATMUL, GFC_STD_F95);
2294 /* Note: amax0 is equivalent to real(max), max1 is equivalent to
2295 int(max). The max function must take at least two arguments. */
2297 add_sym_1m ("max", GFC_ISYM_MAX, CLASS_ELEMENTAL, ACTUAL_NO, BT_UNKNOWN, 0, GFC_STD_F77,
2298 gfc_check_min_max, gfc_simplify_max, gfc_resolve_max,
2299 a1, BT_UNKNOWN, dr, REQUIRED, a2, BT_UNKNOWN, dr, REQUIRED);
2301 add_sym_1m ("max0", GFC_ISYM_MAX, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F77,
2302 gfc_check_min_max_integer, gfc_simplify_max, NULL,
2303 a1, BT_INTEGER, di, REQUIRED, a2, BT_INTEGER, di, REQUIRED);
2305 add_sym_1m ("amax0", GFC_ISYM_MAX, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
2306 gfc_check_min_max_integer, gfc_simplify_max, NULL,
2307 a1, BT_INTEGER, di, REQUIRED, a2, BT_INTEGER, di, REQUIRED);
2309 add_sym_1m ("amax1", GFC_ISYM_MAX, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
2310 gfc_check_min_max_real, gfc_simplify_max, NULL,
2311 a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED);
2313 add_sym_1m ("max1", GFC_ISYM_MAX, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F77,
2314 gfc_check_min_max_real, gfc_simplify_max, NULL,
2315 a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED);
2317 add_sym_1m ("dmax1", GFC_ISYM_MAX, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_F77,
2318 gfc_check_min_max_double, gfc_simplify_max, NULL,
2319 a1, BT_REAL, dd, REQUIRED, a2, BT_REAL, dd, REQUIRED);
2321 make_generic ("max", GFC_ISYM_MAX, GFC_STD_F77);
2323 add_sym_1 ("maxexponent", GFC_ISYM_MAXEXPONENT, CLASS_INQUIRY, ACTUAL_NO, BT_INTEGER, di,
2324 GFC_STD_F95, gfc_check_x, gfc_simplify_maxexponent, NULL,
2325 x, BT_UNKNOWN, dr, REQUIRED);
2327 make_generic ("maxexponent", GFC_ISYM_MAXEXPONENT, GFC_STD_F95);
2329 add_sym_3ml ("maxloc", GFC_ISYM_MAXLOC, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
2330 gfc_check_minloc_maxloc, NULL, gfc_resolve_maxloc,
2331 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
2332 msk, BT_LOGICAL, dl, OPTIONAL);
2334 make_generic ("maxloc", GFC_ISYM_MAXLOC, GFC_STD_F95);
2336 add_sym_3red ("maxval", GFC_ISYM_MAXVAL, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2337 gfc_check_minval_maxval, gfc_simplify_maxval, gfc_resolve_maxval,
2338 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
2339 msk, BT_LOGICAL, dl, OPTIONAL);
2341 make_generic ("maxval", GFC_ISYM_MAXVAL, GFC_STD_F95);
2343 add_sym_0 ("mclock", GFC_ISYM_MCLOCK, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER, di,
2344 GFC_STD_GNU, NULL, NULL, gfc_resolve_mclock);
2346 make_generic ("mclock", GFC_ISYM_MCLOCK, GFC_STD_GNU);
2348 add_sym_0 ("mclock8", GFC_ISYM_MCLOCK8, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
2349 di, GFC_STD_GNU, NULL, NULL, gfc_resolve_mclock8);
2351 make_generic ("mclock8", GFC_ISYM_MCLOCK8, GFC_STD_GNU);
2353 add_sym_3 ("merge", GFC_ISYM_MERGE, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2354 gfc_check_merge, gfc_simplify_merge, gfc_resolve_merge,
2355 ts, BT_REAL, dr, REQUIRED, fs, BT_REAL, dr, REQUIRED,
2356 msk, BT_LOGICAL, dl, REQUIRED);
2358 make_generic ("merge", GFC_ISYM_MERGE, GFC_STD_F95);
2360 add_sym_3 ("merge_bits", GFC_ISYM_MERGE_BITS, CLASS_ELEMENTAL, ACTUAL_NO,
2361 BT_INTEGER, di, GFC_STD_F2008,
2362 gfc_check_merge_bits, gfc_simplify_merge_bits,
2363 gfc_resolve_merge_bits,
2364 i, BT_INTEGER, di, REQUIRED,
2365 j, BT_INTEGER, di, REQUIRED,
2366 msk, BT_INTEGER, di, REQUIRED);
2368 make_generic ("merge_bits", GFC_ISYM_MERGE_BITS, GFC_STD_F2008);
2370 /* Note: amin0 is equivalent to real(min), min1 is equivalent to
2371 int(min). */
2373 add_sym_1m ("min", GFC_ISYM_MIN, CLASS_ELEMENTAL, ACTUAL_NO, BT_UNKNOWN, 0, GFC_STD_F77,
2374 gfc_check_min_max, gfc_simplify_min, gfc_resolve_min,
2375 a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED);
2377 add_sym_1m ("min0", GFC_ISYM_MIN, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F77,
2378 gfc_check_min_max_integer, gfc_simplify_min, NULL,
2379 a1, BT_INTEGER, di, REQUIRED, a2, BT_INTEGER, di, REQUIRED);
2381 add_sym_1m ("amin0", GFC_ISYM_MIN, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
2382 gfc_check_min_max_integer, gfc_simplify_min, NULL,
2383 a1, BT_INTEGER, di, REQUIRED, a2, BT_INTEGER, di, REQUIRED);
2385 add_sym_1m ("amin1", GFC_ISYM_MIN, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
2386 gfc_check_min_max_real, gfc_simplify_min, NULL,
2387 a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED);
2389 add_sym_1m ("min1", GFC_ISYM_MIN, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F77,
2390 gfc_check_min_max_real, gfc_simplify_min, NULL,
2391 a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED);
2393 add_sym_1m ("dmin1", GFC_ISYM_MIN, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_F77,
2394 gfc_check_min_max_double, gfc_simplify_min, NULL,
2395 a1, BT_REAL, dd, REQUIRED, a2, BT_REAL, dd, REQUIRED);
2397 make_generic ("min", GFC_ISYM_MIN, GFC_STD_F77);
2399 add_sym_1 ("minexponent", GFC_ISYM_MINEXPONENT, CLASS_INQUIRY, ACTUAL_NO, BT_INTEGER, di,
2400 GFC_STD_F95, gfc_check_x, gfc_simplify_minexponent, NULL,
2401 x, BT_UNKNOWN, dr, REQUIRED);
2403 make_generic ("minexponent", GFC_ISYM_MINEXPONENT, GFC_STD_F95);
2405 add_sym_3ml ("minloc", GFC_ISYM_MINLOC, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
2406 gfc_check_minloc_maxloc, NULL, gfc_resolve_minloc,
2407 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
2408 msk, BT_LOGICAL, dl, OPTIONAL);
2410 make_generic ("minloc", GFC_ISYM_MINLOC, GFC_STD_F95);
2412 add_sym_3red ("minval", GFC_ISYM_MINVAL, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2413 gfc_check_minval_maxval, gfc_simplify_minval, gfc_resolve_minval,
2414 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
2415 msk, BT_LOGICAL, dl, OPTIONAL);
2417 make_generic ("minval", GFC_ISYM_MINVAL, GFC_STD_F95);
2419 add_sym_2 ("mod", GFC_ISYM_MOD, CLASS_ELEMENTAL, ACTUAL_YES, BT_INTEGER, di, GFC_STD_F77,
2420 gfc_check_a_p, gfc_simplify_mod, gfc_resolve_mod,
2421 a, BT_INTEGER, di, REQUIRED, p, BT_INTEGER, di, REQUIRED);
2423 add_sym_2 ("amod", GFC_ISYM_MOD, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
2424 NULL, gfc_simplify_mod, gfc_resolve_mod,
2425 a, BT_REAL, dr, REQUIRED, p, BT_REAL, dr, REQUIRED);
2427 add_sym_2 ("dmod", GFC_ISYM_MOD, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
2428 gfc_check_x_yd, gfc_simplify_mod, gfc_resolve_mod,
2429 a, BT_REAL, dd, REQUIRED, p, BT_REAL, dd, REQUIRED);
2431 make_generic ("mod", GFC_ISYM_MOD, GFC_STD_F77);
2433 add_sym_2 ("modulo", GFC_ISYM_MODULO, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, di, GFC_STD_F95,
2434 gfc_check_a_p, gfc_simplify_modulo, gfc_resolve_modulo,
2435 a, BT_REAL, di, REQUIRED, p, BT_REAL, di, REQUIRED);
2437 make_generic ("modulo", GFC_ISYM_MODULO, GFC_STD_F95);
2439 add_sym_2 ("nearest", GFC_ISYM_NEAREST, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2440 gfc_check_nearest, gfc_simplify_nearest, gfc_resolve_nearest,
2441 x, BT_REAL, dr, REQUIRED, s, BT_REAL, dr, REQUIRED);
2443 make_generic ("nearest", GFC_ISYM_NEAREST, GFC_STD_F95);
2445 add_sym_1 ("new_line", GFC_ISYM_NEW_LINE, CLASS_INQUIRY, ACTUAL_NO, BT_CHARACTER, dc,
2446 GFC_STD_F2003, gfc_check_new_line, gfc_simplify_new_line, NULL,
2447 a, BT_CHARACTER, dc, REQUIRED);
2449 make_generic ("new_line", GFC_ISYM_NEW_LINE, GFC_STD_F2003);
2451 add_sym_2 ("nint", GFC_ISYM_NINT, CLASS_ELEMENTAL, ACTUAL_YES, BT_INTEGER, di, GFC_STD_F77,
2452 gfc_check_a_ikind, gfc_simplify_nint, gfc_resolve_nint,
2453 a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
2455 add_sym_1 ("idnint", GFC_ISYM_NINT, CLASS_ELEMENTAL, ACTUAL_YES, BT_INTEGER, di, GFC_STD_F77,
2456 gfc_check_idnint, gfc_simplify_idnint, gfc_resolve_idnint,
2457 a, BT_REAL, dd, REQUIRED);
2459 make_generic ("nint", GFC_ISYM_NINT, GFC_STD_F77);
2461 add_sym_1 ("not", GFC_ISYM_NOT, CLASS_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
2462 gfc_check_i, gfc_simplify_not, gfc_resolve_not,
2463 i, BT_INTEGER, di, REQUIRED);
2465 make_generic ("not", GFC_ISYM_NOT, GFC_STD_F95);
2467 add_sym_2 ("norm2", GFC_ISYM_NORM2, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr,
2468 GFC_STD_F2008, gfc_check_norm2, gfc_simplify_norm2, gfc_resolve_norm2,
2469 x, BT_REAL, dr, REQUIRED,
2470 dm, BT_INTEGER, ii, OPTIONAL);
2472 make_generic ("norm2", GFC_ISYM_NORM2, GFC_STD_F2008);
2474 add_sym_1 ("null", GFC_ISYM_NULL, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
2475 gfc_check_null, gfc_simplify_null, NULL,
2476 mo, BT_INTEGER, di, OPTIONAL);
2478 make_generic ("null", GFC_ISYM_NULL, GFC_STD_F95);
2480 add_sym_2 ("num_images", GFC_ISYM_NUM_IMAGES, CLASS_INQUIRY, ACTUAL_NO,
2481 BT_INTEGER, di, GFC_STD_F2008,
2482 gfc_check_num_images, gfc_simplify_num_images, NULL,
2483 dist, BT_INTEGER, di, OPTIONAL,
2484 failed, BT_LOGICAL, dl, OPTIONAL);
2486 add_sym_3 ("pack", GFC_ISYM_PACK, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2487 gfc_check_pack, gfc_simplify_pack, gfc_resolve_pack,
2488 ar, BT_REAL, dr, REQUIRED, msk, BT_LOGICAL, dl, REQUIRED,
2489 v, BT_REAL, dr, OPTIONAL);
2491 make_generic ("pack", GFC_ISYM_PACK, GFC_STD_F95);
2494 add_sym_2 ("parity", GFC_ISYM_PARITY, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_LOGICAL, dl,
2495 GFC_STD_F2008, gfc_check_parity, gfc_simplify_parity, gfc_resolve_parity,
2496 msk, BT_LOGICAL, dl, REQUIRED,
2497 dm, BT_INTEGER, ii, OPTIONAL);
2499 make_generic ("parity", GFC_ISYM_PARITY, GFC_STD_F2008);
2501 add_sym_1 ("popcnt", GFC_ISYM_POPCNT, CLASS_ELEMENTAL, ACTUAL_NO,
2502 BT_INTEGER, di, GFC_STD_F2008,
2503 gfc_check_i, gfc_simplify_popcnt, NULL,
2504 i, BT_INTEGER, di, REQUIRED);
2506 make_generic ("popcnt", GFC_ISYM_POPCNT, GFC_STD_F2008);
2508 add_sym_1 ("poppar", GFC_ISYM_POPPAR, CLASS_ELEMENTAL, ACTUAL_NO,
2509 BT_INTEGER, di, GFC_STD_F2008,
2510 gfc_check_i, gfc_simplify_poppar, NULL,
2511 i, BT_INTEGER, di, REQUIRED);
2513 make_generic ("poppar", GFC_ISYM_POPPAR, GFC_STD_F2008);
2515 add_sym_1 ("precision", GFC_ISYM_PRECISION, CLASS_INQUIRY, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
2516 gfc_check_precision, gfc_simplify_precision, NULL,
2517 x, BT_UNKNOWN, 0, REQUIRED);
2519 make_generic ("precision", GFC_ISYM_PRECISION, GFC_STD_F95);
2521 add_sym_1_intent ("present", GFC_ISYM_PRESENT, CLASS_INQUIRY, ACTUAL_NO,
2522 BT_LOGICAL, dl, GFC_STD_F95, gfc_check_present, NULL, NULL,
2523 a, BT_REAL, dr, REQUIRED, INTENT_UNKNOWN);
2525 make_generic ("present", GFC_ISYM_PRESENT, GFC_STD_F95);
2527 add_sym_3red ("product", GFC_ISYM_PRODUCT, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2528 gfc_check_product_sum, gfc_simplify_product, gfc_resolve_product,
2529 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
2530 msk, BT_LOGICAL, dl, OPTIONAL);
2532 make_generic ("product", GFC_ISYM_PRODUCT, GFC_STD_F95);
2534 add_sym_1 ("radix", GFC_ISYM_RADIX, CLASS_INQUIRY, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
2535 gfc_check_radix, gfc_simplify_radix, NULL,
2536 x, BT_UNKNOWN, 0, REQUIRED);
2538 make_generic ("radix", GFC_ISYM_RADIX, GFC_STD_F95);
2540 /* The following function is for G77 compatibility. */
2541 add_sym_1 ("rand", GFC_ISYM_RAND, CLASS_IMPURE, ACTUAL_NO, BT_REAL,
2542 4, GFC_STD_GNU, gfc_check_rand, NULL, NULL,
2543 i, BT_INTEGER, 4, OPTIONAL);
2545 /* Compatibility with HP FORTRAN 77/iX Reference. Note, rand() and ran()
2546 use slightly different shoddy multiplicative congruential PRNG. */
2547 make_alias ("ran", GFC_STD_GNU);
2549 make_generic ("rand", GFC_ISYM_RAND, GFC_STD_GNU);
2551 add_sym_1 ("range", GFC_ISYM_RANGE, CLASS_INQUIRY, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
2552 gfc_check_range, gfc_simplify_range, NULL,
2553 x, BT_REAL, dr, REQUIRED);
2555 make_generic ("range", GFC_ISYM_RANGE, GFC_STD_F95);
2557 add_sym_1 ("rank", GFC_ISYM_RANK, CLASS_INQUIRY, ACTUAL_NO, BT_INTEGER, di,
2558 GFC_STD_F2008_TS, gfc_check_rank, gfc_simplify_rank, gfc_resolve_rank,
2559 a, BT_REAL, dr, REQUIRED);
2560 make_generic ("rank", GFC_ISYM_RANK, GFC_STD_F2008_TS);
2562 add_sym_2 ("real", GFC_ISYM_REAL, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
2563 gfc_check_real, gfc_simplify_real, gfc_resolve_real,
2564 a, BT_UNKNOWN, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
2566 /* This provides compatibility with g77. */
2567 add_sym_1 ("realpart", GFC_ISYM_REAL, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
2568 gfc_check_fn_c, gfc_simplify_realpart, gfc_resolve_realpart,
2569 a, BT_UNKNOWN, dr, REQUIRED);
2571 add_sym_1 ("float", GFC_ISYM_REAL, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
2572 gfc_check_float, gfc_simplify_float, NULL,
2573 a, BT_INTEGER, di, REQUIRED);
2575 add_sym_1 ("dfloat", GFC_ISYM_REAL, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
2576 gfc_check_float, gfc_simplify_dble, gfc_resolve_dble,
2577 a, BT_REAL, dr, REQUIRED);
2579 add_sym_1 ("sngl", GFC_ISYM_REAL, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
2580 gfc_check_sngl, gfc_simplify_sngl, NULL,
2581 a, BT_REAL, dd, REQUIRED);
2583 make_generic ("real", GFC_ISYM_REAL, GFC_STD_F77);
2585 add_sym_2 ("rename", GFC_ISYM_RENAME, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER, di,
2586 GFC_STD_GNU, gfc_check_rename, NULL, gfc_resolve_rename,
2587 p1, BT_CHARACTER, dc, REQUIRED, p2, BT_CHARACTER, dc, REQUIRED);
2589 make_generic ("rename", GFC_ISYM_RENAME, GFC_STD_GNU);
2591 add_sym_2 ("repeat", GFC_ISYM_REPEAT, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_CHARACTER, dc, GFC_STD_F95,
2592 gfc_check_repeat, gfc_simplify_repeat, gfc_resolve_repeat,
2593 stg, BT_CHARACTER, dc, REQUIRED, ncopies, BT_INTEGER, di, REQUIRED);
2595 make_generic ("repeat", GFC_ISYM_REPEAT, GFC_STD_F95);
2597 add_sym_4 ("reshape", GFC_ISYM_RESHAPE, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2598 gfc_check_reshape, gfc_simplify_reshape, gfc_resolve_reshape,
2599 src, BT_REAL, dr, REQUIRED, shp, BT_INTEGER, ii, REQUIRED,
2600 pad, BT_REAL, dr, OPTIONAL, ord, BT_INTEGER, ii, OPTIONAL);
2602 make_generic ("reshape", GFC_ISYM_RESHAPE, GFC_STD_F95);
2604 add_sym_1 ("rrspacing", GFC_ISYM_RRSPACING, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2605 gfc_check_x, gfc_simplify_rrspacing, gfc_resolve_rrspacing,
2606 x, BT_REAL, dr, REQUIRED);
2608 make_generic ("rrspacing", GFC_ISYM_RRSPACING, GFC_STD_F95);
2610 add_sym_2 ("same_type_as", GFC_ISYM_SAME_TYPE_AS, CLASS_INQUIRY, ACTUAL_NO,
2611 BT_LOGICAL, dl, GFC_STD_F2003,
2612 gfc_check_same_type_as, gfc_simplify_same_type_as, NULL,
2613 a, BT_UNKNOWN, 0, REQUIRED,
2614 b, BT_UNKNOWN, 0, REQUIRED);
2616 add_sym_2 ("scale", GFC_ISYM_SCALE, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2617 gfc_check_scale, gfc_simplify_scale, gfc_resolve_scale,
2618 x, BT_REAL, dr, REQUIRED, i, BT_INTEGER, di, REQUIRED);
2620 make_generic ("scale", GFC_ISYM_SCALE, GFC_STD_F95);
2622 add_sym_4 ("scan", GFC_ISYM_SCAN, CLASS_ELEMENTAL, ACTUAL_NO,
2623 BT_INTEGER, di, GFC_STD_F95,
2624 gfc_check_scan, gfc_simplify_scan, gfc_resolve_scan,
2625 stg, BT_CHARACTER, dc, REQUIRED, set, BT_CHARACTER, dc, REQUIRED,
2626 bck, BT_LOGICAL, dl, OPTIONAL, kind, BT_INTEGER, di, OPTIONAL);
2628 make_generic ("scan", GFC_ISYM_SCAN, GFC_STD_F95);
2630 /* Added for G77 compatibility garbage. */
2631 add_sym_0 ("second", GFC_ISYM_SECOND, CLASS_IMPURE, ACTUAL_NO, BT_REAL,
2632 4, GFC_STD_GNU, NULL, NULL, NULL);
2634 make_generic ("second", GFC_ISYM_SECOND, GFC_STD_GNU);
2636 /* Added for G77 compatibility. */
2637 add_sym_1 ("secnds", GFC_ISYM_SECNDS, CLASS_IMPURE, ACTUAL_NO, BT_REAL,
2638 dr, GFC_STD_GNU, gfc_check_secnds, NULL, gfc_resolve_secnds,
2639 x, BT_REAL, dr, REQUIRED);
2641 make_generic ("secnds", GFC_ISYM_SECNDS, GFC_STD_GNU);
2643 add_sym_1 ("selected_char_kind", GFC_ISYM_SC_KIND, CLASS_TRANSFORMATIONAL,
2644 ACTUAL_NO, BT_INTEGER, di, GFC_STD_F2003,
2645 gfc_check_selected_char_kind, gfc_simplify_selected_char_kind,
2646 NULL, nm, BT_CHARACTER, dc, REQUIRED);
2648 make_generic ("selected_char_kind", GFC_ISYM_SC_KIND, GFC_STD_F2003);
2650 add_sym_1 ("selected_int_kind", GFC_ISYM_SI_KIND, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_INTEGER, di,
2651 GFC_STD_F95, gfc_check_selected_int_kind,
2652 gfc_simplify_selected_int_kind, NULL, r, BT_INTEGER, di, REQUIRED);
2654 make_generic ("selected_int_kind", GFC_ISYM_SI_KIND, GFC_STD_F95);
2656 add_sym_3 ("selected_real_kind", GFC_ISYM_SR_KIND, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_INTEGER, di,
2657 GFC_STD_F95, gfc_check_selected_real_kind,
2658 gfc_simplify_selected_real_kind, NULL,
2659 p, BT_INTEGER, di, OPTIONAL, r, BT_INTEGER, di, OPTIONAL,
2660 "radix", BT_INTEGER, di, OPTIONAL);
2662 make_generic ("selected_real_kind", GFC_ISYM_SR_KIND, GFC_STD_F95);
2664 add_sym_2 ("set_exponent", GFC_ISYM_SET_EXPONENT, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2665 gfc_check_set_exponent, gfc_simplify_set_exponent,
2666 gfc_resolve_set_exponent,
2667 x, BT_REAL, dr, REQUIRED, i, BT_INTEGER, di, REQUIRED);
2669 make_generic ("set_exponent", GFC_ISYM_SET_EXPONENT, GFC_STD_F95);
2671 add_sym_2 ("shape", GFC_ISYM_SHAPE, CLASS_INQUIRY, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
2672 gfc_check_shape, gfc_simplify_shape, gfc_resolve_shape,
2673 src, BT_REAL, dr, REQUIRED,
2674 kind, BT_INTEGER, di, OPTIONAL);
2676 make_generic ("shape", GFC_ISYM_SHAPE, GFC_STD_F95);
2678 add_sym_2 ("shifta", GFC_ISYM_SHIFTA, CLASS_ELEMENTAL, ACTUAL_NO,
2679 BT_INTEGER, di, GFC_STD_F2008,
2680 gfc_check_shift, gfc_simplify_shifta, gfc_resolve_shift,
2681 i, BT_INTEGER, di, REQUIRED,
2682 sh, BT_INTEGER, di, REQUIRED);
2684 make_generic ("shifta", GFC_ISYM_SHIFTA, GFC_STD_F2008);
2686 add_sym_2 ("shiftl", GFC_ISYM_SHIFTL, CLASS_ELEMENTAL, ACTUAL_NO,
2687 BT_INTEGER, di, GFC_STD_F2008,
2688 gfc_check_shift, gfc_simplify_shiftl, gfc_resolve_shift,
2689 i, BT_INTEGER, di, REQUIRED,
2690 sh, BT_INTEGER, di, REQUIRED);
2692 make_generic ("shiftl", GFC_ISYM_SHIFTL, GFC_STD_F2008);
2694 add_sym_2 ("shiftr", GFC_ISYM_SHIFTR, CLASS_ELEMENTAL, ACTUAL_NO,
2695 BT_INTEGER, di, GFC_STD_F2008,
2696 gfc_check_shift, gfc_simplify_shiftr, gfc_resolve_shift,
2697 i, BT_INTEGER, di, REQUIRED,
2698 sh, BT_INTEGER, di, REQUIRED);
2700 make_generic ("shiftr", GFC_ISYM_SHIFTR, GFC_STD_F2008);
2702 add_sym_2 ("sign", GFC_ISYM_SIGN, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
2703 gfc_check_sign, gfc_simplify_sign, gfc_resolve_sign,
2704 a, BT_REAL, dr, REQUIRED, b, BT_REAL, dr, REQUIRED);
2706 add_sym_2 ("isign", GFC_ISYM_SIGN, CLASS_ELEMENTAL, ACTUAL_YES, BT_INTEGER, di, GFC_STD_F77,
2707 NULL, gfc_simplify_sign, gfc_resolve_sign,
2708 a, BT_INTEGER, di, REQUIRED, b, BT_INTEGER, di, REQUIRED);
2710 add_sym_2 ("dsign", GFC_ISYM_SIGN, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
2711 gfc_check_x_yd, gfc_simplify_sign, gfc_resolve_sign,
2712 a, BT_REAL, dd, REQUIRED, b, BT_REAL, dd, REQUIRED);
2714 make_generic ("sign", GFC_ISYM_SIGN, GFC_STD_F77);
2716 add_sym_2 ("signal", GFC_ISYM_SIGNAL, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
2717 di, GFC_STD_GNU, gfc_check_signal, NULL, gfc_resolve_signal,
2718 num, BT_INTEGER, di, REQUIRED, han, BT_VOID, 0, REQUIRED);
2720 make_generic ("signal", GFC_ISYM_SIGNAL, GFC_STD_GNU);
2722 add_sym_1 ("sin", GFC_ISYM_SIN, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
2723 gfc_check_fn_rc, gfc_simplify_sin, gfc_resolve_sin,
2724 x, BT_REAL, dr, REQUIRED);
2726 add_sym_1 ("dsin", GFC_ISYM_SIN, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
2727 gfc_check_fn_d, gfc_simplify_sin, gfc_resolve_sin,
2728 x, BT_REAL, dd, REQUIRED);
2730 add_sym_1 ("csin", GFC_ISYM_SIN, CLASS_ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dz, GFC_STD_F77,
2731 NULL, gfc_simplify_sin, gfc_resolve_sin,
2732 x, BT_COMPLEX, dz, REQUIRED);
2734 add_sym_1 ("zsin", GFC_ISYM_SIN, CLASS_ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dd, GFC_STD_GNU,
2735 NULL, gfc_simplify_sin, gfc_resolve_sin,
2736 x, BT_COMPLEX, dd, REQUIRED);
2738 make_alias ("cdsin", GFC_STD_GNU);
2740 make_generic ("sin", GFC_ISYM_SIN, GFC_STD_F77);
2742 add_sym_1 ("sinh", GFC_ISYM_SINH, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
2743 gfc_check_fn_rc2008, gfc_simplify_sinh, gfc_resolve_sinh,
2744 x, BT_REAL, dr, REQUIRED);
2746 add_sym_1 ("dsinh", GFC_ISYM_SINH,CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
2747 gfc_check_fn_d, gfc_simplify_sinh, gfc_resolve_sinh,
2748 x, BT_REAL, dd, REQUIRED);
2750 make_generic ("sinh", GFC_ISYM_SINH, GFC_STD_F77);
2752 add_sym_3 ("size", GFC_ISYM_SIZE, CLASS_INQUIRY, ACTUAL_NO,
2753 BT_INTEGER, di, GFC_STD_F95,
2754 gfc_check_size, gfc_simplify_size, gfc_resolve_size,
2755 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
2756 kind, BT_INTEGER, di, OPTIONAL);
2758 make_generic ("size", GFC_ISYM_SIZE, GFC_STD_F95);
2760 /* Obtain the stride for a given dimensions; to be used only internally.
2761 "make_from_module" makes it inaccessible for external users. */
2762 add_sym_2 (GFC_PREFIX ("stride"), GFC_ISYM_STRIDE, CLASS_INQUIRY, ACTUAL_NO,
2763 BT_INTEGER, gfc_index_integer_kind, GFC_STD_GNU,
2764 NULL, NULL, gfc_resolve_stride,
2765 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL);
2766 make_from_module();
2768 add_sym_1 ("sizeof", GFC_ISYM_SIZEOF, CLASS_INQUIRY, ACTUAL_NO,
2769 BT_INTEGER, ii, GFC_STD_GNU,
2770 gfc_check_sizeof, gfc_simplify_sizeof, NULL,
2771 x, BT_UNKNOWN, 0, REQUIRED);
2773 make_generic ("sizeof", GFC_ISYM_SIZEOF, GFC_STD_GNU);
2775 /* The following functions are part of ISO_C_BINDING. */
2776 add_sym_2 ("c_associated", GFC_ISYM_C_ASSOCIATED, CLASS_INQUIRY, ACTUAL_NO,
2777 BT_LOGICAL, dl, GFC_STD_F2003, gfc_check_c_associated, NULL, NULL,
2778 "C_PTR_1", BT_VOID, 0, REQUIRED,
2779 "C_PTR_2", BT_VOID, 0, OPTIONAL);
2780 make_from_module();
2782 add_sym_1 ("c_loc", GFC_ISYM_C_LOC, CLASS_INQUIRY, ACTUAL_NO,
2783 BT_VOID, 0, GFC_STD_F2003,
2784 gfc_check_c_loc, NULL, gfc_resolve_c_loc,
2785 x, BT_UNKNOWN, 0, REQUIRED);
2786 make_from_module();
2788 add_sym_1 ("c_funloc", GFC_ISYM_C_FUNLOC, CLASS_INQUIRY, ACTUAL_NO,
2789 BT_VOID, 0, GFC_STD_F2003,
2790 gfc_check_c_funloc, NULL, gfc_resolve_c_funloc,
2791 x, BT_UNKNOWN, 0, REQUIRED);
2792 make_from_module();
2794 add_sym_1 ("c_sizeof", GFC_ISYM_C_SIZEOF, CLASS_INQUIRY, ACTUAL_NO,
2795 BT_INTEGER, gfc_index_integer_kind, GFC_STD_F2008,
2796 gfc_check_c_sizeof, gfc_simplify_sizeof, NULL,
2797 x, BT_UNKNOWN, 0, REQUIRED);
2798 make_from_module();
2800 /* COMPILER_OPTIONS and COMPILER_VERSION are part of ISO_FORTRAN_ENV. */
2801 add_sym_0 ("compiler_options", GFC_ISYM_COMPILER_OPTIONS, CLASS_INQUIRY,
2802 ACTUAL_NO, BT_CHARACTER, dc, GFC_STD_F2008,
2803 NULL, gfc_simplify_compiler_options, NULL);
2804 make_from_module();
2806 add_sym_0 ("compiler_version", GFC_ISYM_COMPILER_VERSION, CLASS_INQUIRY,
2807 ACTUAL_NO, BT_CHARACTER, dc, GFC_STD_F2008,
2808 NULL, gfc_simplify_compiler_version, NULL);
2809 make_from_module();
2811 add_sym_1 ("spacing", GFC_ISYM_SPACING, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2812 gfc_check_x, gfc_simplify_spacing, gfc_resolve_spacing,
2813 x, BT_REAL, dr, REQUIRED);
2815 make_generic ("spacing", GFC_ISYM_SPACING, GFC_STD_F95);
2817 add_sym_3 ("spread", GFC_ISYM_SPREAD, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2818 gfc_check_spread, gfc_simplify_spread, gfc_resolve_spread,
2819 src, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, REQUIRED,
2820 ncopies, BT_INTEGER, di, REQUIRED);
2822 make_generic ("spread", GFC_ISYM_SPREAD, GFC_STD_F95);
2824 add_sym_1 ("sqrt", GFC_ISYM_SQRT, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
2825 gfc_check_fn_rc, gfc_simplify_sqrt, gfc_resolve_sqrt,
2826 x, BT_REAL, dr, REQUIRED);
2828 add_sym_1 ("dsqrt", GFC_ISYM_SQRT, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
2829 gfc_check_fn_d, gfc_simplify_sqrt, gfc_resolve_sqrt,
2830 x, BT_REAL, dd, REQUIRED);
2832 add_sym_1 ("csqrt", GFC_ISYM_SQRT, CLASS_ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dz, GFC_STD_F77,
2833 NULL, gfc_simplify_sqrt, gfc_resolve_sqrt,
2834 x, BT_COMPLEX, dz, REQUIRED);
2836 add_sym_1 ("zsqrt", GFC_ISYM_SQRT, CLASS_ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dd, GFC_STD_GNU,
2837 NULL, gfc_simplify_sqrt, gfc_resolve_sqrt,
2838 x, BT_COMPLEX, dd, REQUIRED);
2840 make_alias ("cdsqrt", GFC_STD_GNU);
2842 make_generic ("sqrt", GFC_ISYM_SQRT, GFC_STD_F77);
2844 add_sym_2_intent ("stat", GFC_ISYM_STAT, CLASS_IMPURE, ACTUAL_NO,
2845 BT_INTEGER, di, GFC_STD_GNU,
2846 gfc_check_stat, NULL, gfc_resolve_stat,
2847 nm, BT_CHARACTER, dc, REQUIRED, INTENT_IN,
2848 vl, BT_INTEGER, di, REQUIRED, INTENT_OUT);
2850 make_generic ("stat", GFC_ISYM_STAT, GFC_STD_GNU);
2852 add_sym_2 ("storage_size", GFC_ISYM_STORAGE_SIZE, CLASS_INQUIRY, ACTUAL_NO,
2853 BT_INTEGER, di, GFC_STD_F2008,
2854 gfc_check_storage_size, gfc_simplify_storage_size,
2855 gfc_resolve_storage_size,
2856 a, BT_UNKNOWN, 0, REQUIRED,
2857 kind, BT_INTEGER, di, OPTIONAL);
2859 add_sym_3red ("sum", GFC_ISYM_SUM, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2860 gfc_check_product_sum, gfc_simplify_sum, gfc_resolve_sum,
2861 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
2862 msk, BT_LOGICAL, dl, OPTIONAL);
2864 make_generic ("sum", GFC_ISYM_SUM, GFC_STD_F95);
2866 add_sym_2 ("symlnk", GFC_ISYM_SYMLNK, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER, di,
2867 GFC_STD_GNU, gfc_check_symlnk, NULL, gfc_resolve_symlnk,
2868 p1, BT_CHARACTER, dc, REQUIRED, p2, BT_CHARACTER, dc, REQUIRED);
2870 make_generic ("symlnk", GFC_ISYM_SYMLNK, GFC_STD_GNU);
2872 add_sym_1 ("system", GFC_ISYM_SYSTEM, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER, di,
2873 GFC_STD_GNU, NULL, NULL, NULL,
2874 com, BT_CHARACTER, dc, REQUIRED);
2876 make_generic ("system", GFC_ISYM_SYSTEM, GFC_STD_GNU);
2878 add_sym_1 ("tan", GFC_ISYM_TAN, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
2879 gfc_check_fn_rc2008, gfc_simplify_tan, gfc_resolve_tan,
2880 x, BT_REAL, dr, REQUIRED);
2882 add_sym_1 ("dtan", GFC_ISYM_TAN, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
2883 gfc_check_fn_d, gfc_simplify_tan, gfc_resolve_tan,
2884 x, BT_REAL, dd, REQUIRED);
2886 make_generic ("tan", GFC_ISYM_TAN, GFC_STD_F77);
2888 add_sym_1 ("tanh", GFC_ISYM_TANH, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
2889 gfc_check_fn_rc2008, gfc_simplify_tanh, gfc_resolve_tanh,
2890 x, BT_REAL, dr, REQUIRED);
2892 add_sym_1 ("dtanh", GFC_ISYM_TANH, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
2893 gfc_check_fn_d, gfc_simplify_tanh, gfc_resolve_tanh,
2894 x, BT_REAL, dd, REQUIRED);
2896 make_generic ("tanh", GFC_ISYM_TANH, GFC_STD_F77);
2898 add_sym_3 ("this_image", GFC_ISYM_THIS_IMAGE, CLASS_INQUIRY, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F2008,
2899 gfc_check_this_image, gfc_simplify_this_image, gfc_resolve_this_image,
2900 ca, BT_REAL, dr, OPTIONAL, dm, BT_INTEGER, ii, OPTIONAL,
2901 dist, BT_INTEGER, di, OPTIONAL);
2903 add_sym_0 ("time", GFC_ISYM_TIME, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
2904 di, GFC_STD_GNU, NULL, NULL, gfc_resolve_time);
2906 make_generic ("time", GFC_ISYM_TIME, GFC_STD_GNU);
2908 add_sym_0 ("time8", GFC_ISYM_TIME8, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
2909 di, GFC_STD_GNU, NULL, NULL, gfc_resolve_time8);
2911 make_generic ("time8", GFC_ISYM_TIME8, GFC_STD_GNU);
2913 add_sym_1 ("tiny", GFC_ISYM_TINY, CLASS_INQUIRY, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2914 gfc_check_x, gfc_simplify_tiny, NULL,
2915 x, BT_REAL, dr, REQUIRED);
2917 make_generic ("tiny", GFC_ISYM_TINY, GFC_STD_F95);
2919 add_sym_1 ("trailz", GFC_ISYM_TRAILZ, CLASS_ELEMENTAL, ACTUAL_NO,
2920 BT_INTEGER, di, GFC_STD_F2008,
2921 gfc_check_i, gfc_simplify_trailz, NULL,
2922 i, BT_INTEGER, di, REQUIRED);
2924 make_generic ("trailz", GFC_ISYM_TRAILZ, GFC_STD_F2008);
2926 add_sym_3 ("transfer", GFC_ISYM_TRANSFER, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2927 gfc_check_transfer, gfc_simplify_transfer, gfc_resolve_transfer,
2928 src, BT_REAL, dr, REQUIRED, mo, BT_REAL, dr, REQUIRED,
2929 sz, BT_INTEGER, di, OPTIONAL);
2931 make_generic ("transfer", GFC_ISYM_TRANSFER, GFC_STD_F95);
2933 add_sym_1 ("transpose", GFC_ISYM_TRANSPOSE, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2934 gfc_check_transpose, gfc_simplify_transpose, gfc_resolve_transpose,
2935 m, BT_REAL, dr, REQUIRED);
2937 make_generic ("transpose", GFC_ISYM_TRANSPOSE, GFC_STD_F95);
2939 add_sym_1 ("trim", GFC_ISYM_TRIM, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_CHARACTER, dc, GFC_STD_F95,
2940 gfc_check_trim, gfc_simplify_trim, gfc_resolve_trim,
2941 stg, BT_CHARACTER, dc, REQUIRED);
2943 make_generic ("trim", GFC_ISYM_TRIM, GFC_STD_F95);
2945 add_sym_1 ("ttynam", GFC_ISYM_TTYNAM, CLASS_IMPURE, ACTUAL_NO, BT_CHARACTER,
2946 0, GFC_STD_GNU, gfc_check_ttynam, NULL, gfc_resolve_ttynam,
2947 ut, BT_INTEGER, di, REQUIRED);
2949 make_generic ("ttynam", GFC_ISYM_TTYNAM, GFC_STD_GNU);
2951 add_sym_3 ("ubound", GFC_ISYM_UBOUND, CLASS_INQUIRY, ACTUAL_NO,
2952 BT_INTEGER, di, GFC_STD_F95,
2953 gfc_check_ubound, gfc_simplify_ubound, gfc_resolve_ubound,
2954 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
2955 kind, BT_INTEGER, di, OPTIONAL);
2957 make_generic ("ubound", GFC_ISYM_UBOUND, GFC_STD_F95);
2959 add_sym_3 ("ucobound", GFC_ISYM_UCOBOUND, CLASS_INQUIRY, ACTUAL_NO,
2960 BT_INTEGER, di, GFC_STD_F2008,
2961 gfc_check_ucobound, gfc_simplify_ucobound, gfc_resolve_ucobound,
2962 ca, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
2963 kind, BT_INTEGER, di, OPTIONAL);
2965 make_generic ("ucobound", GFC_ISYM_UCOBOUND, GFC_STD_F2008);
2967 /* g77 compatibility for UMASK. */
2968 add_sym_1 ("umask", GFC_ISYM_UMASK, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER, di,
2969 GFC_STD_GNU, gfc_check_umask, NULL, gfc_resolve_umask,
2970 msk, BT_INTEGER, di, REQUIRED);
2972 make_generic ("umask", GFC_ISYM_UMASK, GFC_STD_GNU);
2974 /* g77 compatibility for UNLINK. */
2975 add_sym_1 ("unlink", GFC_ISYM_UNLINK, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
2976 di, GFC_STD_GNU, gfc_check_unlink, NULL, gfc_resolve_unlink,
2977 "path", BT_CHARACTER, dc, REQUIRED);
2979 make_generic ("unlink", GFC_ISYM_UNLINK, GFC_STD_GNU);
2981 add_sym_3 ("unpack", GFC_ISYM_UNPACK, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2982 gfc_check_unpack, gfc_simplify_unpack, gfc_resolve_unpack,
2983 v, BT_REAL, dr, REQUIRED, msk, BT_LOGICAL, dl, REQUIRED,
2984 f, BT_REAL, dr, REQUIRED);
2986 make_generic ("unpack", GFC_ISYM_UNPACK, GFC_STD_F95);
2988 add_sym_4 ("verify", GFC_ISYM_VERIFY, CLASS_ELEMENTAL, ACTUAL_NO,
2989 BT_INTEGER, di, GFC_STD_F95,
2990 gfc_check_verify, gfc_simplify_verify, gfc_resolve_verify,
2991 stg, BT_CHARACTER, dc, REQUIRED, set, BT_CHARACTER, dc, REQUIRED,
2992 bck, BT_LOGICAL, dl, OPTIONAL, kind, BT_INTEGER, di, OPTIONAL);
2994 make_generic ("verify", GFC_ISYM_VERIFY, GFC_STD_F95);
2996 add_sym_1 ("loc", GFC_ISYM_LOC, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER, ii,
2997 GFC_STD_GNU, gfc_check_loc, NULL, gfc_resolve_loc,
2998 x, BT_UNKNOWN, 0, REQUIRED);
3000 make_generic ("loc", GFC_ISYM_LOC, GFC_STD_GNU);
3002 /* The following function is internally used for coarray libray functions.
3003 "make_from_module" makes it inaccessible for external users. */
3004 add_sym_1 (GFC_PREFIX ("caf_get"), GFC_ISYM_CAF_GET, CLASS_IMPURE, ACTUAL_NO,
3005 BT_REAL, dr, GFC_STD_GNU, NULL, NULL, NULL,
3006 x, BT_REAL, dr, REQUIRED);
3007 make_from_module();
3011 /* Add intrinsic subroutines. */
3013 static void
3014 add_subroutines (void)
3016 /* Argument names as in the standard (to be used as argument keywords). */
3017 const char
3018 *a = "a", *h = "harvest", *dt = "date", *vl = "values", *pt = "put",
3019 *c = "count", *tm = "time", *tp = "topos", *gt = "get",
3020 *t = "to", *zn = "zone", *fp = "frompos", *cm = "count_max",
3021 *f = "from", *sz = "size", *ln = "len", *cr = "count_rate",
3022 *com = "command", *length = "length", *st = "status",
3023 *val = "value", *num = "number", *name = "name",
3024 *trim_name = "trim_name", *ut = "unit", *han = "handler",
3025 *sec = "seconds", *res = "result", *of = "offset", *md = "mode",
3026 *whence = "whence", *pos = "pos", *ptr = "ptr", *p1 = "path1",
3027 *p2 = "path2", *msk = "mask", *old = "old", *result_image = "result_image",
3028 *stat = "stat", *errmsg = "errmsg";
3030 int di, dr, dc, dl, ii;
3032 di = gfc_default_integer_kind;
3033 dr = gfc_default_real_kind;
3034 dc = gfc_default_character_kind;
3035 dl = gfc_default_logical_kind;
3036 ii = gfc_index_integer_kind;
3038 add_sym_0s ("abort", GFC_ISYM_ABORT, GFC_STD_GNU, NULL);
3040 make_noreturn();
3042 add_sym_3s ("atomic_define", GFC_ISYM_ATOMIC_DEF, CLASS_ATOMIC,
3043 BT_UNKNOWN, 0, GFC_STD_F2008,
3044 gfc_check_atomic_def, NULL, gfc_resolve_atomic_def,
3045 "atom", BT_INTEGER, di, REQUIRED, INTENT_OUT,
3046 "value", BT_INTEGER, di, REQUIRED, INTENT_IN,
3047 stat, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3049 add_sym_3s ("atomic_ref", GFC_ISYM_ATOMIC_REF, CLASS_ATOMIC,
3050 BT_UNKNOWN, 0, GFC_STD_F2008,
3051 gfc_check_atomic_ref, NULL, gfc_resolve_atomic_ref,
3052 "value", BT_INTEGER, di, REQUIRED, INTENT_OUT,
3053 "atom", BT_INTEGER, di, REQUIRED, INTENT_IN,
3054 stat, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3056 add_sym_5s ("atomic_cas", GFC_ISYM_ATOMIC_CAS, CLASS_ATOMIC,
3057 BT_UNKNOWN, 0, GFC_STD_F2008_TS,
3058 gfc_check_atomic_cas, NULL, NULL,
3059 "atom", BT_INTEGER, di, REQUIRED, INTENT_INOUT,
3060 "old", BT_INTEGER, di, REQUIRED, INTENT_OUT,
3061 "compare", BT_INTEGER, di, REQUIRED, INTENT_IN,
3062 "new", BT_INTEGER, di, REQUIRED, INTENT_IN,
3063 stat, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3065 add_sym_3s ("atomic_add", GFC_ISYM_ATOMIC_ADD, CLASS_ATOMIC,
3066 BT_UNKNOWN, 0, GFC_STD_F2008_TS,
3067 gfc_check_atomic_op, NULL, NULL,
3068 "atom", BT_INTEGER, di, REQUIRED, INTENT_OUT,
3069 "value", BT_INTEGER, di, REQUIRED, INTENT_IN,
3070 stat, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3072 add_sym_3s ("atomic_and", GFC_ISYM_ATOMIC_AND, CLASS_ATOMIC,
3073 BT_UNKNOWN, 0, GFC_STD_F2008_TS,
3074 gfc_check_atomic_op, NULL, NULL,
3075 "atom", BT_INTEGER, di, REQUIRED, INTENT_OUT,
3076 "value", BT_INTEGER, di, REQUIRED, INTENT_IN,
3077 stat, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3079 add_sym_3s ("atomic_or", GFC_ISYM_ATOMIC_OR, CLASS_ATOMIC,
3080 BT_UNKNOWN, 0, GFC_STD_F2008_TS,
3081 gfc_check_atomic_op, NULL, NULL,
3082 "atom", BT_INTEGER, di, REQUIRED, INTENT_OUT,
3083 "value", BT_INTEGER, di, REQUIRED, INTENT_IN,
3084 stat, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3086 add_sym_3s ("atomic_xor", GFC_ISYM_ATOMIC_XOR, CLASS_ATOMIC,
3087 BT_UNKNOWN, 0, GFC_STD_F2008_TS,
3088 gfc_check_atomic_op, NULL, NULL,
3089 "atom", BT_INTEGER, di, REQUIRED, INTENT_OUT,
3090 "value", BT_INTEGER, di, REQUIRED, INTENT_IN,
3091 stat, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3093 add_sym_4s ("atomic_fetch_add", GFC_ISYM_ATOMIC_FETCH_ADD, CLASS_ATOMIC,
3094 BT_UNKNOWN, 0, GFC_STD_F2008_TS,
3095 gfc_check_atomic_fetch_op, NULL, NULL,
3096 "atom", BT_INTEGER, di, REQUIRED, INTENT_OUT,
3097 "value", BT_INTEGER, di, REQUIRED, INTENT_IN,
3098 "old", BT_INTEGER, di, REQUIRED, INTENT_OUT,
3099 stat, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3101 add_sym_4s ("atomic_fetch_and", GFC_ISYM_ATOMIC_FETCH_AND, CLASS_ATOMIC,
3102 BT_UNKNOWN, 0, GFC_STD_F2008_TS,
3103 gfc_check_atomic_fetch_op, NULL, NULL,
3104 "atom", BT_INTEGER, di, REQUIRED, INTENT_OUT,
3105 "value", BT_INTEGER, di, REQUIRED, INTENT_IN,
3106 "old", BT_INTEGER, di, REQUIRED, INTENT_OUT,
3107 stat, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3109 add_sym_4s ("atomic_fetch_or", GFC_ISYM_ATOMIC_FETCH_OR, CLASS_ATOMIC,
3110 BT_UNKNOWN, 0, GFC_STD_F2008_TS,
3111 gfc_check_atomic_fetch_op, NULL, NULL,
3112 "atom", BT_INTEGER, di, REQUIRED, INTENT_OUT,
3113 "value", BT_INTEGER, di, REQUIRED, INTENT_IN,
3114 "old", BT_INTEGER, di, REQUIRED, INTENT_OUT,
3115 stat, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3117 add_sym_4s ("atomic_fetch_xor", GFC_ISYM_ATOMIC_FETCH_XOR, CLASS_ATOMIC,
3118 BT_UNKNOWN, 0, GFC_STD_F2008_TS,
3119 gfc_check_atomic_fetch_op, NULL, NULL,
3120 "atom", BT_INTEGER, di, REQUIRED, INTENT_OUT,
3121 "value", BT_INTEGER, di, REQUIRED, INTENT_IN,
3122 "old", BT_INTEGER, di, REQUIRED, INTENT_OUT,
3123 stat, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3125 add_sym_0s ("backtrace", GFC_ISYM_BACKTRACE, GFC_STD_GNU, NULL);
3127 add_sym_1s ("cpu_time", GFC_ISYM_CPU_TIME, CLASS_IMPURE, BT_UNKNOWN, 0,
3128 GFC_STD_F95, gfc_check_cpu_time, NULL, gfc_resolve_cpu_time,
3129 tm, BT_REAL, dr, REQUIRED, INTENT_OUT);
3131 /* More G77 compatibility garbage. */
3132 add_sym_2s ("ctime", GFC_ISYM_CTIME, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3133 gfc_check_ctime_sub, NULL, gfc_resolve_ctime_sub,
3134 tm, BT_INTEGER, di, REQUIRED, INTENT_IN,
3135 res, BT_CHARACTER, dc, REQUIRED, INTENT_OUT);
3137 add_sym_1s ("idate", GFC_ISYM_IDATE, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3138 gfc_check_itime_idate, NULL, gfc_resolve_idate,
3139 vl, BT_INTEGER, 4, REQUIRED, INTENT_OUT);
3141 add_sym_1s ("itime", GFC_ISYM_ITIME, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3142 gfc_check_itime_idate, NULL, gfc_resolve_itime,
3143 vl, BT_INTEGER, 4, REQUIRED, INTENT_OUT);
3145 add_sym_2s ("ltime", GFC_ISYM_LTIME, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3146 gfc_check_ltime_gmtime, NULL, gfc_resolve_ltime,
3147 tm, BT_INTEGER, di, REQUIRED, INTENT_IN,
3148 vl, BT_INTEGER, di, REQUIRED, INTENT_OUT);
3150 add_sym_2s ("gmtime", GFC_ISYM_GMTIME, CLASS_IMPURE, BT_UNKNOWN, 0,
3151 GFC_STD_GNU, gfc_check_ltime_gmtime, NULL, gfc_resolve_gmtime,
3152 tm, BT_INTEGER, di, REQUIRED, INTENT_IN,
3153 vl, BT_INTEGER, di, REQUIRED, INTENT_OUT);
3155 add_sym_1s ("second", GFC_ISYM_SECOND, CLASS_IMPURE, BT_UNKNOWN, 0,
3156 GFC_STD_GNU, gfc_check_second_sub, NULL, gfc_resolve_second_sub,
3157 tm, BT_REAL, dr, REQUIRED, INTENT_OUT);
3159 add_sym_2s ("chdir", GFC_ISYM_CHDIR, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3160 gfc_check_chdir_sub, NULL, gfc_resolve_chdir_sub,
3161 name, BT_CHARACTER, dc, REQUIRED, INTENT_IN,
3162 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3164 add_sym_3s ("chmod", GFC_ISYM_CHMOD, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3165 gfc_check_chmod_sub, NULL, gfc_resolve_chmod_sub,
3166 name, BT_CHARACTER, dc, REQUIRED, INTENT_IN,
3167 md, BT_CHARACTER, dc, REQUIRED, INTENT_IN,
3168 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3170 add_sym_4s ("date_and_time", GFC_ISYM_DATE_AND_TIME, CLASS_IMPURE, BT_UNKNOWN,
3171 0, GFC_STD_F95, gfc_check_date_and_time, NULL, NULL,
3172 dt, BT_CHARACTER, dc, OPTIONAL, INTENT_OUT,
3173 tm, BT_CHARACTER, dc, OPTIONAL, INTENT_OUT,
3174 zn, BT_CHARACTER, dc, OPTIONAL, INTENT_OUT,
3175 vl, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3177 /* More G77 compatibility garbage. */
3178 add_sym_2s ("etime", GFC_ISYM_ETIME, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3179 gfc_check_dtime_etime_sub, NULL, gfc_resolve_etime_sub,
3180 vl, BT_REAL, 4, REQUIRED, INTENT_OUT,
3181 tm, BT_REAL, 4, REQUIRED, INTENT_OUT);
3183 add_sym_2s ("dtime", GFC_ISYM_DTIME, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3184 gfc_check_dtime_etime_sub, NULL, gfc_resolve_dtime_sub,
3185 vl, BT_REAL, 4, REQUIRED, INTENT_OUT,
3186 tm, BT_REAL, 4, REQUIRED, INTENT_OUT);
3188 add_sym_5s ("execute_command_line", GFC_ISYM_EXECUTE_COMMAND_LINE,
3189 CLASS_IMPURE , BT_UNKNOWN, 0, GFC_STD_F2008,
3190 NULL, NULL, gfc_resolve_execute_command_line,
3191 "command", BT_CHARACTER, dc, REQUIRED, INTENT_IN,
3192 "wait", BT_LOGICAL, dl, OPTIONAL, INTENT_IN,
3193 "exitstat", BT_INTEGER, di, OPTIONAL, INTENT_INOUT,
3194 "cmdstat", BT_INTEGER, di, OPTIONAL, INTENT_OUT,
3195 "cmdmsg", BT_CHARACTER, dc, OPTIONAL, INTENT_INOUT);
3197 add_sym_1s ("fdate", GFC_ISYM_FDATE, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3198 gfc_check_fdate_sub, NULL, gfc_resolve_fdate_sub,
3199 dt, BT_CHARACTER, dc, REQUIRED, INTENT_OUT);
3201 add_sym_1s ("gerror", GFC_ISYM_GERROR, CLASS_IMPURE, BT_UNKNOWN,
3202 0, GFC_STD_GNU, gfc_check_gerror, NULL, gfc_resolve_gerror,
3203 res, BT_CHARACTER, dc, REQUIRED, INTENT_OUT);
3205 add_sym_2s ("getcwd", GFC_ISYM_GETCWD, CLASS_IMPURE, BT_UNKNOWN, 0,
3206 GFC_STD_GNU, gfc_check_getcwd_sub, NULL, gfc_resolve_getcwd_sub,
3207 c, BT_CHARACTER, dc, REQUIRED, INTENT_OUT,
3208 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3210 add_sym_2s ("getenv", GFC_ISYM_GETENV, CLASS_IMPURE, BT_UNKNOWN,
3211 0, GFC_STD_GNU, NULL, NULL, NULL,
3212 name, BT_CHARACTER, dc, REQUIRED, INTENT_IN,
3213 val, BT_CHARACTER, dc, REQUIRED, INTENT_OUT);
3215 add_sym_2s ("getarg", GFC_ISYM_GETARG, CLASS_IMPURE, BT_UNKNOWN,
3216 0, GFC_STD_GNU, gfc_check_getarg, NULL, gfc_resolve_getarg,
3217 pos, BT_INTEGER, di, REQUIRED, INTENT_IN,
3218 val, BT_CHARACTER, dc, REQUIRED, INTENT_OUT);
3220 add_sym_1s ("getlog", GFC_ISYM_GETLOG, CLASS_IMPURE, BT_UNKNOWN,
3221 0, GFC_STD_GNU, gfc_check_getlog, NULL, gfc_resolve_getlog,
3222 c, BT_CHARACTER, dc, REQUIRED, INTENT_OUT);
3224 /* F2003 commandline routines. */
3226 add_sym_3s ("get_command", GFC_ISYM_GET_COMMAND, CLASS_IMPURE,
3227 BT_UNKNOWN, 0, GFC_STD_F2003,
3228 NULL, NULL, gfc_resolve_get_command,
3229 com, BT_CHARACTER, dc, OPTIONAL, INTENT_OUT,
3230 length, BT_INTEGER, di, OPTIONAL, INTENT_OUT,
3231 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3233 add_sym_4s ("get_command_argument", GFC_ISYM_GET_COMMAND_ARGUMENT,
3234 CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_F2003, NULL, NULL,
3235 gfc_resolve_get_command_argument,
3236 num, BT_INTEGER, di, REQUIRED, INTENT_IN,
3237 val, BT_CHARACTER, dc, OPTIONAL, INTENT_OUT,
3238 length, BT_INTEGER, di, OPTIONAL, INTENT_OUT,
3239 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3241 /* F2003 subroutine to get environment variables. */
3243 add_sym_5s ("get_environment_variable", GFC_ISYM_GET_ENVIRONMENT_VARIABLE,
3244 CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_F2003,
3245 NULL, NULL, gfc_resolve_get_environment_variable,
3246 name, BT_CHARACTER, dc, REQUIRED, INTENT_IN,
3247 val, BT_CHARACTER, dc, OPTIONAL, INTENT_OUT,
3248 length, BT_INTEGER, di, OPTIONAL, INTENT_OUT,
3249 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT,
3250 trim_name, BT_LOGICAL, dl, OPTIONAL, INTENT_IN);
3252 add_sym_2s ("move_alloc", GFC_ISYM_MOVE_ALLOC, CLASS_PURE, BT_UNKNOWN, 0,
3253 GFC_STD_F2003,
3254 gfc_check_move_alloc, NULL, NULL,
3255 f, BT_UNKNOWN, 0, REQUIRED, INTENT_INOUT,
3256 t, BT_UNKNOWN, 0, REQUIRED, INTENT_OUT);
3258 add_sym_5s ("mvbits", GFC_ISYM_MVBITS, CLASS_ELEMENTAL, BT_UNKNOWN, 0,
3259 GFC_STD_F95, gfc_check_mvbits, gfc_simplify_mvbits,
3260 gfc_resolve_mvbits,
3261 f, BT_INTEGER, di, REQUIRED, INTENT_IN,
3262 fp, BT_INTEGER, di, REQUIRED, INTENT_IN,
3263 ln, BT_INTEGER, di, REQUIRED, INTENT_IN,
3264 t, BT_INTEGER, di, REQUIRED, INTENT_INOUT,
3265 tp, BT_INTEGER, di, REQUIRED, INTENT_IN);
3267 add_sym_1s ("random_number", GFC_ISYM_RANDOM_NUMBER, CLASS_IMPURE,
3268 BT_UNKNOWN, 0, GFC_STD_F95,
3269 gfc_check_random_number, NULL, gfc_resolve_random_number,
3270 h, BT_REAL, dr, REQUIRED, INTENT_OUT);
3272 add_sym_3s ("random_seed", GFC_ISYM_RANDOM_SEED, CLASS_IMPURE,
3273 BT_UNKNOWN, 0, GFC_STD_F95,
3274 gfc_check_random_seed, NULL, gfc_resolve_random_seed,
3275 sz, BT_INTEGER, di, OPTIONAL, INTENT_OUT,
3276 pt, BT_INTEGER, di, OPTIONAL, INTENT_IN,
3277 gt, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3279 /* The following subroutines are part of ISO_C_BINDING. */
3281 add_sym_3s ("c_f_pointer", GFC_ISYM_C_F_POINTER, CLASS_IMPURE, BT_UNKNOWN, 0,
3282 GFC_STD_F2003, gfc_check_c_f_pointer, NULL, NULL,
3283 "cptr", BT_VOID, 0, REQUIRED, INTENT_IN,
3284 "fptr", BT_UNKNOWN, 0, REQUIRED, INTENT_OUT,
3285 "shape", BT_INTEGER, di, OPTIONAL, INTENT_IN);
3286 make_from_module();
3288 add_sym_2s ("c_f_procpointer", GFC_ISYM_C_F_PROCPOINTER, CLASS_IMPURE,
3289 BT_UNKNOWN, 0, GFC_STD_F2003, gfc_check_c_f_procpointer,
3290 NULL, NULL,
3291 "cptr", BT_VOID, 0, REQUIRED, INTENT_IN,
3292 "fptr", BT_UNKNOWN, 0, REQUIRED, INTENT_OUT);
3293 make_from_module();
3295 /* Coarray collectives. */
3296 add_sym_4s ("co_broadcast", GFC_ISYM_CO_BROADCAST, CLASS_IMPURE,
3297 BT_UNKNOWN, 0, GFC_STD_F2008_TS,
3298 gfc_check_co_broadcast, NULL, NULL,
3299 a, BT_REAL, dr, REQUIRED, INTENT_INOUT,
3300 "source_image", BT_INTEGER, di, REQUIRED, INTENT_IN,
3301 stat, BT_INTEGER, di, OPTIONAL, INTENT_OUT,
3302 errmsg, BT_CHARACTER, dc, OPTIONAL, INTENT_OUT);
3304 add_sym_4s ("co_max", GFC_ISYM_CO_MAX, CLASS_IMPURE,
3305 BT_UNKNOWN, 0, GFC_STD_F2008_TS,
3306 gfc_check_co_minmax, NULL, NULL,
3307 a, BT_REAL, dr, REQUIRED, INTENT_INOUT,
3308 result_image, BT_INTEGER, di, OPTIONAL, INTENT_IN,
3309 stat, BT_INTEGER, di, OPTIONAL, INTENT_OUT,
3310 errmsg, BT_CHARACTER, dc, OPTIONAL, INTENT_OUT);
3312 add_sym_4s ("co_min", GFC_ISYM_CO_MIN, CLASS_IMPURE,
3313 BT_UNKNOWN, 0, GFC_STD_F2008_TS,
3314 gfc_check_co_minmax, NULL, NULL,
3315 a, BT_REAL, dr, REQUIRED, INTENT_INOUT,
3316 result_image, BT_INTEGER, di, OPTIONAL, INTENT_IN,
3317 stat, BT_INTEGER, di, OPTIONAL, INTENT_OUT,
3318 errmsg, BT_CHARACTER, dc, OPTIONAL, INTENT_OUT);
3320 add_sym_4s ("co_sum", GFC_ISYM_CO_SUM, CLASS_IMPURE,
3321 BT_UNKNOWN, 0, GFC_STD_F2008_TS,
3322 gfc_check_co_sum, NULL, NULL,
3323 a, BT_REAL, dr, REQUIRED, INTENT_INOUT,
3324 result_image, BT_INTEGER, di, OPTIONAL, INTENT_IN,
3325 stat, BT_INTEGER, di, OPTIONAL, INTENT_OUT,
3326 errmsg, BT_CHARACTER, dc, OPTIONAL, INTENT_OUT);
3328 add_sym_5s ("co_reduce", GFC_ISYM_CO_REDUCE, CLASS_IMPURE,
3329 BT_UNKNOWN, 0, GFC_STD_F2008_TS,
3330 gfc_check_co_reduce, NULL, NULL,
3331 a, BT_REAL, dr, REQUIRED, INTENT_INOUT,
3332 "operator", BT_INTEGER, di, REQUIRED, INTENT_IN,
3333 result_image, BT_INTEGER, di, OPTIONAL, INTENT_IN,
3334 stat, BT_INTEGER, di, OPTIONAL, INTENT_OUT,
3335 errmsg, BT_CHARACTER, dc, OPTIONAL, INTENT_OUT);
3338 /* The following subroutine is internally used for coarray libray functions.
3339 "make_from_module" makes it inaccessible for external users. */
3340 add_sym_2s (GFC_PREFIX ("caf_send"), GFC_ISYM_CAF_SEND, CLASS_IMPURE,
3341 BT_UNKNOWN, 0, GFC_STD_GNU, NULL, NULL, NULL,
3342 "x", BT_REAL, dr, REQUIRED, INTENT_OUT,
3343 "y", BT_REAL, dr, REQUIRED, INTENT_IN);
3344 make_from_module();
3347 /* More G77 compatibility garbage. */
3348 add_sym_3s ("alarm", GFC_ISYM_ALARM, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3349 gfc_check_alarm_sub, NULL, gfc_resolve_alarm_sub,
3350 sec, BT_INTEGER, di, REQUIRED, INTENT_IN,
3351 han, BT_UNKNOWN, 0, REQUIRED, INTENT_IN,
3352 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3354 add_sym_1s ("srand", GFC_ISYM_SRAND, CLASS_IMPURE, BT_UNKNOWN,
3355 di, GFC_STD_GNU, gfc_check_srand, NULL, gfc_resolve_srand,
3356 "seed", BT_INTEGER, 4, REQUIRED, INTENT_IN);
3358 add_sym_1s ("exit", GFC_ISYM_EXIT, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3359 gfc_check_exit, NULL, gfc_resolve_exit,
3360 st, BT_INTEGER, di, OPTIONAL, INTENT_IN);
3362 make_noreturn();
3364 add_sym_3s ("fgetc", GFC_ISYM_FGETC, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3365 gfc_check_fgetputc_sub, NULL, gfc_resolve_fgetc_sub,
3366 ut, BT_INTEGER, di, REQUIRED, INTENT_IN,
3367 c, BT_CHARACTER, dc, REQUIRED, INTENT_OUT,
3368 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3370 add_sym_2s ("fget", GFC_ISYM_FGET, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3371 gfc_check_fgetput_sub, NULL, gfc_resolve_fget_sub,
3372 c, BT_CHARACTER, dc, REQUIRED, INTENT_OUT,
3373 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3375 add_sym_1s ("flush", GFC_ISYM_FLUSH, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3376 gfc_check_flush, NULL, gfc_resolve_flush,
3377 ut, BT_INTEGER, di, OPTIONAL, INTENT_IN);
3379 add_sym_3s ("fputc", GFC_ISYM_FPUTC, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3380 gfc_check_fgetputc_sub, NULL, gfc_resolve_fputc_sub,
3381 ut, BT_INTEGER, di, REQUIRED, INTENT_IN,
3382 c, BT_CHARACTER, dc, REQUIRED, INTENT_IN,
3383 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3385 add_sym_2s ("fput", GFC_ISYM_FPUT, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3386 gfc_check_fgetput_sub, NULL, gfc_resolve_fput_sub,
3387 c, BT_CHARACTER, dc, REQUIRED, INTENT_IN,
3388 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3390 add_sym_1s ("free", GFC_ISYM_FREE, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3391 gfc_check_free, NULL, gfc_resolve_free,
3392 ptr, BT_INTEGER, ii, REQUIRED, INTENT_INOUT);
3394 add_sym_4s ("fseek", GFC_ISYM_FSEEK, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3395 gfc_check_fseek_sub, NULL, gfc_resolve_fseek_sub,
3396 ut, BT_INTEGER, di, REQUIRED, INTENT_IN,
3397 of, BT_INTEGER, di, REQUIRED, INTENT_IN,
3398 whence, BT_INTEGER, di, REQUIRED, INTENT_IN,
3399 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3401 add_sym_2s ("ftell", GFC_ISYM_FTELL, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3402 gfc_check_ftell_sub, NULL, gfc_resolve_ftell_sub,
3403 ut, BT_INTEGER, di, REQUIRED, INTENT_IN,
3404 of, BT_INTEGER, ii, REQUIRED, INTENT_OUT);
3406 add_sym_2s ("hostnm", GFC_ISYM_HOSTNM, CLASS_IMPURE, BT_UNKNOWN, 0,
3407 GFC_STD_GNU, gfc_check_hostnm_sub, NULL, gfc_resolve_hostnm_sub,
3408 c, BT_CHARACTER, dc, REQUIRED, INTENT_OUT,
3409 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3411 add_sym_3s ("kill", GFC_ISYM_KILL, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3412 gfc_check_kill_sub, NULL, gfc_resolve_kill_sub,
3413 c, BT_INTEGER, di, REQUIRED, INTENT_IN,
3414 val, BT_INTEGER, di, REQUIRED, INTENT_IN,
3415 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3417 add_sym_3s ("link", GFC_ISYM_LINK, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3418 gfc_check_link_sub, NULL, gfc_resolve_link_sub,
3419 p1, BT_CHARACTER, dc, REQUIRED, INTENT_IN,
3420 p2, BT_CHARACTER, dc, REQUIRED, INTENT_IN,
3421 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3423 add_sym_1s ("perror", GFC_ISYM_PERROR, CLASS_IMPURE, BT_UNKNOWN,
3424 0, GFC_STD_GNU, gfc_check_perror, NULL, gfc_resolve_perror,
3425 "string", BT_CHARACTER, dc, REQUIRED, INTENT_IN);
3427 add_sym_3s ("rename", GFC_ISYM_RENAME, CLASS_IMPURE, BT_UNKNOWN, 0,
3428 GFC_STD_GNU, gfc_check_rename_sub, NULL, gfc_resolve_rename_sub,
3429 p1, BT_CHARACTER, dc, REQUIRED, INTENT_IN,
3430 p2, BT_CHARACTER, dc, REQUIRED, INTENT_IN,
3431 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3433 add_sym_1s ("sleep", GFC_ISYM_SLEEP, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3434 gfc_check_sleep_sub, NULL, gfc_resolve_sleep_sub,
3435 sec, BT_INTEGER, di, REQUIRED, INTENT_IN);
3437 add_sym_3s ("fstat", GFC_ISYM_FSTAT, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3438 gfc_check_fstat_sub, NULL, gfc_resolve_fstat_sub,
3439 ut, BT_INTEGER, di, REQUIRED, INTENT_IN,
3440 vl, BT_INTEGER, di, REQUIRED, INTENT_OUT,
3441 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3443 add_sym_3s ("lstat", GFC_ISYM_LSTAT, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3444 gfc_check_stat_sub, NULL, gfc_resolve_lstat_sub,
3445 name, BT_CHARACTER, dc, REQUIRED, INTENT_IN,
3446 vl, BT_INTEGER, di, REQUIRED, INTENT_OUT,
3447 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3449 add_sym_3s ("stat", GFC_ISYM_STAT, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3450 gfc_check_stat_sub, NULL, gfc_resolve_stat_sub,
3451 name, BT_CHARACTER, dc, REQUIRED, INTENT_IN,
3452 vl, BT_INTEGER, di, REQUIRED, INTENT_OUT,
3453 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3455 add_sym_3s ("signal", GFC_ISYM_SIGNAL, CLASS_IMPURE, BT_UNKNOWN, 0,
3456 GFC_STD_GNU, gfc_check_signal_sub, NULL, gfc_resolve_signal_sub,
3457 num, BT_INTEGER, di, REQUIRED, INTENT_IN,
3458 han, BT_UNKNOWN, 0, REQUIRED, INTENT_IN,
3459 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3461 add_sym_3s ("symlnk", GFC_ISYM_SYMLINK, CLASS_IMPURE, BT_UNKNOWN, 0,
3462 GFC_STD_GNU, gfc_check_symlnk_sub, NULL, gfc_resolve_symlnk_sub,
3463 p1, BT_CHARACTER, dc, REQUIRED, INTENT_IN,
3464 p2, BT_CHARACTER, dc, REQUIRED, INTENT_IN,
3465 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3467 add_sym_2s ("system", GFC_ISYM_SYSTEM, CLASS_IMPURE, BT_UNKNOWN,
3468 0, GFC_STD_GNU, NULL, NULL, gfc_resolve_system_sub,
3469 com, BT_CHARACTER, dc, REQUIRED, INTENT_IN,
3470 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3472 add_sym_3s ("system_clock", GFC_ISYM_SYSTEM_CLOCK, CLASS_IMPURE,
3473 BT_UNKNOWN, 0, GFC_STD_F95,
3474 gfc_check_system_clock, NULL, gfc_resolve_system_clock,
3475 c, BT_INTEGER, di, OPTIONAL, INTENT_OUT,
3476 cr, BT_INTEGER, di, OPTIONAL, INTENT_OUT,
3477 cm, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3479 add_sym_2s ("ttynam", GFC_ISYM_TTYNAM, CLASS_IMPURE, BT_UNKNOWN, 0,
3480 GFC_STD_GNU, gfc_check_ttynam_sub, NULL, gfc_resolve_ttynam_sub,
3481 ut, BT_INTEGER, di, REQUIRED, INTENT_IN,
3482 name, BT_CHARACTER, dc, REQUIRED, INTENT_OUT);
3484 add_sym_2s ("umask", GFC_ISYM_UMASK, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_GNU,
3485 gfc_check_umask_sub, NULL, gfc_resolve_umask_sub,
3486 msk, BT_INTEGER, di, REQUIRED, INTENT_IN,
3487 old, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3489 add_sym_2s ("unlink", GFC_ISYM_UNLINK, CLASS_IMPURE, BT_UNKNOWN, 0,
3490 GFC_STD_GNU, gfc_check_unlink_sub, NULL, gfc_resolve_unlink_sub,
3491 "path", BT_CHARACTER, dc, REQUIRED, INTENT_IN,
3492 st, BT_INTEGER, di, OPTIONAL, INTENT_OUT);
3496 /* Add a function to the list of conversion symbols. */
3498 static void
3499 add_conv (bt from_type, int from_kind, bt to_type, int to_kind, int standard)
3501 gfc_typespec from, to;
3502 gfc_intrinsic_sym *sym;
3504 if (sizing == SZ_CONVS)
3506 nconv++;
3507 return;
3510 gfc_clear_ts (&from);
3511 from.type = from_type;
3512 from.kind = from_kind;
3514 gfc_clear_ts (&to);
3515 to.type = to_type;
3516 to.kind = to_kind;
3518 sym = conversion + nconv;
3520 sym->name = conv_name (&from, &to);
3521 sym->lib_name = sym->name;
3522 sym->simplify.cc = gfc_convert_constant;
3523 sym->standard = standard;
3524 sym->elemental = 1;
3525 sym->pure = 1;
3526 sym->conversion = 1;
3527 sym->ts = to;
3528 sym->id = GFC_ISYM_CONVERSION;
3530 nconv++;
3534 /* Create gfc_intrinsic_sym nodes for all intrinsic conversion
3535 functions by looping over the kind tables. */
3537 static void
3538 add_conversions (void)
3540 int i, j;
3542 /* Integer-Integer conversions. */
3543 for (i = 0; gfc_integer_kinds[i].kind != 0; i++)
3544 for (j = 0; gfc_integer_kinds[j].kind != 0; j++)
3546 if (i == j)
3547 continue;
3549 add_conv (BT_INTEGER, gfc_integer_kinds[i].kind,
3550 BT_INTEGER, gfc_integer_kinds[j].kind, GFC_STD_F77);
3553 /* Integer-Real/Complex conversions. */
3554 for (i = 0; gfc_integer_kinds[i].kind != 0; i++)
3555 for (j = 0; gfc_real_kinds[j].kind != 0; j++)
3557 add_conv (BT_INTEGER, gfc_integer_kinds[i].kind,
3558 BT_REAL, gfc_real_kinds[j].kind, GFC_STD_F77);
3560 add_conv (BT_REAL, gfc_real_kinds[j].kind,
3561 BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_F77);
3563 add_conv (BT_INTEGER, gfc_integer_kinds[i].kind,
3564 BT_COMPLEX, gfc_real_kinds[j].kind, GFC_STD_F77);
3566 add_conv (BT_COMPLEX, gfc_real_kinds[j].kind,
3567 BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_F77);
3570 if ((gfc_option.allow_std & GFC_STD_LEGACY) != 0)
3572 /* Hollerith-Integer conversions. */
3573 for (i = 0; gfc_integer_kinds[i].kind != 0; i++)
3574 add_conv (BT_HOLLERITH, gfc_default_character_kind,
3575 BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_LEGACY);
3576 /* Hollerith-Real conversions. */
3577 for (i = 0; gfc_real_kinds[i].kind != 0; i++)
3578 add_conv (BT_HOLLERITH, gfc_default_character_kind,
3579 BT_REAL, gfc_real_kinds[i].kind, GFC_STD_LEGACY);
3580 /* Hollerith-Complex conversions. */
3581 for (i = 0; gfc_real_kinds[i].kind != 0; i++)
3582 add_conv (BT_HOLLERITH, gfc_default_character_kind,
3583 BT_COMPLEX, gfc_real_kinds[i].kind, GFC_STD_LEGACY);
3585 /* Hollerith-Character conversions. */
3586 add_conv (BT_HOLLERITH, gfc_default_character_kind, BT_CHARACTER,
3587 gfc_default_character_kind, GFC_STD_LEGACY);
3589 /* Hollerith-Logical conversions. */
3590 for (i = 0; gfc_logical_kinds[i].kind != 0; i++)
3591 add_conv (BT_HOLLERITH, gfc_default_character_kind,
3592 BT_LOGICAL, gfc_logical_kinds[i].kind, GFC_STD_LEGACY);
3595 /* Real/Complex - Real/Complex conversions. */
3596 for (i = 0; gfc_real_kinds[i].kind != 0; i++)
3597 for (j = 0; gfc_real_kinds[j].kind != 0; j++)
3599 if (i != j)
3601 add_conv (BT_REAL, gfc_real_kinds[i].kind,
3602 BT_REAL, gfc_real_kinds[j].kind, GFC_STD_F77);
3604 add_conv (BT_COMPLEX, gfc_real_kinds[i].kind,
3605 BT_COMPLEX, gfc_real_kinds[j].kind, GFC_STD_F77);
3608 add_conv (BT_REAL, gfc_real_kinds[i].kind,
3609 BT_COMPLEX, gfc_real_kinds[j].kind, GFC_STD_F77);
3611 add_conv (BT_COMPLEX, gfc_real_kinds[i].kind,
3612 BT_REAL, gfc_real_kinds[j].kind, GFC_STD_F77);
3615 /* Logical/Logical kind conversion. */
3616 for (i = 0; gfc_logical_kinds[i].kind; i++)
3617 for (j = 0; gfc_logical_kinds[j].kind; j++)
3619 if (i == j)
3620 continue;
3622 add_conv (BT_LOGICAL, gfc_logical_kinds[i].kind,
3623 BT_LOGICAL, gfc_logical_kinds[j].kind, GFC_STD_F77);
3626 /* Integer-Logical and Logical-Integer conversions. */
3627 if ((gfc_option.allow_std & GFC_STD_LEGACY) != 0)
3628 for (i=0; gfc_integer_kinds[i].kind; i++)
3629 for (j=0; gfc_logical_kinds[j].kind; j++)
3631 add_conv (BT_INTEGER, gfc_integer_kinds[i].kind,
3632 BT_LOGICAL, gfc_logical_kinds[j].kind, GFC_STD_LEGACY);
3633 add_conv (BT_LOGICAL, gfc_logical_kinds[j].kind,
3634 BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_LEGACY);
3639 static void
3640 add_char_conversions (void)
3642 int n, i, j;
3644 /* Count possible conversions. */
3645 for (i = 0; gfc_character_kinds[i].kind != 0; i++)
3646 for (j = 0; gfc_character_kinds[j].kind != 0; j++)
3647 if (i != j)
3648 ncharconv++;
3650 /* Allocate memory. */
3651 char_conversions = XCNEWVEC (gfc_intrinsic_sym, ncharconv);
3653 /* Add the conversions themselves. */
3654 n = 0;
3655 for (i = 0; gfc_character_kinds[i].kind != 0; i++)
3656 for (j = 0; gfc_character_kinds[j].kind != 0; j++)
3658 gfc_typespec from, to;
3660 if (i == j)
3661 continue;
3663 gfc_clear_ts (&from);
3664 from.type = BT_CHARACTER;
3665 from.kind = gfc_character_kinds[i].kind;
3667 gfc_clear_ts (&to);
3668 to.type = BT_CHARACTER;
3669 to.kind = gfc_character_kinds[j].kind;
3671 char_conversions[n].name = conv_name (&from, &to);
3672 char_conversions[n].lib_name = char_conversions[n].name;
3673 char_conversions[n].simplify.cc = gfc_convert_char_constant;
3674 char_conversions[n].standard = GFC_STD_F2003;
3675 char_conversions[n].elemental = 1;
3676 char_conversions[n].pure = 1;
3677 char_conversions[n].conversion = 0;
3678 char_conversions[n].ts = to;
3679 char_conversions[n].id = GFC_ISYM_CONVERSION;
3681 n++;
3686 /* Initialize the table of intrinsics. */
3687 void
3688 gfc_intrinsic_init_1 (void)
3690 nargs = nfunc = nsub = nconv = 0;
3692 /* Create a namespace to hold the resolved intrinsic symbols. */
3693 gfc_intrinsic_namespace = gfc_get_namespace (NULL, 0);
3695 sizing = SZ_FUNCS;
3696 add_functions ();
3697 sizing = SZ_SUBS;
3698 add_subroutines ();
3699 sizing = SZ_CONVS;
3700 add_conversions ();
3702 functions = XCNEWVAR (struct gfc_intrinsic_sym,
3703 sizeof (gfc_intrinsic_sym) * (nfunc + nsub)
3704 + sizeof (gfc_intrinsic_arg) * nargs);
3706 next_sym = functions;
3707 subroutines = functions + nfunc;
3709 conversion = XCNEWVEC (gfc_intrinsic_sym, nconv);
3711 next_arg = ((gfc_intrinsic_arg *) (subroutines + nsub)) - 1;
3713 sizing = SZ_NOTHING;
3714 nconv = 0;
3716 add_functions ();
3717 add_subroutines ();
3718 add_conversions ();
3720 /* Character conversion intrinsics need to be treated separately. */
3721 add_char_conversions ();
3725 void
3726 gfc_intrinsic_done_1 (void)
3728 free (functions);
3729 free (conversion);
3730 free (char_conversions);
3731 gfc_free_namespace (gfc_intrinsic_namespace);
3735 /******** Subroutines to check intrinsic interfaces ***********/
3737 /* Given a formal argument list, remove any NULL arguments that may
3738 have been left behind by a sort against some formal argument list. */
3740 static void
3741 remove_nullargs (gfc_actual_arglist **ap)
3743 gfc_actual_arglist *head, *tail, *next;
3745 tail = NULL;
3747 for (head = *ap; head; head = next)
3749 next = head->next;
3751 if (head->expr == NULL && !head->label)
3753 head->next = NULL;
3754 gfc_free_actual_arglist (head);
3756 else
3758 if (tail == NULL)
3759 *ap = head;
3760 else
3761 tail->next = head;
3763 tail = head;
3764 tail->next = NULL;
3768 if (tail == NULL)
3769 *ap = NULL;
3773 /* Given an actual arglist and a formal arglist, sort the actual
3774 arglist so that its arguments are in a one-to-one correspondence
3775 with the format arglist. Arguments that are not present are given
3776 a blank gfc_actual_arglist structure. If something is obviously
3777 wrong (say, a missing required argument) we abort sorting and
3778 return false. */
3780 static bool
3781 sort_actual (const char *name, gfc_actual_arglist **ap,
3782 gfc_intrinsic_arg *formal, locus *where)
3784 gfc_actual_arglist *actual, *a;
3785 gfc_intrinsic_arg *f;
3787 remove_nullargs (ap);
3788 actual = *ap;
3790 for (f = formal; f; f = f->next)
3791 f->actual = NULL;
3793 f = formal;
3794 a = actual;
3796 if (f == NULL && a == NULL) /* No arguments */
3797 return true;
3799 for (;;)
3800 { /* Put the nonkeyword arguments in a 1:1 correspondence */
3801 if (f == NULL)
3802 break;
3803 if (a == NULL)
3804 goto optional;
3806 if (a->name != NULL)
3807 goto keywords;
3809 f->actual = a;
3811 f = f->next;
3812 a = a->next;
3815 if (a == NULL)
3816 goto do_sort;
3818 gfc_error ("Too many arguments in call to %qs at %L", name, where);
3819 return false;
3821 keywords:
3822 /* Associate the remaining actual arguments, all of which have
3823 to be keyword arguments. */
3824 for (; a; a = a->next)
3826 for (f = formal; f; f = f->next)
3827 if (strcmp (a->name, f->name) == 0)
3828 break;
3830 if (f == NULL)
3832 if (a->name[0] == '%')
3833 gfc_error ("The argument list functions %%VAL, %%LOC or %%REF "
3834 "are not allowed in this context at %L", where);
3835 else
3836 gfc_error ("Can't find keyword named %qs in call to %qs at %L",
3837 a->name, name, where);
3838 return false;
3841 if (f->actual != NULL)
3843 gfc_error ("Argument %qs appears twice in call to %qs at %L",
3844 f->name, name, where);
3845 return false;
3848 f->actual = a;
3851 optional:
3852 /* At this point, all unmatched formal args must be optional. */
3853 for (f = formal; f; f = f->next)
3855 if (f->actual == NULL && f->optional == 0)
3857 gfc_error ("Missing actual argument %qs in call to %qs at %L",
3858 f->name, name, where);
3859 return false;
3863 do_sort:
3864 /* Using the formal argument list, string the actual argument list
3865 together in a way that corresponds with the formal list. */
3866 actual = NULL;
3868 for (f = formal; f; f = f->next)
3870 if (f->actual && f->actual->label != NULL && f->ts.type)
3872 gfc_error ("ALTERNATE RETURN not permitted at %L", where);
3873 return false;
3876 if (f->actual == NULL)
3878 a = gfc_get_actual_arglist ();
3879 a->missing_arg_type = f->ts.type;
3881 else
3882 a = f->actual;
3884 if (actual == NULL)
3885 *ap = a;
3886 else
3887 actual->next = a;
3889 actual = a;
3891 actual->next = NULL; /* End the sorted argument list. */
3893 return true;
3897 /* Compare an actual argument list with an intrinsic's formal argument
3898 list. The lists are checked for agreement of type. We don't check
3899 for arrayness here. */
3901 static bool
3902 check_arglist (gfc_actual_arglist **ap, gfc_intrinsic_sym *sym,
3903 int error_flag)
3905 gfc_actual_arglist *actual;
3906 gfc_intrinsic_arg *formal;
3907 int i;
3909 formal = sym->formal;
3910 actual = *ap;
3912 i = 0;
3913 for (; formal; formal = formal->next, actual = actual->next, i++)
3915 gfc_typespec ts;
3917 if (actual->expr == NULL)
3918 continue;
3920 ts = formal->ts;
3922 /* A kind of 0 means we don't check for kind. */
3923 if (ts.kind == 0)
3924 ts.kind = actual->expr->ts.kind;
3926 if (!gfc_compare_types (&ts, &actual->expr->ts))
3928 if (error_flag)
3929 gfc_error ("Type of argument %qs in call to %qs at %L should "
3930 "be %s, not %s", gfc_current_intrinsic_arg[i]->name,
3931 gfc_current_intrinsic, &actual->expr->where,
3932 gfc_typename (&formal->ts),
3933 gfc_typename (&actual->expr->ts));
3934 return false;
3937 /* If the formal argument is INTENT([IN]OUT), check for definability. */
3938 if (formal->intent == INTENT_INOUT || formal->intent == INTENT_OUT)
3940 const char* context = (error_flag
3941 ? _("actual argument to INTENT = OUT/INOUT")
3942 : NULL);
3944 /* No pointer arguments for intrinsics. */
3945 if (!gfc_check_vardef_context (actual->expr, false, false, false, context))
3946 return false;
3950 return true;
3954 /* Given a pointer to an intrinsic symbol and an expression node that
3955 represent the function call to that subroutine, figure out the type
3956 of the result. This may involve calling a resolution subroutine. */
3958 static void
3959 resolve_intrinsic (gfc_intrinsic_sym *specific, gfc_expr *e)
3961 gfc_expr *a1, *a2, *a3, *a4, *a5;
3962 gfc_actual_arglist *arg;
3964 if (specific->resolve.f1 == NULL)
3966 if (e->value.function.name == NULL)
3967 e->value.function.name = specific->lib_name;
3969 if (e->ts.type == BT_UNKNOWN)
3970 e->ts = specific->ts;
3971 return;
3974 arg = e->value.function.actual;
3976 /* Special case hacks for MIN and MAX. */
3977 if (specific->resolve.f1m == gfc_resolve_max
3978 || specific->resolve.f1m == gfc_resolve_min)
3980 (*specific->resolve.f1m) (e, arg);
3981 return;
3984 if (arg == NULL)
3986 (*specific->resolve.f0) (e);
3987 return;
3990 a1 = arg->expr;
3991 arg = arg->next;
3993 if (arg == NULL)
3995 (*specific->resolve.f1) (e, a1);
3996 return;
3999 a2 = arg->expr;
4000 arg = arg->next;
4002 if (arg == NULL)
4004 (*specific->resolve.f2) (e, a1, a2);
4005 return;
4008 a3 = arg->expr;
4009 arg = arg->next;
4011 if (arg == NULL)
4013 (*specific->resolve.f3) (e, a1, a2, a3);
4014 return;
4017 a4 = arg->expr;
4018 arg = arg->next;
4020 if (arg == NULL)
4022 (*specific->resolve.f4) (e, a1, a2, a3, a4);
4023 return;
4026 a5 = arg->expr;
4027 arg = arg->next;
4029 if (arg == NULL)
4031 (*specific->resolve.f5) (e, a1, a2, a3, a4, a5);
4032 return;
4035 gfc_internal_error ("resolve_intrinsic(): Too many args for intrinsic");
4039 /* Given an intrinsic symbol node and an expression node, call the
4040 simplification function (if there is one), perhaps replacing the
4041 expression with something simpler. We return false on an error
4042 of the simplification, true if the simplification worked, even
4043 if nothing has changed in the expression itself. */
4045 static bool
4046 do_simplify (gfc_intrinsic_sym *specific, gfc_expr *e)
4048 gfc_expr *result, *a1, *a2, *a3, *a4, *a5;
4049 gfc_actual_arglist *arg;
4051 /* Max and min require special handling due to the variable number
4052 of args. */
4053 if (specific->simplify.f1 == gfc_simplify_min)
4055 result = gfc_simplify_min (e);
4056 goto finish;
4059 if (specific->simplify.f1 == gfc_simplify_max)
4061 result = gfc_simplify_max (e);
4062 goto finish;
4065 if (specific->simplify.f1 == NULL)
4067 result = NULL;
4068 goto finish;
4071 arg = e->value.function.actual;
4073 if (arg == NULL)
4075 result = (*specific->simplify.f0) ();
4076 goto finish;
4079 a1 = arg->expr;
4080 arg = arg->next;
4082 if (specific->simplify.cc == gfc_convert_constant
4083 || specific->simplify.cc == gfc_convert_char_constant)
4085 result = specific->simplify.cc (a1, specific->ts.type, specific->ts.kind);
4086 goto finish;
4089 if (arg == NULL)
4090 result = (*specific->simplify.f1) (a1);
4091 else
4093 a2 = arg->expr;
4094 arg = arg->next;
4096 if (arg == NULL)
4097 result = (*specific->simplify.f2) (a1, a2);
4098 else
4100 a3 = arg->expr;
4101 arg = arg->next;
4103 if (arg == NULL)
4104 result = (*specific->simplify.f3) (a1, a2, a3);
4105 else
4107 a4 = arg->expr;
4108 arg = arg->next;
4110 if (arg == NULL)
4111 result = (*specific->simplify.f4) (a1, a2, a3, a4);
4112 else
4114 a5 = arg->expr;
4115 arg = arg->next;
4117 if (arg == NULL)
4118 result = (*specific->simplify.f5) (a1, a2, a3, a4, a5);
4119 else
4120 gfc_internal_error
4121 ("do_simplify(): Too many args for intrinsic");
4127 finish:
4128 if (result == &gfc_bad_expr)
4129 return false;
4131 if (result == NULL)
4132 resolve_intrinsic (specific, e); /* Must call at run-time */
4133 else
4135 result->where = e->where;
4136 gfc_replace_expr (e, result);
4139 return true;
4143 /* Initialize the gfc_current_intrinsic_arg[] array for the benefit of
4144 error messages. This subroutine returns false if a subroutine
4145 has more than MAX_INTRINSIC_ARGS, in which case the actual argument
4146 list cannot match any intrinsic. */
4148 static void
4149 init_arglist (gfc_intrinsic_sym *isym)
4151 gfc_intrinsic_arg *formal;
4152 int i;
4154 gfc_current_intrinsic = isym->name;
4156 i = 0;
4157 for (formal = isym->formal; formal; formal = formal->next)
4159 if (i >= MAX_INTRINSIC_ARGS)
4160 gfc_internal_error ("init_arglist(): too many arguments");
4161 gfc_current_intrinsic_arg[i++] = formal;
4166 /* Given a pointer to an intrinsic symbol and an expression consisting
4167 of a function call, see if the function call is consistent with the
4168 intrinsic's formal argument list. Return true if the expression
4169 and intrinsic match, false otherwise. */
4171 static bool
4172 check_specific (gfc_intrinsic_sym *specific, gfc_expr *expr, int error_flag)
4174 gfc_actual_arglist *arg, **ap;
4175 bool t;
4177 ap = &expr->value.function.actual;
4179 init_arglist (specific);
4181 /* Don't attempt to sort the argument list for min or max. */
4182 if (specific->check.f1m == gfc_check_min_max
4183 || specific->check.f1m == gfc_check_min_max_integer
4184 || specific->check.f1m == gfc_check_min_max_real
4185 || specific->check.f1m == gfc_check_min_max_double)
4187 if (!do_ts29113_check (specific, *ap))
4188 return false;
4189 return (*specific->check.f1m) (*ap);
4192 if (!sort_actual (specific->name, ap, specific->formal, &expr->where))
4193 return false;
4195 if (!do_ts29113_check (specific, *ap))
4196 return false;
4198 if (specific->check.f3ml == gfc_check_minloc_maxloc)
4199 /* This is special because we might have to reorder the argument list. */
4200 t = gfc_check_minloc_maxloc (*ap);
4201 else if (specific->check.f3red == gfc_check_minval_maxval)
4202 /* This is also special because we also might have to reorder the
4203 argument list. */
4204 t = gfc_check_minval_maxval (*ap);
4205 else if (specific->check.f3red == gfc_check_product_sum)
4206 /* Same here. The difference to the previous case is that we allow a
4207 general numeric type. */
4208 t = gfc_check_product_sum (*ap);
4209 else if (specific->check.f3red == gfc_check_transf_bit_intrins)
4210 /* Same as for PRODUCT and SUM, but different checks. */
4211 t = gfc_check_transf_bit_intrins (*ap);
4212 else
4214 if (specific->check.f1 == NULL)
4216 t = check_arglist (ap, specific, error_flag);
4217 if (t)
4218 expr->ts = specific->ts;
4220 else
4221 t = do_check (specific, *ap);
4224 /* Check conformance of elemental intrinsics. */
4225 if (t && specific->elemental)
4227 int n = 0;
4228 gfc_expr *first_expr;
4229 arg = expr->value.function.actual;
4231 /* There is no elemental intrinsic without arguments. */
4232 gcc_assert(arg != NULL);
4233 first_expr = arg->expr;
4235 for ( ; arg && arg->expr; arg = arg->next, n++)
4236 if (!gfc_check_conformance (first_expr, arg->expr,
4237 "arguments '%s' and '%s' for "
4238 "intrinsic '%s'",
4239 gfc_current_intrinsic_arg[0]->name,
4240 gfc_current_intrinsic_arg[n]->name,
4241 gfc_current_intrinsic))
4242 return false;
4245 if (!t)
4246 remove_nullargs (ap);
4248 return t;
4252 /* Check whether an intrinsic belongs to whatever standard the user
4253 has chosen, taking also into account -fall-intrinsics. Here, no
4254 warning/error is emitted; but if symstd is not NULL, it is pointed to a
4255 textual representation of the symbols standard status (like
4256 "new in Fortran 2008", "a GNU extension" or "obsolescent in Fortran 95") that
4257 can be used to construct a detailed warning/error message in case of
4258 a false. */
4260 bool
4261 gfc_check_intrinsic_standard (const gfc_intrinsic_sym* isym,
4262 const char** symstd, bool silent, locus where)
4264 const char* symstd_msg;
4266 /* For -fall-intrinsics, just succeed. */
4267 if (flag_all_intrinsics)
4268 return true;
4270 /* Find the symbol's standard message for later usage. */
4271 switch (isym->standard)
4273 case GFC_STD_F77:
4274 symstd_msg = "available since Fortran 77";
4275 break;
4277 case GFC_STD_F95_OBS:
4278 symstd_msg = "obsolescent in Fortran 95";
4279 break;
4281 case GFC_STD_F95_DEL:
4282 symstd_msg = "deleted in Fortran 95";
4283 break;
4285 case GFC_STD_F95:
4286 symstd_msg = "new in Fortran 95";
4287 break;
4289 case GFC_STD_F2003:
4290 symstd_msg = "new in Fortran 2003";
4291 break;
4293 case GFC_STD_F2008:
4294 symstd_msg = "new in Fortran 2008";
4295 break;
4297 case GFC_STD_F2008_TS:
4298 symstd_msg = "new in TS 29113/TS 18508";
4299 break;
4301 case GFC_STD_GNU:
4302 symstd_msg = "a GNU Fortran extension";
4303 break;
4305 case GFC_STD_LEGACY:
4306 symstd_msg = "for backward compatibility";
4307 break;
4309 default:
4310 gfc_internal_error ("Invalid standard code on intrinsic %qs (%d)",
4311 isym->name, isym->standard);
4314 /* If warning about the standard, warn and succeed. */
4315 if (gfc_option.warn_std & isym->standard)
4317 /* Do only print a warning if not a GNU extension. */
4318 if (!silent && isym->standard != GFC_STD_GNU)
4319 gfc_warning (0, "Intrinsic %qs (is %s) is used at %L",
4320 isym->name, _(symstd_msg), &where);
4322 return true;
4325 /* If allowing the symbol's standard, succeed, too. */
4326 if (gfc_option.allow_std & isym->standard)
4327 return true;
4329 /* Otherwise, fail. */
4330 if (symstd)
4331 *symstd = _(symstd_msg);
4332 return false;
4336 /* See if a function call corresponds to an intrinsic function call.
4337 We return:
4339 MATCH_YES if the call corresponds to an intrinsic, simplification
4340 is done if possible.
4342 MATCH_NO if the call does not correspond to an intrinsic
4344 MATCH_ERROR if the call corresponds to an intrinsic but there was an
4345 error during the simplification process.
4347 The error_flag parameter enables an error reporting. */
4349 match
4350 gfc_intrinsic_func_interface (gfc_expr *expr, int error_flag)
4352 gfc_intrinsic_sym *isym, *specific;
4353 gfc_actual_arglist *actual;
4354 const char *name;
4355 int flag;
4357 if (expr->value.function.isym != NULL)
4358 return (!do_simplify(expr->value.function.isym, expr))
4359 ? MATCH_ERROR : MATCH_YES;
4361 if (!error_flag)
4362 gfc_push_suppress_errors ();
4363 flag = 0;
4365 for (actual = expr->value.function.actual; actual; actual = actual->next)
4366 if (actual->expr != NULL)
4367 flag |= (actual->expr->ts.type != BT_INTEGER
4368 && actual->expr->ts.type != BT_CHARACTER);
4370 name = expr->symtree->n.sym->name;
4372 if (expr->symtree->n.sym->intmod_sym_id)
4374 gfc_isym_id id = gfc_isym_id_by_intmod_sym (expr->symtree->n.sym);
4375 isym = specific = gfc_intrinsic_function_by_id (id);
4377 else
4378 isym = specific = gfc_find_function (name);
4380 if (isym == NULL)
4382 if (!error_flag)
4383 gfc_pop_suppress_errors ();
4384 return MATCH_NO;
4387 if ((isym->id == GFC_ISYM_REAL || isym->id == GFC_ISYM_DBLE
4388 || isym->id == GFC_ISYM_CMPLX)
4389 && gfc_init_expr_flag
4390 && !gfc_notify_std (GFC_STD_F2003, "Function %qs as initialization "
4391 "expression at %L", name, &expr->where))
4393 if (!error_flag)
4394 gfc_pop_suppress_errors ();
4395 return MATCH_ERROR;
4398 gfc_current_intrinsic_where = &expr->where;
4400 /* Bypass the generic list for min, max and ISO_C_Binding's c_loc. */
4401 if (isym->check.f1m == gfc_check_min_max)
4403 init_arglist (isym);
4405 if (isym->check.f1m(expr->value.function.actual))
4406 goto got_specific;
4408 if (!error_flag)
4409 gfc_pop_suppress_errors ();
4410 return MATCH_NO;
4413 /* If the function is generic, check all of its specific
4414 incarnations. If the generic name is also a specific, we check
4415 that name last, so that any error message will correspond to the
4416 specific. */
4417 gfc_push_suppress_errors ();
4419 if (isym->generic)
4421 for (specific = isym->specific_head; specific;
4422 specific = specific->next)
4424 if (specific == isym)
4425 continue;
4426 if (check_specific (specific, expr, 0))
4428 gfc_pop_suppress_errors ();
4429 goto got_specific;
4434 gfc_pop_suppress_errors ();
4436 if (!check_specific (isym, expr, error_flag))
4438 if (!error_flag)
4439 gfc_pop_suppress_errors ();
4440 return MATCH_NO;
4443 specific = isym;
4445 got_specific:
4446 expr->value.function.isym = specific;
4447 if (!expr->symtree->n.sym->module)
4448 gfc_intrinsic_symbol (expr->symtree->n.sym);
4450 if (!error_flag)
4451 gfc_pop_suppress_errors ();
4453 if (!do_simplify (specific, expr))
4454 return MATCH_ERROR;
4456 /* F95, 7.1.6.1, Initialization expressions
4457 (4) An elemental intrinsic function reference of type integer or
4458 character where each argument is an initialization expression
4459 of type integer or character
4461 F2003, 7.1.7 Initialization expression
4462 (4) A reference to an elemental standard intrinsic function,
4463 where each argument is an initialization expression */
4465 if (gfc_init_expr_flag && isym->elemental && flag
4466 && !gfc_notify_std (GFC_STD_F2003, "Elemental function as "
4467 "initialization expression with non-integer/non-"
4468 "character arguments at %L", &expr->where))
4469 return MATCH_ERROR;
4471 return MATCH_YES;
4475 /* See if a CALL statement corresponds to an intrinsic subroutine.
4476 Returns MATCH_YES if the subroutine corresponds to an intrinsic,
4477 MATCH_NO if not, and MATCH_ERROR if there was an error (but did
4478 correspond). */
4480 match
4481 gfc_intrinsic_sub_interface (gfc_code *c, int error_flag)
4483 gfc_intrinsic_sym *isym;
4484 const char *name;
4486 name = c->symtree->n.sym->name;
4488 if (c->symtree->n.sym->intmod_sym_id)
4490 gfc_isym_id id;
4491 id = gfc_isym_id_by_intmod_sym (c->symtree->n.sym);
4492 isym = gfc_intrinsic_subroutine_by_id (id);
4494 else
4495 isym = gfc_find_subroutine (name);
4496 if (isym == NULL)
4497 return MATCH_NO;
4499 if (!error_flag)
4500 gfc_push_suppress_errors ();
4502 init_arglist (isym);
4504 if (!sort_actual (name, &c->ext.actual, isym->formal, &c->loc))
4505 goto fail;
4507 if (!do_ts29113_check (isym, c->ext.actual))
4508 goto fail;
4510 if (isym->check.f1 != NULL)
4512 if (!do_check (isym, c->ext.actual))
4513 goto fail;
4515 else
4517 if (!check_arglist (&c->ext.actual, isym, 1))
4518 goto fail;
4521 /* The subroutine corresponds to an intrinsic. Allow errors to be
4522 seen at this point. */
4523 if (!error_flag)
4524 gfc_pop_suppress_errors ();
4526 c->resolved_isym = isym;
4527 if (isym->resolve.s1 != NULL)
4528 isym->resolve.s1 (c);
4529 else
4531 c->resolved_sym = gfc_get_intrinsic_sub_symbol (isym->lib_name);
4532 c->resolved_sym->attr.elemental = isym->elemental;
4535 if (gfc_do_concurrent_flag && !isym->pure)
4537 gfc_error ("Subroutine call to intrinsic %qs in DO CONCURRENT "
4538 "block at %L is not PURE", name, &c->loc);
4539 return MATCH_ERROR;
4542 if (!isym->pure && gfc_pure (NULL))
4544 gfc_error ("Subroutine call to intrinsic %qs at %L is not PURE", name,
4545 &c->loc);
4546 return MATCH_ERROR;
4549 if (!isym->pure)
4550 gfc_unset_implicit_pure (NULL);
4552 c->resolved_sym->attr.noreturn = isym->noreturn;
4554 return MATCH_YES;
4556 fail:
4557 if (!error_flag)
4558 gfc_pop_suppress_errors ();
4559 return MATCH_NO;
4563 /* Call gfc_convert_type() with warning enabled. */
4565 bool
4566 gfc_convert_type (gfc_expr *expr, gfc_typespec *ts, int eflag)
4568 return gfc_convert_type_warn (expr, ts, eflag, 1);
4572 /* Try to convert an expression (in place) from one type to another.
4573 'eflag' controls the behavior on error.
4575 The possible values are:
4577 1 Generate a gfc_error()
4578 2 Generate a gfc_internal_error().
4580 'wflag' controls the warning related to conversion. */
4582 bool
4583 gfc_convert_type_warn (gfc_expr *expr, gfc_typespec *ts, int eflag, int wflag)
4585 gfc_intrinsic_sym *sym;
4586 gfc_typespec from_ts;
4587 locus old_where;
4588 gfc_expr *new_expr;
4589 int rank;
4590 mpz_t *shape;
4592 from_ts = expr->ts; /* expr->ts gets clobbered */
4594 if (ts->type == BT_UNKNOWN)
4595 goto bad;
4597 /* NULL and zero size arrays get their type here. */
4598 if (expr->expr_type == EXPR_NULL
4599 || (expr->expr_type == EXPR_ARRAY && expr->value.constructor == NULL))
4601 /* Sometimes the RHS acquire the type. */
4602 expr->ts = *ts;
4603 return true;
4606 if (expr->ts.type == BT_UNKNOWN)
4607 goto bad;
4609 if (expr->ts.type == BT_DERIVED && ts->type == BT_DERIVED
4610 && gfc_compare_types (&expr->ts, ts))
4611 return true;
4613 sym = find_conv (&expr->ts, ts);
4614 if (sym == NULL)
4615 goto bad;
4617 /* At this point, a conversion is necessary. A warning may be needed. */
4618 if ((gfc_option.warn_std & sym->standard) != 0)
4620 gfc_warning_now (0, "Extension: Conversion from %s to %s at %L",
4621 gfc_typename (&from_ts), gfc_typename (ts),
4622 &expr->where);
4624 else if (wflag)
4626 if (flag_range_check && expr->expr_type == EXPR_CONSTANT
4627 && from_ts.type == ts->type)
4629 /* Do nothing. Constants of the same type are range-checked
4630 elsewhere. If a value too large for the target type is
4631 assigned, an error is generated. Not checking here avoids
4632 duplications of warnings/errors.
4633 If range checking was disabled, but -Wconversion enabled,
4634 a non range checked warning is generated below. */
4636 else if (from_ts.type == BT_LOGICAL || ts->type == BT_LOGICAL)
4638 /* Do nothing. This block exists only to simplify the other
4639 else-if expressions.
4640 LOGICAL <> LOGICAL no warning, independent of kind values
4641 LOGICAL <> INTEGER extension, warned elsewhere
4642 LOGICAL <> REAL invalid, error generated elsewhere
4643 LOGICAL <> COMPLEX invalid, error generated elsewhere */
4645 else if (from_ts.type == ts->type
4646 || (from_ts.type == BT_INTEGER && ts->type == BT_REAL)
4647 || (from_ts.type == BT_INTEGER && ts->type == BT_COMPLEX)
4648 || (from_ts.type == BT_REAL && ts->type == BT_COMPLEX))
4650 /* Larger kinds can hold values of smaller kinds without problems.
4651 Hence, only warn if target kind is smaller than the source
4652 kind - or if -Wconversion-extra is specified. */
4653 if (warn_conversion && from_ts.kind > ts->kind)
4654 gfc_warning_now (OPT_Wconversion, "Possible change of value in "
4655 "conversion from %s to %s at %L",
4656 gfc_typename (&from_ts), gfc_typename (ts),
4657 &expr->where);
4658 else if (warn_conversion_extra)
4659 gfc_warning_now (OPT_Wconversion_extra, "Conversion from %s to %s "
4660 "at %L", gfc_typename (&from_ts),
4661 gfc_typename (ts), &expr->where);
4663 else if ((from_ts.type == BT_REAL && ts->type == BT_INTEGER)
4664 || (from_ts.type == BT_COMPLEX && ts->type == BT_INTEGER)
4665 || (from_ts.type == BT_COMPLEX && ts->type == BT_REAL))
4667 /* Conversion from REAL/COMPLEX to INTEGER or COMPLEX to REAL
4668 usually comes with a loss of information, regardless of kinds. */
4669 if (warn_conversion)
4670 gfc_warning_now (OPT_Wconversion, "Possible change of value in "
4671 "conversion from %s to %s at %L",
4672 gfc_typename (&from_ts), gfc_typename (ts),
4673 &expr->where);
4675 else if (from_ts.type == BT_HOLLERITH || ts->type == BT_HOLLERITH)
4677 /* If HOLLERITH is involved, all bets are off. */
4678 if (warn_conversion)
4679 gfc_warning_now (OPT_Wconversion, "Conversion from %s to %s at %L",
4680 gfc_typename (&from_ts), gfc_typename (ts),
4681 &expr->where);
4683 else
4684 gcc_unreachable ();
4687 /* Insert a pre-resolved function call to the right function. */
4688 old_where = expr->where;
4689 rank = expr->rank;
4690 shape = expr->shape;
4692 new_expr = gfc_get_expr ();
4693 *new_expr = *expr;
4695 new_expr = gfc_build_conversion (new_expr);
4696 new_expr->value.function.name = sym->lib_name;
4697 new_expr->value.function.isym = sym;
4698 new_expr->where = old_where;
4699 new_expr->rank = rank;
4700 new_expr->shape = gfc_copy_shape (shape, rank);
4702 gfc_get_ha_sym_tree (sym->name, &new_expr->symtree);
4703 new_expr->symtree->n.sym->result = new_expr->symtree->n.sym;
4704 new_expr->symtree->n.sym->ts = *ts;
4705 new_expr->symtree->n.sym->attr.flavor = FL_PROCEDURE;
4706 new_expr->symtree->n.sym->attr.function = 1;
4707 new_expr->symtree->n.sym->attr.elemental = 1;
4708 new_expr->symtree->n.sym->attr.pure = 1;
4709 new_expr->symtree->n.sym->attr.referenced = 1;
4710 gfc_intrinsic_symbol(new_expr->symtree->n.sym);
4711 gfc_commit_symbol (new_expr->symtree->n.sym);
4713 *expr = *new_expr;
4715 free (new_expr);
4716 expr->ts = *ts;
4718 if (gfc_is_constant_expr (expr->value.function.actual->expr)
4719 && !do_simplify (sym, expr))
4722 if (eflag == 2)
4723 goto bad;
4724 return false; /* Error already generated in do_simplify() */
4727 return true;
4729 bad:
4730 if (eflag == 1)
4732 gfc_error ("Can't convert %s to %s at %L",
4733 gfc_typename (&from_ts), gfc_typename (ts), &expr->where);
4734 return false;
4737 gfc_internal_error ("Can't convert %qs to %qs at %L",
4738 gfc_typename (&from_ts), gfc_typename (ts),
4739 &expr->where);
4740 /* Not reached */
4744 bool
4745 gfc_convert_chartype (gfc_expr *expr, gfc_typespec *ts)
4747 gfc_intrinsic_sym *sym;
4748 locus old_where;
4749 gfc_expr *new_expr;
4750 int rank;
4751 mpz_t *shape;
4753 gcc_assert (expr->ts.type == BT_CHARACTER && ts->type == BT_CHARACTER);
4755 sym = find_char_conv (&expr->ts, ts);
4756 gcc_assert (sym);
4758 /* Insert a pre-resolved function call to the right function. */
4759 old_where = expr->where;
4760 rank = expr->rank;
4761 shape = expr->shape;
4763 new_expr = gfc_get_expr ();
4764 *new_expr = *expr;
4766 new_expr = gfc_build_conversion (new_expr);
4767 new_expr->value.function.name = sym->lib_name;
4768 new_expr->value.function.isym = sym;
4769 new_expr->where = old_where;
4770 new_expr->rank = rank;
4771 new_expr->shape = gfc_copy_shape (shape, rank);
4773 gfc_get_ha_sym_tree (sym->name, &new_expr->symtree);
4774 new_expr->symtree->n.sym->ts = *ts;
4775 new_expr->symtree->n.sym->attr.flavor = FL_PROCEDURE;
4776 new_expr->symtree->n.sym->attr.function = 1;
4777 new_expr->symtree->n.sym->attr.elemental = 1;
4778 new_expr->symtree->n.sym->attr.referenced = 1;
4779 gfc_intrinsic_symbol(new_expr->symtree->n.sym);
4780 gfc_commit_symbol (new_expr->symtree->n.sym);
4782 *expr = *new_expr;
4784 free (new_expr);
4785 expr->ts = *ts;
4787 if (gfc_is_constant_expr (expr->value.function.actual->expr)
4788 && !do_simplify (sym, expr))
4790 /* Error already generated in do_simplify() */
4791 return false;
4794 return true;
4798 /* Check if the passed name is name of an intrinsic (taking into account the
4799 current -std=* and -fall-intrinsic settings). If it is, see if we should
4800 warn about this as a user-procedure having the same name as an intrinsic
4801 (-Wintrinsic-shadow enabled) and do so if we should. */
4803 void
4804 gfc_warn_intrinsic_shadow (const gfc_symbol* sym, bool in_module, bool func)
4806 gfc_intrinsic_sym* isym;
4808 /* If the warning is disabled, do nothing at all. */
4809 if (!warn_intrinsic_shadow)
4810 return;
4812 /* Try to find an intrinsic of the same name. */
4813 if (func)
4814 isym = gfc_find_function (sym->name);
4815 else
4816 isym = gfc_find_subroutine (sym->name);
4818 /* If no intrinsic was found with this name or it's not included in the
4819 selected standard, everything's fine. */
4820 if (!isym || !gfc_check_intrinsic_standard (isym, NULL, true,
4821 sym->declared_at))
4822 return;
4824 /* Emit the warning. */
4825 if (in_module || sym->ns->proc_name)
4826 gfc_warning (OPT_Wintrinsic_shadow,
4827 "%qs declared at %L may shadow the intrinsic of the same"
4828 " name. In order to call the intrinsic, explicit INTRINSIC"
4829 " declarations may be required.",
4830 sym->name, &sym->declared_at);
4831 else
4832 gfc_warning (OPT_Wintrinsic_shadow,
4833 "%qs declared at %L is also the name of an intrinsic. It can"
4834 " only be called via an explicit interface or if declared"
4835 " EXTERNAL.", sym->name, &sym->declared_at);