1 /* Build up a list of intrinsic subroutines and functions for the
3 Copyright (C) 2000, 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, Boston, MA
35 #include "intrinsic.h"
38 /* Namespace to hold the resolved symbols for intrinsic subroutines. */
39 static gfc_namespace *gfc_intrinsic_namespace;
41 int gfc_init_expr = 0;
43 /* Pointers to a intrinsic function and its argument names being
46 char *gfc_current_intrinsic, *gfc_current_intrinsic_arg[MAX_INTRINSIC_ARGS];
47 locus *gfc_current_intrinsic_where;
49 static gfc_intrinsic_sym *functions, *subroutines, *conversion, *next_sym;
50 static gfc_intrinsic_arg *next_arg;
52 static int nfunc, nsub, nargs, nconv;
55 { SZ_NOTHING = 0, SZ_SUBS, SZ_FUNCS, SZ_CONVS }
59 /* Return a letter based on the passed type. Used to construct the
60 name of a type-dependent subroutine. */
63 gfc_type_letter (bt type)
94 /* Get a symbol for a resolved name. */
97 gfc_get_intrinsic_sub_symbol (const char * name)
101 gfc_get_symbol (name, gfc_intrinsic_namespace, &sym);
102 sym->attr.always_explicit = 1;
103 sym->attr.subroutine = 1;
104 sym->attr.flavor = FL_PROCEDURE;
105 sym->attr.proc = PROC_INTRINSIC;
111 /* Return a pointer to the name of a conversion function given two
115 conv_name (gfc_typespec * from, gfc_typespec * to)
117 static char name[30];
119 sprintf (name, "__convert_%c%d_%c%d", gfc_type_letter (from->type),
120 from->kind, gfc_type_letter (to->type), to->kind);
126 /* Given a pair of typespecs, find the gfc_intrinsic_sym node that
127 corresponds to the conversion. Returns NULL if the conversion
130 static gfc_intrinsic_sym *
131 find_conv (gfc_typespec * from, gfc_typespec * to)
133 gfc_intrinsic_sym *sym;
137 target = conv_name (from, to);
140 for (i = 0; i < nconv; i++, sym++)
141 if (strcmp (target, sym->name) == 0)
148 /* Interface to the check functions. We break apart an argument list
149 and call the proper check function rather than forcing each
150 function to manipulate the argument list. */
153 do_check (gfc_intrinsic_sym * specific, gfc_actual_arglist * arg)
155 gfc_expr *a1, *a2, *a3, *a4, *a5;
158 return (*specific->check.f0) ();
163 return (*specific->check.f1) (a1);
168 return (*specific->check.f2) (a1, a2);
173 return (*specific->check.f3) (a1, a2, a3);
178 return (*specific->check.f4) (a1, a2, a3, a4);
183 return (*specific->check.f5) (a1, a2, a3, a4, a5);
185 gfc_internal_error ("do_check(): too many args");
189 /*********** Subroutines to build the intrinsic list ****************/
191 /* Add a single intrinsic symbol to the current list.
194 char * name of function
195 int whether function is elemental
196 int If the function can be used as an actual argument
197 bt return type of function
198 int kind of return type of function
199 int Fortran standard version
200 check pointer to check function
201 simplify pointer to simplification function
202 resolve pointer to resolution function
204 Optional arguments come in multiples of four:
205 char * name of argument
208 int arg optional flag (1=optional, 0=required)
210 The sequence is terminated by a NULL name.
212 TODO: Are checks on actual_ok implemented elsewhere, or is that just
216 add_sym (const char *name, int elemental, int actual_ok ATTRIBUTE_UNUSED,
217 bt type, int kind, int standard, gfc_check_f check,
218 gfc_simplify_f simplify, gfc_resolve_f resolve, ...)
221 int optional, first_flag;
224 /* First check that the intrinsic belongs to the selected standard.
225 If not, don't add it to the symbol list. */
226 if (!(gfc_option.allow_std & standard))
240 strcpy (next_sym->name, name);
242 strcpy (next_sym->lib_name, "_gfortran_");
243 strcat (next_sym->lib_name, name);
245 next_sym->elemental = elemental;
246 next_sym->ts.type = type;
247 next_sym->ts.kind = kind;
248 next_sym->standard = standard;
249 next_sym->simplify = simplify;
250 next_sym->check = check;
251 next_sym->resolve = resolve;
252 next_sym->specific = 0;
253 next_sym->generic = 0;
257 gfc_internal_error ("add_sym(): Bad sizing mode");
260 va_start (argp, resolve);
266 name = va_arg (argp, char *);
270 type = (bt) va_arg (argp, int);
271 kind = va_arg (argp, int);
272 optional = va_arg (argp, int);
274 if (sizing != SZ_NOTHING)
281 next_sym->formal = next_arg;
283 (next_arg - 1)->next = next_arg;
287 strcpy (next_arg->name, name);
288 next_arg->ts.type = type;
289 next_arg->ts.kind = kind;
290 next_arg->optional = optional;
300 static void add_sym_0 (const char *name, int elemental, int actual_ok, bt type,
301 int kind, int standard,
303 gfc_expr *(*simplify)(void),
304 void (*resolve)(gfc_expr *)
314 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
319 static void add_sym_1 (const char *name, int elemental, int actual_ok, bt type,
320 int kind, int standard,
321 try (*check)(gfc_expr *),
322 gfc_expr *(*simplify)(gfc_expr *),
323 void (*resolve)(gfc_expr *,gfc_expr *),
324 const char* a1, bt type1, int kind1, int optional1
334 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
335 a1, type1, kind1, optional1,
341 add_sym_0s (const char * name, int actual_ok, int standard,
342 void (*resolve)(gfc_code *))
352 add_sym (name, 1, actual_ok, BT_UNKNOWN, 0, standard, cf, sf, rf,
357 static void add_sym_1s (const char *name, int elemental, int actual_ok, bt type,
358 int kind, int standard,
359 try (*check)(gfc_expr *),
360 gfc_expr *(*simplify)(gfc_expr *),
361 void (*resolve)(gfc_code *),
362 const char* a1, bt type1, int kind1, int optional1
372 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
373 a1, type1, kind1, optional1,
378 static void add_sym_1m (const char *name, int elemental, int actual_ok, bt type,
379 int kind, int standard,
380 try (*check)(gfc_actual_arglist *),
381 gfc_expr *(*simplify)(gfc_expr *),
382 void (*resolve)(gfc_expr *,gfc_actual_arglist *),
383 const char* a1, bt type1, int kind1, int optional1,
384 const char* a2, bt type2, int kind2, int optional2
394 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
395 a1, type1, kind1, optional1,
396 a2, type2, kind2, optional2,
401 static void add_sym_2 (const char *name, int elemental, int actual_ok, bt type,
402 int kind, int standard,
403 try (*check)(gfc_expr *,gfc_expr *),
404 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *),
405 void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *),
406 const char* a1, bt type1, int kind1, int optional1,
407 const char* a2, bt type2, int kind2, int optional2
417 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
418 a1, type1, kind1, optional1,
419 a2, type2, kind2, optional2,
424 /* Add the name of an intrinsic subroutine with two arguments to the list
425 of intrinsic names. */
427 static void add_sym_2s (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_code *),
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 static void add_sym_3 (const char *name, int elemental, int actual_ok, bt type,
451 int kind, int standard,
452 try (*check)(gfc_expr *,gfc_expr *,gfc_expr *),
453 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *),
454 void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
455 const char* a1, bt type1, int kind1, int optional1,
456 const char* a2, bt type2, int kind2, int optional2,
457 const char* a3, bt type3, int kind3, int optional3
467 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
468 a1, type1, kind1, optional1,
469 a2, type2, kind2, optional2,
470 a3, type3, kind3, optional3,
474 /* MINLOC and MAXLOC get special treatment because their argument
475 might have to be reordered. */
477 static void add_sym_3ml (const char *name, int elemental,
478 int actual_ok, bt type, int kind, int standard,
479 try (*check)(gfc_actual_arglist *),
480 gfc_expr*(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *),
481 void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
482 const char* a1, bt type1, int kind1, int optional1,
483 const char* a2, bt type2, int kind2, int optional2,
484 const char* a3, bt type3, int kind3, int optional3
494 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
495 a1, type1, kind1, optional1,
496 a2, type2, kind2, optional2,
497 a3, type3, kind3, optional3,
501 /* MINVAL, MAXVAL, PRODUCT, and SUM also get special treatment because
502 their argument also might have to be reordered. */
504 static void add_sym_3red (const char *name, int elemental,
505 int actual_ok, bt type, int kind, int standard,
506 try (*check)(gfc_actual_arglist *),
507 gfc_expr*(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *),
508 void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
509 const char* a1, bt type1, int kind1, int optional1,
510 const char* a2, bt type2, int kind2, int optional2,
511 const char* a3, bt type3, int kind3, int optional3
521 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
522 a1, type1, kind1, optional1,
523 a2, type2, kind2, optional2,
524 a3, type3, kind3, optional3,
528 /* Add the name of an intrinsic subroutine with three arguments to the list
529 of intrinsic names. */
531 static void add_sym_3s (const char *name, int elemental, int actual_ok, bt type,
532 int kind, int standard,
533 try (*check)(gfc_expr *,gfc_expr *,gfc_expr *),
534 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *),
535 void (*resolve)(gfc_code *),
536 const char* a1, bt type1, int kind1, int optional1,
537 const char* a2, bt type2, int kind2, int optional2,
538 const char* a3, bt type3, int kind3, int optional3
548 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
549 a1, type1, kind1, optional1,
550 a2, type2, kind2, optional2,
551 a3, type3, kind3, optional3,
556 static void add_sym_4 (const char *name, int elemental, int actual_ok, bt type,
557 int kind, int standard,
558 try (*check)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
559 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
560 void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
561 const char* a1, bt type1, int kind1, int optional1,
562 const char* a2, bt type2, int kind2, int optional2,
563 const char* a3, bt type3, int kind3, int optional3,
564 const char* a4, bt type4, int kind4, int optional4
574 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
575 a1, type1, kind1, optional1,
576 a2, type2, kind2, optional2,
577 a3, type3, kind3, optional3,
578 a4, type4, kind4, optional4,
583 static void add_sym_4s (const char *name, int elemental, int actual_ok,
584 bt type, int kind, int standard,
585 try (*check)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
586 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
587 void (*resolve)(gfc_code *),
588 const char* a1, bt type1, int kind1, int optional1,
589 const char* a2, bt type2, int kind2, int optional2,
590 const char* a3, bt type3, int kind3, int optional3,
591 const char* a4, bt type4, int kind4, int optional4)
601 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
602 a1, type1, kind1, optional1,
603 a2, type2, kind2, optional2,
604 a3, type3, kind3, optional3,
605 a4, type4, kind4, optional4,
610 static void add_sym_5s
612 const char *name, int elemental, int actual_ok,
613 bt type, int kind, int standard,
614 try (*check)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
615 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
616 void (*resolve)(gfc_code *),
617 const char* a1, bt type1, int kind1, int optional1,
618 const char* a2, bt type2, int kind2, int optional2,
619 const char* a3, bt type3, int kind3, int optional3,
620 const char* a4, bt type4, int kind4, int optional4,
621 const char* a5, bt type5, int kind5, int optional5)
631 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
632 a1, type1, kind1, optional1,
633 a2, type2, kind2, optional2,
634 a3, type3, kind3, optional3,
635 a4, type4, kind4, optional4,
636 a5, type5, kind5, optional5,
641 /* Locate an intrinsic symbol given a base pointer, number of elements
642 in the table and a pointer to a name. Returns the NULL pointer if
643 a name is not found. */
645 static gfc_intrinsic_sym *
646 find_sym (gfc_intrinsic_sym * start, int n, const char *name)
651 if (strcmp (name, start->name) == 0)
662 /* Given a name, find a function in the intrinsic function table.
663 Returns NULL if not found. */
666 gfc_find_function (const char *name)
669 return find_sym (functions, nfunc, name);
673 /* Given a name, find a function in the intrinsic subroutine table.
674 Returns NULL if not found. */
676 static gfc_intrinsic_sym *
677 find_subroutine (const char *name)
680 return find_sym (subroutines, nsub, name);
684 /* Given a string, figure out if it is the name of a generic intrinsic
688 gfc_generic_intrinsic (const char *name)
690 gfc_intrinsic_sym *sym;
692 sym = gfc_find_function (name);
693 return (sym == NULL) ? 0 : sym->generic;
697 /* Given a string, figure out if it is the name of a specific
698 intrinsic function or not. */
701 gfc_specific_intrinsic (const char *name)
703 gfc_intrinsic_sym *sym;
705 sym = gfc_find_function (name);
706 return (sym == NULL) ? 0 : sym->specific;
710 /* Given a string, figure out if it is the name of an intrinsic
711 subroutine or function. There are no generic intrinsic
712 subroutines, they are all specific. */
715 gfc_intrinsic_name (const char *name, int subroutine_flag)
718 return subroutine_flag ?
719 find_subroutine (name) != NULL : gfc_find_function (name) != NULL;
723 /* Collect a set of intrinsic functions into a generic collection.
724 The first argument is the name of the generic function, which is
725 also the name of a specific function. The rest of the specifics
726 currently in the table are placed into the list of specific
727 functions associated with that generic. */
730 make_generic (const char *name, gfc_generic_isym_id generic_id, int standard)
732 gfc_intrinsic_sym *g;
734 if (!(gfc_option.allow_std & standard))
737 if (sizing != SZ_NOTHING)
740 g = gfc_find_function (name);
742 gfc_internal_error ("make_generic(): Can't find generic symbol '%s'",
747 g->generic_id = generic_id;
748 if ((g + 1)->name[0] != '\0')
749 g->specific_head = g + 1;
752 while (g->name[0] != '\0')
756 g->generic_id = generic_id;
765 /* Create a duplicate intrinsic function entry for the current
766 function, the only difference being the alternate name. Note that
767 we use argument lists more than once, but all argument lists are
768 freed as a single block. */
771 make_alias (const char *name)
785 next_sym[0] = next_sym[-1];
786 strcpy (next_sym->name, name);
796 /* Add intrinsic functions. */
802 /* Argument names as in the standard (to be used as argument keywords). */
804 *a = "a", *f = "field", *pt = "pointer", *tg = "target",
805 *b = "b", *m = "matrix", *ma = "matrix_a", *mb = "matrix_b",
806 *c = "c", *n = "ncopies", *pos = "pos", *bck = "back",
807 *i = "i", *v = "vector", *va = "vector_a", *vb = "vector_b",
808 *j = "j", *a1 = "a1", *fs = "fsource", *ts = "tsource",
809 *l = "l", *a2 = "a2", *mo = "mold", *ord = "order",
810 *p = "p", *ar = "array", *shp = "shape", *src = "source",
811 *r = "r", *bd = "boundary", *pad = "pad", *set = "set",
812 *s = "s", *dm = "dim", *kind = "kind", *msk = "mask",
813 *x = "x", *sh = "shift", *stg = "string", *ssg = "substring",
814 *y = "y", *sz = "size", *sta = "string_a", *stb = "string_b",
815 *z = "z", *ln = "len";
817 int di, dr, dd, dl, dc, dz, ii;
819 di = gfc_default_integer_kind;
820 dr = gfc_default_real_kind;
821 dd = gfc_default_double_kind;
822 dl = gfc_default_logical_kind;
823 dc = gfc_default_character_kind;
824 dz = gfc_default_complex_kind;
825 ii = gfc_index_integer_kind;
827 add_sym_1 ("abs", 1, 1, BT_REAL, dr, GFC_STD_F77,
828 gfc_check_abs, gfc_simplify_abs, gfc_resolve_abs,
831 add_sym_1 ("iabs", 1, 1, BT_INTEGER, di, GFC_STD_F77,
832 NULL, gfc_simplify_abs, gfc_resolve_abs,
833 a, BT_INTEGER, di, 0);
835 add_sym_1 ("dabs", 1, 1, BT_REAL, dd, GFC_STD_F77,
836 NULL, gfc_simplify_abs, gfc_resolve_abs, a, BT_REAL, dd, 0);
838 add_sym_1 ("cabs", 1, 1, BT_REAL, dr, GFC_STD_F77,
839 NULL, gfc_simplify_abs, gfc_resolve_abs,
840 a, BT_COMPLEX, dz, 0);
842 add_sym_1 ("zabs", 1, 1, BT_REAL, dd, GFC_STD_GNU,
843 NULL, gfc_simplify_abs, gfc_resolve_abs,
844 a, BT_COMPLEX, dd, 0);
846 make_alias ("cdabs");
848 make_generic ("abs", GFC_ISYM_ABS, GFC_STD_F77);
850 add_sym_1 ("achar", 1, 1, BT_CHARACTER, dc, GFC_STD_F95,
851 NULL, gfc_simplify_achar, NULL, i, BT_INTEGER, di, 0);
853 make_generic ("achar", GFC_ISYM_ACHAR, GFC_STD_F95);
855 add_sym_1 ("acos", 1, 1, BT_REAL, dr, GFC_STD_F77,
856 NULL, gfc_simplify_acos, gfc_resolve_acos,
859 add_sym_1 ("dacos", 1, 1, BT_REAL, dd, GFC_STD_F77,
860 NULL, gfc_simplify_acos, gfc_resolve_acos,
863 make_generic ("acos", GFC_ISYM_ACOS, GFC_STD_F77);
865 add_sym_1 ("adjustl", 1, 1, BT_CHARACTER, dc, GFC_STD_F95,
866 NULL, gfc_simplify_adjustl, NULL, stg, BT_CHARACTER, dc, 0);
868 make_generic ("adjustl", GFC_ISYM_ADJUSTL, GFC_STD_F95);
870 add_sym_1 ("adjustr", 1, 1, BT_CHARACTER, dc, GFC_STD_F95,
871 NULL, gfc_simplify_adjustr, NULL, stg, BT_CHARACTER, dc, 0);
873 make_generic ("adjustr", GFC_ISYM_ADJUSTR, GFC_STD_F95);
875 add_sym_1 ("aimag", 1, 1, BT_REAL, dr, GFC_STD_F77,
876 NULL, gfc_simplify_aimag, gfc_resolve_aimag,
877 z, BT_COMPLEX, dz, 0);
879 add_sym_1 ("dimag", 1, 1, BT_REAL, dd, GFC_STD_GNU,
880 NULL, gfc_simplify_aimag, gfc_resolve_aimag,
881 z, BT_COMPLEX, dd, 0);
883 make_generic ("aimag", GFC_ISYM_AIMAG, GFC_STD_F77);
885 add_sym_2 ("aint", 1, 1, BT_REAL, dr, GFC_STD_F77,
886 gfc_check_a_xkind, gfc_simplify_aint, gfc_resolve_aint,
887 a, BT_REAL, dr, 0, kind, BT_INTEGER, di, 1);
889 add_sym_1 ("dint", 1, 1, BT_REAL, dd, GFC_STD_F77,
890 NULL, gfc_simplify_dint, gfc_resolve_dint,
893 make_generic ("aint", GFC_ISYM_AINT, GFC_STD_F77);
895 add_sym_2 ("all", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
896 gfc_check_all_any, NULL, gfc_resolve_all,
897 msk, BT_LOGICAL, dl, 0, dm, BT_INTEGER, ii, 1);
899 make_generic ("all", GFC_ISYM_ALL, GFC_STD_F95);
901 add_sym_1 ("allocated", 0, 1, BT_LOGICAL, dl, GFC_STD_F95,
902 gfc_check_allocated, NULL, NULL, ar, BT_UNKNOWN, 0, 0);
904 make_generic ("allocated", GFC_ISYM_ALLOCATED, GFC_STD_F95);
906 add_sym_2 ("anint", 1, 1, BT_REAL, dr, GFC_STD_F77,
907 gfc_check_a_xkind, gfc_simplify_anint, gfc_resolve_anint,
908 a, BT_REAL, dr, 0, kind, BT_INTEGER, di, 1);
910 add_sym_1 ("dnint", 1, 1, BT_REAL, dd, GFC_STD_F77,
911 NULL, gfc_simplify_dnint, gfc_resolve_dnint,
914 make_generic ("anint", GFC_ISYM_ANINT, GFC_STD_F77);
916 add_sym_2 ("any", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
917 gfc_check_all_any, NULL, gfc_resolve_any,
918 msk, BT_LOGICAL, dl, 0, dm, BT_INTEGER, ii, 1);
920 make_generic ("any", GFC_ISYM_ANY, GFC_STD_F95);
922 add_sym_1 ("asin", 1, 1, BT_REAL, dr, GFC_STD_F77,
923 NULL, gfc_simplify_asin, gfc_resolve_asin,
926 add_sym_1 ("dasin", 1, 1, BT_REAL, dd, GFC_STD_F77,
927 NULL, gfc_simplify_asin, gfc_resolve_asin,
930 make_generic ("asin", GFC_ISYM_ASIN, GFC_STD_F77);
932 add_sym_2 ("associated", 0, 1, BT_LOGICAL, dl, GFC_STD_F95,
933 gfc_check_associated, NULL, NULL,
934 pt, BT_UNKNOWN, 0, 0, tg, BT_UNKNOWN, 0, 1);
936 make_generic ("associated", GFC_ISYM_ASSOCIATED, GFC_STD_F95);
938 add_sym_1 ("atan", 1, 1, BT_REAL, dr, GFC_STD_F77,
939 NULL, gfc_simplify_atan, gfc_resolve_atan,
942 add_sym_1 ("datan", 1, 1, BT_REAL, dd, GFC_STD_F77,
943 NULL, gfc_simplify_atan, gfc_resolve_atan,
946 make_generic ("atan", GFC_ISYM_ATAN, GFC_STD_F77);
948 add_sym_2 ("atan2", 1, 1, BT_REAL, dr, GFC_STD_F77,
949 gfc_check_atan2, gfc_simplify_atan2, gfc_resolve_atan2,
950 y, BT_REAL, dr, 0, x, BT_REAL, dr, 0);
952 add_sym_2 ("datan2", 1, 1, BT_REAL, dd, GFC_STD_F77,
953 NULL, gfc_simplify_atan2, gfc_resolve_atan2,
954 y, BT_REAL, dd, 0, x, BT_REAL, dd, 0);
956 make_generic ("atan2", GFC_ISYM_ATAN2, GFC_STD_F77);
958 /* Bessel and Neumann functions for G77 compatibility. */
960 add_sym_1 ("besj0", 1, 0, BT_REAL, dr, GFC_STD_GNU,
961 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
964 add_sym_1 ("dbesj0", 1, 0, BT_REAL, dd, GFC_STD_GNU,
965 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
968 make_generic ("besj0", GFC_ISYM_J0, GFC_STD_GNU);
970 add_sym_1 ("besj1", 1, 0, BT_REAL, dr, GFC_STD_GNU,
971 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
974 add_sym_1 ("dbesj1", 1, 0, BT_REAL, dd, GFC_STD_GNU,
975 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
978 make_generic ("besj1", GFC_ISYM_J1, GFC_STD_GNU);
980 add_sym_2 ("besjn", 1, 0, BT_REAL, dr, GFC_STD_GNU,
981 gfc_check_besn, NULL, gfc_resolve_besn, n, BT_INTEGER, di, 1,
984 add_sym_2 ("dbesjn", 1, 0, BT_REAL, dd, GFC_STD_GNU,
985 gfc_check_besn, NULL, gfc_resolve_besn, n, BT_INTEGER, di, 1,
988 make_generic ("besjn", GFC_ISYM_JN, GFC_STD_GNU);
990 add_sym_1 ("besy0", 1, 0, BT_REAL, dr, GFC_STD_GNU,
991 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
994 add_sym_1 ("dbesy0", 1, 0, BT_REAL, dd, GFC_STD_GNU,
995 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
998 make_generic ("besy0", GFC_ISYM_Y0, GFC_STD_GNU);
1000 add_sym_1 ("besy1", 1, 0, BT_REAL, dr, GFC_STD_GNU,
1001 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1004 add_sym_1 ("dbesy1", 1, 0, BT_REAL, dd, GFC_STD_GNU,
1005 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1008 make_generic ("besy1", GFC_ISYM_Y1, GFC_STD_GNU);
1010 add_sym_2 ("besyn", 1, 0, BT_REAL, dr, GFC_STD_GNU,
1011 gfc_check_besn, NULL, gfc_resolve_besn, n, BT_INTEGER, di, 1,
1014 add_sym_2 ("dbesyn", 1, 0, BT_REAL, dd, GFC_STD_GNU,
1015 gfc_check_besn, NULL, gfc_resolve_besn, n, BT_INTEGER, di, 1,
1018 make_generic ("besyn", GFC_ISYM_YN, GFC_STD_GNU);
1020 add_sym_1 ("bit_size", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1021 gfc_check_i, gfc_simplify_bit_size, NULL,
1022 i, BT_INTEGER, di, 0);
1024 make_generic ("bit_size", GFC_ISYM_NONE, GFC_STD_F95);
1026 add_sym_2 ("btest", 1, 1, BT_LOGICAL, dl, GFC_STD_F95,
1027 gfc_check_btest, gfc_simplify_btest, gfc_resolve_btest,
1028 i, BT_INTEGER, di, 0, pos, BT_INTEGER, di, 0);
1030 make_generic ("btest", GFC_ISYM_BTEST, GFC_STD_F95);
1032 add_sym_2 ("ceiling", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1033 gfc_check_a_ikind, gfc_simplify_ceiling, gfc_resolve_ceiling,
1034 a, BT_REAL, dr, 0, kind, BT_INTEGER, di, 1);
1036 make_generic ("ceiling", GFC_ISYM_CEILING, GFC_STD_F95);
1038 add_sym_2 ("char", 1, 0, BT_CHARACTER, dc, GFC_STD_F77,
1039 gfc_check_char, gfc_simplify_char, gfc_resolve_char,
1040 i, BT_INTEGER, di, 0, kind, BT_INTEGER, di, 1);
1042 make_generic ("char", GFC_ISYM_CHAR, GFC_STD_F77);
1044 add_sym_3 ("cmplx", 1, 1, BT_COMPLEX, dz, GFC_STD_F77,
1045 gfc_check_cmplx, gfc_simplify_cmplx, gfc_resolve_cmplx,
1046 x, BT_UNKNOWN, dr, 0, y, BT_UNKNOWN, dr, 1,
1047 kind, BT_INTEGER, di, 1);
1049 make_generic ("cmplx", GFC_ISYM_CMPLX, GFC_STD_F77);
1051 /* Making dcmplx a specific of cmplx causes cmplx to return a double
1052 complex instead of the default complex. */
1054 add_sym_2 ("dcmplx", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
1055 gfc_check_dcmplx, gfc_simplify_dcmplx, gfc_resolve_dcmplx,
1056 x, BT_REAL, dd, 0, y, BT_REAL, dd, 1);
1058 make_generic ("dcmplx", GFC_ISYM_CMPLX, GFC_STD_GNU);
1060 add_sym_1 ("conjg", 1, 1, BT_COMPLEX, dz, GFC_STD_F77,
1061 NULL, gfc_simplify_conjg, gfc_resolve_conjg,
1062 z, BT_COMPLEX, dz, 0);
1064 add_sym_1 ("dconjg", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
1065 NULL, gfc_simplify_conjg, gfc_resolve_conjg,
1066 z, BT_COMPLEX, dd, 0);
1068 make_generic ("conjg", GFC_ISYM_CONJG, GFC_STD_F77);
1070 add_sym_1 ("cos", 1, 1, BT_REAL, dr, GFC_STD_F77,
1071 NULL, gfc_simplify_cos, gfc_resolve_cos, x, BT_REAL, dr, 0);
1073 add_sym_1 ("dcos", 1, 1, BT_REAL, dd, GFC_STD_F77,
1074 NULL, gfc_simplify_cos, gfc_resolve_cos, x, BT_REAL, dd, 0);
1076 add_sym_1 ("ccos", 1, 1, BT_COMPLEX, dz, GFC_STD_F77,
1077 NULL, gfc_simplify_cos, gfc_resolve_cos,
1078 x, BT_COMPLEX, dz, 0);
1080 add_sym_1 ("zcos", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
1081 NULL, gfc_simplify_cos, gfc_resolve_cos,
1082 x, BT_COMPLEX, dd, 0);
1084 make_alias ("cdcos");
1086 make_generic ("cos", GFC_ISYM_COS, GFC_STD_F77);
1088 add_sym_1 ("cosh", 1, 1, BT_REAL, dr, GFC_STD_F77,
1089 NULL, gfc_simplify_cosh, gfc_resolve_cosh,
1092 add_sym_1 ("dcosh", 1, 1, BT_REAL, dd, GFC_STD_F77,
1093 NULL, gfc_simplify_cosh, gfc_resolve_cosh,
1096 make_generic ("cosh", GFC_ISYM_COSH, GFC_STD_F77);
1098 add_sym_2 ("count", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1099 gfc_check_count, NULL, gfc_resolve_count,
1100 msk, BT_LOGICAL, dl, 0, dm, BT_INTEGER, ii, 1);
1102 make_generic ("count", GFC_ISYM_COUNT, GFC_STD_F95);
1104 add_sym_3 ("cshift", 0, 1, BT_REAL, dr, GFC_STD_F95,
1105 gfc_check_cshift, NULL, gfc_resolve_cshift,
1106 ar, BT_REAL, dr, 0, sh, BT_INTEGER, di, 0,
1107 dm, BT_INTEGER, ii, 1);
1109 make_generic ("cshift", GFC_ISYM_CSHIFT, GFC_STD_F95);
1111 add_sym_1 ("dble", 1, 1, BT_REAL, dd, GFC_STD_F77,
1112 gfc_check_dble, gfc_simplify_dble, gfc_resolve_dble,
1115 make_alias ("dfloat");
1117 make_generic ("dble", GFC_ISYM_DBLE, GFC_STD_F77);
1119 add_sym_1 ("digits", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1120 gfc_check_digits, gfc_simplify_digits, NULL,
1121 x, BT_UNKNOWN, dr, 0);
1123 make_generic ("digits", GFC_ISYM_NONE, GFC_STD_F95);
1125 add_sym_2 ("dim", 1, 1, BT_REAL, dr, GFC_STD_F77,
1126 gfc_check_a_p, gfc_simplify_dim, gfc_resolve_dim,
1127 x, BT_UNKNOWN, dr, 0, y, BT_UNKNOWN, dr, 0);
1129 add_sym_2 ("idim", 1, 1, BT_INTEGER, di, GFC_STD_F77,
1130 NULL, gfc_simplify_dim, gfc_resolve_dim,
1131 x, BT_INTEGER, di, 0, y, BT_INTEGER, di, 0);
1133 add_sym_2 ("ddim", 1, 1, BT_REAL, dd, GFC_STD_F77,
1134 NULL, gfc_simplify_dim, gfc_resolve_dim,
1135 x, BT_REAL, dd, 0, y, BT_REAL, dd, 0);
1137 make_generic ("dim", GFC_ISYM_DIM, GFC_STD_F77);
1139 add_sym_2 ("dot_product", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
1140 gfc_check_dot_product, NULL, gfc_resolve_dot_product,
1141 va, BT_REAL, dr, 0, vb, BT_REAL, dr, 0);
1143 make_generic ("dot_product", GFC_ISYM_DOT_PRODUCT, GFC_STD_F95);
1145 add_sym_2 ("dprod", 1, 1, BT_REAL, dd, GFC_STD_F77,
1146 NULL, gfc_simplify_dprod, gfc_resolve_dprod,
1147 x, BT_REAL, dr, 0, y, BT_REAL, dr, 0);
1149 make_generic ("dprod", GFC_ISYM_DPROD, GFC_STD_F77);
1151 add_sym_1 ("dreal", 1, 0, BT_REAL, dd, GFC_STD_GNU,
1152 NULL, NULL, NULL, a, BT_COMPLEX, dd, 0);
1154 make_generic ("dreal", GFC_ISYM_REAL, GFC_STD_GNU);
1156 add_sym_4 ("eoshift", 0, 1, BT_REAL, dr, GFC_STD_F95,
1157 gfc_check_eoshift, NULL, gfc_resolve_eoshift,
1158 ar, BT_REAL, dr, 0, sh, BT_INTEGER, ii, 0,
1159 bd, BT_REAL, dr, 1, dm, BT_INTEGER, ii, 1);
1161 make_generic ("eoshift", GFC_ISYM_EOSHIFT, GFC_STD_F95);
1163 add_sym_1 ("epsilon", 0, 1, BT_REAL, dr, GFC_STD_F95,
1164 gfc_check_x, gfc_simplify_epsilon, NULL,
1167 make_generic ("epsilon", GFC_ISYM_NONE, GFC_STD_F95);
1169 /* G77 compatibility for the ERF() and ERFC() functions. */
1170 add_sym_1 ("erf", 1, 0, BT_REAL, dr, GFC_STD_GNU,
1171 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1174 add_sym_1 ("derf", 1, 0, BT_REAL, dd, GFC_STD_GNU,
1175 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1178 make_generic ("erf", GFC_ISYM_ERF, GFC_STD_GNU);
1180 add_sym_1 ("erfc", 1, 0, BT_REAL, dr, GFC_STD_GNU,
1181 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1184 add_sym_1 ("derfc", 1, 0, BT_REAL, dd, GFC_STD_GNU,
1185 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1188 make_generic ("erfc", GFC_ISYM_ERFC, GFC_STD_GNU);
1190 /* G77 compatibility */
1191 add_sym_1 ("etime", 0, 1, BT_REAL, 4, GFC_STD_GNU,
1192 gfc_check_etime, NULL, NULL,
1195 make_alias ("dtime");
1197 make_generic ("etime", GFC_ISYM_ETIME, GFC_STD_GNU);
1200 add_sym_1 ("exp", 1, 1, BT_REAL, dr, GFC_STD_F77,
1201 NULL, gfc_simplify_exp, gfc_resolve_exp, x, BT_REAL, dr, 0);
1203 add_sym_1 ("dexp", 1, 1, BT_REAL, dd, GFC_STD_F77,
1204 NULL, gfc_simplify_exp, gfc_resolve_exp, x, BT_REAL, dd, 0);
1206 add_sym_1 ("cexp", 1, 1, BT_COMPLEX, dz, GFC_STD_F77,
1207 NULL, gfc_simplify_exp, gfc_resolve_exp,
1208 x, BT_COMPLEX, dz, 0);
1210 add_sym_1 ("zexp", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
1211 NULL, gfc_simplify_exp, gfc_resolve_exp,
1212 x, BT_COMPLEX, dd, 0);
1214 make_alias ("cdexp");
1216 make_generic ("exp", GFC_ISYM_EXP, GFC_STD_F77);
1218 add_sym_1 ("exponent", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1219 gfc_check_x, gfc_simplify_exponent, gfc_resolve_exponent,
1222 make_generic ("exponent", GFC_ISYM_EXPONENT, GFC_STD_F95);
1224 add_sym_2 ("floor", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1225 gfc_check_a_ikind, gfc_simplify_floor, gfc_resolve_floor,
1226 a, BT_REAL, dr, 0, kind, BT_INTEGER, di, 1);
1228 make_generic ("floor", GFC_ISYM_FLOOR, GFC_STD_F95);
1230 add_sym_1 ("fraction", 1, 1, BT_REAL, dr, GFC_STD_F95,
1231 gfc_check_x, gfc_simplify_fraction, gfc_resolve_fraction,
1234 make_generic ("fraction", GFC_ISYM_FRACTION, GFC_STD_F95);
1236 /* Unix IDs (g77 compatibility) */
1237 add_sym_1 ("getcwd", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
1238 NULL, NULL, gfc_resolve_getcwd,
1239 c, BT_CHARACTER, dc, 0);
1240 make_generic ("getcwd", GFC_ISYM_GETCWD, GFC_STD_GNU);
1242 add_sym_0 ("getgid", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
1243 NULL, NULL, gfc_resolve_getgid);
1244 make_generic ("getgid", GFC_ISYM_GETGID, GFC_STD_GNU);
1246 add_sym_0 ("getpid", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
1247 NULL, NULL, gfc_resolve_getpid);
1248 make_generic ("getpid", GFC_ISYM_GETPID, GFC_STD_GNU);
1250 add_sym_0 ("getuid", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
1251 NULL, NULL, gfc_resolve_getuid);
1252 make_generic ("getuid", GFC_ISYM_GETUID, GFC_STD_GNU);
1254 add_sym_1 ("huge", 0, 1, BT_REAL, dr, GFC_STD_F95,
1255 gfc_check_huge, gfc_simplify_huge, NULL,
1256 x, BT_UNKNOWN, dr, 0);
1258 make_generic ("huge", GFC_ISYM_NONE, GFC_STD_F95);
1260 add_sym_1 ("iachar", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1261 NULL, gfc_simplify_iachar, NULL, c, BT_CHARACTER, dc, 0);
1263 make_generic ("iachar", GFC_ISYM_IACHAR, GFC_STD_F95);
1265 add_sym_2 ("iand", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1266 gfc_check_iand, gfc_simplify_iand, gfc_resolve_iand,
1267 i, BT_INTEGER, di, 0, j, BT_INTEGER, di, 0);
1269 make_generic ("iand", GFC_ISYM_IAND, GFC_STD_F95);
1271 add_sym_0 ("iargc", 1, 1, BT_INTEGER, di, GFC_STD_GNU,NULL, NULL, NULL);
1272 make_generic ("iargc", GFC_ISYM_IARGC, GFC_STD_GNU);
1274 add_sym_0 ("command_argument_count", 1, 1, BT_INTEGER, di, GFC_STD_F2003, NULL, NULL, NULL);
1275 make_generic ("command_argument_count", GFC_ISYM_COMMAND_ARGUMENT_COUNT, GFC_STD_F2003);
1277 add_sym_2 ("ibclr", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1278 gfc_check_ibclr, gfc_simplify_ibclr, gfc_resolve_ibclr,
1279 i, BT_INTEGER, di, 0, pos, BT_INTEGER, di, 0);
1281 make_generic ("ibclr", GFC_ISYM_IBCLR, GFC_STD_F95);
1283 add_sym_3 ("ibits", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1284 gfc_check_ibits, gfc_simplify_ibits, gfc_resolve_ibits,
1285 i, BT_INTEGER, di, 0, pos, BT_INTEGER, di, 0,
1286 ln, BT_INTEGER, di, 0);
1288 make_generic ("ibits", GFC_ISYM_IBITS, GFC_STD_F95);
1290 add_sym_2 ("ibset", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1291 gfc_check_ibset, gfc_simplify_ibset, gfc_resolve_ibset,
1292 i, BT_INTEGER, di, 0, pos, BT_INTEGER, di, 0);
1294 make_generic ("ibset", GFC_ISYM_IBSET, GFC_STD_F95);
1296 add_sym_1 ("ichar", 1, 0, BT_INTEGER, di, GFC_STD_F77,
1297 NULL, gfc_simplify_ichar, gfc_resolve_ichar,
1298 c, BT_CHARACTER, dc, 0);
1300 make_generic ("ichar", GFC_ISYM_ICHAR, GFC_STD_F77);
1302 add_sym_2 ("ieor", 1, 1, BT_INTEGER, di, GFC_STD_GNU,
1303 gfc_check_ieor, gfc_simplify_ieor, gfc_resolve_ieor,
1304 i, BT_INTEGER, di, 0, j, BT_INTEGER, di, 0);
1306 make_generic ("ieor", GFC_ISYM_IEOR, GFC_STD_GNU);
1308 add_sym_3 ("index", 1, 1, BT_INTEGER, di, GFC_STD_F77,
1309 gfc_check_index, gfc_simplify_index, NULL,
1310 stg, BT_CHARACTER, dc, 0, ssg, BT_CHARACTER, dc, 0,
1311 bck, BT_LOGICAL, dl, 1);
1313 make_generic ("index", GFC_ISYM_INDEX, GFC_STD_F77);
1315 add_sym_2 ("int", 1, 1, BT_INTEGER, di, GFC_STD_F77,
1316 gfc_check_int, gfc_simplify_int, gfc_resolve_int,
1317 a, BT_REAL, dr, 0, kind, BT_INTEGER, di, 1);
1319 add_sym_1 ("ifix", 1, 0, BT_INTEGER, di, GFC_STD_F77,
1320 NULL, gfc_simplify_ifix, NULL, a, BT_REAL, dr, 0);
1322 add_sym_1 ("idint", 1, 0, BT_INTEGER, di, GFC_STD_F77,
1323 NULL, gfc_simplify_idint, NULL, a, BT_REAL, dd, 0);
1325 make_generic ("int", GFC_ISYM_INT, GFC_STD_F77);
1327 add_sym_2 ("ior", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1328 gfc_check_ior, gfc_simplify_ior, gfc_resolve_ior,
1329 i, BT_INTEGER, di, 0, j, BT_INTEGER, di, 0);
1331 make_generic ("ior", GFC_ISYM_IOR, GFC_STD_F95);
1333 /* The following function is for G77 compatibility. */
1334 add_sym_1 ("irand", 0, 1, BT_INTEGER, 4, GFC_STD_GNU,
1335 gfc_check_irand, NULL, NULL,
1336 i, BT_INTEGER, 4, 1);
1338 make_generic ("irand", GFC_ISYM_IRAND, GFC_STD_GNU);
1340 add_sym_2 ("ishft", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1341 gfc_check_ishft, gfc_simplify_ishft, gfc_resolve_ishft,
1342 i, BT_INTEGER, di, 0, sh, BT_INTEGER, di, 0);
1344 make_generic ("ishft", GFC_ISYM_ISHFT, GFC_STD_F95);
1346 add_sym_3 ("ishftc", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1347 gfc_check_ishftc, gfc_simplify_ishftc, gfc_resolve_ishftc,
1348 i, BT_INTEGER, di, 0, sh, BT_INTEGER, di, 0,
1349 sz, BT_INTEGER, di, 1);
1351 make_generic ("ishftc", GFC_ISYM_ISHFTC, GFC_STD_F95);
1353 add_sym_1 ("kind", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1354 gfc_check_kind, gfc_simplify_kind, NULL, x, BT_REAL, dr, 0);
1356 make_generic ("kind", GFC_ISYM_NONE, GFC_STD_F95);
1358 add_sym_2 ("lbound", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1359 gfc_check_lbound, gfc_simplify_lbound, gfc_resolve_lbound,
1360 ar, BT_REAL, dr, 0, dm, BT_INTEGER, di, 1);
1362 make_generic ("lbound", GFC_ISYM_LBOUND, GFC_STD_F95);
1364 add_sym_1 ("len", 0, 1, BT_INTEGER, di, GFC_STD_F77,
1365 NULL, gfc_simplify_len, gfc_resolve_len,
1366 stg, BT_CHARACTER, dc, 0);
1368 make_generic ("len", GFC_ISYM_LEN, GFC_STD_F77);
1370 add_sym_1 ("len_trim", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1371 NULL, gfc_simplify_len_trim, gfc_resolve_len_trim,
1372 stg, BT_CHARACTER, dc, 0);
1374 make_generic ("len_trim", GFC_ISYM_LEN_TRIM, GFC_STD_F95);
1376 add_sym_2 ("lge", 1, 0, BT_LOGICAL, dl, GFC_STD_F77,
1377 NULL, gfc_simplify_lge, NULL,
1378 sta, BT_CHARACTER, dc, 0, stb, BT_CHARACTER, dc, 0);
1380 make_generic ("lge", GFC_ISYM_LGE, GFC_STD_F77);
1382 add_sym_2 ("lgt", 1, 0, BT_LOGICAL, dl, GFC_STD_F77,
1383 NULL, gfc_simplify_lgt, NULL,
1384 sta, BT_CHARACTER, dc, 0, stb, BT_CHARACTER, dc, 0);
1386 make_generic ("lgt", GFC_ISYM_LGT, GFC_STD_F77);
1388 add_sym_2 ("lle", 1, 0, BT_LOGICAL, dl, GFC_STD_F77,
1389 NULL, gfc_simplify_lle, NULL,
1390 sta, BT_CHARACTER, dc, 0, stb, BT_CHARACTER, dc, 0);
1392 make_generic ("lle", GFC_ISYM_LLE, GFC_STD_F77);
1394 add_sym_2 ("llt", 1, 0, BT_LOGICAL, dl, GFC_STD_F77,
1395 NULL, gfc_simplify_llt, NULL,
1396 sta, BT_CHARACTER, dc, 0, stb, BT_CHARACTER, dc, 0);
1398 make_generic ("llt", GFC_ISYM_LLT, GFC_STD_F77);
1400 add_sym_1 ("log", 1, 1, BT_REAL, dr, GFC_STD_F77,
1401 NULL, gfc_simplify_log, gfc_resolve_log, x, BT_REAL, dr, 0);
1403 add_sym_1 ("alog", 1, 1, BT_REAL, dr, GFC_STD_F77,
1404 NULL, gfc_simplify_log, gfc_resolve_log, x, BT_REAL, dr, 0);
1406 add_sym_1 ("dlog", 1, 1, BT_REAL, dd, GFC_STD_F77,
1407 NULL, gfc_simplify_log, gfc_resolve_log, x, BT_REAL, dd, 0);
1409 add_sym_1 ("clog", 1, 1, BT_COMPLEX, dz, GFC_STD_F77,
1410 NULL, gfc_simplify_log, gfc_resolve_log,
1411 x, BT_COMPLEX, dz, 0);
1413 add_sym_1 ("zlog", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
1414 NULL, gfc_simplify_log, gfc_resolve_log, x, BT_COMPLEX, dd, 0);
1416 make_alias ("cdlog");
1418 make_generic ("log", GFC_ISYM_LOG, GFC_STD_F77);
1420 add_sym_1 ("log10", 1, 1, BT_REAL, dr, GFC_STD_F77,
1421 NULL, gfc_simplify_log10, gfc_resolve_log10,
1424 add_sym_1 ("alog10", 1, 1, BT_REAL, dr, GFC_STD_F77,
1425 NULL, gfc_simplify_log10, gfc_resolve_log10,
1428 add_sym_1 ("dlog10", 1, 1, BT_REAL, dd, GFC_STD_F77,
1429 NULL, gfc_simplify_log10, gfc_resolve_log10,
1432 make_generic ("log10", GFC_ISYM_LOG10, GFC_STD_F77);
1434 add_sym_2 ("logical", 0, 1, BT_LOGICAL, dl, GFC_STD_F95,
1435 gfc_check_logical, gfc_simplify_logical, gfc_resolve_logical,
1436 l, BT_LOGICAL, dl, 0, kind, BT_INTEGER, di, 1);
1438 make_generic ("logical", GFC_ISYM_LOGICAL, GFC_STD_F95);
1440 add_sym_2 ("matmul", 0, 1, BT_REAL, dr, GFC_STD_F95,
1441 gfc_check_matmul, NULL, gfc_resolve_matmul,
1442 ma, BT_REAL, dr, 0, mb, BT_REAL, dr, 0);
1444 make_generic ("matmul", GFC_ISYM_MATMUL, GFC_STD_F95);
1446 /* Note: amax0 is equivalent to real(max), max1 is equivalent to
1447 int(max). The max function must take at least two arguments. */
1449 add_sym_1m ("max", 1, 0, BT_UNKNOWN, 0, GFC_STD_F77,
1450 gfc_check_min_max, gfc_simplify_max, gfc_resolve_max,
1451 a1, BT_UNKNOWN, dr, 0, a2, BT_UNKNOWN, dr, 0);
1453 add_sym_1m ("max0", 1, 0, BT_INTEGER, di, GFC_STD_F77,
1454 gfc_check_min_max_integer, gfc_simplify_max, NULL,
1455 a1, BT_INTEGER, di, 0, a2, BT_INTEGER, di, 0);
1457 add_sym_1m ("amax0", 1, 0, BT_REAL, dr, GFC_STD_F77,
1458 gfc_check_min_max_integer, gfc_simplify_max, NULL,
1459 a1, BT_INTEGER, di, 0, a2, BT_INTEGER, di, 0);
1461 add_sym_1m ("amax1", 1, 0, BT_REAL, dr, GFC_STD_F77,
1462 gfc_check_min_max_real, gfc_simplify_max, NULL,
1463 a1, BT_REAL, dr, 0, a2, BT_REAL, dr, 0);
1465 add_sym_1m ("max1", 1, 0, BT_INTEGER, di, GFC_STD_F77,
1466 gfc_check_min_max_real, gfc_simplify_max, NULL,
1467 a1, BT_REAL, dr, 0, a2, BT_REAL, dr, 0);
1469 add_sym_1m ("dmax1", 1, 0, BT_REAL, dd, GFC_STD_F77,
1470 gfc_check_min_max_double, gfc_simplify_max, NULL,
1471 a1, BT_REAL, dd, 0, a2, BT_REAL, dd, 0);
1473 make_generic ("max", GFC_ISYM_MAX, GFC_STD_F77);
1475 add_sym_1 ("maxexponent", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1476 gfc_check_x, gfc_simplify_maxexponent, NULL,
1477 x, BT_UNKNOWN, dr, 0);
1479 make_generic ("maxexponent", GFC_ISYM_NONE, GFC_STD_F95);
1481 add_sym_3ml ("maxloc", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1482 gfc_check_minloc_maxloc, NULL, gfc_resolve_maxloc,
1483 ar, BT_REAL, dr, 0, dm, BT_INTEGER, ii, 1,
1484 msk, BT_LOGICAL, dl, 1);
1486 make_generic ("maxloc", GFC_ISYM_MAXLOC, GFC_STD_F95);
1488 add_sym_3red ("maxval", 0, 1, BT_REAL, dr, GFC_STD_F95,
1489 gfc_check_minval_maxval, NULL, gfc_resolve_maxval,
1490 ar, BT_REAL, dr, 0, dm, BT_INTEGER, ii, 1,
1491 msk, BT_LOGICAL, dl, 1);
1493 make_generic ("maxval", GFC_ISYM_MAXVAL, GFC_STD_F95);
1495 add_sym_3 ("merge", 1, 1, BT_REAL, dr, GFC_STD_F95,
1496 gfc_check_merge, NULL, gfc_resolve_merge,
1497 ts, BT_REAL, dr, 0, fs, BT_REAL, dr, 0,
1498 msk, BT_LOGICAL, dl, 0);
1500 make_generic ("merge", GFC_ISYM_MERGE, GFC_STD_F95);
1502 /* Note: amin0 is equivalent to real(min), min1 is equivalent to int(min). */
1504 add_sym_1m ("min", 1, 0, BT_UNKNOWN, 0, GFC_STD_F77,
1505 gfc_check_min_max, gfc_simplify_min, gfc_resolve_min,
1506 a1, BT_REAL, dr, 0, a2, BT_REAL, dr, 0);
1508 add_sym_1m ("min0", 1, 0, BT_INTEGER, di, GFC_STD_F77,
1509 gfc_check_min_max_integer, gfc_simplify_min, NULL,
1510 a1, BT_INTEGER, di, 0, a2, BT_INTEGER, di, 0);
1512 add_sym_1m ("amin0", 1, 0, BT_REAL, dr, GFC_STD_F77,
1513 gfc_check_min_max_integer, gfc_simplify_min, NULL,
1514 a1, BT_INTEGER, di, 0, a2, BT_INTEGER, di, 0);
1516 add_sym_1m ("amin1", 1, 0, BT_REAL, dr, GFC_STD_F77,
1517 gfc_check_min_max_real, gfc_simplify_min, NULL,
1518 a1, BT_REAL, dr, 0, a2, BT_REAL, dr, 0);
1520 add_sym_1m ("min1", 1, 0, BT_INTEGER, di, GFC_STD_F77,
1521 gfc_check_min_max_real, gfc_simplify_min, NULL,
1522 a1, BT_REAL, dr, 0, a2, BT_REAL, dr, 0);
1524 add_sym_1m ("dmin1", 1, 0, BT_REAL, dd, GFC_STD_F77,
1525 gfc_check_min_max_double, gfc_simplify_min, NULL,
1526 a1, BT_REAL, dd, 0, a2, BT_REAL, dd, 0);
1528 make_generic ("min", GFC_ISYM_MIN, GFC_STD_F77);
1530 add_sym_1 ("minexponent", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1531 gfc_check_x, gfc_simplify_minexponent, NULL,
1532 x, BT_UNKNOWN, dr, 0);
1534 make_generic ("minexponent", GFC_ISYM_NONE, GFC_STD_F95);
1536 add_sym_3ml ("minloc", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1537 gfc_check_minloc_maxloc, NULL, gfc_resolve_minloc,
1538 ar, BT_REAL, dr, 0, dm, BT_INTEGER, ii, 1,
1539 msk, BT_LOGICAL, dl, 1);
1541 make_generic ("minloc", GFC_ISYM_MINLOC, GFC_STD_F95);
1543 add_sym_3red ("minval", 0, 1, BT_REAL, dr, GFC_STD_F95,
1544 gfc_check_minval_maxval, NULL, gfc_resolve_minval,
1545 ar, BT_REAL, dr, 0, dm, BT_INTEGER, ii, 1,
1546 msk, BT_LOGICAL, dl, 1);
1548 make_generic ("minval", GFC_ISYM_MINVAL, GFC_STD_F95);
1550 add_sym_2 ("mod", 1, 1, BT_INTEGER, di, GFC_STD_F77,
1551 gfc_check_a_p, gfc_simplify_mod, gfc_resolve_mod,
1552 a, BT_INTEGER, di, 0, p, BT_INTEGER, di, 0);
1554 add_sym_2 ("amod", 1, 1, BT_REAL, dr, GFC_STD_F77,
1555 NULL, gfc_simplify_mod, gfc_resolve_mod,
1556 a, BT_REAL, dr, 0, p, BT_REAL, dr, 0);
1558 add_sym_2 ("dmod", 1, 1, BT_REAL, dd, GFC_STD_F77,
1559 NULL, gfc_simplify_mod, gfc_resolve_mod,
1560 a, BT_REAL, dd, 0, p, BT_REAL, dd, 0);
1562 make_generic ("mod", GFC_ISYM_MOD, GFC_STD_F77);
1564 add_sym_2 ("modulo", 1, 1, BT_REAL, di, GFC_STD_F95,
1565 gfc_check_a_p, gfc_simplify_modulo, gfc_resolve_modulo,
1566 a, BT_REAL, di, 0, p, BT_REAL, di, 0);
1568 make_generic ("modulo", GFC_ISYM_MODULO, GFC_STD_F95);
1570 add_sym_2 ("nearest", 1, 1, BT_REAL, dr, GFC_STD_F95,
1571 gfc_check_nearest, gfc_simplify_nearest, gfc_resolve_nearest,
1572 x, BT_REAL, dr, 0, s, BT_REAL, dr, 0);
1574 make_generic ("nearest", GFC_ISYM_NEAREST, GFC_STD_F95);
1576 add_sym_2 ("nint", 1, 1, BT_INTEGER, di, GFC_STD_F77,
1577 gfc_check_a_ikind, gfc_simplify_nint, gfc_resolve_nint,
1578 a, BT_REAL, dr, 0, kind, BT_INTEGER, di, 1);
1580 add_sym_1 ("idnint", 1, 1, BT_INTEGER, di, GFC_STD_F77,
1581 gfc_check_idnint, gfc_simplify_idnint, gfc_resolve_idnint,
1584 make_generic ("nint", GFC_ISYM_NINT, GFC_STD_F77);
1586 add_sym_1 ("not", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1587 gfc_check_i, gfc_simplify_not, gfc_resolve_not,
1588 i, BT_INTEGER, di, 0);
1590 make_generic ("not", GFC_ISYM_NOT, GFC_STD_F95);
1592 add_sym_1 ("null", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1593 gfc_check_null, gfc_simplify_null, NULL,
1594 mo, BT_INTEGER, di, 1);
1596 make_generic ("null", GFC_ISYM_NONE, GFC_STD_F95);
1598 add_sym_3 ("pack", 0, 1, BT_REAL, dr, GFC_STD_F95,
1599 gfc_check_pack, NULL, gfc_resolve_pack,
1600 ar, BT_REAL, dr, 0, msk, BT_LOGICAL, dl, 0,
1603 make_generic ("pack", GFC_ISYM_PACK, GFC_STD_F95);
1605 add_sym_1 ("precision", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1606 gfc_check_precision, gfc_simplify_precision, NULL,
1607 x, BT_UNKNOWN, 0, 0);
1609 make_generic ("precision", GFC_ISYM_NONE, GFC_STD_F95);
1611 add_sym_1 ("present", 0, 1, BT_LOGICAL, dl, GFC_STD_F95,
1612 gfc_check_present, NULL, NULL, a, BT_REAL, dr, 0);
1614 make_generic ("present", GFC_ISYM_PRESENT, GFC_STD_F95);
1616 add_sym_3red ("product", 0, 1, BT_REAL, dr, GFC_STD_F95,
1617 gfc_check_product_sum, NULL, gfc_resolve_product,
1618 ar, BT_REAL, dr, 0, dm, BT_INTEGER, ii, 1,
1619 msk, BT_LOGICAL, dl, 1);
1621 make_generic ("product", GFC_ISYM_PRODUCT, GFC_STD_F95);
1623 add_sym_1 ("radix", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1624 gfc_check_radix, gfc_simplify_radix, NULL,
1625 x, BT_UNKNOWN, 0, 0);
1627 make_generic ("radix", GFC_ISYM_NONE, GFC_STD_F95);
1629 /* The following function is for G77 compatibility. */
1630 add_sym_1 ("rand", 0, 1, BT_REAL, 4, GFC_STD_GNU,
1631 gfc_check_rand, NULL, NULL,
1632 i, BT_INTEGER, 4, 1);
1634 /* Compatibility with HP FORTRAN 77/iX Reference. Note, rand() and
1635 ran() use slightly different shoddy multiplicative congruential
1639 make_generic ("rand", GFC_ISYM_RAND, GFC_STD_GNU);
1641 add_sym_1 ("range", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1642 gfc_check_range, gfc_simplify_range, NULL,
1645 make_generic ("range", GFC_ISYM_NONE, GFC_STD_F95);
1647 add_sym_2 ("real", 1, 0, BT_REAL, dr, GFC_STD_F77,
1648 gfc_check_real, gfc_simplify_real, gfc_resolve_real,
1649 a, BT_UNKNOWN, dr, 0, kind, BT_INTEGER, di, 1);
1651 add_sym_1 ("float", 1, 0, BT_REAL, dr, GFC_STD_F77,
1652 NULL, gfc_simplify_float, NULL, a, BT_INTEGER, di, 0);
1654 add_sym_1 ("sngl", 1, 0, BT_REAL, dr, GFC_STD_F77,
1655 NULL, gfc_simplify_sngl, NULL, a, BT_REAL, dd, 0);
1657 make_generic ("real", GFC_ISYM_REAL, GFC_STD_F77);
1659 add_sym_2 ("repeat", 0, 1, BT_CHARACTER, dc, GFC_STD_F95,
1660 gfc_check_repeat, gfc_simplify_repeat, gfc_resolve_repeat,
1661 stg, BT_CHARACTER, dc, 0, n, BT_INTEGER, di, 0);
1663 make_generic ("repeat", GFC_ISYM_REPEAT, GFC_STD_F95);
1665 add_sym_4 ("reshape", 0, 1, BT_REAL, dr, GFC_STD_F95,
1666 gfc_check_reshape, gfc_simplify_reshape, gfc_resolve_reshape,
1667 src, BT_REAL, dr, 0, shp, BT_INTEGER, ii, 0,
1668 pad, BT_REAL, dr, 1, ord, BT_INTEGER, ii, 1);
1670 make_generic ("reshape", GFC_ISYM_RESHAPE, GFC_STD_F95);
1672 add_sym_1 ("rrspacing", 1, 1, BT_REAL, dr, GFC_STD_F95,
1673 gfc_check_x, gfc_simplify_rrspacing, gfc_resolve_rrspacing,
1676 make_generic ("rrspacing", GFC_ISYM_RRSPACING, GFC_STD_F95);
1678 add_sym_2 ("scale", 1, 1, BT_REAL, dr, GFC_STD_F95,
1679 gfc_check_scale, gfc_simplify_scale, gfc_resolve_scale,
1680 x, BT_REAL, dr, 0, i, BT_INTEGER, di, 0);
1682 make_generic ("scale", GFC_ISYM_SCALE, GFC_STD_F95);
1684 add_sym_3 ("scan", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1685 gfc_check_scan, gfc_simplify_scan, gfc_resolve_scan,
1686 stg, BT_CHARACTER, dc, 0, set, BT_CHARACTER, dc, 0,
1687 bck, BT_LOGICAL, dl, 1);
1689 make_generic ("scan", GFC_ISYM_SCAN, GFC_STD_F95);
1691 /* Added for G77 compatibility garbage. */
1692 add_sym_0 ("second", 0, 1, BT_REAL, 4, GFC_STD_GNU,NULL, NULL, NULL);
1694 make_generic ("second", GFC_ISYM_SECOND, GFC_STD_GNU);
1696 add_sym_1 ("selected_int_kind", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1697 NULL, gfc_simplify_selected_int_kind, NULL,
1698 r, BT_INTEGER, di, 0);
1700 make_generic ("selected_int_kind", GFC_ISYM_SI_KIND, GFC_STD_F95);
1702 add_sym_2 ("selected_real_kind", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1703 gfc_check_selected_real_kind, gfc_simplify_selected_real_kind,
1704 NULL, p, BT_INTEGER, di, 1, r, BT_INTEGER, di, 1);
1706 make_generic ("selected_real_kind", GFC_ISYM_SR_KIND, GFC_STD_F95);
1708 add_sym_2 ("set_exponent", 1, 1, BT_REAL, dr, GFC_STD_F95,
1709 gfc_check_set_exponent, gfc_simplify_set_exponent,
1710 gfc_resolve_set_exponent,
1711 x, BT_REAL, dr, 0, i, BT_INTEGER, di, 0);
1713 make_generic ("set_exponent", GFC_ISYM_SET_EXPONENT, GFC_STD_F95);
1715 add_sym_1 ("shape", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1716 gfc_check_shape, gfc_simplify_shape, gfc_resolve_shape,
1717 src, BT_REAL, dr, 0);
1719 make_generic ("shape", GFC_ISYM_SHAPE, GFC_STD_F95);
1721 add_sym_2 ("sign", 1, 1, BT_REAL, dr, GFC_STD_F77,
1722 gfc_check_sign, gfc_simplify_sign, gfc_resolve_sign,
1723 a, BT_REAL, dr, 0, b, BT_REAL, dr, 0);
1725 add_sym_2 ("isign", 1, 1, BT_INTEGER, di, GFC_STD_F77,
1726 NULL, gfc_simplify_sign, gfc_resolve_sign,
1727 a, BT_INTEGER, di, 0, b, BT_INTEGER, di, 0);
1729 add_sym_2 ("dsign", 1, 1, BT_REAL, dd, GFC_STD_F77,
1730 NULL, gfc_simplify_sign, gfc_resolve_sign,
1731 a, BT_REAL, dd, 0, b, BT_REAL, dd, 0);
1733 make_generic ("sign", GFC_ISYM_SIGN, GFC_STD_F77);
1735 add_sym_1 ("sin", 1, 1, BT_REAL, dr, GFC_STD_F77,
1736 NULL, gfc_simplify_sin, gfc_resolve_sin, x, BT_REAL, dr, 0);
1738 add_sym_1 ("dsin", 1, 1, BT_REAL, dd, GFC_STD_F77,
1739 NULL, gfc_simplify_sin, gfc_resolve_sin, x, BT_REAL, dd, 0);
1741 add_sym_1 ("csin", 1, 1, BT_COMPLEX, dz, GFC_STD_F77,
1742 NULL, gfc_simplify_sin, gfc_resolve_sin,
1743 x, BT_COMPLEX, dz, 0);
1745 add_sym_1 ("zsin", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
1746 NULL, gfc_simplify_sin, gfc_resolve_sin, x, BT_COMPLEX, dd, 0);
1748 make_alias ("cdsin");
1750 make_generic ("sin", GFC_ISYM_SIN, GFC_STD_F77);
1752 add_sym_1 ("sinh", 1, 1, BT_REAL, dr, GFC_STD_F77,
1753 NULL, gfc_simplify_sinh, gfc_resolve_sinh,
1756 add_sym_1 ("dsinh", 1, 1, BT_REAL, dd, GFC_STD_F77,
1757 NULL, gfc_simplify_sinh, gfc_resolve_sinh,
1760 make_generic ("sinh", GFC_ISYM_SINH, GFC_STD_F77);
1762 add_sym_2 ("size", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1763 gfc_check_size, gfc_simplify_size, NULL,
1764 ar, BT_REAL, dr, 0, dm, BT_INTEGER, ii, 1);
1766 make_generic ("size", GFC_ISYM_SIZE, GFC_STD_F95);
1768 add_sym_1 ("spacing", 1, 1, BT_REAL, dr, GFC_STD_F95,
1769 gfc_check_x, gfc_simplify_spacing, gfc_resolve_spacing,
1772 make_generic ("spacing", GFC_ISYM_SPACING, GFC_STD_F95);
1774 add_sym_3 ("spread", 0, 1, BT_REAL, dr, GFC_STD_F95,
1775 gfc_check_spread, NULL, gfc_resolve_spread,
1776 src, BT_REAL, dr, 0, dm, BT_INTEGER, ii, 0,
1777 n, BT_INTEGER, di, 0);
1779 make_generic ("spread", GFC_ISYM_SPREAD, GFC_STD_F95);
1781 add_sym_1 ("sqrt", 1, 1, BT_REAL, dr, GFC_STD_F77,
1782 NULL, gfc_simplify_sqrt, gfc_resolve_sqrt,
1785 add_sym_1 ("dsqrt", 1, 1, BT_REAL, dd, GFC_STD_F77,
1786 NULL, gfc_simplify_sqrt, gfc_resolve_sqrt,
1789 add_sym_1 ("csqrt", 1, 1, BT_COMPLEX, dz, GFC_STD_F77,
1790 NULL, gfc_simplify_sqrt, gfc_resolve_sqrt,
1791 x, BT_COMPLEX, dz, 0);
1793 add_sym_1 ("zsqrt", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
1794 NULL, gfc_simplify_sqrt, gfc_resolve_sqrt, x, BT_COMPLEX, dd, 0);
1796 make_alias ("cdsqrt");
1798 make_generic ("sqrt", GFC_ISYM_SQRT, GFC_STD_F77);
1800 add_sym_3red ("sum", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
1801 gfc_check_product_sum, NULL, gfc_resolve_sum,
1802 ar, BT_REAL, dr, 0, dm, BT_INTEGER, ii, 1,
1803 msk, BT_LOGICAL, dl, 1);
1805 make_generic ("sum", GFC_ISYM_SUM, GFC_STD_F95);
1807 add_sym_1 ("system", 1, 1, BT_INTEGER, di, GFC_STD_GNU, NULL, NULL, NULL,
1808 c, BT_CHARACTER, dc, 0);
1809 make_generic ("system", GFC_ISYM_SYSTEM, GFC_STD_GNU);
1811 add_sym_1 ("tan", 1, 1, BT_REAL, dr, GFC_STD_F77,
1812 NULL, gfc_simplify_tan, gfc_resolve_tan, x, BT_REAL, dr, 0);
1814 add_sym_1 ("dtan", 1, 1, BT_REAL, dd, GFC_STD_F77,
1815 NULL, gfc_simplify_tan, gfc_resolve_tan, x, BT_REAL, dd, 0);
1817 make_generic ("tan", GFC_ISYM_TAN, GFC_STD_F77);
1819 add_sym_1 ("tanh", 1, 1, BT_REAL, dr, GFC_STD_F77,
1820 NULL, gfc_simplify_tanh, gfc_resolve_tanh,
1823 add_sym_1 ("dtanh", 1, 1, BT_REAL, dd, GFC_STD_F77,
1824 NULL, gfc_simplify_tanh, gfc_resolve_tanh,
1827 make_generic ("tanh", GFC_ISYM_TANH, GFC_STD_F77);
1829 add_sym_1 ("tiny", 0, 1, BT_REAL, dr, GFC_STD_F95,
1830 gfc_check_x, gfc_simplify_tiny, NULL, x, BT_REAL, dr, 0);
1832 make_generic ("tiny", GFC_ISYM_NONE, GFC_STD_F95);
1834 add_sym_3 ("transfer", 0, 1, BT_REAL, dr, GFC_STD_F95,
1835 gfc_check_transfer, NULL, gfc_resolve_transfer,
1836 src, BT_REAL, dr, 0, mo, BT_REAL, dr, 0,
1837 sz, BT_INTEGER, di, 1);
1839 make_generic ("transfer", GFC_ISYM_TRANSFER, GFC_STD_F95);
1841 add_sym_1 ("transpose", 0, 1, BT_REAL, dr, GFC_STD_F95,
1842 gfc_check_transpose, NULL, gfc_resolve_transpose,
1845 make_generic ("transpose", GFC_ISYM_TRANSPOSE, GFC_STD_F95);
1847 add_sym_1 ("trim", 0, 1, BT_CHARACTER, dc, GFC_STD_F95,
1848 gfc_check_trim, gfc_simplify_trim, gfc_resolve_trim,
1849 stg, BT_CHARACTER, dc, 0);
1851 make_generic ("trim", GFC_ISYM_TRIM, GFC_STD_F95);
1853 add_sym_2 ("ubound", 0, 1, BT_INTEGER, di, GFC_STD_F95,
1854 gfc_check_ubound, gfc_simplify_ubound, gfc_resolve_ubound,
1855 ar, BT_REAL, dr, 0, dm, BT_INTEGER, ii, 1);
1857 make_generic ("ubound", GFC_ISYM_UBOUND, GFC_STD_F95);
1859 add_sym_3 ("unpack", 0, 1, BT_REAL, dr, GFC_STD_F95,
1860 gfc_check_unpack, NULL, gfc_resolve_unpack,
1861 v, BT_REAL, dr, 0, msk, BT_LOGICAL, dl, 0,
1864 make_generic ("unpack", GFC_ISYM_UNPACK, GFC_STD_F95);
1866 add_sym_3 ("verify", 1, 1, BT_INTEGER, di, GFC_STD_F95,
1867 gfc_check_verify, gfc_simplify_verify, gfc_resolve_verify,
1868 stg, BT_CHARACTER, dc, 0, set, BT_CHARACTER, dc, 0,
1869 bck, BT_LOGICAL, dl, 1);
1871 make_generic ("verify", GFC_ISYM_VERIFY, GFC_STD_F95);
1878 /* Add intrinsic subroutines. */
1881 add_subroutines (void)
1883 /* Argument names as in the standard (to be used as argument keywords). */
1885 *h = "harvest", *dt = "date", *vl = "values", *pt = "put",
1886 *c = "count", *tm = "time", *tp = "topos", *gt = "get",
1887 *t = "to", *zn = "zone", *fp = "frompos", *cm = "count_max",
1888 *f = "from", *sz = "size", *ln = "len", *cr = "count_rate",
1889 *com = "command", *length = "length", *st = "status",
1890 *val = "value", *num = "number", *name = "name",
1891 *trim_name = "trim_name";
1895 di = gfc_default_integer_kind;
1896 dr = gfc_default_real_kind;
1897 dc = gfc_default_character_kind;
1898 dl = gfc_default_logical_kind;
1900 add_sym_0s ("abort", 1, GFC_STD_GNU, NULL);
1902 add_sym_1s ("cpu_time", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
1903 gfc_check_cpu_time, NULL, gfc_resolve_cpu_time,
1904 tm, BT_REAL, dr, 0);
1906 /* More G77 compatibility garbage. */
1907 add_sym_1s ("second", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
1908 gfc_check_second_sub, NULL, gfc_resolve_second_sub,
1909 tm, BT_REAL, dr, 0);
1911 add_sym_4s ("date_and_time", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
1912 gfc_check_date_and_time, NULL, NULL,
1913 dt, BT_CHARACTER, dc, 1, tm, BT_CHARACTER, dc, 1,
1914 zn, BT_CHARACTER, dc, 1, vl, BT_INTEGER, di, 1);
1916 /* More G77 compatibility garbage. */
1917 add_sym_2s ("etime", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
1918 gfc_check_etime_sub, NULL, gfc_resolve_etime_sub,
1919 vl, BT_REAL, 4, 0, tm, BT_REAL, 4, 0);
1921 add_sym_2s ("dtime", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
1922 gfc_check_etime_sub, NULL, gfc_resolve_etime_sub,
1923 vl, BT_REAL, 4, 0, tm, BT_REAL, 4, 0);
1925 add_sym_2s ("getcwd", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
1926 gfc_check_getcwd_sub, NULL, gfc_resolve_getcwd_sub,
1927 c, BT_CHARACTER, dc, 0,
1928 st, BT_INTEGER, di, 1);
1930 add_sym_2s ("getenv", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
1932 name, BT_CHARACTER, dc, 0,
1933 val, BT_CHARACTER, dc, 0);
1935 add_sym_2s ("getarg", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
1936 NULL, NULL, gfc_resolve_getarg,
1937 c, BT_INTEGER, di, 0, vl, BT_CHARACTER, dc, 0);
1940 /* F2003 commandline routines. */
1942 add_sym_3s ("get_command", 0, 1, BT_UNKNOWN, 0, GFC_STD_F2003,
1943 NULL, NULL, gfc_resolve_get_command,
1944 com, BT_CHARACTER, dc, 1,
1945 length, BT_INTEGER, di, 1,
1946 st, BT_INTEGER, di, 1);
1948 add_sym_4s ("get_command_argument", 0, 1, BT_UNKNOWN, 0, GFC_STD_F2003,
1949 NULL, NULL, gfc_resolve_get_command_argument,
1950 num, BT_INTEGER, di, 0,
1951 val, BT_CHARACTER, dc, 1,
1952 length, BT_INTEGER, di, 1,
1953 st, BT_INTEGER, di, 1);
1956 /* F2003 subroutine to get environment variables. */
1958 add_sym_5s ("get_environment_variable", 0, 1, BT_UNKNOWN, 0, GFC_STD_F2003,
1959 NULL, NULL, gfc_resolve_get_environment_variable,
1960 name, BT_CHARACTER, dc, 0,
1961 val, BT_CHARACTER, dc, 1,
1962 length, BT_INTEGER, di, 1,
1963 st, BT_INTEGER, di, 1,
1964 trim_name, BT_LOGICAL, dl, 1);
1967 add_sym_5s ("mvbits", 1, 1, BT_UNKNOWN, 0, GFC_STD_F95,
1968 gfc_check_mvbits, gfc_simplify_mvbits, gfc_resolve_mvbits,
1969 f, BT_INTEGER, di, 0, fp, BT_INTEGER, di, 0,
1970 ln, BT_INTEGER, di, 0, t, BT_INTEGER, di, 0,
1971 tp, BT_INTEGER, di, 0);
1973 add_sym_1s ("random_number", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
1974 gfc_check_random_number, NULL, gfc_resolve_random_number,
1977 add_sym_3s ("random_seed", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
1978 gfc_check_random_seed, NULL, NULL,
1979 sz, BT_INTEGER, di, 1, pt, BT_INTEGER, di, 1,
1980 gt, BT_INTEGER, di, 1);
1982 /* More G77 compatibility garbage. */
1983 add_sym_1s ("srand", 0, 1, BT_UNKNOWN, di, GFC_STD_GNU,
1984 gfc_check_srand, NULL, gfc_resolve_srand,
1985 c, BT_INTEGER, 4, 0);
1987 add_sym_2s ("system", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
1988 NULL, NULL, gfc_resolve_system_sub,
1989 c, BT_CHARACTER, dc, 0,
1990 st, BT_INTEGER, di, 1);
1992 add_sym_3s ("system_clock", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
1993 gfc_check_system_clock, NULL, gfc_resolve_system_clock,
1994 c, BT_INTEGER, di, 1, cr, BT_INTEGER, di, 1,
1995 cm, BT_INTEGER, di, 1);
1999 /* Add a function to the list of conversion symbols. */
2002 add_conv (bt from_type, int from_kind, bt to_type, int to_kind,
2003 gfc_expr * (*simplify) (gfc_expr *, bt, int))
2006 gfc_typespec from, to;
2007 gfc_intrinsic_sym *sym;
2009 if (sizing == SZ_CONVS)
2015 gfc_clear_ts (&from);
2016 from.type = from_type;
2017 from.kind = from_kind;
2023 sym = conversion + nconv;
2025 strcpy (sym->name, conv_name (&from, &to));
2026 strcpy (sym->lib_name, sym->name);
2027 sym->simplify.cc = simplify;
2030 sym->generic_id = GFC_ISYM_CONVERSION;
2036 /* Create gfc_intrinsic_sym nodes for all intrinsic conversion
2037 functions by looping over the kind tables. */
2040 add_conversions (void)
2044 /* Integer-Integer conversions. */
2045 for (i = 0; gfc_integer_kinds[i].kind != 0; i++)
2046 for (j = 0; gfc_integer_kinds[j].kind != 0; j++)
2051 add_conv (BT_INTEGER, gfc_integer_kinds[i].kind,
2052 BT_INTEGER, gfc_integer_kinds[j].kind, gfc_convert_constant);
2055 /* Integer-Real/Complex conversions. */
2056 for (i = 0; gfc_integer_kinds[i].kind != 0; i++)
2057 for (j = 0; gfc_real_kinds[j].kind != 0; j++)
2059 add_conv (BT_INTEGER, gfc_integer_kinds[i].kind,
2060 BT_REAL, gfc_real_kinds[j].kind, gfc_convert_constant);
2062 add_conv (BT_REAL, gfc_real_kinds[j].kind,
2063 BT_INTEGER, gfc_integer_kinds[i].kind, gfc_convert_constant);
2065 add_conv (BT_INTEGER, gfc_integer_kinds[i].kind,
2066 BT_COMPLEX, gfc_real_kinds[j].kind, gfc_convert_constant);
2068 add_conv (BT_COMPLEX, gfc_real_kinds[j].kind,
2069 BT_INTEGER, gfc_integer_kinds[i].kind, gfc_convert_constant);
2072 /* Real/Complex - Real/Complex conversions. */
2073 for (i = 0; gfc_real_kinds[i].kind != 0; i++)
2074 for (j = 0; gfc_real_kinds[j].kind != 0; j++)
2078 add_conv (BT_REAL, gfc_real_kinds[i].kind,
2079 BT_REAL, gfc_real_kinds[j].kind, gfc_convert_constant);
2081 add_conv (BT_COMPLEX, gfc_real_kinds[i].kind,
2082 BT_COMPLEX, gfc_real_kinds[j].kind, gfc_convert_constant);
2085 add_conv (BT_REAL, gfc_real_kinds[i].kind,
2086 BT_COMPLEX, gfc_real_kinds[j].kind, gfc_convert_constant);
2088 add_conv (BT_COMPLEX, gfc_real_kinds[i].kind,
2089 BT_REAL, gfc_real_kinds[j].kind, gfc_convert_constant);
2092 /* Logical/Logical kind conversion. */
2093 for (i = 0; gfc_logical_kinds[i].kind; i++)
2094 for (j = 0; gfc_logical_kinds[j].kind; j++)
2099 add_conv (BT_LOGICAL, gfc_logical_kinds[i].kind,
2100 BT_LOGICAL, gfc_logical_kinds[j].kind, gfc_convert_constant);
2105 /* Initialize the table of intrinsics. */
2107 gfc_intrinsic_init_1 (void)
2111 nargs = nfunc = nsub = nconv = 0;
2113 /* Create a namespace to hold the resolved intrinsic symbols. */
2114 gfc_intrinsic_namespace = gfc_get_namespace (NULL);
2123 functions = gfc_getmem (sizeof (gfc_intrinsic_sym) * (nfunc + nsub)
2124 + sizeof (gfc_intrinsic_arg) * nargs);
2126 next_sym = functions;
2127 subroutines = functions + nfunc;
2129 conversion = gfc_getmem (sizeof (gfc_intrinsic_sym) * nconv);
2131 next_arg = ((gfc_intrinsic_arg *) (subroutines + nsub)) - 1;
2133 sizing = SZ_NOTHING;
2140 /* Set the pure flag. All intrinsic functions are pure, and
2141 intrinsic subroutines are pure if they are elemental. */
2143 for (i = 0; i < nfunc; i++)
2144 functions[i].pure = 1;
2146 for (i = 0; i < nsub; i++)
2147 subroutines[i].pure = subroutines[i].elemental;
2152 gfc_intrinsic_done_1 (void)
2154 gfc_free (functions);
2155 gfc_free (conversion);
2156 gfc_free_namespace (gfc_intrinsic_namespace);
2160 /******** Subroutines to check intrinsic interfaces ***********/
2162 /* Given a formal argument list, remove any NULL arguments that may
2163 have been left behind by a sort against some formal argument list. */
2166 remove_nullargs (gfc_actual_arglist ** ap)
2168 gfc_actual_arglist *head, *tail, *next;
2172 for (head = *ap; head; head = next)
2176 if (head->expr == NULL)
2179 gfc_free_actual_arglist (head);
2198 /* Given an actual arglist and a formal arglist, sort the actual
2199 arglist so that its arguments are in a one-to-one correspondence
2200 with the format arglist. Arguments that are not present are given
2201 a blank gfc_actual_arglist structure. If something is obviously
2202 wrong (say, a missing required argument) we abort sorting and
2206 sort_actual (const char *name, gfc_actual_arglist ** ap,
2207 gfc_intrinsic_arg * formal, locus * where)
2210 gfc_actual_arglist *actual, *a;
2211 gfc_intrinsic_arg *f;
2213 remove_nullargs (ap);
2216 for (f = formal; f; f = f->next)
2222 if (f == NULL && a == NULL) /* No arguments */
2226 { /* Put the nonkeyword arguments in a 1:1 correspondence */
2232 if (a->name[0] != '\0')
2244 gfc_error ("Too many arguments in call to '%s' at %L", name, where);
2248 /* Associate the remaining actual arguments, all of which have
2249 to be keyword arguments. */
2250 for (; a; a = a->next)
2252 for (f = formal; f; f = f->next)
2253 if (strcmp (a->name, f->name) == 0)
2258 gfc_error ("Can't find keyword named '%s' in call to '%s' at %L",
2259 a->name, name, where);
2263 if (f->actual != NULL)
2265 gfc_error ("Argument '%s' is appears twice in call to '%s' at %L",
2266 f->name, name, where);
2274 /* At this point, all unmatched formal args must be optional. */
2275 for (f = formal; f; f = f->next)
2277 if (f->actual == NULL && f->optional == 0)
2279 gfc_error ("Missing actual argument '%s' in call to '%s' at %L",
2280 f->name, name, where);
2286 /* Using the formal argument list, string the actual argument list
2287 together in a way that corresponds with the formal list. */
2290 for (f = formal; f; f = f->next)
2292 if (f->actual == NULL)
2294 a = gfc_get_actual_arglist ();
2295 a->missing_arg_type = f->ts.type;
2307 actual->next = NULL; /* End the sorted argument list. */
2313 /* Compare an actual argument list with an intrinsic's formal argument
2314 list. The lists are checked for agreement of type. We don't check
2315 for arrayness here. */
2318 check_arglist (gfc_actual_arglist ** ap, gfc_intrinsic_sym * sym,
2321 gfc_actual_arglist *actual;
2322 gfc_intrinsic_arg *formal;
2325 formal = sym->formal;
2329 for (; formal; formal = formal->next, actual = actual->next, i++)
2331 if (actual->expr == NULL)
2334 if (!gfc_compare_types (&formal->ts, &actual->expr->ts))
2338 ("Type of argument '%s' in call to '%s' at %L should be "
2339 "%s, not %s", gfc_current_intrinsic_arg[i],
2340 gfc_current_intrinsic, &actual->expr->where,
2341 gfc_typename (&formal->ts), gfc_typename (&actual->expr->ts));
2350 /* Given a pointer to an intrinsic symbol and an expression node that
2351 represent the function call to that subroutine, figure out the type
2352 of the result. This may involve calling a resolution subroutine. */
2355 resolve_intrinsic (gfc_intrinsic_sym * specific, gfc_expr * e)
2357 gfc_expr *a1, *a2, *a3, *a4, *a5;
2358 gfc_actual_arglist *arg;
2360 if (specific->resolve.f1 == NULL)
2362 if (e->value.function.name == NULL)
2363 e->value.function.name = specific->lib_name;
2365 if (e->ts.type == BT_UNKNOWN)
2366 e->ts = specific->ts;
2370 arg = e->value.function.actual;
2372 /* Special case hacks for MIN and MAX. */
2373 if (specific->resolve.f1m == gfc_resolve_max
2374 || specific->resolve.f1m == gfc_resolve_min)
2376 (*specific->resolve.f1m) (e, arg);
2382 (*specific->resolve.f0) (e);
2391 (*specific->resolve.f1) (e, a1);
2400 (*specific->resolve.f2) (e, a1, a2);
2409 (*specific->resolve.f3) (e, a1, a2, a3);
2418 (*specific->resolve.f4) (e, a1, a2, a3, a4);
2427 (*specific->resolve.f5) (e, a1, a2, a3, a4, a5);
2431 gfc_internal_error ("resolve_intrinsic(): Too many args for intrinsic");
2435 /* Given an intrinsic symbol node and an expression node, call the
2436 simplification function (if there is one), perhaps replacing the
2437 expression with something simpler. We return FAILURE on an error
2438 of the simplification, SUCCESS if the simplification worked, even
2439 if nothing has changed in the expression itself. */
2442 do_simplify (gfc_intrinsic_sym * specific, gfc_expr * e)
2444 gfc_expr *result, *a1, *a2, *a3, *a4, *a5;
2445 gfc_actual_arglist *arg;
2447 /* Max and min require special handling due to the variable number
2449 if (specific->simplify.f1 == gfc_simplify_min)
2451 result = gfc_simplify_min (e);
2455 if (specific->simplify.f1 == gfc_simplify_max)
2457 result = gfc_simplify_max (e);
2461 if (specific->simplify.f1 == NULL)
2467 arg = e->value.function.actual;
2471 result = (*specific->simplify.f0) ();
2478 if (specific->simplify.cc == gfc_convert_constant)
2480 result = gfc_convert_constant (a1, specific->ts.type, specific->ts.kind);
2484 /* TODO: Warn if -pedantic and initialization expression and arg
2485 types not integer or character */
2488 result = (*specific->simplify.f1) (a1);
2495 result = (*specific->simplify.f2) (a1, a2);
2502 result = (*specific->simplify.f3) (a1, a2, a3);
2509 result = (*specific->simplify.f4) (a1, a2, a3, a4);
2516 result = (*specific->simplify.f5) (a1, a2, a3, a4, a5);
2519 ("do_simplify(): Too many args for intrinsic");
2526 if (result == &gfc_bad_expr)
2530 resolve_intrinsic (specific, e); /* Must call at run-time */
2533 result->where = e->where;
2534 gfc_replace_expr (e, result);
2541 /* Initialize the gfc_current_intrinsic_arg[] array for the benefit of
2542 error messages. This subroutine returns FAILURE if a subroutine
2543 has more than MAX_INTRINSIC_ARGS, in which case the actual argument
2544 list cannot match any intrinsic. */
2547 init_arglist (gfc_intrinsic_sym * isym)
2549 gfc_intrinsic_arg *formal;
2552 gfc_current_intrinsic = isym->name;
2555 for (formal = isym->formal; formal; formal = formal->next)
2557 if (i >= MAX_INTRINSIC_ARGS)
2558 gfc_internal_error ("init_arglist(): too many arguments");
2559 gfc_current_intrinsic_arg[i++] = formal->name;
2564 /* Given a pointer to an intrinsic symbol and an expression consisting
2565 of a function call, see if the function call is consistent with the
2566 intrinsic's formal argument list. Return SUCCESS if the expression
2567 and intrinsic match, FAILURE otherwise. */
2570 check_specific (gfc_intrinsic_sym * specific, gfc_expr * expr, int error_flag)
2572 gfc_actual_arglist *arg, **ap;
2576 ap = &expr->value.function.actual;
2578 init_arglist (specific);
2580 /* Don't attempt to sort the argument list for min or max. */
2581 if (specific->check.f1m == gfc_check_min_max
2582 || specific->check.f1m == gfc_check_min_max_integer
2583 || specific->check.f1m == gfc_check_min_max_real
2584 || specific->check.f1m == gfc_check_min_max_double)
2585 return (*specific->check.f1m) (*ap);
2587 if (sort_actual (specific->name, ap, specific->formal,
2588 &expr->where) == FAILURE)
2591 if (specific->check.f3ml == gfc_check_minloc_maxloc)
2592 /* This is special because we might have to reorder the argument
2594 t = gfc_check_minloc_maxloc (*ap);
2595 else if (specific->check.f3red == gfc_check_minval_maxval)
2596 /* This is also special because we also might have to reorder the
2598 t = gfc_check_minval_maxval (*ap);
2599 else if (specific->check.f3red == gfc_check_product_sum)
2600 /* Same here. The difference to the previous case is that we allow a
2601 general numeric type. */
2602 t = gfc_check_product_sum (*ap);
2605 if (specific->check.f1 == NULL)
2607 t = check_arglist (ap, specific, error_flag);
2609 expr->ts = specific->ts;
2612 t = do_check (specific, *ap);
2615 /* Check ranks for elemental intrinsics. */
2616 if (t == SUCCESS && specific->elemental)
2619 for (arg = expr->value.function.actual; arg; arg = arg->next)
2621 if (arg->expr == NULL || arg->expr->rank == 0)
2625 r = arg->expr->rank;
2629 if (arg->expr->rank != r)
2632 ("Ranks of arguments to elemental intrinsic '%s' differ "
2633 "at %L", specific->name, &arg->expr->where);
2640 remove_nullargs (ap);
2646 /* See if an intrinsic is one of the intrinsics we evaluate
2650 gfc_init_expr_extensions (gfc_intrinsic_sym *isym)
2652 /* FIXME: This should be moved into the intrinsic definitions. */
2653 static const char * const init_expr_extensions[] = {
2654 "digits", "epsilon", "huge", "kind", "maxexponent", "minexponent",
2655 "precision", "present", "radix", "range", "selected_real_kind",
2661 for (i = 0; init_expr_extensions[i]; i++)
2662 if (strcmp (init_expr_extensions[i], isym->name) == 0)
2669 /* Check whether an intrinsic belongs to whatever standard the user
2673 check_intrinsic_standard (const char *name, int standard, locus * where)
2675 if (!gfc_option.warn_nonstd_intrinsics)
2678 gfc_notify_std (standard, "Intrinsic '%s' at %L is not included"
2679 "in the selected standard", name, where);
2683 /* See if a function call corresponds to an intrinsic function call.
2686 MATCH_YES if the call corresponds to an intrinsic, simplification
2687 is done if possible.
2689 MATCH_NO if the call does not correspond to an intrinsic
2691 MATCH_ERROR if the call corresponds to an intrinsic but there was an
2692 error during the simplification process.
2694 The error_flag parameter enables an error reporting. */
2697 gfc_intrinsic_func_interface (gfc_expr * expr, int error_flag)
2699 gfc_intrinsic_sym *isym, *specific;
2700 gfc_actual_arglist *actual;
2704 if (expr->value.function.isym != NULL)
2705 return (do_simplify (expr->value.function.isym, expr) == FAILURE)
2706 ? MATCH_ERROR : MATCH_YES;
2708 gfc_suppress_error = !error_flag;
2711 for (actual = expr->value.function.actual; actual; actual = actual->next)
2712 if (actual->expr != NULL)
2713 flag |= (actual->expr->ts.type != BT_INTEGER
2714 && actual->expr->ts.type != BT_CHARACTER);
2716 name = expr->symtree->n.sym->name;
2718 isym = specific = gfc_find_function (name);
2721 gfc_suppress_error = 0;
2725 gfc_current_intrinsic_where = &expr->where;
2727 /* Bypass the generic list for min and max. */
2728 if (isym->check.f1m == gfc_check_min_max)
2730 init_arglist (isym);
2732 if (gfc_check_min_max (expr->value.function.actual) == SUCCESS)
2735 gfc_suppress_error = 0;
2739 /* If the function is generic, check all of its specific
2740 incarnations. If the generic name is also a specific, we check
2741 that name last, so that any error message will correspond to the
2743 gfc_suppress_error = 1;
2747 for (specific = isym->specific_head; specific;
2748 specific = specific->next)
2750 if (specific == isym)
2752 if (check_specific (specific, expr, 0) == SUCCESS)
2757 gfc_suppress_error = !error_flag;
2759 if (check_specific (isym, expr, error_flag) == FAILURE)
2761 gfc_suppress_error = 0;
2768 expr->value.function.isym = specific;
2769 gfc_intrinsic_symbol (expr->symtree->n.sym);
2771 if (do_simplify (specific, expr) == FAILURE)
2773 gfc_suppress_error = 0;
2777 /* TODO: We should probably only allow elemental functions here. */
2778 flag |= (expr->ts.type != BT_INTEGER && expr->ts.type != BT_CHARACTER);
2780 gfc_suppress_error = 0;
2781 if (pedantic && gfc_init_expr
2782 && flag && gfc_init_expr_extensions (specific))
2784 if (gfc_notify_std (GFC_STD_GNU, "Extension: Evaluation of "
2785 "nonstandard initialization expression at %L", &expr->where)
2792 check_intrinsic_standard (name, isym->standard, &expr->where);
2798 /* See if a CALL statement corresponds to an intrinsic subroutine.
2799 Returns MATCH_YES if the subroutine corresponds to an intrinsic,
2800 MATCH_NO if not, and MATCH_ERROR if there was an error (but did
2804 gfc_intrinsic_sub_interface (gfc_code * c, int error_flag)
2806 gfc_intrinsic_sym *isym;
2809 name = c->symtree->n.sym->name;
2811 isym = find_subroutine (name);
2815 gfc_suppress_error = !error_flag;
2817 init_arglist (isym);
2819 if (sort_actual (name, &c->ext.actual, isym->formal, &c->loc) == FAILURE)
2822 if (isym->check.f1 != NULL)
2824 if (do_check (isym, c->ext.actual) == FAILURE)
2829 if (check_arglist (&c->ext.actual, isym, 1) == FAILURE)
2833 /* The subroutine corresponds to an intrinsic. Allow errors to be
2834 seen at this point. */
2835 gfc_suppress_error = 0;
2837 if (isym->resolve.s1 != NULL)
2838 isym->resolve.s1 (c);
2840 c->resolved_sym = gfc_get_intrinsic_sub_symbol (isym->lib_name);
2842 if (gfc_pure (NULL) && !isym->elemental)
2844 gfc_error ("Subroutine call to intrinsic '%s' at %L is not PURE", name,
2849 check_intrinsic_standard (name, isym->standard, &c->loc);
2854 gfc_suppress_error = 0;
2859 /* Call gfc_convert_type() with warning enabled. */
2862 gfc_convert_type (gfc_expr * expr, gfc_typespec * ts, int eflag)
2864 return gfc_convert_type_warn (expr, ts, eflag, 1);
2868 /* Try to convert an expression (in place) from one type to another.
2869 'eflag' controls the behavior on error.
2871 The possible values are:
2873 1 Generate a gfc_error()
2874 2 Generate a gfc_internal_error().
2876 'wflag' controls the warning related to conversion. */
2879 gfc_convert_type_warn (gfc_expr * expr, gfc_typespec * ts, int eflag,
2882 gfc_intrinsic_sym *sym;
2883 gfc_typespec from_ts;
2888 from_ts = expr->ts; /* expr->ts gets clobbered */
2890 if (ts->type == BT_UNKNOWN)
2893 /* NULL and zero size arrays get their type here. */
2894 if (expr->expr_type == EXPR_NULL
2895 || (expr->expr_type == EXPR_ARRAY
2896 && expr->value.constructor == NULL))
2898 /* Sometimes the RHS acquire the type. */
2903 if (expr->ts.type == BT_UNKNOWN)
2906 if (expr->ts.type == BT_DERIVED
2907 && ts->type == BT_DERIVED
2908 && gfc_compare_types (&expr->ts, ts))
2911 sym = find_conv (&expr->ts, ts);
2915 /* At this point, a conversion is necessary. A warning may be needed. */
2916 if (wflag && gfc_option.warn_conversion)
2917 gfc_warning_now ("Conversion from %s to %s at %L",
2918 gfc_typename (&from_ts), gfc_typename (ts), &expr->where);
2920 /* Insert a pre-resolved function call to the right function. */
2921 old_where = expr->where;
2923 new = gfc_get_expr ();
2926 new = gfc_build_conversion (new);
2927 new->value.function.name = sym->lib_name;
2928 new->value.function.isym = sym;
2929 new->where = old_where;
2937 if (gfc_is_constant_expr (expr->value.function.actual->expr)
2938 && do_simplify (sym, expr) == FAILURE)
2943 return FAILURE; /* Error already generated in do_simplify() */
2951 gfc_error ("Can't convert %s to %s at %L",
2952 gfc_typename (&from_ts), gfc_typename (ts), &expr->where);
2956 gfc_internal_error ("Can't convert %s to %s at %L",
2957 gfc_typename (&from_ts), gfc_typename (ts),