1 /* Build up a list of intrinsic subroutines and functions for the
3 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation,
5 Contributed by Andy Vaught & Katherine Holcomb
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 2, or (at your option) any later
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING. If not, write to the Free
21 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
29 #include "intrinsic.h"
32 /* Namespace to hold the resolved symbols for intrinsic subroutines. */
33 static gfc_namespace *gfc_intrinsic_namespace;
35 int gfc_init_expr = 0;
37 /* Pointers to an intrinsic function and its argument names that are being
40 const char *gfc_current_intrinsic;
41 const char *gfc_current_intrinsic_arg[MAX_INTRINSIC_ARGS];
42 locus *gfc_current_intrinsic_where;
44 static gfc_intrinsic_sym *functions, *subroutines, *conversion, *next_sym;
45 static gfc_intrinsic_arg *next_arg;
47 static int nfunc, nsub, nargs, nconv;
50 { SZ_NOTHING = 0, SZ_SUBS, SZ_FUNCS, SZ_CONVS }
56 /* Return a letter based on the passed type. Used to construct the
57 name of a type-dependent subroutine. */
60 gfc_type_letter (bt type)
95 /* Get a symbol for a resolved name. */
98 gfc_get_intrinsic_sub_symbol (const char * name)
102 gfc_get_symbol (name, gfc_intrinsic_namespace, &sym);
103 sym->attr.always_explicit = 1;
104 sym->attr.subroutine = 1;
105 sym->attr.flavor = FL_PROCEDURE;
106 sym->attr.proc = PROC_INTRINSIC;
112 /* Return a pointer to the name of a conversion function given two
116 conv_name (gfc_typespec * from, gfc_typespec * to)
118 static char name[30];
120 sprintf (name, "__convert_%c%d_%c%d", gfc_type_letter (from->type),
121 from->kind, gfc_type_letter (to->type), to->kind);
123 return gfc_get_string (name);
127 /* Given a pair of typespecs, find the gfc_intrinsic_sym node that
128 corresponds to the conversion. Returns NULL if the conversion
131 static gfc_intrinsic_sym *
132 find_conv (gfc_typespec * from, gfc_typespec * to)
134 gfc_intrinsic_sym *sym;
138 target = conv_name (from, to);
141 for (i = 0; i < nconv; i++, sym++)
142 if (strcmp (target, sym->name) == 0)
149 /* Interface to the check functions. We break apart an argument list
150 and call the proper check function rather than forcing each
151 function to manipulate the argument list. */
154 do_check (gfc_intrinsic_sym * specific, gfc_actual_arglist * arg)
156 gfc_expr *a1, *a2, *a3, *a4, *a5;
159 return (*specific->check.f0) ();
164 return (*specific->check.f1) (a1);
169 return (*specific->check.f2) (a1, a2);
174 return (*specific->check.f3) (a1, a2, a3);
179 return (*specific->check.f4) (a1, a2, a3, a4);
184 return (*specific->check.f5) (a1, a2, a3, a4, a5);
186 gfc_internal_error ("do_check(): too many args");
190 /*********** Subroutines to build the intrinsic list ****************/
192 /* Add a single intrinsic symbol to the current list.
195 char * name of function
196 int whether function is elemental
197 int If the function can be used as an actual argument
198 bt return type of function
199 int kind of return type of function
200 int Fortran standard version
201 check pointer to check function
202 simplify pointer to simplification function
203 resolve pointer to resolution function
205 Optional arguments come in multiples of four:
206 char * name of argument
209 int arg optional flag (1=optional, 0=required)
211 The sequence is terminated by a NULL name.
213 TODO: Are checks on actual_ok implemented elsewhere, or is that just
217 add_sym (const char *name, int elemental, int actual_ok ATTRIBUTE_UNUSED,
218 bt type, int kind, int standard, gfc_check_f check,
219 gfc_simplify_f simplify, gfc_resolve_f resolve, ...)
221 char buf[GFC_MAX_SYMBOL_LEN + 11]; /* 10 for '_gfortran_', 1 for '\0' */
222 int optional, first_flag;
225 /* First check that the intrinsic belongs to the selected standard.
226 If not, don't add it to the symbol list. */
227 if (!(gfc_option.allow_std & standard)
228 && gfc_option.flag_all_intrinsics == 0)
242 next_sym->name = gfc_get_string (name);
244 strcpy (buf, "_gfortran_");
246 next_sym->lib_name = gfc_get_string (buf);
248 next_sym->elemental = elemental;
249 next_sym->ts.type = type;
250 next_sym->ts.kind = kind;
251 next_sym->standard = standard;
252 next_sym->simplify = simplify;
253 next_sym->check = check;
254 next_sym->resolve = resolve;
255 next_sym->specific = 0;
256 next_sym->generic = 0;
260 gfc_internal_error ("add_sym(): Bad sizing mode");
263 va_start (argp, resolve);
269 name = va_arg (argp, char *);
273 type = (bt) va_arg (argp, int);
274 kind = va_arg (argp, int);
275 optional = va_arg (argp, int);
277 if (sizing != SZ_NOTHING)
284 next_sym->formal = next_arg;
286 (next_arg - 1)->next = next_arg;
290 strcpy (next_arg->name, name);
291 next_arg->ts.type = type;
292 next_arg->ts.kind = kind;
293 next_arg->optional = optional;
303 /* Add a symbol to the function list where the function takes
307 add_sym_0 (const char *name, int elemental, int actual_ok, bt type,
308 int kind, int standard,
310 gfc_expr *(*simplify)(void),
311 void (*resolve)(gfc_expr *))
321 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
326 /* Add a symbol to the subroutine list where the subroutine takes
330 add_sym_0s (const char * name, int actual_ok, int standard,
331 void (*resolve)(gfc_code *))
341 add_sym (name, 1, actual_ok, BT_UNKNOWN, 0, standard, cf, sf, rf,
346 /* Add a symbol to the function list where the function takes
350 add_sym_1 (const char *name, int elemental, int actual_ok, bt type,
351 int kind, int standard,
352 try (*check)(gfc_expr *),
353 gfc_expr *(*simplify)(gfc_expr *),
354 void (*resolve)(gfc_expr *,gfc_expr *),
355 const char* a1, bt type1, int kind1, int optional1)
365 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
366 a1, type1, kind1, optional1,
371 /* Add a symbol to the subroutine list where the subroutine takes
375 add_sym_1s (const char *name, int elemental, int actual_ok, bt type,
376 int kind, int standard,
377 try (*check)(gfc_expr *),
378 gfc_expr *(*simplify)(gfc_expr *),
379 void (*resolve)(gfc_code *),
380 const char* a1, bt type1, int kind1, int optional1)
390 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
391 a1, type1, kind1, optional1,
396 /* Add a symbol from the MAX/MIN family of intrinsic functions to the
397 function. MAX et al take 2 or more arguments. */
400 add_sym_1m (const char *name, int elemental, int actual_ok, bt type,
401 int kind, int standard,
402 try (*check)(gfc_actual_arglist *),
403 gfc_expr *(*simplify)(gfc_expr *),
404 void (*resolve)(gfc_expr *,gfc_actual_arglist *),
405 const char* a1, bt type1, int kind1, int optional1,
406 const char* a2, bt type2, int kind2, int optional2)
416 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
417 a1, type1, kind1, optional1,
418 a2, type2, kind2, optional2,
423 /* Add a symbol to the function list where the function takes
427 add_sym_2 (const char *name, int elemental, int actual_ok, bt type,
428 int kind, int standard,
429 try (*check)(gfc_expr *,gfc_expr *),
430 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *),
431 void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *),
432 const char* a1, bt type1, int kind1, int optional1,
433 const char* a2, bt type2, int kind2, int optional2)
443 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
444 a1, type1, kind1, optional1,
445 a2, type2, kind2, optional2,
450 /* Add a symbol to the subroutine list where the subroutine takes
454 add_sym_2s (const char *name, int elemental, int actual_ok, bt type,
455 int kind, int standard,
456 try (*check)(gfc_expr *,gfc_expr *),
457 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *),
458 void (*resolve)(gfc_code *),
459 const char* a1, bt type1, int kind1, int optional1,
460 const char* a2, bt type2, int kind2, int optional2)
470 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
471 a1, type1, kind1, optional1,
472 a2, type2, kind2, optional2,
477 /* Add a symbol to the function list where the function takes
481 add_sym_3 (const char *name, int elemental, int actual_ok, bt type,
482 int kind, int standard,
483 try (*check)(gfc_expr *,gfc_expr *,gfc_expr *),
484 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *),
485 void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
486 const char* a1, bt type1, int kind1, int optional1,
487 const char* a2, bt type2, int kind2, int optional2,
488 const char* a3, bt type3, int kind3, int optional3)
498 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
499 a1, type1, kind1, optional1,
500 a2, type2, kind2, optional2,
501 a3, type3, kind3, optional3,
506 /* MINLOC and MAXLOC get special treatment because their argument
507 might have to be reordered. */
510 add_sym_3ml (const char *name, int elemental,
511 int actual_ok, bt type, int kind, int standard,
512 try (*check)(gfc_actual_arglist *),
513 gfc_expr*(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *),
514 void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
515 const char* a1, bt type1, int kind1, int optional1,
516 const char* a2, bt type2, int kind2, int optional2,
517 const char* a3, bt type3, int kind3, int optional3)
527 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
528 a1, type1, kind1, optional1,
529 a2, type2, kind2, optional2,
530 a3, type3, kind3, optional3,
535 /* MINVAL, MAXVAL, PRODUCT, and SUM also get special treatment because
536 their argument also might have to be reordered. */
539 add_sym_3red (const char *name, int elemental,
540 int actual_ok, bt type, int kind, int standard,
541 try (*check)(gfc_actual_arglist *),
542 gfc_expr*(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *),
543 void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
544 const char* a1, bt type1, int kind1, int optional1,
545 const char* a2, bt type2, int kind2, int optional2,
546 const char* a3, bt type3, int kind3, int optional3)
556 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
557 a1, type1, kind1, optional1,
558 a2, type2, kind2, optional2,
559 a3, type3, kind3, optional3,
564 /* Add a symbol to the subroutine list where the subroutine takes
568 add_sym_3s (const char *name, int elemental, int actual_ok, bt type,
569 int kind, int standard,
570 try (*check)(gfc_expr *,gfc_expr *,gfc_expr *),
571 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *),
572 void (*resolve)(gfc_code *),
573 const char* a1, bt type1, int kind1, int optional1,
574 const char* a2, bt type2, int kind2, int optional2,
575 const char* a3, bt type3, int kind3, int optional3)
585 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
586 a1, type1, kind1, optional1,
587 a2, type2, kind2, optional2,
588 a3, type3, kind3, optional3,
593 /* Add a symbol to the function list where the function takes
597 add_sym_4 (const char *name, int elemental, int actual_ok, bt type,
598 int kind, int standard,
599 try (*check)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
600 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
601 void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
602 const char* a1, bt type1, int kind1, int optional1,
603 const char* a2, bt type2, int kind2, int optional2,
604 const char* a3, bt type3, int kind3, int optional3,
605 const char* a4, bt type4, int kind4, int optional4 )
615 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
616 a1, type1, kind1, optional1,
617 a2, type2, kind2, optional2,
618 a3, type3, kind3, optional3,
619 a4, type4, kind4, optional4,
624 /* Add a symbol to the subroutine list where the subroutine takes
628 add_sym_4s (const char *name, int elemental, int actual_ok,
629 bt type, int kind, int standard,
630 try (*check)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
631 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
632 void (*resolve)(gfc_code *),
633 const char* a1, bt type1, int kind1, int optional1,
634 const char* a2, bt type2, int kind2, int optional2,
635 const char* a3, bt type3, int kind3, int optional3,
636 const char* a4, bt type4, int kind4, int optional4)
646 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
647 a1, type1, kind1, optional1,
648 a2, type2, kind2, optional2,
649 a3, type3, kind3, optional3,
650 a4, type4, kind4, optional4,
655 /* Add a symbol to the subroutine list where the subroutine takes
659 add_sym_5s (const char *name, int elemental, int actual_ok,
660 bt type, int kind, int standard,
661 try (*check)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
662 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
663 void (*resolve)(gfc_code *),
664 const char* a1, bt type1, int kind1, int optional1,
665 const char* a2, bt type2, int kind2, int optional2,
666 const char* a3, bt type3, int kind3, int optional3,
667 const char* a4, bt type4, int kind4, int optional4,
668 const char* a5, bt type5, int kind5, int optional5)
678 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
679 a1, type1, kind1, optional1,
680 a2, type2, kind2, optional2,
681 a3, type3, kind3, optional3,
682 a4, type4, kind4, optional4,
683 a5, type5, kind5, optional5,
688 /* Locate an intrinsic symbol given a base pointer, number of elements
689 in the table and a pointer to a name. Returns the NULL pointer if
690 a name is not found. */
692 static gfc_intrinsic_sym *
693 find_sym (gfc_intrinsic_sym * start, int n, const char *name)
698 if (strcmp (name, start->name) == 0)
709 /* Given a name, find a function in the intrinsic function table.
710 Returns NULL if not found. */
713 gfc_find_function (const char *name)
715 gfc_intrinsic_sym *sym;
717 sym = find_sym (functions, nfunc, name);
719 sym = find_sym (conversion, nconv, name);
725 /* Given a name, find a function in the intrinsic subroutine table.
726 Returns NULL if not found. */
728 static gfc_intrinsic_sym *
729 find_subroutine (const char *name)
732 return find_sym (subroutines, nsub, name);
736 /* Given a string, figure out if it is the name of a generic intrinsic
740 gfc_generic_intrinsic (const char *name)
742 gfc_intrinsic_sym *sym;
744 sym = gfc_find_function (name);
745 return (sym == NULL) ? 0 : sym->generic;
749 /* Given a string, figure out if it is the name of a specific
750 intrinsic function or not. */
753 gfc_specific_intrinsic (const char *name)
755 gfc_intrinsic_sym *sym;
757 sym = gfc_find_function (name);
758 return (sym == NULL) ? 0 : sym->specific;
762 /* Given a string, figure out if it is the name of an intrinsic
763 subroutine or function. There are no generic intrinsic
764 subroutines, they are all specific. */
767 gfc_intrinsic_name (const char *name, int subroutine_flag)
770 return subroutine_flag ?
771 find_subroutine (name) != NULL : gfc_find_function (name) != NULL;
775 /* Collect a set of intrinsic functions into a generic collection.
776 The first argument is the name of the generic function, which is
777 also the name of a specific function. The rest of the specifics
778 currently in the table are placed into the list of specific
779 functions associated with that generic. */
782 make_generic (const char *name, gfc_generic_isym_id generic_id, int standard)
784 gfc_intrinsic_sym *g;
786 if (!(gfc_option.allow_std & standard)
787 && gfc_option.flag_all_intrinsics == 0)
790 if (sizing != SZ_NOTHING)
793 g = gfc_find_function (name);
795 gfc_internal_error ("make_generic(): Can't find generic symbol '%s'",
800 g->generic_id = generic_id;
801 if ((g + 1)->name != NULL)
802 g->specific_head = g + 1;
805 while (g->name != NULL)
809 g->generic_id = generic_id;
818 /* Create a duplicate intrinsic function entry for the current
819 function, the only difference being the alternate name. Note that
820 we use argument lists more than once, but all argument lists are
821 freed as a single block. */
824 make_alias (const char *name, int standard)
827 /* First check that the intrinsic belongs to the selected standard.
828 If not, don't add it to the symbol list. */
829 if (!(gfc_option.allow_std & standard)
830 && gfc_option.flag_all_intrinsics == 0)
844 next_sym[0] = next_sym[-1];
845 next_sym->name = gfc_get_string (name);
854 /* Make the current subroutine noreturn. */
859 if (sizing == SZ_NOTHING)
860 next_sym[-1].noreturn = 1;
863 /* Add intrinsic functions. */
869 /* Argument names as in the standard (to be used as argument keywords). */
871 *a = "a", *f = "field", *pt = "pointer", *tg = "target",
872 *b = "b", *m = "matrix", *ma = "matrix_a", *mb = "matrix_b",
873 *c = "c", *n = "ncopies", *pos = "pos", *bck = "back",
874 *i = "i", *v = "vector", *va = "vector_a", *vb = "vector_b",
875 *j = "j", *a1 = "a1", *fs = "fsource", *ts = "tsource",
876 *l = "l", *a2 = "a2", *mo = "mold", *ord = "order",
877 *p = "p", *ar = "array", *shp = "shape", *src = "source",
878 *r = "r", *bd = "boundary", *pad = "pad", *set = "set",
879 *s = "s", *dm = "dim", *kind = "kind", *msk = "mask",
880 *x = "x", *sh = "shift", *stg = "string", *ssg = "substring",
881 *y = "y", *sz = "size", *sta = "string_a", *stb = "string_b",
882 *z = "z", *ln = "len", *ut = "unit", *han = "handler",
883 *num = "number", *tm = "time", *nm = "name", *md = "mode";
885 int di, dr, dd, dl, dc, dz, ii;
887 di = gfc_default_integer_kind;
888 dr = gfc_default_real_kind;
889 dd = gfc_default_double_kind;
890 dl = gfc_default_logical_kind;
891 dc = gfc_default_character_kind;
892 dz = gfc_default_complex_kind;
893 ii = gfc_index_integer_kind;
895 add_sym_1 ("abs", 1, 1, BT_REAL, dr, GFC_STD_F77,
896 gfc_check_abs, gfc_simplify_abs, gfc_resolve_abs,
897 a, BT_REAL, dr, REQUIRED);
899 add_sym_1 ("iabs", 1, 1, BT_INTEGER, di, GFC_STD_F77,
900 NULL, gfc_simplify_abs, gfc_resolve_abs,
901 a, BT_INTEGER, di, REQUIRED);
903 add_sym_1 ("dabs", 1, 1, BT_REAL, dd, GFC_STD_F77,
904 NULL, gfc_simplify_abs, gfc_resolve_abs,
905 a, BT_REAL, dd, REQUIRED);
907 add_sym_1 ("cabs", 1, 1, BT_REAL, dr, GFC_STD_F77,
908 NULL, gfc_simplify_abs, gfc_resolve_abs,
909 a, BT_COMPLEX, dz, REQUIRED);
911 add_sym_1 ("zabs", 1, 1, BT_REAL, dd, GFC_STD_GNU,
912 NULL, gfc_simplify_abs, gfc_resolve_abs,
913 a, BT_COMPLEX, dd, REQUIRED);
915 make_alias ("cdabs", GFC_STD_GNU);
917 make_generic ("abs", GFC_ISYM_ABS, GFC_STD_F77);
919 add_sym_2 ("access", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
920 gfc_check_access_func, NULL, gfc_resolve_access,
921 nm, BT_CHARACTER, dc, REQUIRED, md, BT_CHARACTER, dc, REQUIRED);
923 make_generic ("access", GFC_ISYM_ACCESS, GFC_STD_GNU);
925 add_sym_1 ("achar", 1, 1, BT_CHARACTER, dc, GFC_STD_F95,
926 gfc_check_achar, gfc_simplify_achar, NULL,
927 i, BT_INTEGER, di, REQUIRED);
929 make_generic ("achar", GFC_ISYM_ACHAR, GFC_STD_F95);
931 add_sym_1 ("acos", 1, 1, BT_REAL, dr, GFC_STD_F77,
932 gfc_check_fn_r, gfc_simplify_acos, gfc_resolve_acos,
933 x, BT_REAL, dr, REQUIRED);
935 add_sym_1 ("dacos", 1, 1, BT_REAL, dd, GFC_STD_F77,
936 NULL, gfc_simplify_acos, gfc_resolve_acos,
937 x, BT_REAL, dd, REQUIRED);
939 make_generic ("acos", GFC_ISYM_ACOS, GFC_STD_F77);
941 add_sym_1 ("acosh", 1, 1, BT_REAL, dr, GFC_STD_GNU,
942 gfc_check_fn_r, gfc_simplify_acosh, gfc_resolve_acosh,
943 x, BT_REAL, dr, REQUIRED);
945 add_sym_1 ("dacosh", 1, 1, BT_REAL, dd, GFC_STD_GNU,
946 NULL, gfc_simplify_acosh, gfc_resolve_acosh,
947 x, BT_REAL, dd, REQUIRED);
949 make_generic ("acosh", GFC_ISYM_ACOSH, GFC_STD_GNU);
951 add_sym_1 ("adjustl", 1, 1, BT_CHARACTER, dc, GFC_STD_F95,
952 NULL, gfc_simplify_adjustl, NULL,
953 stg, BT_CHARACTER, dc, REQUIRED);
955 make_generic ("adjustl", GFC_ISYM_ADJUSTL, GFC_STD_F95);
957 add_sym_1 ("adjustr", 1, 1, BT_CHARACTER, dc, GFC_STD_F95,
958 NULL, gfc_simplify_adjustr, NULL,
959 stg, BT_CHARACTER, dc, REQUIRED);
961 make_generic ("adjustr", GFC_ISYM_ADJUSTR, GFC_STD_F95);
963 add_sym_1 ("aimag", 1, 1, BT_REAL, dr, GFC_STD_F77,
964 gfc_check_fn_c, gfc_simplify_aimag, gfc_resolve_aimag,
965 z, BT_COMPLEX, dz, REQUIRED);
967 make_alias ("imag", GFC_STD_GNU);
968 make_alias ("imagpart", GFC_STD_GNU);
970 add_sym_1 ("dimag", 1, 1, BT_REAL, dd, GFC_STD_GNU,
971 NULL, gfc_simplify_aimag, gfc_resolve_aimag,
972 z, BT_COMPLEX, dd, REQUIRED);
975 make_generic ("aimag", GFC_ISYM_AIMAG, GFC_STD_F77);
977 add_sym_2 ("aint", 1, 1, BT_REAL, dr, GFC_STD_F77,
978 gfc_check_a_xkind, gfc_simplify_aint, gfc_resolve_aint,
979 a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
981 add_sym_1 ("dint", 1, 1, BT_REAL, dd, GFC_STD_F77,
982 NULL, gfc_simplify_dint, gfc_resolve_dint,
983 a, BT_REAL, dd, REQUIRED);
985 make_generic ("aint", GFC_ISYM_AINT, GFC_STD_F77);
987 add_sym_2 ("all", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
988 gfc_check_all_any, NULL, gfc_resolve_all,
989 msk, BT_LOGICAL, dl, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL);
991 make_generic ("all", GFC_ISYM_ALL, GFC_STD_F95);
993 add_sym_1 ("allocated", 0, 1, BT_LOGICAL, dl, GFC_STD_F95,
994 gfc_check_allocated, NULL, NULL,
995 ar, BT_UNKNOWN, 0, REQUIRED);
997 make_generic ("allocated", GFC_ISYM_ALLOCATED, GFC_STD_F95);
999 add_sym_2 ("anint", 1, 1, BT_REAL, dr, GFC_STD_F77,
1000 gfc_check_a_xkind, gfc_simplify_anint, gfc_resolve_anint,
1001 a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1003 add_sym_1 ("dnint", 1, 1, BT_REAL, dd, GFC_STD_F77,
1004 NULL, gfc_simplify_dnint, gfc_resolve_dnint,
1005 a, BT_REAL, dd, REQUIRED);
1007 make_generic ("anint", GFC_ISYM_ANINT, GFC_STD_F77);
1009 add_sym_2 ("any", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
1010 gfc_check_all_any, NULL, gfc_resolve_any,
1011 msk, BT_LOGICAL, dl, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL);
1013 make_generic ("any", GFC_ISYM_ANY, GFC_STD_F95);
1015 add_sym_1 ("asin", 1, 1, BT_REAL, dr, GFC_STD_F77,
1016 gfc_check_fn_r, gfc_simplify_asin, gfc_resolve_asin,
1017 x, BT_REAL, dr, REQUIRED);
1019 add_sym_1 ("dasin", 1, 1, BT_REAL, dd, GFC_STD_F77,
1020 NULL, gfc_simplify_asin, gfc_resolve_asin,
1021 x, BT_REAL, dd, REQUIRED);
1023 make_generic ("asin", GFC_ISYM_ASIN, GFC_STD_F77);
1025 add_sym_1 ("asinh", 1, 1, BT_REAL, dr, GFC_STD_GNU,
1026 gfc_check_fn_r, gfc_simplify_asinh, gfc_resolve_asinh,
1027 x, BT_REAL, dr, REQUIRED);
1029 add_sym_1 ("dasinh", 1, 1, BT_REAL, dd, GFC_STD_GNU,
1030 NULL, gfc_simplify_asinh, gfc_resolve_asinh,
1031 x, BT_REAL, dd, REQUIRED);
1033 make_generic ("asinh", GFC_ISYM_ASINH, GFC_STD_GNU);
1035 add_sym_2 ("associated", 0, 1, BT_LOGICAL, dl, GFC_STD_F95,
1036 gfc_check_associated, NULL, NULL,
1037 pt, BT_UNKNOWN, 0, REQUIRED, tg, BT_UNKNOWN, 0, OPTIONAL);
1039 make_generic ("associated", GFC_ISYM_ASSOCIATED, GFC_STD_F95);
1041 add_sym_1 ("atan", 1, 1, BT_REAL, dr, GFC_STD_F77,
1042 gfc_check_fn_r, gfc_simplify_atan, gfc_resolve_atan,
1043 x, BT_REAL, dr, REQUIRED);
1045 add_sym_1 ("datan", 1, 1, BT_REAL, dd, GFC_STD_F77,
1046 NULL, gfc_simplify_atan, gfc_resolve_atan,
1047 x, BT_REAL, dd, REQUIRED);
1049 make_generic ("atan", GFC_ISYM_ATAN, GFC_STD_F77);
1051 add_sym_1 ("atanh", 1, 1, BT_REAL, dr, GFC_STD_GNU,
1052 gfc_check_fn_r, gfc_simplify_atanh, gfc_resolve_atanh,
1053 x, BT_REAL, dr, REQUIRED);
1055 add_sym_1 ("datanh", 1, 1, BT_REAL, dd, GFC_STD_GNU,
1056 NULL, gfc_simplify_atanh, gfc_resolve_atanh,
1057 x, BT_REAL, dd, REQUIRED);
1059 make_generic ("atanh", GFC_ISYM_ATANH, GFC_STD_GNU);
1061 add_sym_2 ("atan2", 1, 1, BT_REAL, dr, GFC_STD_F77,
1062 gfc_check_atan2, gfc_simplify_atan2, gfc_resolve_atan2,
1063 y, BT_REAL, dr, REQUIRED, x, BT_REAL, dr, REQUIRED);
1065 add_sym_2 ("datan2", 1, 1, BT_REAL, dd, GFC_STD_F77,
1066 NULL, gfc_simplify_atan2, gfc_resolve_atan2,
1067 y, BT_REAL, dd, REQUIRED, x, BT_REAL, dd, REQUIRED);
1069 make_generic ("atan2", GFC_ISYM_ATAN2, GFC_STD_F77);
1071 /* Bessel and Neumann functions for G77 compatibility. */
1072 add_sym_1 ("besj0", 1, 0, BT_REAL, dr, GFC_STD_GNU,
1073 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1074 x, BT_REAL, dr, REQUIRED);
1076 add_sym_1 ("dbesj0", 1, 0, BT_REAL, dd, GFC_STD_GNU,
1077 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1078 x, BT_REAL, dd, REQUIRED);
1080 make_generic ("besj0", GFC_ISYM_J0, GFC_STD_GNU);
1082 add_sym_1 ("besj1", 1, 0, BT_REAL, dr, GFC_STD_GNU,
1083 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1084 x, BT_REAL, dr, REQUIRED);
1086 add_sym_1 ("dbesj1", 1, 0, BT_REAL, dd, GFC_STD_GNU,
1087 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1088 x, BT_REAL, dd, REQUIRED);
1090 make_generic ("besj1", GFC_ISYM_J1, GFC_STD_GNU);
1092 add_sym_2 ("besjn", 1, 0, BT_REAL, dr, GFC_STD_GNU,
1093 gfc_check_besn, NULL, gfc_resolve_besn,
1094 n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dr, REQUIRED);
1096 add_sym_2 ("dbesjn", 1, 0, BT_REAL, dd, GFC_STD_GNU,
1097 gfc_check_besn, NULL, gfc_resolve_besn,
1098 n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dd, REQUIRED);
1100 make_generic ("besjn", GFC_ISYM_JN, GFC_STD_GNU);
1102 add_sym_1 ("besy0", 1, 0, BT_REAL, dr, GFC_STD_GNU,
1103 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1104 x, BT_REAL, dr, REQUIRED);
1106 add_sym_1 ("dbesy0", 1, 0, BT_REAL, dd, GFC_STD_GNU,
1107 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1108 x, BT_REAL, dd, REQUIRED);
1110 make_generic ("besy0", GFC_ISYM_Y0, GFC_STD_GNU);
1112 add_sym_1 ("besy1", 1, 0, BT_REAL, dr, GFC_STD_GNU,
1113 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1114 x, BT_REAL, dr, REQUIRED);
1116 add_sym_1 ("dbesy1", 1, 0, BT_REAL, dd, GFC_STD_GNU,
1117 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1118 x, BT_REAL, dd, REQUIRED);
1120 make_generic ("besy1", GFC_ISYM_Y1, GFC_STD_GNU);
1122 add_sym_2 ("besyn", 1, 0, BT_REAL, dr, GFC_STD_GNU,
1123 gfc_check_besn, NULL, gfc_resolve_besn,
1124 n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dr, REQUIRED);
1126 add_sym_2 ("dbesyn", 1, 0, BT_REAL, dd, GFC_STD_GNU,
1127 gfc_check_besn, NULL, gfc_resolve_besn,
1128 n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dd, REQUIRED);
1130 make_generic ("besyn", GFC_ISYM_YN, GFC_STD_GNU);
1132 add_sym_1 ("bit_size", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1133 gfc_check_i, gfc_simplify_bit_size, NULL,
1134 i, BT_INTEGER, di, REQUIRED);
1136 make_generic ("bit_size", GFC_ISYM_NONE, GFC_STD_F95);
1138 add_sym_2 ("btest", 1, 1, BT_LOGICAL, dl, GFC_STD_F95,
1139 gfc_check_btest, gfc_simplify_btest, gfc_resolve_btest,
1140 i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED);
1142 make_generic ("btest", GFC_ISYM_BTEST, GFC_STD_F95);
1144 add_sym_2 ("ceiling", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1145 gfc_check_a_ikind, gfc_simplify_ceiling, gfc_resolve_ceiling,
1146 a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1148 make_generic ("ceiling", GFC_ISYM_CEILING, GFC_STD_F95);
1150 add_sym_2 ("char", 1, 0, BT_CHARACTER, dc, GFC_STD_F77,
1151 gfc_check_char, gfc_simplify_char, gfc_resolve_char,
1152 i, BT_INTEGER, di, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1154 make_generic ("char", GFC_ISYM_CHAR, GFC_STD_F77);
1156 add_sym_1 ("chdir", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
1157 gfc_check_chdir, NULL, gfc_resolve_chdir,
1158 a, BT_CHARACTER, dc, REQUIRED);
1160 make_generic ("chdir", GFC_ISYM_CHDIR, GFC_STD_GNU);
1162 add_sym_2 ("chmod", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
1163 gfc_check_chmod, NULL, gfc_resolve_chmod,
1164 nm, BT_CHARACTER, dc, REQUIRED, md, BT_CHARACTER, dc, REQUIRED);
1166 make_generic ("chmod", GFC_ISYM_CHMOD, GFC_STD_GNU);
1168 add_sym_3 ("cmplx", 1, 1, BT_COMPLEX, dz, GFC_STD_F77,
1169 gfc_check_cmplx, gfc_simplify_cmplx, gfc_resolve_cmplx,
1170 x, BT_UNKNOWN, dr, REQUIRED, y, BT_UNKNOWN, dr, OPTIONAL,
1171 kind, BT_INTEGER, di, OPTIONAL);
1173 make_generic ("cmplx", GFC_ISYM_CMPLX, GFC_STD_F77);
1175 add_sym_2 ("complex", 1, 1, BT_COMPLEX, dz, GFC_STD_GNU,
1176 gfc_check_complex, gfc_simplify_complex, gfc_resolve_complex,
1177 x, BT_UNKNOWN, dr, REQUIRED, y, BT_UNKNOWN, dr, REQUIRED);
1179 make_generic ("complex", GFC_ISYM_COMPLEX, GFC_STD_GNU);
1181 /* Making dcmplx a specific of cmplx causes cmplx to return a double
1182 complex instead of the default complex. */
1184 add_sym_2 ("dcmplx", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
1185 gfc_check_dcmplx, gfc_simplify_dcmplx, gfc_resolve_dcmplx,
1186 x, BT_REAL, dd, REQUIRED, y, BT_REAL, dd, OPTIONAL);
1188 make_generic ("dcmplx", GFC_ISYM_CMPLX, GFC_STD_GNU);
1190 add_sym_1 ("conjg", 1, 1, BT_COMPLEX, dz, GFC_STD_F77,
1191 gfc_check_fn_c, gfc_simplify_conjg, gfc_resolve_conjg,
1192 z, BT_COMPLEX, dz, REQUIRED);
1194 add_sym_1 ("dconjg", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
1195 NULL, gfc_simplify_conjg, gfc_resolve_conjg,
1196 z, BT_COMPLEX, dd, REQUIRED);
1198 make_generic ("conjg", GFC_ISYM_CONJG, GFC_STD_F77);
1200 add_sym_1 ("cos", 1, 1, BT_REAL, dr, GFC_STD_F77,
1201 gfc_check_fn_rc, gfc_simplify_cos, gfc_resolve_cos,
1202 x, BT_REAL, dr, REQUIRED);
1204 add_sym_1 ("dcos", 1, 1, BT_REAL, dd, GFC_STD_F77,
1205 gfc_check_fn_rc, gfc_simplify_cos, gfc_resolve_cos,
1206 x, BT_REAL, dd, REQUIRED);
1208 add_sym_1 ("ccos", 1, 1, BT_COMPLEX, dz, GFC_STD_F77,
1209 NULL, gfc_simplify_cos, gfc_resolve_cos,
1210 x, BT_COMPLEX, dz, REQUIRED);
1212 add_sym_1 ("zcos", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
1213 NULL, gfc_simplify_cos, gfc_resolve_cos,
1214 x, BT_COMPLEX, dd, REQUIRED);
1216 make_alias ("cdcos", GFC_STD_GNU);
1218 make_generic ("cos", GFC_ISYM_COS, GFC_STD_F77);
1220 add_sym_1 ("cosh", 1, 1, BT_REAL, dr, GFC_STD_F77,
1221 gfc_check_fn_r, gfc_simplify_cosh, gfc_resolve_cosh,
1222 x, BT_REAL, dr, REQUIRED);
1224 add_sym_1 ("dcosh", 1, 1, BT_REAL, dd, GFC_STD_F77,
1225 NULL, gfc_simplify_cosh, gfc_resolve_cosh,
1226 x, BT_REAL, dd, REQUIRED);
1228 make_generic ("cosh", GFC_ISYM_COSH, GFC_STD_F77);
1230 add_sym_2 ("count", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1231 gfc_check_count, NULL, gfc_resolve_count,
1232 msk, BT_LOGICAL, dl, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL);
1234 make_generic ("count", GFC_ISYM_COUNT, GFC_STD_F95);
1236 add_sym_3 ("cshift", 0, 1, BT_REAL, dr, GFC_STD_F95,
1237 gfc_check_cshift, NULL, gfc_resolve_cshift,
1238 ar, BT_REAL, dr, REQUIRED, sh, BT_INTEGER, di, REQUIRED,
1239 dm, BT_INTEGER, ii, OPTIONAL);
1241 make_generic ("cshift", GFC_ISYM_CSHIFT, GFC_STD_F95);
1243 add_sym_1 ("ctime", 0, 1, BT_CHARACTER, 0, GFC_STD_GNU,
1244 gfc_check_ctime, NULL, gfc_resolve_ctime,
1245 tm, BT_INTEGER, di, REQUIRED);
1247 make_generic ("ctime", GFC_ISYM_CTIME, GFC_STD_GNU);
1249 add_sym_1 ("dble", 1, 1, BT_REAL, dd, GFC_STD_F77,
1250 gfc_check_dble, gfc_simplify_dble, gfc_resolve_dble,
1251 a, BT_REAL, dr, REQUIRED);
1253 make_alias ("dfloat", GFC_STD_GNU);
1255 make_generic ("dble", GFC_ISYM_DBLE, GFC_STD_F77);
1257 add_sym_1 ("digits", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1258 gfc_check_digits, gfc_simplify_digits, NULL,
1259 x, BT_UNKNOWN, dr, REQUIRED);
1261 make_generic ("digits", GFC_ISYM_NONE, GFC_STD_F95);
1263 add_sym_2 ("dim", 1, 1, BT_REAL, dr, GFC_STD_F77,
1264 gfc_check_a_p, gfc_simplify_dim, gfc_resolve_dim,
1265 x, BT_UNKNOWN, dr, REQUIRED, y, BT_UNKNOWN, dr, REQUIRED);
1267 add_sym_2 ("idim", 1, 1, BT_INTEGER, di, GFC_STD_F77,
1268 NULL, gfc_simplify_dim, gfc_resolve_dim,
1269 x, BT_INTEGER, di, REQUIRED, y, BT_INTEGER, di, REQUIRED);
1271 add_sym_2 ("ddim", 1, 1, BT_REAL, dd, GFC_STD_F77,
1272 NULL, gfc_simplify_dim, gfc_resolve_dim,
1273 x, BT_REAL, dd, REQUIRED, y, BT_REAL, dd, REQUIRED);
1275 make_generic ("dim", GFC_ISYM_DIM, GFC_STD_F77);
1277 add_sym_2 ("dot_product", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
1278 gfc_check_dot_product, NULL, gfc_resolve_dot_product,
1279 va, BT_REAL, dr, REQUIRED, vb, BT_REAL, dr, REQUIRED);
1281 make_generic ("dot_product", GFC_ISYM_DOT_PRODUCT, GFC_STD_F95);
1283 add_sym_2 ("dprod", 1, 1, BT_REAL, dd, GFC_STD_F77,
1284 NULL, gfc_simplify_dprod, gfc_resolve_dprod,
1285 x, BT_REAL, dr, REQUIRED, y, BT_REAL, dr, REQUIRED);
1287 make_generic ("dprod", GFC_ISYM_DPROD, GFC_STD_F77);
1289 add_sym_1 ("dreal", 1, 0, BT_REAL, dd, GFC_STD_GNU,
1291 a, BT_COMPLEX, dd, REQUIRED);
1293 make_generic ("dreal", GFC_ISYM_REAL, GFC_STD_GNU);
1295 add_sym_4 ("eoshift", 0, 1, BT_REAL, dr, GFC_STD_F95,
1296 gfc_check_eoshift, NULL, gfc_resolve_eoshift,
1297 ar, BT_REAL, dr, 0, sh, BT_INTEGER, ii, REQUIRED,
1298 bd, BT_REAL, dr, 1, dm, BT_INTEGER, ii, OPTIONAL);
1300 make_generic ("eoshift", GFC_ISYM_EOSHIFT, GFC_STD_F95);
1302 add_sym_1 ("epsilon", 0, 1, BT_REAL, dr, GFC_STD_F95,
1303 gfc_check_x, gfc_simplify_epsilon, NULL,
1304 x, BT_REAL, dr, REQUIRED);
1306 make_generic ("epsilon", GFC_ISYM_NONE, GFC_STD_F95);
1308 /* G77 compatibility for the ERF() and ERFC() functions. */
1309 add_sym_1 ("erf", 1, 0, BT_REAL, dr, GFC_STD_GNU,
1310 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1311 x, BT_REAL, dr, REQUIRED);
1313 add_sym_1 ("derf", 1, 0, BT_REAL, dd, GFC_STD_GNU,
1314 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1315 x, BT_REAL, dd, REQUIRED);
1317 make_generic ("erf", GFC_ISYM_ERF, GFC_STD_GNU);
1319 add_sym_1 ("erfc", 1, 0, BT_REAL, dr, GFC_STD_GNU,
1320 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1321 x, BT_REAL, dr, REQUIRED);
1323 add_sym_1 ("derfc", 1, 0, BT_REAL, dd, GFC_STD_GNU,
1324 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1325 x, BT_REAL, dd, REQUIRED);
1327 make_generic ("erfc", GFC_ISYM_ERFC, GFC_STD_GNU);
1329 /* G77 compatibility */
1330 add_sym_1 ("etime", 0, 1, BT_REAL, 4, GFC_STD_GNU,
1331 gfc_check_etime, NULL, NULL,
1332 x, BT_REAL, 4, REQUIRED);
1334 make_alias ("dtime", GFC_STD_GNU);
1336 make_generic ("etime", GFC_ISYM_ETIME, GFC_STD_GNU);
1338 add_sym_1 ("exp", 1, 1, BT_REAL, dr, GFC_STD_F77,
1339 gfc_check_fn_rc, gfc_simplify_exp, gfc_resolve_exp,
1340 x, BT_REAL, dr, REQUIRED);
1342 add_sym_1 ("dexp", 1, 1, BT_REAL, dd, GFC_STD_F77,
1343 NULL, gfc_simplify_exp, gfc_resolve_exp,
1344 x, BT_REAL, dd, REQUIRED);
1346 add_sym_1 ("cexp", 1, 1, BT_COMPLEX, dz, GFC_STD_F77,
1347 NULL, gfc_simplify_exp, gfc_resolve_exp,
1348 x, BT_COMPLEX, dz, REQUIRED);
1350 add_sym_1 ("zexp", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
1351 NULL, gfc_simplify_exp, gfc_resolve_exp,
1352 x, BT_COMPLEX, dd, REQUIRED);
1354 make_alias ("cdexp", GFC_STD_GNU);
1356 make_generic ("exp", GFC_ISYM_EXP, GFC_STD_F77);
1358 add_sym_1 ("exponent", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1359 gfc_check_x, gfc_simplify_exponent, gfc_resolve_exponent,
1360 x, BT_REAL, dr, REQUIRED);
1362 make_generic ("exponent", GFC_ISYM_EXPONENT, GFC_STD_F95);
1364 add_sym_0 ("fdate", 1, 0, BT_CHARACTER, dc, GFC_STD_GNU,
1365 NULL, NULL, gfc_resolve_fdate);
1367 make_generic ("fdate", GFC_ISYM_FDATE, GFC_STD_GNU);
1369 add_sym_2 ("floor", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1370 gfc_check_a_ikind, gfc_simplify_floor, gfc_resolve_floor,
1371 a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1373 make_generic ("floor", GFC_ISYM_FLOOR, GFC_STD_F95);
1375 /* G77 compatible fnum */
1376 add_sym_1 ("fnum", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
1377 gfc_check_fnum, NULL, gfc_resolve_fnum,
1378 ut, BT_INTEGER, di, REQUIRED);
1380 make_generic ("fnum", GFC_ISYM_FNUM, GFC_STD_GNU);
1382 add_sym_1 ("fraction", 1, 1, BT_REAL, dr, GFC_STD_F95,
1383 gfc_check_x, gfc_simplify_fraction, gfc_resolve_fraction,
1384 x, BT_REAL, dr, REQUIRED);
1386 make_generic ("fraction", GFC_ISYM_FRACTION, GFC_STD_F95);
1388 add_sym_2 ("fstat", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
1389 gfc_check_fstat, NULL, gfc_resolve_fstat,
1390 a, BT_INTEGER, di, REQUIRED, b, BT_INTEGER, di, REQUIRED);
1392 make_generic ("fstat", GFC_ISYM_FSTAT, GFC_STD_GNU);
1394 add_sym_1 ("ftell", 0, 1, BT_INTEGER, ii, GFC_STD_GNU,
1395 gfc_check_ftell, NULL, gfc_resolve_ftell,
1396 ut, BT_INTEGER, di, REQUIRED);
1398 make_generic ("ftell", GFC_ISYM_FTELL, GFC_STD_GNU);
1400 add_sym_2 ("fgetc", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
1401 gfc_check_fgetputc, NULL, gfc_resolve_fgetc,
1402 ut, BT_INTEGER, di, REQUIRED, c, BT_CHARACTER, dc, REQUIRED);
1404 make_generic ("fgetc", GFC_ISYM_FGETC, GFC_STD_GNU);
1406 add_sym_1 ("fget", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
1407 gfc_check_fgetput, NULL, gfc_resolve_fget,
1408 c, BT_CHARACTER, dc, REQUIRED);
1410 make_generic ("fget", GFC_ISYM_FGET, GFC_STD_GNU);
1412 add_sym_2 ("fputc", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
1413 gfc_check_fgetputc, NULL, gfc_resolve_fputc,
1414 ut, BT_INTEGER, di, REQUIRED, c, BT_CHARACTER, dc, REQUIRED);
1416 make_generic ("fputc", GFC_ISYM_FPUTC, GFC_STD_GNU);
1418 add_sym_1 ("fput", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
1419 gfc_check_fgetput, NULL, gfc_resolve_fput,
1420 c, BT_CHARACTER, dc, REQUIRED);
1422 make_generic ("fput", GFC_ISYM_FPUT, GFC_STD_GNU);
1424 /* Unix IDs (g77 compatibility) */
1425 add_sym_1 ("getcwd", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
1426 NULL, NULL, gfc_resolve_getcwd,
1427 c, BT_CHARACTER, dc, REQUIRED);
1429 make_generic ("getcwd", GFC_ISYM_GETCWD, GFC_STD_GNU);
1431 add_sym_0 ("getgid", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
1432 NULL, NULL, gfc_resolve_getgid);
1434 make_generic ("getgid", GFC_ISYM_GETGID, GFC_STD_GNU);
1436 add_sym_0 ("getpid", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
1437 NULL, NULL, gfc_resolve_getpid);
1439 make_generic ("getpid", GFC_ISYM_GETPID, GFC_STD_GNU);
1441 add_sym_0 ("getuid", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
1442 NULL, NULL, gfc_resolve_getuid);
1444 make_generic ("getuid", GFC_ISYM_GETUID, GFC_STD_GNU);
1446 add_sym_1 ("hostnm", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
1447 gfc_check_hostnm, NULL, gfc_resolve_hostnm,
1448 a, BT_CHARACTER, dc, REQUIRED);
1450 make_generic ("hostnm", GFC_ISYM_HOSTNM, GFC_STD_GNU);
1452 add_sym_1 ("huge", 0, 1, BT_REAL, dr, GFC_STD_F95,
1453 gfc_check_huge, gfc_simplify_huge, NULL,
1454 x, BT_UNKNOWN, dr, REQUIRED);
1456 make_generic ("huge", GFC_ISYM_NONE, GFC_STD_F95);
1458 add_sym_1 ("iachar", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1459 gfc_check_ichar_iachar, gfc_simplify_iachar, NULL,
1460 c, BT_CHARACTER, dc, REQUIRED);
1462 make_generic ("iachar", GFC_ISYM_IACHAR, GFC_STD_F95);
1464 add_sym_2 ("iand", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1465 gfc_check_iand, gfc_simplify_iand, gfc_resolve_iand,
1466 i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED);
1468 make_generic ("iand", GFC_ISYM_IAND, GFC_STD_F95);
1470 add_sym_2 ("and", 1, 0, BT_UNKNOWN, 0, GFC_STD_GNU,
1471 gfc_check_and, gfc_simplify_and, gfc_resolve_and,
1472 i, BT_UNKNOWN, 0, REQUIRED, j, BT_UNKNOWN, 0, REQUIRED);
1474 make_generic ("and", GFC_ISYM_AND, GFC_STD_GNU);
1476 add_sym_0 ("iargc", 1, 1, BT_INTEGER, di, GFC_STD_GNU,
1479 make_generic ("iargc", GFC_ISYM_IARGC, GFC_STD_GNU);
1481 add_sym_0 ("command_argument_count", 1, 1, BT_INTEGER, di, GFC_STD_F2003,
1484 make_generic ("command_argument_count", GFC_ISYM_COMMAND_ARGUMENT_COUNT,
1487 add_sym_2 ("ibclr", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1488 gfc_check_ibclr, gfc_simplify_ibclr, gfc_resolve_ibclr,
1489 i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED);
1491 make_generic ("ibclr", GFC_ISYM_IBCLR, GFC_STD_F95);
1493 add_sym_3 ("ibits", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1494 gfc_check_ibits, gfc_simplify_ibits, gfc_resolve_ibits,
1495 i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED,
1496 ln, BT_INTEGER, di, REQUIRED);
1498 make_generic ("ibits", GFC_ISYM_IBITS, GFC_STD_F95);
1500 add_sym_2 ("ibset", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1501 gfc_check_ibset, gfc_simplify_ibset, gfc_resolve_ibset,
1502 i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED);
1504 make_generic ("ibset", GFC_ISYM_IBSET, GFC_STD_F95);
1506 add_sym_1 ("ichar", 1, 0, BT_INTEGER, di, GFC_STD_F77,
1507 gfc_check_ichar_iachar, gfc_simplify_ichar, gfc_resolve_ichar,
1508 c, BT_CHARACTER, dc, REQUIRED);
1510 make_generic ("ichar", GFC_ISYM_ICHAR, GFC_STD_F77);
1512 add_sym_2 ("ieor", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1513 gfc_check_ieor, gfc_simplify_ieor, gfc_resolve_ieor,
1514 i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED);
1516 make_generic ("ieor", GFC_ISYM_IEOR, GFC_STD_F95);
1518 add_sym_2 ("xor", 1, 0, BT_UNKNOWN, 0, GFC_STD_GNU,
1519 gfc_check_and, gfc_simplify_xor, gfc_resolve_xor,
1520 i, BT_UNKNOWN, 0, REQUIRED, j, BT_UNKNOWN, 0, REQUIRED);
1522 make_generic ("xor", GFC_ISYM_XOR, GFC_STD_GNU);
1524 add_sym_0 ("ierrno", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
1525 NULL, NULL, gfc_resolve_ierrno);
1527 make_generic ("ierrno", GFC_ISYM_IERRNO, GFC_STD_GNU);
1529 add_sym_3 ("index", 1, 1, BT_INTEGER, di, GFC_STD_F77,
1530 gfc_check_index, gfc_simplify_index, NULL,
1531 stg, BT_CHARACTER, dc, REQUIRED, ssg, BT_CHARACTER, dc, REQUIRED,
1532 bck, BT_LOGICAL, dl, OPTIONAL);
1534 make_generic ("index", GFC_ISYM_INDEX, GFC_STD_F77);
1536 add_sym_2 ("int", 1, 1, BT_INTEGER, di, GFC_STD_F77,
1537 gfc_check_int, gfc_simplify_int, gfc_resolve_int,
1538 a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1540 add_sym_1 ("ifix", 1, 0, BT_INTEGER, di, GFC_STD_F77,
1541 NULL, gfc_simplify_ifix, NULL,
1542 a, BT_REAL, dr, REQUIRED);
1544 add_sym_1 ("idint", 1, 0, BT_INTEGER, di, GFC_STD_F77,
1545 NULL, gfc_simplify_idint, NULL,
1546 a, BT_REAL, dd, REQUIRED);
1548 make_generic ("int", GFC_ISYM_INT, GFC_STD_F77);
1550 add_sym_1 ("int2", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
1551 gfc_check_intconv, gfc_simplify_int2, gfc_resolve_int2,
1552 a, BT_REAL, dr, REQUIRED);
1554 make_alias ("short", GFC_STD_GNU);
1556 make_generic ("int2", GFC_ISYM_INT2, GFC_STD_GNU);
1558 add_sym_1 ("int8", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
1559 gfc_check_intconv, gfc_simplify_int8, gfc_resolve_int8,
1560 a, BT_REAL, dr, REQUIRED);
1562 make_generic ("int8", GFC_ISYM_INT8, GFC_STD_GNU);
1564 add_sym_1 ("long", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
1565 gfc_check_intconv, gfc_simplify_long, gfc_resolve_long,
1566 a, BT_REAL, dr, REQUIRED);
1568 make_generic ("long", GFC_ISYM_LONG, GFC_STD_GNU);
1570 add_sym_2 ("ior", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1571 gfc_check_ior, gfc_simplify_ior, gfc_resolve_ior,
1572 i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED);
1574 make_generic ("ior", GFC_ISYM_IOR, GFC_STD_F95);
1576 add_sym_2 ("or", 1, 0, BT_UNKNOWN, 0, GFC_STD_GNU,
1577 gfc_check_and, gfc_simplify_or, gfc_resolve_or,
1578 i, BT_UNKNOWN, 0, REQUIRED, j, BT_UNKNOWN, 0, REQUIRED);
1580 make_generic ("or", GFC_ISYM_OR, GFC_STD_GNU);
1582 /* The following function is for G77 compatibility. */
1583 add_sym_1 ("irand", 0, 1, BT_INTEGER, 4, GFC_STD_GNU,
1584 gfc_check_irand, NULL, NULL,
1585 i, BT_INTEGER, 4, OPTIONAL);
1587 make_generic ("irand", GFC_ISYM_IRAND, GFC_STD_GNU);
1589 add_sym_1 ("isatty", 0, 0, BT_LOGICAL, dl, GFC_STD_GNU,
1590 gfc_check_isatty, NULL, gfc_resolve_isatty,
1591 ut, BT_INTEGER, di, REQUIRED);
1593 make_generic ("isatty", GFC_ISYM_ISATTY, GFC_STD_GNU);
1595 add_sym_2 ("rshift", 1, 1, BT_INTEGER, di, GFC_STD_GNU,
1596 gfc_check_ishft, NULL, gfc_resolve_rshift,
1597 i, BT_INTEGER, di, REQUIRED, sh, BT_INTEGER, di, REQUIRED);
1599 make_generic ("rshift", GFC_ISYM_RSHIFT, GFC_STD_GNU);
1601 add_sym_2 ("lshift", 1, 1, BT_INTEGER, di, GFC_STD_GNU,
1602 gfc_check_ishft, NULL, gfc_resolve_lshift,
1603 i, BT_INTEGER, di, REQUIRED, sh, BT_INTEGER, di, REQUIRED);
1605 make_generic ("lshift", GFC_ISYM_LSHIFT, GFC_STD_GNU);
1607 add_sym_2 ("ishft", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1608 gfc_check_ishft, gfc_simplify_ishft, gfc_resolve_ishft,
1609 i, BT_INTEGER, di, REQUIRED, sh, BT_INTEGER, di, REQUIRED);
1611 make_generic ("ishft", GFC_ISYM_ISHFT, GFC_STD_F95);
1613 add_sym_3 ("ishftc", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1614 gfc_check_ishftc, gfc_simplify_ishftc, gfc_resolve_ishftc,
1615 i, BT_INTEGER, di, REQUIRED, sh, BT_INTEGER, di, REQUIRED,
1616 sz, BT_INTEGER, di, OPTIONAL);
1618 make_generic ("ishftc", GFC_ISYM_ISHFTC, GFC_STD_F95);
1620 add_sym_2 ("kill", 1, 1, BT_INTEGER, di, GFC_STD_GNU,
1621 gfc_check_kill, NULL, gfc_resolve_kill,
1622 a, BT_INTEGER, di, REQUIRED, b, BT_INTEGER, di, REQUIRED);
1624 make_generic ("kill", GFC_ISYM_KILL, GFC_STD_GNU);
1626 add_sym_1 ("kind", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1627 gfc_check_kind, gfc_simplify_kind, NULL,
1628 x, BT_REAL, dr, REQUIRED);
1630 make_generic ("kind", GFC_ISYM_NONE, GFC_STD_F95);
1632 add_sym_2 ("lbound", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1633 gfc_check_lbound, gfc_simplify_lbound, gfc_resolve_lbound,
1634 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, di, OPTIONAL);
1636 make_generic ("lbound", GFC_ISYM_LBOUND, GFC_STD_F95);
1638 add_sym_1 ("len", 0, 1, BT_INTEGER, di, GFC_STD_F77,
1639 NULL, gfc_simplify_len, gfc_resolve_len,
1640 stg, BT_CHARACTER, dc, REQUIRED);
1642 make_generic ("len", GFC_ISYM_LEN, GFC_STD_F77);
1644 add_sym_1 ("len_trim", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1645 NULL, gfc_simplify_len_trim, gfc_resolve_len_trim,
1646 stg, BT_CHARACTER, dc, REQUIRED);
1648 make_alias ("lnblnk", GFC_STD_GNU);
1650 make_generic ("len_trim", GFC_ISYM_LEN_TRIM, GFC_STD_F95);
1652 add_sym_2 ("lge", 1, 0, BT_LOGICAL, dl, GFC_STD_F77,
1653 NULL, gfc_simplify_lge, NULL,
1654 sta, BT_CHARACTER, dc, REQUIRED, stb, BT_CHARACTER, dc, REQUIRED);
1656 make_generic ("lge", GFC_ISYM_LGE, GFC_STD_F77);
1658 add_sym_2 ("lgt", 1, 0, BT_LOGICAL, dl, GFC_STD_F77,
1659 NULL, gfc_simplify_lgt, NULL,
1660 sta, BT_CHARACTER, dc, REQUIRED, stb, BT_CHARACTER, dc, REQUIRED);
1662 make_generic ("lgt", GFC_ISYM_LGT, GFC_STD_F77);
1664 add_sym_2 ("lle", 1, 0, BT_LOGICAL, dl, GFC_STD_F77,
1665 NULL, gfc_simplify_lle, NULL,
1666 sta, BT_CHARACTER, dc, REQUIRED, stb, BT_CHARACTER, dc, REQUIRED);
1668 make_generic ("lle", GFC_ISYM_LLE, GFC_STD_F77);
1670 add_sym_2 ("llt", 1, 0, BT_LOGICAL, dl, GFC_STD_F77,
1671 NULL, gfc_simplify_llt, NULL,
1672 sta, BT_CHARACTER, dc, REQUIRED, stb, BT_CHARACTER, dc, REQUIRED);
1674 make_generic ("llt", GFC_ISYM_LLT, GFC_STD_F77);
1676 add_sym_2 ("link", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
1677 gfc_check_link, NULL, gfc_resolve_link,
1678 a, BT_CHARACTER, dc, REQUIRED, b, BT_CHARACTER, dc, REQUIRED);
1680 make_generic ("link", GFC_ISYM_LINK, GFC_STD_GNU);
1682 add_sym_1 ("log", 1, 1, BT_REAL, dr, GFC_STD_F77,
1683 gfc_check_fn_rc, gfc_simplify_log, gfc_resolve_log,
1684 x, BT_REAL, dr, REQUIRED);
1686 add_sym_1 ("alog", 1, 1, BT_REAL, dr, GFC_STD_F77,
1687 NULL, gfc_simplify_log, gfc_resolve_log,
1688 x, BT_REAL, dr, REQUIRED);
1690 add_sym_1 ("dlog", 1, 1, BT_REAL, dd, GFC_STD_F77,
1691 NULL, gfc_simplify_log, gfc_resolve_log,
1692 x, BT_REAL, dd, REQUIRED);
1694 add_sym_1 ("clog", 1, 1, BT_COMPLEX, dz, GFC_STD_F77,
1695 NULL, gfc_simplify_log, gfc_resolve_log,
1696 x, BT_COMPLEX, dz, REQUIRED);
1698 add_sym_1 ("zlog", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
1699 NULL, gfc_simplify_log, gfc_resolve_log,
1700 x, BT_COMPLEX, dd, REQUIRED);
1702 make_alias ("cdlog", GFC_STD_GNU);
1704 make_generic ("log", GFC_ISYM_LOG, GFC_STD_F77);
1706 add_sym_1 ("log10", 1, 1, BT_REAL, dr, GFC_STD_F77,
1707 gfc_check_fn_r, gfc_simplify_log10, gfc_resolve_log10,
1708 x, BT_REAL, dr, REQUIRED);
1710 add_sym_1 ("alog10", 1, 1, BT_REAL, dr, GFC_STD_F77,
1711 NULL, gfc_simplify_log10, gfc_resolve_log10,
1712 x, BT_REAL, dr, REQUIRED);
1714 add_sym_1 ("dlog10", 1, 1, BT_REAL, dd, GFC_STD_F77,
1715 NULL, gfc_simplify_log10, gfc_resolve_log10,
1716 x, BT_REAL, dd, REQUIRED);
1718 make_generic ("log10", GFC_ISYM_LOG10, GFC_STD_F77);
1720 add_sym_2 ("logical", 1, 1, BT_LOGICAL, dl, GFC_STD_F95,
1721 gfc_check_logical, gfc_simplify_logical, gfc_resolve_logical,
1722 l, BT_LOGICAL, dl, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1724 make_generic ("logical", GFC_ISYM_LOGICAL, GFC_STD_F95);
1726 add_sym_2 ("lstat", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
1727 gfc_check_stat, NULL, gfc_resolve_lstat,
1728 a, BT_CHARACTER, dc, REQUIRED, b, BT_INTEGER, di, REQUIRED);
1730 make_generic ("lstat", GFC_ISYM_LSTAT, GFC_STD_GNU);
1732 add_sym_1 ("malloc", 0, 1, BT_INTEGER, ii, GFC_STD_GNU, gfc_check_malloc,
1733 NULL, gfc_resolve_malloc, a, BT_INTEGER, di, REQUIRED);
1735 make_generic ("malloc", GFC_ISYM_MALLOC, GFC_STD_GNU);
1737 add_sym_2 ("matmul", 0, 1, BT_REAL, dr, GFC_STD_F95,
1738 gfc_check_matmul, NULL, gfc_resolve_matmul,
1739 ma, BT_REAL, dr, REQUIRED, mb, BT_REAL, dr, REQUIRED);
1741 make_generic ("matmul", GFC_ISYM_MATMUL, GFC_STD_F95);
1743 /* Note: amax0 is equivalent to real(max), max1 is equivalent to
1744 int(max). The max function must take at least two arguments. */
1746 add_sym_1m ("max", 1, 0, BT_UNKNOWN, 0, GFC_STD_F77,
1747 gfc_check_min_max, gfc_simplify_max, gfc_resolve_max,
1748 a1, BT_UNKNOWN, dr, REQUIRED, a2, BT_UNKNOWN, dr, REQUIRED);
1750 add_sym_1m ("max0", 1, 0, BT_INTEGER, di, GFC_STD_F77,
1751 gfc_check_min_max_integer, gfc_simplify_max, NULL,
1752 a1, BT_INTEGER, di, REQUIRED, a2, BT_INTEGER, di, REQUIRED);
1754 add_sym_1m ("amax0", 1, 0, BT_REAL, dr, GFC_STD_F77,
1755 gfc_check_min_max_integer, gfc_simplify_max, NULL,
1756 a1, BT_INTEGER, di, REQUIRED, a2, BT_INTEGER, di, REQUIRED);
1758 add_sym_1m ("amax1", 1, 0, BT_REAL, dr, GFC_STD_F77,
1759 gfc_check_min_max_real, gfc_simplify_max, NULL,
1760 a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED);
1762 add_sym_1m ("max1", 1, 0, BT_INTEGER, di, GFC_STD_F77,
1763 gfc_check_min_max_real, gfc_simplify_max, NULL,
1764 a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED);
1766 add_sym_1m ("dmax1", 1, 0, BT_REAL, dd, GFC_STD_F77,
1767 gfc_check_min_max_double, gfc_simplify_max, NULL,
1768 a1, BT_REAL, dd, REQUIRED, a2, BT_REAL, dd, REQUIRED);
1770 make_generic ("max", GFC_ISYM_MAX, GFC_STD_F77);
1772 add_sym_1 ("maxexponent", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1773 gfc_check_x, gfc_simplify_maxexponent, NULL,
1774 x, BT_UNKNOWN, dr, REQUIRED);
1776 make_generic ("maxexponent", GFC_ISYM_NONE, GFC_STD_F95);
1778 add_sym_3ml ("maxloc", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1779 gfc_check_minloc_maxloc, NULL, gfc_resolve_maxloc,
1780 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
1781 msk, BT_LOGICAL, dl, OPTIONAL);
1783 make_generic ("maxloc", GFC_ISYM_MAXLOC, GFC_STD_F95);
1785 add_sym_3red ("maxval", 0, 1, BT_REAL, dr, GFC_STD_F95,
1786 gfc_check_minval_maxval, NULL, gfc_resolve_maxval,
1787 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
1788 msk, BT_LOGICAL, dl, OPTIONAL);
1790 make_generic ("maxval", GFC_ISYM_MAXVAL, GFC_STD_F95);
1792 add_sym_0 ("mclock", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
1793 NULL, NULL, gfc_resolve_mclock);
1795 make_generic ("mclock", GFC_ISYM_MCLOCK, GFC_STD_GNU);
1797 add_sym_0 ("mclock8", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
1798 NULL, NULL, gfc_resolve_mclock8);
1800 make_generic ("mclock8", GFC_ISYM_MCLOCK8, GFC_STD_GNU);
1802 add_sym_3 ("merge", 1, 1, BT_REAL, dr, GFC_STD_F95,
1803 gfc_check_merge, NULL, gfc_resolve_merge,
1804 ts, BT_REAL, dr, REQUIRED, fs, BT_REAL, dr, REQUIRED,
1805 msk, BT_LOGICAL, dl, REQUIRED);
1807 make_generic ("merge", GFC_ISYM_MERGE, GFC_STD_F95);
1809 /* Note: amin0 is equivalent to real(min), min1 is equivalent to
1812 add_sym_1m ("min", 1, 0, BT_UNKNOWN, 0, GFC_STD_F77,
1813 gfc_check_min_max, gfc_simplify_min, gfc_resolve_min,
1814 a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED);
1816 add_sym_1m ("min0", 1, 0, BT_INTEGER, di, GFC_STD_F77,
1817 gfc_check_min_max_integer, gfc_simplify_min, NULL,
1818 a1, BT_INTEGER, di, REQUIRED, a2, BT_INTEGER, di, REQUIRED);
1820 add_sym_1m ("amin0", 1, 0, BT_REAL, dr, GFC_STD_F77,
1821 gfc_check_min_max_integer, gfc_simplify_min, NULL,
1822 a1, BT_INTEGER, di, REQUIRED, a2, BT_INTEGER, di, REQUIRED);
1824 add_sym_1m ("amin1", 1, 0, BT_REAL, dr, GFC_STD_F77,
1825 gfc_check_min_max_real, gfc_simplify_min, NULL,
1826 a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED);
1828 add_sym_1m ("min1", 1, 0, BT_INTEGER, di, GFC_STD_F77,
1829 gfc_check_min_max_real, gfc_simplify_min, NULL,
1830 a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED);
1832 add_sym_1m ("dmin1", 1, 0, BT_REAL, dd, GFC_STD_F77,
1833 gfc_check_min_max_double, gfc_simplify_min, NULL,
1834 a1, BT_REAL, dd, REQUIRED, a2, BT_REAL, dd, REQUIRED);
1836 make_generic ("min", GFC_ISYM_MIN, GFC_STD_F77);
1838 add_sym_1 ("minexponent", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1839 gfc_check_x, gfc_simplify_minexponent, NULL,
1840 x, BT_UNKNOWN, dr, REQUIRED);
1842 make_generic ("minexponent", GFC_ISYM_NONE, GFC_STD_F95);
1844 add_sym_3ml ("minloc", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1845 gfc_check_minloc_maxloc, NULL, gfc_resolve_minloc,
1846 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
1847 msk, BT_LOGICAL, dl, OPTIONAL);
1849 make_generic ("minloc", GFC_ISYM_MINLOC, GFC_STD_F95);
1851 add_sym_3red ("minval", 0, 1, BT_REAL, dr, GFC_STD_F95,
1852 gfc_check_minval_maxval, NULL, gfc_resolve_minval,
1853 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
1854 msk, BT_LOGICAL, dl, OPTIONAL);
1856 make_generic ("minval", GFC_ISYM_MINVAL, GFC_STD_F95);
1858 add_sym_2 ("mod", 1, 1, BT_INTEGER, di, GFC_STD_F77,
1859 gfc_check_a_p, gfc_simplify_mod, gfc_resolve_mod,
1860 a, BT_INTEGER, di, REQUIRED, p, BT_INTEGER, di, REQUIRED);
1862 add_sym_2 ("amod", 1, 1, BT_REAL, dr, GFC_STD_F77,
1863 NULL, gfc_simplify_mod, gfc_resolve_mod,
1864 a, BT_REAL, dr, REQUIRED, p, BT_REAL, dr, REQUIRED);
1866 add_sym_2 ("dmod", 1, 1, BT_REAL, dd, GFC_STD_F77,
1867 NULL, gfc_simplify_mod, gfc_resolve_mod,
1868 a, BT_REAL, dd, REQUIRED, p, BT_REAL, dd, REQUIRED);
1870 make_generic ("mod", GFC_ISYM_MOD, GFC_STD_F77);
1872 add_sym_2 ("modulo", 1, 0, BT_REAL, di, GFC_STD_F95,
1873 gfc_check_a_p, gfc_simplify_modulo, gfc_resolve_modulo,
1874 a, BT_REAL, di, REQUIRED, p, BT_REAL, di, REQUIRED);
1876 make_generic ("modulo", GFC_ISYM_MODULO, GFC_STD_F95);
1878 add_sym_2 ("nearest", 1, 1, BT_REAL, dr, GFC_STD_F95,
1879 gfc_check_nearest, gfc_simplify_nearest, gfc_resolve_nearest,
1880 x, BT_REAL, dr, REQUIRED, s, BT_REAL, dr, REQUIRED);
1882 make_generic ("nearest", GFC_ISYM_NEAREST, GFC_STD_F95);
1884 add_sym_2 ("nint", 1, 1, BT_INTEGER, di, GFC_STD_F77,
1885 gfc_check_a_ikind, gfc_simplify_nint, gfc_resolve_nint,
1886 a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1888 add_sym_1 ("idnint", 1, 1, BT_INTEGER, di, GFC_STD_F77,
1889 gfc_check_idnint, gfc_simplify_idnint, gfc_resolve_idnint,
1890 a, BT_REAL, dd, REQUIRED);
1892 make_generic ("nint", GFC_ISYM_NINT, GFC_STD_F77);
1894 add_sym_1 ("not", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1895 gfc_check_i, gfc_simplify_not, gfc_resolve_not,
1896 i, BT_INTEGER, di, REQUIRED);
1898 make_generic ("not", GFC_ISYM_NOT, GFC_STD_F95);
1900 add_sym_1 ("null", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1901 gfc_check_null, gfc_simplify_null, NULL,
1902 mo, BT_INTEGER, di, OPTIONAL);
1904 make_generic ("null", GFC_ISYM_NONE, GFC_STD_F95);
1906 add_sym_3 ("pack", 0, 1, BT_REAL, dr, GFC_STD_F95,
1907 gfc_check_pack, NULL, gfc_resolve_pack,
1908 ar, BT_REAL, dr, REQUIRED, msk, BT_LOGICAL, dl, REQUIRED,
1909 v, BT_REAL, dr, OPTIONAL);
1911 make_generic ("pack", GFC_ISYM_PACK, GFC_STD_F95);
1913 add_sym_1 ("precision", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1914 gfc_check_precision, gfc_simplify_precision, NULL,
1915 x, BT_UNKNOWN, 0, REQUIRED);
1917 make_generic ("precision", GFC_ISYM_NONE, GFC_STD_F95);
1919 add_sym_1 ("present", 0, 1, BT_LOGICAL, dl, GFC_STD_F95,
1920 gfc_check_present, NULL, NULL,
1921 a, BT_REAL, dr, REQUIRED);
1923 make_generic ("present", GFC_ISYM_PRESENT, GFC_STD_F95);
1925 add_sym_3red ("product", 0, 1, BT_REAL, dr, GFC_STD_F95,
1926 gfc_check_product_sum, NULL, gfc_resolve_product,
1927 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
1928 msk, BT_LOGICAL, dl, OPTIONAL);
1930 make_generic ("product", GFC_ISYM_PRODUCT, GFC_STD_F95);
1932 add_sym_1 ("radix", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1933 gfc_check_radix, gfc_simplify_radix, NULL,
1934 x, BT_UNKNOWN, 0, REQUIRED);
1936 make_generic ("radix", GFC_ISYM_NONE, GFC_STD_F95);
1938 /* The following function is for G77 compatibility. */
1939 add_sym_1 ("rand", 0, 1, BT_REAL, 4, GFC_STD_GNU,
1940 gfc_check_rand, NULL, NULL,
1941 i, BT_INTEGER, 4, OPTIONAL);
1943 /* Compatibility with HP FORTRAN 77/iX Reference. Note, rand() and ran()
1944 use slightly different shoddy multiplicative congruential PRNG. */
1945 make_alias ("ran", GFC_STD_GNU);
1947 make_generic ("rand", GFC_ISYM_RAND, GFC_STD_GNU);
1949 add_sym_1 ("range", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1950 gfc_check_range, gfc_simplify_range, NULL,
1951 x, BT_REAL, dr, REQUIRED);
1953 make_generic ("range", GFC_ISYM_NONE, GFC_STD_F95);
1955 add_sym_2 ("real", 1, 0, BT_REAL, dr, GFC_STD_F77,
1956 gfc_check_real, gfc_simplify_real, gfc_resolve_real,
1957 a, BT_UNKNOWN, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1959 /* This provides compatibility with g77. */
1960 add_sym_1 ("realpart", 1, 0, BT_REAL, dr, GFC_STD_GNU,
1961 gfc_check_fn_c, gfc_simplify_realpart, gfc_resolve_realpart,
1962 a, BT_UNKNOWN, dr, REQUIRED);
1964 add_sym_1 ("float", 1, 0, BT_REAL, dr, GFC_STD_F77,
1965 gfc_check_i, gfc_simplify_float, NULL,
1966 a, BT_INTEGER, di, REQUIRED);
1968 add_sym_1 ("sngl", 1, 0, BT_REAL, dr, GFC_STD_F77,
1969 NULL, gfc_simplify_sngl, NULL,
1970 a, BT_REAL, dd, REQUIRED);
1972 make_generic ("real", GFC_ISYM_REAL, GFC_STD_F77);
1974 add_sym_2 ("rename", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
1975 gfc_check_rename, NULL, gfc_resolve_rename,
1976 a, BT_CHARACTER, dc, REQUIRED, b, BT_CHARACTER, dc, REQUIRED);
1978 make_generic ("rename", GFC_ISYM_RENAME, GFC_STD_GNU);
1980 add_sym_2 ("repeat", 0, 1, BT_CHARACTER, dc, GFC_STD_F95,
1981 gfc_check_repeat, gfc_simplify_repeat, gfc_resolve_repeat,
1982 stg, BT_CHARACTER, dc, REQUIRED, n, BT_INTEGER, di, REQUIRED);
1984 make_generic ("repeat", GFC_ISYM_REPEAT, GFC_STD_F95);
1986 add_sym_4 ("reshape", 0, 1, BT_REAL, dr, GFC_STD_F95,
1987 gfc_check_reshape, gfc_simplify_reshape, gfc_resolve_reshape,
1988 src, BT_REAL, dr, REQUIRED, shp, BT_INTEGER, ii, REQUIRED,
1989 pad, BT_REAL, dr, OPTIONAL, ord, BT_INTEGER, ii, OPTIONAL);
1991 make_generic ("reshape", GFC_ISYM_RESHAPE, GFC_STD_F95);
1993 add_sym_1 ("rrspacing", 1, 1, BT_REAL, dr, GFC_STD_F95,
1994 gfc_check_x, gfc_simplify_rrspacing, gfc_resolve_rrspacing,
1995 x, BT_REAL, dr, REQUIRED);
1997 make_generic ("rrspacing", GFC_ISYM_RRSPACING, GFC_STD_F95);
1999 add_sym_2 ("scale", 1, 1, BT_REAL, dr, GFC_STD_F95,
2000 gfc_check_scale, gfc_simplify_scale, gfc_resolve_scale,
2001 x, BT_REAL, dr, REQUIRED, i, BT_INTEGER, di, REQUIRED);
2003 make_generic ("scale", GFC_ISYM_SCALE, GFC_STD_F95);
2005 add_sym_3 ("scan", 1, 1, BT_INTEGER, di, GFC_STD_F95,
2006 gfc_check_scan, gfc_simplify_scan, gfc_resolve_scan,
2007 stg, BT_CHARACTER, dc, REQUIRED, set, BT_CHARACTER, dc, REQUIRED,
2008 bck, BT_LOGICAL, dl, OPTIONAL);
2010 make_generic ("scan", GFC_ISYM_SCAN, GFC_STD_F95);
2012 /* Added for G77 compatibility garbage. */
2013 add_sym_0 ("second", 0, 1, BT_REAL, 4, GFC_STD_GNU,
2016 make_generic ("second", GFC_ISYM_SECOND, GFC_STD_GNU);
2018 /* Added for G77 compatibility. */
2019 add_sym_1 ("secnds", 0, 1, BT_REAL, dr, GFC_STD_GNU,
2020 gfc_check_secnds, NULL, gfc_resolve_secnds,
2021 x, BT_REAL, dr, REQUIRED);
2023 make_generic ("secnds", GFC_ISYM_SECNDS, GFC_STD_GNU);
2025 add_sym_1 ("selected_int_kind", 0, 1, BT_INTEGER, di, GFC_STD_F95,
2026 gfc_check_selected_int_kind, gfc_simplify_selected_int_kind, NULL,
2027 r, BT_INTEGER, di, REQUIRED);
2029 make_generic ("selected_int_kind", GFC_ISYM_SI_KIND, GFC_STD_F95);
2031 add_sym_2 ("selected_real_kind", 0, 1, BT_INTEGER, di, GFC_STD_F95,
2032 gfc_check_selected_real_kind, gfc_simplify_selected_real_kind,
2034 p, BT_INTEGER, di, OPTIONAL, r, BT_INTEGER, di, OPTIONAL);
2036 make_generic ("selected_real_kind", GFC_ISYM_SR_KIND, GFC_STD_F95);
2038 add_sym_2 ("set_exponent", 1, 1, BT_REAL, dr, GFC_STD_F95,
2039 gfc_check_set_exponent, gfc_simplify_set_exponent,
2040 gfc_resolve_set_exponent,
2041 x, BT_REAL, dr, REQUIRED, i, BT_INTEGER, di, REQUIRED);
2043 make_generic ("set_exponent", GFC_ISYM_SET_EXPONENT, GFC_STD_F95);
2045 add_sym_1 ("shape", 0, 1, BT_INTEGER, di, GFC_STD_F95,
2046 gfc_check_shape, gfc_simplify_shape, gfc_resolve_shape,
2047 src, BT_REAL, dr, REQUIRED);
2049 make_generic ("shape", GFC_ISYM_SHAPE, GFC_STD_F95);
2051 add_sym_2 ("sign", 1, 1, BT_REAL, dr, GFC_STD_F77,
2052 gfc_check_sign, gfc_simplify_sign, gfc_resolve_sign,
2053 a, BT_REAL, dr, REQUIRED, b, BT_REAL, dr, REQUIRED);
2055 add_sym_2 ("isign", 1, 1, BT_INTEGER, di, GFC_STD_F77,
2056 NULL, gfc_simplify_sign, gfc_resolve_sign,
2057 a, BT_INTEGER, di, REQUIRED, b, BT_INTEGER, di, REQUIRED);
2059 add_sym_2 ("dsign", 1, 1, BT_REAL, dd, GFC_STD_F77,
2060 NULL, gfc_simplify_sign, gfc_resolve_sign,
2061 a, BT_REAL, dd, REQUIRED, b, BT_REAL, dd, REQUIRED);
2063 make_generic ("sign", GFC_ISYM_SIGN, GFC_STD_F77);
2065 add_sym_2 ("signal", 1, 1, BT_INTEGER, di, GFC_STD_GNU,
2066 gfc_check_signal, NULL, gfc_resolve_signal,
2067 num, BT_INTEGER, di, REQUIRED, han, BT_UNKNOWN, 0, REQUIRED);
2069 make_generic ("signal", GFC_ISYM_SIGNAL, GFC_STD_GNU);
2071 add_sym_1 ("sin", 1, 1, BT_REAL, dr, GFC_STD_F77,
2072 gfc_check_fn_rc, gfc_simplify_sin, gfc_resolve_sin,
2073 x, BT_REAL, dr, REQUIRED);
2075 add_sym_1 ("dsin", 1, 1, BT_REAL, dd, GFC_STD_F77,
2076 NULL, gfc_simplify_sin, gfc_resolve_sin,
2077 x, BT_REAL, dd, REQUIRED);
2079 add_sym_1 ("csin", 1, 1, BT_COMPLEX, dz, GFC_STD_F77,
2080 NULL, gfc_simplify_sin, gfc_resolve_sin,
2081 x, BT_COMPLEX, dz, REQUIRED);
2083 add_sym_1 ("zsin", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
2084 NULL, gfc_simplify_sin, gfc_resolve_sin,
2085 x, BT_COMPLEX, dd, REQUIRED);
2087 make_alias ("cdsin", GFC_STD_GNU);
2089 make_generic ("sin", GFC_ISYM_SIN, GFC_STD_F77);
2091 add_sym_1 ("sinh", 1, 1, BT_REAL, dr, GFC_STD_F77,
2092 gfc_check_fn_r, gfc_simplify_sinh, gfc_resolve_sinh,
2093 x, BT_REAL, dr, REQUIRED);
2095 add_sym_1 ("dsinh", 1, 1, BT_REAL, dd, GFC_STD_F77,
2096 NULL, gfc_simplify_sinh, gfc_resolve_sinh,
2097 x, BT_REAL, dd, REQUIRED);
2099 make_generic ("sinh", GFC_ISYM_SINH, GFC_STD_F77);
2101 add_sym_2 ("size", 0, 1, BT_INTEGER, di, GFC_STD_F95,
2102 gfc_check_size, gfc_simplify_size, NULL,
2103 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL);
2105 make_generic ("size", GFC_ISYM_SIZE, GFC_STD_F95);
2107 add_sym_1 ("spacing", 1, 1, BT_REAL, dr, GFC_STD_F95,
2108 gfc_check_x, gfc_simplify_spacing, gfc_resolve_spacing,
2109 x, BT_REAL, dr, REQUIRED);
2111 make_generic ("spacing", GFC_ISYM_SPACING, GFC_STD_F95);
2113 add_sym_3 ("spread", 0, 1, BT_REAL, dr, GFC_STD_F95,
2114 gfc_check_spread, NULL, gfc_resolve_spread,
2115 src, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, REQUIRED,
2116 n, BT_INTEGER, di, REQUIRED);
2118 make_generic ("spread", GFC_ISYM_SPREAD, GFC_STD_F95);
2120 add_sym_1 ("sqrt", 1, 1, BT_REAL, dr, GFC_STD_F77,
2121 gfc_check_fn_rc, gfc_simplify_sqrt, gfc_resolve_sqrt,
2122 x, BT_REAL, dr, REQUIRED);
2124 add_sym_1 ("dsqrt", 1, 1, BT_REAL, dd, GFC_STD_F77,
2125 NULL, gfc_simplify_sqrt, gfc_resolve_sqrt,
2126 x, BT_REAL, dd, REQUIRED);
2128 add_sym_1 ("csqrt", 1, 1, BT_COMPLEX, dz, GFC_STD_F77,
2129 NULL, gfc_simplify_sqrt, gfc_resolve_sqrt,
2130 x, BT_COMPLEX, dz, REQUIRED);
2132 add_sym_1 ("zsqrt", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
2133 NULL, gfc_simplify_sqrt, gfc_resolve_sqrt,
2134 x, BT_COMPLEX, dd, REQUIRED);
2136 make_alias ("cdsqrt", GFC_STD_GNU);
2138 make_generic ("sqrt", GFC_ISYM_SQRT, GFC_STD_F77);
2140 add_sym_2 ("stat", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
2141 gfc_check_stat, NULL, gfc_resolve_stat,
2142 a, BT_CHARACTER, dc, REQUIRED, b, BT_INTEGER, di, REQUIRED);
2144 make_generic ("stat", GFC_ISYM_STAT, GFC_STD_GNU);
2146 add_sym_3red ("sum", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
2147 gfc_check_product_sum, NULL, gfc_resolve_sum,
2148 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
2149 msk, BT_LOGICAL, dl, OPTIONAL);
2151 make_generic ("sum", GFC_ISYM_SUM, GFC_STD_F95);
2153 add_sym_2 ("symlnk", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
2154 gfc_check_symlnk, NULL, gfc_resolve_symlnk,
2155 a, BT_CHARACTER, dc, REQUIRED, b, BT_CHARACTER, dc, REQUIRED);
2157 make_generic ("symlnk", GFC_ISYM_SYMLNK, GFC_STD_GNU);
2159 add_sym_1 ("system", 1, 1, BT_INTEGER, di, GFC_STD_GNU,
2161 c, BT_CHARACTER, dc, REQUIRED);
2163 make_generic ("system", GFC_ISYM_SYSTEM, GFC_STD_GNU);
2165 add_sym_1 ("tan", 1, 1, BT_REAL, dr, GFC_STD_F77,
2166 gfc_check_fn_r, gfc_simplify_tan, gfc_resolve_tan,
2167 x, BT_REAL, dr, REQUIRED);
2169 add_sym_1 ("dtan", 1, 1, BT_REAL, dd, GFC_STD_F77,
2170 NULL, gfc_simplify_tan, gfc_resolve_tan,
2171 x, BT_REAL, dd, REQUIRED);
2173 make_generic ("tan", GFC_ISYM_TAN, GFC_STD_F77);
2175 add_sym_1 ("tanh", 1, 1, BT_REAL, dr, GFC_STD_F77,
2176 gfc_check_fn_r, gfc_simplify_tanh, gfc_resolve_tanh,
2177 x, BT_REAL, dr, REQUIRED);
2179 add_sym_1 ("dtanh", 1, 1, BT_REAL, dd, GFC_STD_F77,
2180 NULL, gfc_simplify_tanh, gfc_resolve_tanh,
2181 x, BT_REAL, dd, REQUIRED);
2183 make_generic ("tanh", GFC_ISYM_TANH, GFC_STD_F77);
2185 add_sym_0 ("time", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
2186 NULL, NULL, gfc_resolve_time);
2188 make_generic ("time", GFC_ISYM_TIME, GFC_STD_GNU);
2190 add_sym_0 ("time8", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
2191 NULL, NULL, gfc_resolve_time8);
2193 make_generic ("time8", GFC_ISYM_TIME8, GFC_STD_GNU);
2195 add_sym_1 ("tiny", 0, 1, BT_REAL, dr, GFC_STD_F95,
2196 gfc_check_x, gfc_simplify_tiny, NULL,
2197 x, BT_REAL, dr, REQUIRED);
2199 make_generic ("tiny", GFC_ISYM_NONE, GFC_STD_F95);
2201 add_sym_3 ("transfer", 0, 1, BT_REAL, dr, GFC_STD_F95,
2202 gfc_check_transfer, gfc_simplify_transfer, gfc_resolve_transfer,
2203 src, BT_REAL, dr, REQUIRED, mo, BT_REAL, dr, REQUIRED,
2204 sz, BT_INTEGER, di, OPTIONAL);
2206 make_generic ("transfer", GFC_ISYM_TRANSFER, GFC_STD_F95);
2208 add_sym_1 ("transpose", 0, 1, BT_REAL, dr, GFC_STD_F95,
2209 gfc_check_transpose, NULL, gfc_resolve_transpose,
2210 m, BT_REAL, dr, REQUIRED);
2212 make_generic ("transpose", GFC_ISYM_TRANSPOSE, GFC_STD_F95);
2214 add_sym_1 ("trim", 0, 1, BT_CHARACTER, dc, GFC_STD_F95,
2215 gfc_check_trim, gfc_simplify_trim, gfc_resolve_trim,
2216 stg, BT_CHARACTER, dc, REQUIRED);
2218 make_generic ("trim", GFC_ISYM_TRIM, GFC_STD_F95);
2220 add_sym_1 ("ttynam", 0, 1, BT_CHARACTER, 0, GFC_STD_GNU,
2221 gfc_check_ttynam, NULL, gfc_resolve_ttynam,
2222 ut, BT_INTEGER, di, REQUIRED);
2224 make_generic ("ttynam", GFC_ISYM_TTYNAM, GFC_STD_GNU);
2226 add_sym_2 ("ubound", 0, 1, BT_INTEGER, di, GFC_STD_F95,
2227 gfc_check_ubound, gfc_simplify_ubound, gfc_resolve_ubound,
2228 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL);
2230 make_generic ("ubound", GFC_ISYM_UBOUND, GFC_STD_F95);
2232 /* g77 compatibility for UMASK. */
2233 add_sym_1 ("umask", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
2234 gfc_check_umask, NULL, gfc_resolve_umask,
2235 a, BT_INTEGER, di, REQUIRED);
2237 make_generic ("umask", GFC_ISYM_UMASK, GFC_STD_GNU);
2239 /* g77 compatibility for UNLINK. */
2240 add_sym_1 ("unlink", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
2241 gfc_check_unlink, NULL, gfc_resolve_unlink,
2242 a, BT_CHARACTER, dc, REQUIRED);
2244 make_generic ("unlink", GFC_ISYM_UNLINK, GFC_STD_GNU);
2246 add_sym_3 ("unpack", 0, 1, BT_REAL, dr, GFC_STD_F95,
2247 gfc_check_unpack, NULL, gfc_resolve_unpack,
2248 v, BT_REAL, dr, REQUIRED, msk, BT_LOGICAL, dl, REQUIRED,
2249 f, BT_REAL, dr, REQUIRED);
2251 make_generic ("unpack", GFC_ISYM_UNPACK, GFC_STD_F95);
2253 add_sym_3 ("verify", 1, 1, BT_INTEGER, di, GFC_STD_F95,
2254 gfc_check_verify, gfc_simplify_verify, gfc_resolve_verify,
2255 stg, BT_CHARACTER, dc, REQUIRED, set, BT_CHARACTER, dc, REQUIRED,
2256 bck, BT_LOGICAL, dl, OPTIONAL);
2258 make_generic ("verify", GFC_ISYM_VERIFY, GFC_STD_F95);
2260 add_sym_1 ("loc", 0, 1, BT_INTEGER, ii, GFC_STD_GNU,
2261 gfc_check_loc, NULL, gfc_resolve_loc,
2262 ar, BT_UNKNOWN, 0, REQUIRED);
2264 make_generic ("loc", GFC_ISYM_LOC, GFC_STD_GNU);
2269 /* Add intrinsic subroutines. */
2272 add_subroutines (void)
2274 /* Argument names as in the standard (to be used as argument keywords). */
2276 *h = "harvest", *dt = "date", *vl = "values", *pt = "put",
2277 *c = "count", *tm = "time", *tp = "topos", *gt = "get",
2278 *t = "to", *zn = "zone", *fp = "frompos", *cm = "count_max",
2279 *f = "from", *sz = "size", *ln = "len", *cr = "count_rate",
2280 *com = "command", *length = "length", *st = "status",
2281 *val = "value", *num = "number", *name = "name",
2282 *trim_name = "trim_name", *ut = "unit", *han = "handler",
2283 *sec = "seconds", *res = "result", *of = "offset", *md = "mode";
2285 int di, dr, dc, dl, ii;
2287 di = gfc_default_integer_kind;
2288 dr = gfc_default_real_kind;
2289 dc = gfc_default_character_kind;
2290 dl = gfc_default_logical_kind;
2291 ii = gfc_index_integer_kind;
2293 add_sym_0s ("abort", 1, GFC_STD_GNU, NULL);
2295 if ((gfc_option.allow_std & GFC_STD_GNU) || gfc_option.flag_all_intrinsics)
2298 add_sym_1s ("cpu_time", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
2299 gfc_check_cpu_time, NULL, gfc_resolve_cpu_time,
2300 tm, BT_REAL, dr, REQUIRED);
2302 /* More G77 compatibility garbage. */
2303 add_sym_2s ("ctime", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2304 gfc_check_ctime_sub, NULL, gfc_resolve_ctime_sub,
2305 tm, BT_INTEGER, di, REQUIRED, res, BT_CHARACTER, dc, REQUIRED);
2307 add_sym_1s ("idate", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2308 gfc_check_itime_idate, NULL, gfc_resolve_idate,
2309 vl, BT_INTEGER, 4, REQUIRED);
2311 add_sym_1s ("itime", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2312 gfc_check_itime_idate, NULL, gfc_resolve_itime,
2313 vl, BT_INTEGER, 4, REQUIRED);
2315 add_sym_2s ("ltime", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2316 gfc_check_ltime_gmtime, NULL, gfc_resolve_ltime,
2317 tm, BT_INTEGER, di, REQUIRED, vl, BT_INTEGER, di, REQUIRED);
2319 add_sym_2s ("gmtime", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2320 gfc_check_ltime_gmtime, NULL, gfc_resolve_gmtime,
2321 tm, BT_INTEGER, di, REQUIRED, vl, BT_INTEGER, di, REQUIRED);
2323 add_sym_1s ("second", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2324 gfc_check_second_sub, NULL, gfc_resolve_second_sub,
2325 tm, BT_REAL, dr, REQUIRED);
2327 add_sym_2s ("chdir", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2328 gfc_check_chdir_sub, NULL, gfc_resolve_chdir_sub,
2329 name, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2331 add_sym_3s ("chmod", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2332 gfc_check_chmod_sub, NULL, gfc_resolve_chmod_sub,
2333 name, BT_CHARACTER, dc, REQUIRED, md, BT_CHARACTER, dc, REQUIRED,
2334 st, BT_INTEGER, di, OPTIONAL);
2336 add_sym_4s ("date_and_time", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
2337 gfc_check_date_and_time, NULL, NULL,
2338 dt, BT_CHARACTER, dc, OPTIONAL, tm, BT_CHARACTER, dc, OPTIONAL,
2339 zn, BT_CHARACTER, dc, OPTIONAL, vl, BT_INTEGER, di, OPTIONAL);
2341 /* More G77 compatibility garbage. */
2342 add_sym_2s ("etime", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2343 gfc_check_etime_sub, NULL, gfc_resolve_etime_sub,
2344 vl, BT_REAL, 4, REQUIRED, tm, BT_REAL, 4, REQUIRED);
2346 add_sym_2s ("dtime", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2347 gfc_check_etime_sub, NULL, gfc_resolve_etime_sub,
2348 vl, BT_REAL, 4, REQUIRED, tm, BT_REAL, 4, REQUIRED);
2350 add_sym_1s ("fdate", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2351 gfc_check_fdate_sub, NULL, gfc_resolve_fdate_sub,
2352 dt, BT_CHARACTER, dc, REQUIRED);
2354 add_sym_1s ("gerror", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2355 gfc_check_gerror, NULL, gfc_resolve_gerror, c, BT_CHARACTER,
2358 add_sym_2s ("getcwd", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2359 gfc_check_getcwd_sub, NULL, gfc_resolve_getcwd_sub,
2360 c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2362 add_sym_2s ("getenv", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2364 name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER, dc, REQUIRED);
2366 add_sym_2s ("getarg", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2367 NULL, NULL, gfc_resolve_getarg,
2368 c, BT_INTEGER, di, REQUIRED, vl, BT_CHARACTER, dc, REQUIRED);
2370 add_sym_1s ("getlog", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2371 gfc_check_getlog, NULL, gfc_resolve_getlog, c, BT_CHARACTER,
2374 /* F2003 commandline routines. */
2376 add_sym_3s ("get_command", 0, 1, BT_UNKNOWN, 0, GFC_STD_F2003,
2377 NULL, NULL, gfc_resolve_get_command,
2378 com, BT_CHARACTER, dc, OPTIONAL, length, BT_INTEGER, di, OPTIONAL,
2379 st, BT_INTEGER, di, OPTIONAL);
2381 add_sym_4s ("get_command_argument", 0, 1, BT_UNKNOWN, 0, GFC_STD_F2003,
2382 NULL, NULL, gfc_resolve_get_command_argument,
2383 num, BT_INTEGER, di, REQUIRED, val, BT_CHARACTER, dc, OPTIONAL,
2384 length, BT_INTEGER, di, OPTIONAL, st, BT_INTEGER, di, OPTIONAL);
2386 /* F2003 subroutine to get environment variables. */
2388 add_sym_5s ("get_environment_variable", 0, 1, BT_UNKNOWN, 0, GFC_STD_F2003,
2389 NULL, NULL, gfc_resolve_get_environment_variable,
2390 name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER, dc, OPTIONAL,
2391 length, BT_INTEGER, di, OPTIONAL, st, BT_INTEGER, di, OPTIONAL,
2392 trim_name, BT_LOGICAL, dl, OPTIONAL);
2394 add_sym_5s ("mvbits", 1, 1, BT_UNKNOWN, 0, GFC_STD_F95,
2395 gfc_check_mvbits, gfc_simplify_mvbits, gfc_resolve_mvbits,
2396 f, BT_INTEGER, di, REQUIRED, fp, BT_INTEGER, di, REQUIRED,
2397 ln, BT_INTEGER, di, REQUIRED, t, BT_INTEGER, di, REQUIRED,
2398 tp, BT_INTEGER, di, REQUIRED);
2400 add_sym_1s ("random_number", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
2401 gfc_check_random_number, NULL, gfc_resolve_random_number,
2402 h, BT_REAL, dr, REQUIRED);
2404 add_sym_3s ("random_seed", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
2405 gfc_check_random_seed, NULL, NULL,
2406 sz, BT_INTEGER, di, OPTIONAL, pt, BT_INTEGER, di, OPTIONAL,
2407 gt, BT_INTEGER, di, OPTIONAL);
2409 /* More G77 compatibility garbage. */
2410 add_sym_3s ("alarm", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2411 gfc_check_alarm_sub, NULL, gfc_resolve_alarm_sub,
2412 sec, BT_INTEGER, di, REQUIRED, han, BT_UNKNOWN, 0, REQUIRED,
2413 st, BT_INTEGER, di, OPTIONAL);
2415 add_sym_1s ("srand", 0, 1, BT_UNKNOWN, di, GFC_STD_GNU,
2416 gfc_check_srand, NULL, gfc_resolve_srand,
2417 c, BT_INTEGER, 4, REQUIRED);
2419 add_sym_1s ("exit", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2420 gfc_check_exit, NULL, gfc_resolve_exit,
2421 c, BT_INTEGER, di, OPTIONAL);
2423 if ((gfc_option.allow_std & GFC_STD_GNU) || gfc_option.flag_all_intrinsics)
2426 add_sym_3s ("fgetc", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2427 gfc_check_fgetputc_sub, NULL, gfc_resolve_fgetc_sub,
2428 ut, BT_INTEGER, di, REQUIRED, c, BT_CHARACTER, dc, REQUIRED,
2429 st, BT_INTEGER, di, OPTIONAL);
2431 add_sym_2s ("fget", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2432 gfc_check_fgetput_sub, NULL, gfc_resolve_fget_sub,
2433 c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2435 add_sym_1s ("flush", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2436 gfc_check_flush, NULL, gfc_resolve_flush,
2437 c, BT_INTEGER, di, OPTIONAL);
2439 add_sym_3s ("fputc", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2440 gfc_check_fgetputc_sub, NULL, gfc_resolve_fputc_sub,
2441 ut, BT_INTEGER, di, REQUIRED, c, BT_CHARACTER, dc, REQUIRED,
2442 st, BT_INTEGER, di, OPTIONAL);
2444 add_sym_2s ("fput", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2445 gfc_check_fgetput_sub, NULL, gfc_resolve_fput_sub,
2446 c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2448 add_sym_1s ("free", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, gfc_check_free,
2449 NULL, gfc_resolve_free, c, BT_INTEGER, ii, REQUIRED);
2451 add_sym_2s ("ftell", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2452 gfc_check_ftell_sub, NULL, gfc_resolve_ftell_sub,
2453 ut, BT_INTEGER, di, REQUIRED, of, BT_INTEGER, ii, REQUIRED);
2455 add_sym_2s ("hostnm", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2456 gfc_check_hostnm_sub, NULL, gfc_resolve_hostnm_sub,
2457 c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2459 add_sym_3s ("kill", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU, gfc_check_kill_sub,
2460 NULL, gfc_resolve_kill_sub, c, BT_INTEGER, di, REQUIRED,
2461 val, BT_INTEGER, di, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2463 add_sym_3s ("link", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2464 gfc_check_link_sub, NULL, gfc_resolve_link_sub,
2465 name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER,
2466 dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2468 add_sym_1s ("perror", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2469 gfc_check_perror, NULL, gfc_resolve_perror,
2470 c, BT_CHARACTER, dc, REQUIRED);
2472 add_sym_3s ("rename", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2473 gfc_check_rename_sub, NULL, gfc_resolve_rename_sub,
2474 name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER,
2475 dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2477 add_sym_1s ("sleep", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2478 gfc_check_sleep_sub, NULL, gfc_resolve_sleep_sub,
2479 val, BT_CHARACTER, dc, REQUIRED);
2481 add_sym_3s ("fstat", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2482 gfc_check_fstat_sub, NULL, gfc_resolve_fstat_sub,
2483 ut, BT_INTEGER, di, REQUIRED, vl, BT_INTEGER, di, REQUIRED,
2484 st, BT_INTEGER, di, OPTIONAL);
2486 add_sym_3s ("lstat", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2487 gfc_check_stat_sub, NULL, gfc_resolve_lstat_sub,
2488 name, BT_CHARACTER, dc, REQUIRED, vl, BT_INTEGER, di, REQUIRED,
2489 st, BT_INTEGER, di, OPTIONAL);
2491 add_sym_3s ("stat", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2492 gfc_check_stat_sub, NULL, gfc_resolve_stat_sub,
2493 name, BT_CHARACTER, dc, REQUIRED, vl, BT_INTEGER, di, REQUIRED,
2494 st, BT_INTEGER, di, OPTIONAL);
2496 add_sym_3s ("signal", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2497 gfc_check_signal_sub, NULL, gfc_resolve_signal_sub,
2498 num, BT_INTEGER, di, REQUIRED, han, BT_UNKNOWN, 0, REQUIRED,
2499 st, BT_INTEGER, di, OPTIONAL);
2501 add_sym_3s ("symlnk", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2502 gfc_check_symlnk_sub, NULL, gfc_resolve_symlnk_sub,
2503 name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER,
2504 dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2506 add_sym_2s ("system", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2507 NULL, NULL, gfc_resolve_system_sub,
2508 c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2510 add_sym_3s ("system_clock", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
2511 gfc_check_system_clock, NULL, gfc_resolve_system_clock,
2512 c, BT_INTEGER, di, OPTIONAL, cr, BT_INTEGER, di, OPTIONAL,
2513 cm, BT_INTEGER, di, OPTIONAL);
2515 add_sym_2s ("ttynam", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2516 gfc_check_ttynam_sub, NULL, gfc_resolve_ttynam_sub,
2517 ut, BT_INTEGER, di, REQUIRED, c, BT_CHARACTER, dc, REQUIRED);
2519 add_sym_2s ("umask", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2520 gfc_check_umask_sub, NULL, gfc_resolve_umask_sub,
2521 val, BT_INTEGER, di, REQUIRED, num, BT_INTEGER, di, OPTIONAL);
2523 add_sym_2s ("unlink", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
2524 gfc_check_unlink_sub, NULL, gfc_resolve_unlink_sub,
2525 c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2530 /* Add a function to the list of conversion symbols. */
2533 add_conv (bt from_type, int from_kind, bt to_type, int to_kind, int standard)
2536 gfc_typespec from, to;
2537 gfc_intrinsic_sym *sym;
2539 if (sizing == SZ_CONVS)
2545 gfc_clear_ts (&from);
2546 from.type = from_type;
2547 from.kind = from_kind;
2553 sym = conversion + nconv;
2555 sym->name = conv_name (&from, &to);
2556 sym->lib_name = sym->name;
2557 sym->simplify.cc = gfc_convert_constant;
2558 sym->standard = standard;
2561 sym->generic_id = GFC_ISYM_CONVERSION;
2567 /* Create gfc_intrinsic_sym nodes for all intrinsic conversion
2568 functions by looping over the kind tables. */
2571 add_conversions (void)
2575 /* Integer-Integer conversions. */
2576 for (i = 0; gfc_integer_kinds[i].kind != 0; i++)
2577 for (j = 0; gfc_integer_kinds[j].kind != 0; j++)
2582 add_conv (BT_INTEGER, gfc_integer_kinds[i].kind,
2583 BT_INTEGER, gfc_integer_kinds[j].kind, GFC_STD_F77);
2586 /* Integer-Real/Complex conversions. */
2587 for (i = 0; gfc_integer_kinds[i].kind != 0; i++)
2588 for (j = 0; gfc_real_kinds[j].kind != 0; j++)
2590 add_conv (BT_INTEGER, gfc_integer_kinds[i].kind,
2591 BT_REAL, gfc_real_kinds[j].kind, GFC_STD_F77);
2593 add_conv (BT_REAL, gfc_real_kinds[j].kind,
2594 BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_F77);
2596 add_conv (BT_INTEGER, gfc_integer_kinds[i].kind,
2597 BT_COMPLEX, gfc_real_kinds[j].kind, GFC_STD_F77);
2599 add_conv (BT_COMPLEX, gfc_real_kinds[j].kind,
2600 BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_F77);
2603 if ((gfc_option.allow_std & GFC_STD_LEGACY) != 0)
2605 /* Hollerith-Integer conversions. */
2606 for (i = 0; gfc_integer_kinds[i].kind != 0; i++)
2607 add_conv (BT_HOLLERITH, gfc_default_character_kind,
2608 BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_LEGACY);
2609 /* Hollerith-Real conversions. */
2610 for (i = 0; gfc_real_kinds[i].kind != 0; i++)
2611 add_conv (BT_HOLLERITH, gfc_default_character_kind,
2612 BT_REAL, gfc_real_kinds[i].kind, GFC_STD_LEGACY);
2613 /* Hollerith-Complex conversions. */
2614 for (i = 0; gfc_real_kinds[i].kind != 0; i++)
2615 add_conv (BT_HOLLERITH, gfc_default_character_kind,
2616 BT_COMPLEX, gfc_real_kinds[i].kind, GFC_STD_LEGACY);
2618 /* Hollerith-Character conversions. */
2619 add_conv (BT_HOLLERITH, gfc_default_character_kind, BT_CHARACTER,
2620 gfc_default_character_kind, GFC_STD_LEGACY);
2622 /* Hollerith-Logical conversions. */
2623 for (i = 0; gfc_logical_kinds[i].kind != 0; i++)
2624 add_conv (BT_HOLLERITH, gfc_default_character_kind,
2625 BT_LOGICAL, gfc_logical_kinds[i].kind, GFC_STD_LEGACY);
2628 /* Real/Complex - Real/Complex conversions. */
2629 for (i = 0; gfc_real_kinds[i].kind != 0; i++)
2630 for (j = 0; gfc_real_kinds[j].kind != 0; j++)
2634 add_conv (BT_REAL, gfc_real_kinds[i].kind,
2635 BT_REAL, gfc_real_kinds[j].kind, GFC_STD_F77);
2637 add_conv (BT_COMPLEX, gfc_real_kinds[i].kind,
2638 BT_COMPLEX, gfc_real_kinds[j].kind, GFC_STD_F77);
2641 add_conv (BT_REAL, gfc_real_kinds[i].kind,
2642 BT_COMPLEX, gfc_real_kinds[j].kind, GFC_STD_F77);
2644 add_conv (BT_COMPLEX, gfc_real_kinds[i].kind,
2645 BT_REAL, gfc_real_kinds[j].kind, GFC_STD_F77);
2648 /* Logical/Logical kind conversion. */
2649 for (i = 0; gfc_logical_kinds[i].kind; i++)
2650 for (j = 0; gfc_logical_kinds[j].kind; j++)
2655 add_conv (BT_LOGICAL, gfc_logical_kinds[i].kind,
2656 BT_LOGICAL, gfc_logical_kinds[j].kind, GFC_STD_F77);
2659 /* Integer-Logical and Logical-Integer conversions. */
2660 if ((gfc_option.allow_std & GFC_STD_LEGACY) != 0)
2661 for (i=0; gfc_integer_kinds[i].kind; i++)
2662 for (j=0; gfc_logical_kinds[j].kind; j++)
2664 add_conv (BT_INTEGER, gfc_integer_kinds[i].kind,
2665 BT_LOGICAL, gfc_logical_kinds[j].kind, GFC_STD_LEGACY);
2666 add_conv (BT_LOGICAL, gfc_logical_kinds[j].kind,
2667 BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_LEGACY);
2672 /* Initialize the table of intrinsics. */
2674 gfc_intrinsic_init_1 (void)
2678 nargs = nfunc = nsub = nconv = 0;
2680 /* Create a namespace to hold the resolved intrinsic symbols. */
2681 gfc_intrinsic_namespace = gfc_get_namespace (NULL, 0);
2690 functions = gfc_getmem (sizeof (gfc_intrinsic_sym) * (nfunc + nsub)
2691 + sizeof (gfc_intrinsic_arg) * nargs);
2693 next_sym = functions;
2694 subroutines = functions + nfunc;
2696 conversion = gfc_getmem (sizeof (gfc_intrinsic_sym) * nconv);
2698 next_arg = ((gfc_intrinsic_arg *) (subroutines + nsub)) - 1;
2700 sizing = SZ_NOTHING;
2707 /* Set the pure flag. All intrinsic functions are pure, and
2708 intrinsic subroutines are pure if they are elemental. */
2710 for (i = 0; i < nfunc; i++)
2711 functions[i].pure = 1;
2713 for (i = 0; i < nsub; i++)
2714 subroutines[i].pure = subroutines[i].elemental;
2719 gfc_intrinsic_done_1 (void)
2721 gfc_free (functions);
2722 gfc_free (conversion);
2723 gfc_free_namespace (gfc_intrinsic_namespace);
2727 /******** Subroutines to check intrinsic interfaces ***********/
2729 /* Given a formal argument list, remove any NULL arguments that may
2730 have been left behind by a sort against some formal argument list. */
2733 remove_nullargs (gfc_actual_arglist ** ap)
2735 gfc_actual_arglist *head, *tail, *next;
2739 for (head = *ap; head; head = next)
2743 if (head->expr == NULL)
2746 gfc_free_actual_arglist (head);
2765 /* Given an actual arglist and a formal arglist, sort the actual
2766 arglist so that its arguments are in a one-to-one correspondence
2767 with the format arglist. Arguments that are not present are given
2768 a blank gfc_actual_arglist structure. If something is obviously
2769 wrong (say, a missing required argument) we abort sorting and
2773 sort_actual (const char *name, gfc_actual_arglist ** ap,
2774 gfc_intrinsic_arg * formal, locus * where)
2777 gfc_actual_arglist *actual, *a;
2778 gfc_intrinsic_arg *f;
2780 remove_nullargs (ap);
2783 for (f = formal; f; f = f->next)
2789 if (f == NULL && a == NULL) /* No arguments */
2793 { /* Put the nonkeyword arguments in a 1:1 correspondence */
2799 if (a->name != NULL)
2811 gfc_error ("Too many arguments in call to '%s' at %L", name, where);
2815 /* Associate the remaining actual arguments, all of which have
2816 to be keyword arguments. */
2817 for (; a; a = a->next)
2819 for (f = formal; f; f = f->next)
2820 if (strcmp (a->name, f->name) == 0)
2825 gfc_error ("Can't find keyword named '%s' in call to '%s' at %L",
2826 a->name, name, where);
2830 if (f->actual != NULL)
2832 gfc_error ("Argument '%s' is appears twice in call to '%s' at %L",
2833 f->name, name, where);
2841 /* At this point, all unmatched formal args must be optional. */
2842 for (f = formal; f; f = f->next)
2844 if (f->actual == NULL && f->optional == 0)
2846 gfc_error ("Missing actual argument '%s' in call to '%s' at %L",
2847 f->name, name, where);
2853 /* Using the formal argument list, string the actual argument list
2854 together in a way that corresponds with the formal list. */
2857 for (f = formal; f; f = f->next)
2859 if (f->actual == NULL)
2861 a = gfc_get_actual_arglist ();
2862 a->missing_arg_type = f->ts.type;
2874 actual->next = NULL; /* End the sorted argument list. */
2880 /* Compare an actual argument list with an intrinsic's formal argument
2881 list. The lists are checked for agreement of type. We don't check
2882 for arrayness here. */
2885 check_arglist (gfc_actual_arglist ** ap, gfc_intrinsic_sym * sym,
2888 gfc_actual_arglist *actual;
2889 gfc_intrinsic_arg *formal;
2892 formal = sym->formal;
2896 for (; formal; formal = formal->next, actual = actual->next, i++)
2898 if (actual->expr == NULL)
2901 if (!gfc_compare_types (&formal->ts, &actual->expr->ts))
2905 ("Type of argument '%s' in call to '%s' at %L should be "
2906 "%s, not %s", gfc_current_intrinsic_arg[i],
2907 gfc_current_intrinsic, &actual->expr->where,
2908 gfc_typename (&formal->ts), gfc_typename (&actual->expr->ts));
2917 /* Given a pointer to an intrinsic symbol and an expression node that
2918 represent the function call to that subroutine, figure out the type
2919 of the result. This may involve calling a resolution subroutine. */
2922 resolve_intrinsic (gfc_intrinsic_sym * specific, gfc_expr * e)
2924 gfc_expr *a1, *a2, *a3, *a4, *a5;
2925 gfc_actual_arglist *arg;
2927 if (specific->resolve.f1 == NULL)
2929 if (e->value.function.name == NULL)
2930 e->value.function.name = specific->lib_name;
2932 if (e->ts.type == BT_UNKNOWN)
2933 e->ts = specific->ts;
2937 arg = e->value.function.actual;
2939 /* Special case hacks for MIN and MAX. */
2940 if (specific->resolve.f1m == gfc_resolve_max
2941 || specific->resolve.f1m == gfc_resolve_min)
2943 (*specific->resolve.f1m) (e, arg);
2949 (*specific->resolve.f0) (e);
2958 (*specific->resolve.f1) (e, a1);
2967 (*specific->resolve.f2) (e, a1, a2);
2976 (*specific->resolve.f3) (e, a1, a2, a3);
2985 (*specific->resolve.f4) (e, a1, a2, a3, a4);
2994 (*specific->resolve.f5) (e, a1, a2, a3, a4, a5);
2998 gfc_internal_error ("resolve_intrinsic(): Too many args for intrinsic");
3002 /* Given an intrinsic symbol node and an expression node, call the
3003 simplification function (if there is one), perhaps replacing the
3004 expression with something simpler. We return FAILURE on an error
3005 of the simplification, SUCCESS if the simplification worked, even
3006 if nothing has changed in the expression itself. */
3009 do_simplify (gfc_intrinsic_sym * specific, gfc_expr * e)
3011 gfc_expr *result, *a1, *a2, *a3, *a4, *a5;
3012 gfc_actual_arglist *arg;
3014 /* Check the arguments if there are Hollerith constants. We deal with
3015 them at run-time. */
3016 for (arg = e->value.function.actual; arg != NULL; arg = arg->next)
3018 if (arg->expr && arg->expr->from_H)
3024 /* Max and min require special handling due to the variable number
3026 if (specific->simplify.f1 == gfc_simplify_min)
3028 result = gfc_simplify_min (e);
3032 if (specific->simplify.f1 == gfc_simplify_max)
3034 result = gfc_simplify_max (e);
3038 if (specific->simplify.f1 == NULL)
3044 arg = e->value.function.actual;
3048 result = (*specific->simplify.f0) ();
3055 if (specific->simplify.cc == gfc_convert_constant)
3057 result = gfc_convert_constant (a1, specific->ts.type, specific->ts.kind);
3061 /* TODO: Warn if -pedantic and initialization expression and arg
3062 types not integer or character */
3065 result = (*specific->simplify.f1) (a1);
3072 result = (*specific->simplify.f2) (a1, a2);
3079 result = (*specific->simplify.f3) (a1, a2, a3);
3086 result = (*specific->simplify.f4) (a1, a2, a3, a4);
3093 result = (*specific->simplify.f5) (a1, a2, a3, a4, a5);
3096 ("do_simplify(): Too many args for intrinsic");
3103 if (result == &gfc_bad_expr)
3107 resolve_intrinsic (specific, e); /* Must call at run-time */
3110 result->where = e->where;
3111 gfc_replace_expr (e, result);
3118 /* Initialize the gfc_current_intrinsic_arg[] array for the benefit of
3119 error messages. This subroutine returns FAILURE if a subroutine
3120 has more than MAX_INTRINSIC_ARGS, in which case the actual argument
3121 list cannot match any intrinsic. */
3124 init_arglist (gfc_intrinsic_sym * isym)
3126 gfc_intrinsic_arg *formal;
3129 gfc_current_intrinsic = isym->name;
3132 for (formal = isym->formal; formal; formal = formal->next)
3134 if (i >= MAX_INTRINSIC_ARGS)
3135 gfc_internal_error ("init_arglist(): too many arguments");
3136 gfc_current_intrinsic_arg[i++] = formal->name;
3141 /* Given a pointer to an intrinsic symbol and an expression consisting
3142 of a function call, see if the function call is consistent with the
3143 intrinsic's formal argument list. Return SUCCESS if the expression
3144 and intrinsic match, FAILURE otherwise. */
3147 check_specific (gfc_intrinsic_sym * specific, gfc_expr * expr, int error_flag)
3149 gfc_actual_arglist *arg, **ap;
3153 ap = &expr->value.function.actual;
3155 init_arglist (specific);
3157 /* Don't attempt to sort the argument list for min or max. */
3158 if (specific->check.f1m == gfc_check_min_max
3159 || specific->check.f1m == gfc_check_min_max_integer
3160 || specific->check.f1m == gfc_check_min_max_real
3161 || specific->check.f1m == gfc_check_min_max_double)
3162 return (*specific->check.f1m) (*ap);
3164 if (sort_actual (specific->name, ap, specific->formal,
3165 &expr->where) == FAILURE)
3168 if (specific->check.f3ml == gfc_check_minloc_maxloc)
3169 /* This is special because we might have to reorder the argument
3171 t = gfc_check_minloc_maxloc (*ap);
3172 else if (specific->check.f3red == gfc_check_minval_maxval)
3173 /* This is also special because we also might have to reorder the
3175 t = gfc_check_minval_maxval (*ap);
3176 else if (specific->check.f3red == gfc_check_product_sum)
3177 /* Same here. The difference to the previous case is that we allow a
3178 general numeric type. */
3179 t = gfc_check_product_sum (*ap);
3182 if (specific->check.f1 == NULL)
3184 t = check_arglist (ap, specific, error_flag);
3186 expr->ts = specific->ts;
3189 t = do_check (specific, *ap);
3192 /* Check ranks for elemental intrinsics. */
3193 if (t == SUCCESS && specific->elemental)
3196 for (arg = expr->value.function.actual; arg; arg = arg->next)
3198 if (arg->expr == NULL || arg->expr->rank == 0)
3202 r = arg->expr->rank;
3206 if (arg->expr->rank != r)
3209 ("Ranks of arguments to elemental intrinsic '%s' differ "
3210 "at %L", specific->name, &arg->expr->where);
3217 remove_nullargs (ap);
3223 /* See if an intrinsic is one of the intrinsics we evaluate
3227 gfc_init_expr_extensions (gfc_intrinsic_sym *isym)
3229 /* FIXME: This should be moved into the intrinsic definitions. */
3230 static const char * const init_expr_extensions[] = {
3231 "digits", "epsilon", "huge", "kind", "maxexponent", "minexponent",
3232 "precision", "present", "radix", "range", "selected_real_kind",
3238 for (i = 0; init_expr_extensions[i]; i++)
3239 if (strcmp (init_expr_extensions[i], isym->name) == 0)
3246 /* Check whether an intrinsic belongs to whatever standard the user
3250 check_intrinsic_standard (const char *name, int standard, locus * where)
3252 if (!gfc_option.warn_nonstd_intrinsics)
3255 gfc_notify_std (standard, "Intrinsic '%s' at %L is not included "
3256 "in the selected standard", name, where);
3260 /* See if a function call corresponds to an intrinsic function call.
3263 MATCH_YES if the call corresponds to an intrinsic, simplification
3264 is done if possible.
3266 MATCH_NO if the call does not correspond to an intrinsic
3268 MATCH_ERROR if the call corresponds to an intrinsic but there was an
3269 error during the simplification process.
3271 The error_flag parameter enables an error reporting. */
3274 gfc_intrinsic_func_interface (gfc_expr * expr, int error_flag)
3276 gfc_intrinsic_sym *isym, *specific;
3277 gfc_actual_arglist *actual;
3281 if (expr->value.function.isym != NULL)
3282 return (do_simplify (expr->value.function.isym, expr) == FAILURE)
3283 ? MATCH_ERROR : MATCH_YES;
3285 gfc_suppress_error = !error_flag;
3288 for (actual = expr->value.function.actual; actual; actual = actual->next)
3289 if (actual->expr != NULL)
3290 flag |= (actual->expr->ts.type != BT_INTEGER
3291 && actual->expr->ts.type != BT_CHARACTER);
3293 name = expr->symtree->n.sym->name;
3295 isym = specific = gfc_find_function (name);
3298 gfc_suppress_error = 0;
3302 gfc_current_intrinsic_where = &expr->where;
3304 /* Bypass the generic list for min and max. */
3305 if (isym->check.f1m == gfc_check_min_max)
3307 init_arglist (isym);
3309 if (gfc_check_min_max (expr->value.function.actual) == SUCCESS)
3312 gfc_suppress_error = 0;
3316 /* If the function is generic, check all of its specific
3317 incarnations. If the generic name is also a specific, we check
3318 that name last, so that any error message will correspond to the
3320 gfc_suppress_error = 1;
3324 for (specific = isym->specific_head; specific;
3325 specific = specific->next)
3327 if (specific == isym)
3329 if (check_specific (specific, expr, 0) == SUCCESS)
3334 gfc_suppress_error = !error_flag;
3336 if (check_specific (isym, expr, error_flag) == FAILURE)
3338 gfc_suppress_error = 0;
3345 expr->value.function.isym = specific;
3346 gfc_intrinsic_symbol (expr->symtree->n.sym);
3348 gfc_suppress_error = 0;
3349 if (do_simplify (specific, expr) == FAILURE)
3352 /* TODO: We should probably only allow elemental functions here. */
3353 flag |= (expr->ts.type != BT_INTEGER && expr->ts.type != BT_CHARACTER);
3355 if (pedantic && gfc_init_expr
3356 && flag && gfc_init_expr_extensions (specific))
3358 if (gfc_notify_std (GFC_STD_GNU, "Extension: Evaluation of "
3359 "nonstandard initialization expression at %L", &expr->where)
3366 check_intrinsic_standard (name, isym->standard, &expr->where);
3372 /* See if a CALL statement corresponds to an intrinsic subroutine.
3373 Returns MATCH_YES if the subroutine corresponds to an intrinsic,
3374 MATCH_NO if not, and MATCH_ERROR if there was an error (but did
3378 gfc_intrinsic_sub_interface (gfc_code * c, int error_flag)
3380 gfc_intrinsic_sym *isym;
3383 name = c->symtree->n.sym->name;
3385 isym = find_subroutine (name);
3389 gfc_suppress_error = !error_flag;
3391 init_arglist (isym);
3393 if (sort_actual (name, &c->ext.actual, isym->formal, &c->loc) == FAILURE)
3396 if (isym->check.f1 != NULL)
3398 if (do_check (isym, c->ext.actual) == FAILURE)
3403 if (check_arglist (&c->ext.actual, isym, 1) == FAILURE)
3407 /* The subroutine corresponds to an intrinsic. Allow errors to be
3408 seen at this point. */
3409 gfc_suppress_error = 0;
3411 if (isym->resolve.s1 != NULL)
3412 isym->resolve.s1 (c);
3414 c->resolved_sym = gfc_get_intrinsic_sub_symbol (isym->lib_name);
3416 if (gfc_pure (NULL) && !isym->elemental)
3418 gfc_error ("Subroutine call to intrinsic '%s' at %L is not PURE", name,
3423 c->resolved_sym->attr.noreturn = isym->noreturn;
3424 check_intrinsic_standard (name, isym->standard, &c->loc);
3429 gfc_suppress_error = 0;
3434 /* Call gfc_convert_type() with warning enabled. */
3437 gfc_convert_type (gfc_expr * expr, gfc_typespec * ts, int eflag)
3439 return gfc_convert_type_warn (expr, ts, eflag, 1);
3443 /* Try to convert an expression (in place) from one type to another.
3444 'eflag' controls the behavior on error.
3446 The possible values are:
3448 1 Generate a gfc_error()
3449 2 Generate a gfc_internal_error().
3451 'wflag' controls the warning related to conversion. */
3454 gfc_convert_type_warn (gfc_expr * expr, gfc_typespec * ts, int eflag,
3457 gfc_intrinsic_sym *sym;
3458 gfc_typespec from_ts;
3464 from_ts = expr->ts; /* expr->ts gets clobbered */
3466 if (ts->type == BT_UNKNOWN)
3469 /* NULL and zero size arrays get their type here. */
3470 if (expr->expr_type == EXPR_NULL
3471 || (expr->expr_type == EXPR_ARRAY
3472 && expr->value.constructor == NULL))
3474 /* Sometimes the RHS acquire the type. */
3479 if (expr->ts.type == BT_UNKNOWN)
3482 if (expr->ts.type == BT_DERIVED
3483 && ts->type == BT_DERIVED
3484 && gfc_compare_types (&expr->ts, ts))
3487 sym = find_conv (&expr->ts, ts);
3491 /* At this point, a conversion is necessary. A warning may be needed. */
3492 if ((gfc_option.warn_std & sym->standard) != 0)
3493 gfc_warning_now ("Extension: Conversion from %s to %s at %L",
3494 gfc_typename (&from_ts), gfc_typename (ts), &expr->where);
3495 else if (wflag && gfc_option.warn_conversion)
3496 gfc_warning_now ("Conversion from %s to %s at %L",
3497 gfc_typename (&from_ts), gfc_typename (ts), &expr->where);
3499 /* Insert a pre-resolved function call to the right function. */
3500 old_where = expr->where;
3502 shape = expr->shape;
3504 new = gfc_get_expr ();
3507 new = gfc_build_conversion (new);
3508 new->value.function.name = sym->lib_name;
3509 new->value.function.isym = sym;
3510 new->where = old_where;
3512 new->shape = gfc_copy_shape (shape, rank);
3514 gfc_get_ha_sym_tree (sym->name, &new->symtree);
3515 new->symtree->n.sym->ts = *ts;
3516 new->symtree->n.sym->attr.flavor = FL_PROCEDURE;
3517 new->symtree->n.sym->attr.function = 1;
3518 new->symtree->n.sym->attr.intrinsic = 1;
3519 new->symtree->n.sym->attr.elemental = 1;
3520 new->symtree->n.sym->attr.pure = 1;
3521 new->symtree->n.sym->attr.referenced = 1;
3522 gfc_intrinsic_symbol(new->symtree->n.sym);
3523 gfc_commit_symbol (new->symtree->n.sym);
3530 if (gfc_is_constant_expr (expr->value.function.actual->expr)
3531 && do_simplify (sym, expr) == FAILURE)
3536 return FAILURE; /* Error already generated in do_simplify() */
3544 gfc_error ("Can't convert %s to %s at %L",
3545 gfc_typename (&from_ts), gfc_typename (ts), &expr->where);
3549 gfc_internal_error ("Can't convert %s to %s at %L",
3550 gfc_typename (&from_ts), gfc_typename (ts),