* intrinsic.c (add_sym_0s, add_sym_1s, add_sym_2s, add_sym_3s,
[official-gcc.git] / gcc / fortran / intrinsic.c
blobc2c37e829a090ef4a2f247543fa0419a1d398f1d
1 /* Build up a list of intrinsic subroutines and functions for the
2 name-resolution stage.
3 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006
4 Free Software Foundation, Inc.
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
12 version.
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 for more details.
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
22 02110-1301, USA. */
25 #include "config.h"
26 #include "system.h"
27 #include "flags.h"
28 #include "gfortran.h"
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
38 checked. */
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;
49 static enum
50 { SZ_NOTHING = 0, SZ_SUBS, SZ_FUNCS, SZ_CONVS }
51 sizing;
53 #define NOT_ELEMENTAL 0
54 #define ELEMENTAL 1
56 #define ACTUAL_NO 0
57 #define ACTUAL_YES 1
59 #define REQUIRED 0
60 #define OPTIONAL 1
62 /* Return a letter based on the passed type. Used to construct the
63 name of a type-dependent subroutine. */
65 char
66 gfc_type_letter (bt type)
68 char c;
70 switch (type)
72 case BT_LOGICAL:
73 c = 'l';
74 break;
75 case BT_CHARACTER:
76 c = 's';
77 break;
78 case BT_INTEGER:
79 c = 'i';
80 break;
81 case BT_REAL:
82 c = 'r';
83 break;
84 case BT_COMPLEX:
85 c = 'c';
86 break;
88 case BT_HOLLERITH:
89 c = 'h';
90 break;
92 default:
93 c = 'u';
94 break;
97 return c;
101 /* Get a symbol for a resolved name. */
103 gfc_symbol *
104 gfc_get_intrinsic_sub_symbol (const char * name)
106 gfc_symbol *sym;
108 gfc_get_symbol (name, gfc_intrinsic_namespace, &sym);
109 sym->attr.always_explicit = 1;
110 sym->attr.subroutine = 1;
111 sym->attr.flavor = FL_PROCEDURE;
112 sym->attr.proc = PROC_INTRINSIC;
114 return sym;
118 /* Return a pointer to the name of a conversion function given two
119 typespecs. */
121 static const char *
122 conv_name (gfc_typespec * from, gfc_typespec * to)
124 static char name[30];
126 sprintf (name, "__convert_%c%d_%c%d", gfc_type_letter (from->type),
127 from->kind, gfc_type_letter (to->type), to->kind);
129 return gfc_get_string (name);
133 /* Given a pair of typespecs, find the gfc_intrinsic_sym node that
134 corresponds to the conversion. Returns NULL if the conversion
135 isn't found. */
137 static gfc_intrinsic_sym *
138 find_conv (gfc_typespec * from, gfc_typespec * to)
140 gfc_intrinsic_sym *sym;
141 const char *target;
142 int i;
144 target = conv_name (from, to);
145 sym = conversion;
147 for (i = 0; i < nconv; i++, sym++)
148 if (strcmp (target, sym->name) == 0)
149 return sym;
151 return NULL;
155 /* Interface to the check functions. We break apart an argument list
156 and call the proper check function rather than forcing each
157 function to manipulate the argument list. */
159 static try
160 do_check (gfc_intrinsic_sym * specific, gfc_actual_arglist * arg)
162 gfc_expr *a1, *a2, *a3, *a4, *a5;
164 if (arg == NULL)
165 return (*specific->check.f0) ();
167 a1 = arg->expr;
168 arg = arg->next;
169 if (arg == NULL)
170 return (*specific->check.f1) (a1);
172 a2 = arg->expr;
173 arg = arg->next;
174 if (arg == NULL)
175 return (*specific->check.f2) (a1, a2);
177 a3 = arg->expr;
178 arg = arg->next;
179 if (arg == NULL)
180 return (*specific->check.f3) (a1, a2, a3);
182 a4 = arg->expr;
183 arg = arg->next;
184 if (arg == NULL)
185 return (*specific->check.f4) (a1, a2, a3, a4);
187 a5 = arg->expr;
188 arg = arg->next;
189 if (arg == NULL)
190 return (*specific->check.f5) (a1, a2, a3, a4, a5);
192 gfc_internal_error ("do_check(): too many args");
196 /*********** Subroutines to build the intrinsic list ****************/
198 /* Add a single intrinsic symbol to the current list.
200 Argument list:
201 char * name of function
202 int whether function is elemental
203 int If the function can be used as an actual argument [1] [2]
204 bt return type of function
205 int kind of return type of function
206 int Fortran standard version
207 check pointer to check function
208 simplify pointer to simplification function
209 resolve pointer to resolution function
211 Optional arguments come in multiples of four:
212 char * name of argument
213 bt type of argument
214 int kind of argument
215 int arg optional flag (1=optional, 0=required)
217 The sequence is terminated by a NULL name.
220 [1] Whether a function can or cannot be used as an actual argument is
221 determined by its presence on the 13.6 list in Fortran 2003. The
222 following intrinsics, which are GNU extensions, are considered allowed
223 as actual arguments: ACOSH ATANH DACOSH DASINH DATANH DCONJG DIMAG
224 ZABS ZCOS ZEXP ZLOG ZSIN ZSQRT.
225 [2] The value 2 is used in this field for CHAR, which is allowed as an
226 actual argument in F2003, but not in F95. It is the only such
227 intrinsic function. */
229 static void
230 add_sym (const char *name, int elemental, int actual_ok, bt type, int kind,
231 int standard, gfc_check_f check, gfc_simplify_f simplify,
232 gfc_resolve_f resolve, ...)
234 char buf[GFC_MAX_SYMBOL_LEN + 11]; /* 10 for '_gfortran_', 1 for '\0' */
235 int optional, first_flag;
236 va_list argp;
238 /* First check that the intrinsic belongs to the selected standard.
239 If not, don't add it to the symbol list. */
240 if (!(gfc_option.allow_std & standard)
241 && gfc_option.flag_all_intrinsics == 0)
242 return;
244 switch (sizing)
246 case SZ_SUBS:
247 nsub++;
248 break;
250 case SZ_FUNCS:
251 nfunc++;
252 break;
254 case SZ_NOTHING:
255 next_sym->name = gfc_get_string (name);
257 strcpy (buf, "_gfortran_");
258 strcat (buf, name);
259 next_sym->lib_name = gfc_get_string (buf);
261 next_sym->elemental = elemental;
262 next_sym->actual_ok = actual_ok;
263 next_sym->ts.type = type;
264 next_sym->ts.kind = kind;
265 next_sym->standard = standard;
266 next_sym->simplify = simplify;
267 next_sym->check = check;
268 next_sym->resolve = resolve;
269 next_sym->specific = 0;
270 next_sym->generic = 0;
271 break;
273 default:
274 gfc_internal_error ("add_sym(): Bad sizing mode");
277 va_start (argp, resolve);
279 first_flag = 1;
281 for (;;)
283 name = va_arg (argp, char *);
284 if (name == NULL)
285 break;
287 type = (bt) va_arg (argp, int);
288 kind = va_arg (argp, int);
289 optional = va_arg (argp, int);
291 if (sizing != SZ_NOTHING)
292 nargs++;
293 else
295 next_arg++;
297 if (first_flag)
298 next_sym->formal = next_arg;
299 else
300 (next_arg - 1)->next = next_arg;
302 first_flag = 0;
304 strcpy (next_arg->name, name);
305 next_arg->ts.type = type;
306 next_arg->ts.kind = kind;
307 next_arg->optional = optional;
311 va_end (argp);
313 next_sym++;
317 /* Add a symbol to the function list where the function takes
318 0 arguments. */
320 static void
321 add_sym_0 (const char *name, int elemental, int actual_ok, bt type,
322 int kind, int standard,
323 try (*check)(void),
324 gfc_expr *(*simplify)(void),
325 void (*resolve)(gfc_expr *))
327 gfc_simplify_f sf;
328 gfc_check_f cf;
329 gfc_resolve_f rf;
331 cf.f0 = check;
332 sf.f0 = simplify;
333 rf.f0 = resolve;
335 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
336 (void*)0);
340 /* Add a symbol to the subroutine list where the subroutine takes
341 0 arguments. */
343 static void
344 add_sym_0s (const char * name, int standard,
345 void (*resolve)(gfc_code *))
347 gfc_check_f cf;
348 gfc_simplify_f sf;
349 gfc_resolve_f rf;
351 cf.f1 = NULL;
352 sf.f1 = NULL;
353 rf.s1 = resolve;
355 add_sym (name, ELEMENTAL, ACTUAL_NO, BT_UNKNOWN, 0, standard, cf, sf, rf,
356 (void*)0);
360 /* Add a symbol to the function list where the function takes
361 1 arguments. */
363 static void
364 add_sym_1 (const char *name, int elemental, int actual_ok, bt type,
365 int kind, int standard,
366 try (*check)(gfc_expr *),
367 gfc_expr *(*simplify)(gfc_expr *),
368 void (*resolve)(gfc_expr *,gfc_expr *),
369 const char* a1, bt type1, int kind1, int optional1)
371 gfc_check_f cf;
372 gfc_simplify_f sf;
373 gfc_resolve_f rf;
375 cf.f1 = check;
376 sf.f1 = simplify;
377 rf.f1 = resolve;
379 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
380 a1, type1, kind1, optional1,
381 (void*)0);
385 /* Add a symbol to the subroutine list where the subroutine takes
386 1 arguments. */
388 static void
389 add_sym_1s (const char *name, int elemental, bt type,
390 int kind, int standard,
391 try (*check)(gfc_expr *),
392 gfc_expr *(*simplify)(gfc_expr *),
393 void (*resolve)(gfc_code *),
394 const char* a1, bt type1, int kind1, int optional1)
396 gfc_check_f cf;
397 gfc_simplify_f sf;
398 gfc_resolve_f rf;
400 cf.f1 = check;
401 sf.f1 = simplify;
402 rf.s1 = resolve;
404 add_sym (name, elemental, ACTUAL_NO, type, kind, standard, cf, sf, rf,
405 a1, type1, kind1, optional1,
406 (void*)0);
410 /* Add a symbol from the MAX/MIN family of intrinsic functions to the
411 function. MAX et al take 2 or more arguments. */
413 static void
414 add_sym_1m (const char *name, int elemental, int actual_ok, bt type,
415 int kind, int standard,
416 try (*check)(gfc_actual_arglist *),
417 gfc_expr *(*simplify)(gfc_expr *),
418 void (*resolve)(gfc_expr *,gfc_actual_arglist *),
419 const char* a1, bt type1, int kind1, int optional1,
420 const char* a2, bt type2, int kind2, int optional2)
422 gfc_check_f cf;
423 gfc_simplify_f sf;
424 gfc_resolve_f rf;
426 cf.f1m = check;
427 sf.f1 = simplify;
428 rf.f1m = resolve;
430 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
431 a1, type1, kind1, optional1,
432 a2, type2, kind2, optional2,
433 (void*)0);
437 /* Add a symbol to the function list where the function takes
438 2 arguments. */
440 static void
441 add_sym_2 (const char *name, int elemental, int actual_ok, bt type,
442 int kind, int standard,
443 try (*check)(gfc_expr *,gfc_expr *),
444 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *),
445 void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *),
446 const char* a1, bt type1, int kind1, int optional1,
447 const char* a2, bt type2, int kind2, int optional2)
449 gfc_check_f cf;
450 gfc_simplify_f sf;
451 gfc_resolve_f rf;
453 cf.f2 = check;
454 sf.f2 = simplify;
455 rf.f2 = resolve;
457 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
458 a1, type1, kind1, optional1,
459 a2, type2, kind2, optional2,
460 (void*)0);
464 /* Add a symbol to the subroutine list where the subroutine takes
465 2 arguments. */
467 static void
468 add_sym_2s (const char *name, int elemental, bt type,
469 int kind, int standard,
470 try (*check)(gfc_expr *,gfc_expr *),
471 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *),
472 void (*resolve)(gfc_code *),
473 const char* a1, bt type1, int kind1, int optional1,
474 const char* a2, bt type2, int kind2, int optional2)
476 gfc_check_f cf;
477 gfc_simplify_f sf;
478 gfc_resolve_f rf;
480 cf.f2 = check;
481 sf.f2 = simplify;
482 rf.s1 = resolve;
484 add_sym (name, elemental, ACTUAL_NO, type, kind, standard, cf, sf, rf,
485 a1, type1, kind1, optional1,
486 a2, type2, kind2, optional2,
487 (void*)0);
491 /* Add a symbol to the function list where the function takes
492 3 arguments. */
494 static void
495 add_sym_3 (const char *name, int elemental, int actual_ok, bt type,
496 int kind, int standard,
497 try (*check)(gfc_expr *,gfc_expr *,gfc_expr *),
498 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *),
499 void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
500 const char* a1, bt type1, int kind1, int optional1,
501 const char* a2, bt type2, int kind2, int optional2,
502 const char* a3, bt type3, int kind3, int optional3)
504 gfc_check_f cf;
505 gfc_simplify_f sf;
506 gfc_resolve_f rf;
508 cf.f3 = check;
509 sf.f3 = simplify;
510 rf.f3 = resolve;
512 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
513 a1, type1, kind1, optional1,
514 a2, type2, kind2, optional2,
515 a3, type3, kind3, optional3,
516 (void*)0);
520 /* MINLOC and MAXLOC get special treatment because their argument
521 might have to be reordered. */
523 static void
524 add_sym_3ml (const char *name, int elemental,
525 int actual_ok, bt type, int kind, int standard,
526 try (*check)(gfc_actual_arglist *),
527 gfc_expr*(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *),
528 void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
529 const char* a1, bt type1, int kind1, int optional1,
530 const char* a2, bt type2, int kind2, int optional2,
531 const char* a3, bt type3, int kind3, int optional3)
533 gfc_check_f cf;
534 gfc_simplify_f sf;
535 gfc_resolve_f rf;
537 cf.f3ml = check;
538 sf.f3 = simplify;
539 rf.f3 = resolve;
541 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
542 a1, type1, kind1, optional1,
543 a2, type2, kind2, optional2,
544 a3, type3, kind3, optional3,
545 (void*)0);
549 /* MINVAL, MAXVAL, PRODUCT, and SUM also get special treatment because
550 their argument also might have to be reordered. */
552 static void
553 add_sym_3red (const char *name, int elemental,
554 int actual_ok, bt type, int kind, int standard,
555 try (*check)(gfc_actual_arglist *),
556 gfc_expr*(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *),
557 void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
558 const char* a1, bt type1, int kind1, int optional1,
559 const char* a2, bt type2, int kind2, int optional2,
560 const char* a3, bt type3, int kind3, int optional3)
562 gfc_check_f cf;
563 gfc_simplify_f sf;
564 gfc_resolve_f rf;
566 cf.f3red = check;
567 sf.f3 = simplify;
568 rf.f3 = resolve;
570 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
571 a1, type1, kind1, optional1,
572 a2, type2, kind2, optional2,
573 a3, type3, kind3, optional3,
574 (void*)0);
578 /* Add a symbol to the subroutine list where the subroutine takes
579 3 arguments. */
581 static void
582 add_sym_3s (const char *name, int elemental, bt type,
583 int kind, int standard,
584 try (*check)(gfc_expr *,gfc_expr *,gfc_expr *),
585 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *),
586 void (*resolve)(gfc_code *),
587 const char* a1, bt type1, int kind1, int optional1,
588 const char* a2, bt type2, int kind2, int optional2,
589 const char* a3, bt type3, int kind3, int optional3)
591 gfc_check_f cf;
592 gfc_simplify_f sf;
593 gfc_resolve_f rf;
595 cf.f3 = check;
596 sf.f3 = simplify;
597 rf.s1 = resolve;
599 add_sym (name, elemental, ACTUAL_NO, type, kind, standard, cf, sf, rf,
600 a1, type1, kind1, optional1,
601 a2, type2, kind2, optional2,
602 a3, type3, kind3, optional3,
603 (void*)0);
607 /* Add a symbol to the function list where the function takes
608 4 arguments. */
610 static void
611 add_sym_4 (const char *name, int elemental, int actual_ok, bt type,
612 int kind, int standard,
613 try (*check)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
614 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
615 void (*resolve)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
616 const char* a1, bt type1, int kind1, int optional1,
617 const char* a2, bt type2, int kind2, int optional2,
618 const char* a3, bt type3, int kind3, int optional3,
619 const char* a4, bt type4, int kind4, int optional4 )
621 gfc_check_f cf;
622 gfc_simplify_f sf;
623 gfc_resolve_f rf;
625 cf.f4 = check;
626 sf.f4 = simplify;
627 rf.f4 = resolve;
629 add_sym (name, elemental, actual_ok, type, kind, standard, cf, sf, rf,
630 a1, type1, kind1, optional1,
631 a2, type2, kind2, optional2,
632 a3, type3, kind3, optional3,
633 a4, type4, kind4, optional4,
634 (void*)0);
638 /* Add a symbol to the subroutine list where the subroutine takes
639 4 arguments. */
641 static void
642 add_sym_4s (const char *name, int elemental,
643 bt type, int kind, int standard,
644 try (*check)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
645 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
646 void (*resolve)(gfc_code *),
647 const char* a1, bt type1, int kind1, int optional1,
648 const char* a2, bt type2, int kind2, int optional2,
649 const char* a3, bt type3, int kind3, int optional3,
650 const char* a4, bt type4, int kind4, int optional4)
652 gfc_check_f cf;
653 gfc_simplify_f sf;
654 gfc_resolve_f rf;
656 cf.f4 = check;
657 sf.f4 = simplify;
658 rf.s1 = resolve;
660 add_sym (name, elemental, ACTUAL_NO, type, kind, standard, cf, sf, rf,
661 a1, type1, kind1, optional1,
662 a2, type2, kind2, optional2,
663 a3, type3, kind3, optional3,
664 a4, type4, kind4, optional4,
665 (void*)0);
669 /* Add a symbol to the subroutine list where the subroutine takes
670 5 arguments. */
672 static void
673 add_sym_5s (const char *name, int elemental,
674 bt type, int kind, int standard,
675 try (*check)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
676 gfc_expr *(*simplify)(gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *,gfc_expr *),
677 void (*resolve)(gfc_code *),
678 const char* a1, bt type1, int kind1, int optional1,
679 const char* a2, bt type2, int kind2, int optional2,
680 const char* a3, bt type3, int kind3, int optional3,
681 const char* a4, bt type4, int kind4, int optional4,
682 const char* a5, bt type5, int kind5, int optional5)
684 gfc_check_f cf;
685 gfc_simplify_f sf;
686 gfc_resolve_f rf;
688 cf.f5 = check;
689 sf.f5 = simplify;
690 rf.s1 = resolve;
692 add_sym (name, elemental, ACTUAL_NO, type, kind, standard, cf, sf, rf,
693 a1, type1, kind1, optional1,
694 a2, type2, kind2, optional2,
695 a3, type3, kind3, optional3,
696 a4, type4, kind4, optional4,
697 a5, type5, kind5, optional5,
698 (void*)0);
702 /* Locate an intrinsic symbol given a base pointer, number of elements
703 in the table and a pointer to a name. Returns the NULL pointer if
704 a name is not found. */
706 static gfc_intrinsic_sym *
707 find_sym (gfc_intrinsic_sym * start, int n, const char *name)
710 while (n > 0)
712 if (strcmp (name, start->name) == 0)
713 return start;
715 start++;
716 n--;
719 return NULL;
723 /* Given a name, find a function in the intrinsic function table.
724 Returns NULL if not found. */
726 gfc_intrinsic_sym *
727 gfc_find_function (const char *name)
729 gfc_intrinsic_sym *sym;
731 sym = find_sym (functions, nfunc, name);
732 if (!sym)
733 sym = find_sym (conversion, nconv, name);
735 return sym;
739 /* Given a name, find a function in the intrinsic subroutine table.
740 Returns NULL if not found. */
742 static gfc_intrinsic_sym *
743 find_subroutine (const char *name)
746 return find_sym (subroutines, nsub, name);
750 /* Given a string, figure out if it is the name of a generic intrinsic
751 function or not. */
754 gfc_generic_intrinsic (const char *name)
756 gfc_intrinsic_sym *sym;
758 sym = gfc_find_function (name);
759 return (sym == NULL) ? 0 : sym->generic;
763 /* Given a string, figure out if it is the name of a specific
764 intrinsic function or not. */
767 gfc_specific_intrinsic (const char *name)
769 gfc_intrinsic_sym *sym;
771 sym = gfc_find_function (name);
772 return (sym == NULL) ? 0 : sym->specific;
776 /* Given a string, figure out if it is the name of an intrinsic function
777 or subroutine allowed as an actual argument or not. */
779 gfc_intrinsic_actual_ok (const char *name, const bool subroutine_flag)
781 gfc_intrinsic_sym *sym;
783 /* Intrinsic subroutines are not allowed as actual arguments. */
784 if (subroutine_flag)
785 return 0;
786 else
788 sym = gfc_find_function (name);
789 return (sym == NULL) ? 0 : sym->actual_ok;
794 /* Given a string, figure out if it is the name of an intrinsic
795 subroutine or function. There are no generic intrinsic
796 subroutines, they are all specific. */
799 gfc_intrinsic_name (const char *name, int subroutine_flag)
802 return subroutine_flag ?
803 find_subroutine (name) != NULL : gfc_find_function (name) != NULL;
807 /* Collect a set of intrinsic functions into a generic collection.
808 The first argument is the name of the generic function, which is
809 also the name of a specific function. The rest of the specifics
810 currently in the table are placed into the list of specific
811 functions associated with that generic. */
813 static void
814 make_generic (const char *name, gfc_generic_isym_id generic_id, int standard)
816 gfc_intrinsic_sym *g;
818 if (!(gfc_option.allow_std & standard)
819 && gfc_option.flag_all_intrinsics == 0)
820 return;
822 if (sizing != SZ_NOTHING)
823 return;
825 g = gfc_find_function (name);
826 if (g == NULL)
827 gfc_internal_error ("make_generic(): Can't find generic symbol '%s'",
828 name);
830 g->generic = 1;
831 g->specific = 1;
832 g->generic_id = generic_id;
833 if ((g + 1)->name != NULL)
834 g->specific_head = g + 1;
835 g++;
837 while (g->name != NULL)
839 g->next = g + 1;
840 g->specific = 1;
841 g->generic_id = generic_id;
842 g++;
845 g--;
846 g->next = NULL;
850 /* Create a duplicate intrinsic function entry for the current
851 function, the only difference being the alternate name. Note that
852 we use argument lists more than once, but all argument lists are
853 freed as a single block. */
855 static void
856 make_alias (const char *name, int standard)
859 /* First check that the intrinsic belongs to the selected standard.
860 If not, don't add it to the symbol list. */
861 if (!(gfc_option.allow_std & standard)
862 && gfc_option.flag_all_intrinsics == 0)
863 return;
865 switch (sizing)
867 case SZ_FUNCS:
868 nfunc++;
869 break;
871 case SZ_SUBS:
872 nsub++;
873 break;
875 case SZ_NOTHING:
876 next_sym[0] = next_sym[-1];
877 next_sym->name = gfc_get_string (name);
878 next_sym++;
879 break;
881 default:
882 break;
886 /* Make the current subroutine noreturn. */
888 static void
889 make_noreturn(void)
891 if (sizing == SZ_NOTHING)
892 next_sym[-1].noreturn = 1;
895 /* Add intrinsic functions. */
897 static void
898 add_functions (void)
901 /* Argument names as in the standard (to be used as argument keywords). */
902 const char
903 *a = "a", *f = "field", *pt = "pointer", *tg = "target",
904 *b = "b", *m = "matrix", *ma = "matrix_a", *mb = "matrix_b",
905 *c = "c", *n = "ncopies", *pos = "pos", *bck = "back",
906 *i = "i", *v = "vector", *va = "vector_a", *vb = "vector_b",
907 *j = "j", *a1 = "a1", *fs = "fsource", *ts = "tsource",
908 *l = "l", *a2 = "a2", *mo = "mold", *ord = "order",
909 *p = "p", *ar = "array", *shp = "shape", *src = "source",
910 *r = "r", *bd = "boundary", *pad = "pad", *set = "set",
911 *s = "s", *dm = "dim", *kind = "kind", *msk = "mask",
912 *x = "x", *sh = "shift", *stg = "string", *ssg = "substring",
913 *y = "y", *sz = "size", *sta = "string_a", *stb = "string_b",
914 *z = "z", *ln = "len", *ut = "unit", *han = "handler",
915 *num = "number", *tm = "time", *nm = "name", *md = "mode";
917 int di, dr, dd, dl, dc, dz, ii;
919 di = gfc_default_integer_kind;
920 dr = gfc_default_real_kind;
921 dd = gfc_default_double_kind;
922 dl = gfc_default_logical_kind;
923 dc = gfc_default_character_kind;
924 dz = gfc_default_complex_kind;
925 ii = gfc_index_integer_kind;
927 add_sym_1 ("abs", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
928 gfc_check_abs, gfc_simplify_abs, gfc_resolve_abs,
929 a, BT_REAL, dr, REQUIRED);
931 add_sym_1 ("iabs", ELEMENTAL, ACTUAL_YES, BT_INTEGER, di, GFC_STD_F77,
932 NULL, gfc_simplify_abs, gfc_resolve_abs,
933 a, BT_INTEGER, di, REQUIRED);
935 add_sym_1 ("dabs", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
936 NULL, gfc_simplify_abs, gfc_resolve_abs,
937 a, BT_REAL, dd, REQUIRED);
939 add_sym_1 ("cabs", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
940 NULL, gfc_simplify_abs, gfc_resolve_abs,
941 a, BT_COMPLEX, dz, REQUIRED);
943 add_sym_1 ("zabs", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_GNU,
944 NULL, gfc_simplify_abs, gfc_resolve_abs,
945 a, BT_COMPLEX, dd, REQUIRED);
947 make_alias ("cdabs", GFC_STD_GNU);
949 make_generic ("abs", GFC_ISYM_ABS, GFC_STD_F77);
951 /* The checking function for ACCESS is called gfc_check_access_func
952 because the name gfc_check_access is already used in module.c. */
953 add_sym_2 ("access", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
954 gfc_check_access_func, NULL, gfc_resolve_access,
955 nm, BT_CHARACTER, dc, REQUIRED, md, BT_CHARACTER, dc, REQUIRED);
957 make_generic ("access", GFC_ISYM_ACCESS, GFC_STD_GNU);
959 add_sym_1 ("achar", ELEMENTAL, ACTUAL_NO, BT_CHARACTER, dc, GFC_STD_F95,
960 gfc_check_achar, gfc_simplify_achar, NULL,
961 i, BT_INTEGER, di, REQUIRED);
963 make_generic ("achar", GFC_ISYM_ACHAR, GFC_STD_F95);
965 add_sym_1 ("acos", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
966 gfc_check_fn_r, gfc_simplify_acos, gfc_resolve_acos,
967 x, BT_REAL, dr, REQUIRED);
969 add_sym_1 ("dacos", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
970 NULL, gfc_simplify_acos, gfc_resolve_acos,
971 x, BT_REAL, dd, REQUIRED);
973 make_generic ("acos", GFC_ISYM_ACOS, GFC_STD_F77);
975 add_sym_1 ("acosh", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_GNU,
976 gfc_check_fn_r, gfc_simplify_acosh, gfc_resolve_acosh,
977 x, BT_REAL, dr, REQUIRED);
979 add_sym_1 ("dacosh", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_GNU,
980 NULL, gfc_simplify_acosh, gfc_resolve_acosh,
981 x, BT_REAL, dd, REQUIRED);
983 make_generic ("acosh", GFC_ISYM_ACOSH, GFC_STD_GNU);
985 add_sym_1 ("adjustl", ELEMENTAL, ACTUAL_NO, BT_CHARACTER, dc, GFC_STD_F95,
986 NULL, gfc_simplify_adjustl, NULL,
987 stg, BT_CHARACTER, dc, REQUIRED);
989 make_generic ("adjustl", GFC_ISYM_ADJUSTL, GFC_STD_F95);
991 add_sym_1 ("adjustr", ELEMENTAL, ACTUAL_NO, BT_CHARACTER, dc, GFC_STD_F95,
992 NULL, gfc_simplify_adjustr, NULL,
993 stg, BT_CHARACTER, dc, REQUIRED);
995 make_generic ("adjustr", GFC_ISYM_ADJUSTR, GFC_STD_F95);
997 add_sym_1 ("aimag", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
998 gfc_check_fn_c, gfc_simplify_aimag, gfc_resolve_aimag,
999 z, BT_COMPLEX, dz, REQUIRED);
1001 make_alias ("imag", GFC_STD_GNU);
1002 make_alias ("imagpart", GFC_STD_GNU);
1004 add_sym_1 ("dimag", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_GNU,
1005 NULL, gfc_simplify_aimag, gfc_resolve_aimag,
1006 z, BT_COMPLEX, dd, REQUIRED);
1008 make_generic ("aimag", GFC_ISYM_AIMAG, GFC_STD_F77);
1010 add_sym_2 ("aint", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1011 gfc_check_a_xkind, gfc_simplify_aint, gfc_resolve_aint,
1012 a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1014 add_sym_1 ("dint", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1015 NULL, gfc_simplify_dint, gfc_resolve_dint,
1016 a, BT_REAL, dd, REQUIRED);
1018 make_generic ("aint", GFC_ISYM_AINT, GFC_STD_F77);
1020 add_sym_2 ("all", NOT_ELEMENTAL, ACTUAL_NO, BT_UNKNOWN, 0, GFC_STD_F95,
1021 gfc_check_all_any, NULL, gfc_resolve_all,
1022 msk, BT_LOGICAL, dl, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL);
1024 make_generic ("all", GFC_ISYM_ALL, GFC_STD_F95);
1026 add_sym_1 ("allocated", NOT_ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_F95,
1027 gfc_check_allocated, NULL, NULL,
1028 ar, BT_UNKNOWN, 0, REQUIRED);
1030 make_generic ("allocated", GFC_ISYM_ALLOCATED, GFC_STD_F95);
1032 add_sym_2 ("anint", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1033 gfc_check_a_xkind, gfc_simplify_anint, gfc_resolve_anint,
1034 a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1036 add_sym_1 ("dnint", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1037 NULL, gfc_simplify_dnint, gfc_resolve_dnint,
1038 a, BT_REAL, dd, REQUIRED);
1040 make_generic ("anint", GFC_ISYM_ANINT, GFC_STD_F77);
1042 add_sym_2 ("any", NOT_ELEMENTAL, ACTUAL_NO, BT_UNKNOWN, 0, GFC_STD_F95,
1043 gfc_check_all_any, NULL, gfc_resolve_any,
1044 msk, BT_LOGICAL, dl, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL);
1046 make_generic ("any", GFC_ISYM_ANY, GFC_STD_F95);
1048 add_sym_1 ("asin", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1049 gfc_check_fn_r, gfc_simplify_asin, gfc_resolve_asin,
1050 x, BT_REAL, dr, REQUIRED);
1052 add_sym_1 ("dasin", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1053 NULL, gfc_simplify_asin, gfc_resolve_asin,
1054 x, BT_REAL, dd, REQUIRED);
1056 make_generic ("asin", GFC_ISYM_ASIN, GFC_STD_F77);
1058 add_sym_1 ("asinh", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_GNU,
1059 gfc_check_fn_r, gfc_simplify_asinh, gfc_resolve_asinh,
1060 x, BT_REAL, dr, REQUIRED);
1062 add_sym_1 ("dasinh", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_GNU,
1063 NULL, gfc_simplify_asinh, gfc_resolve_asinh,
1064 x, BT_REAL, dd, REQUIRED);
1066 make_generic ("asinh", GFC_ISYM_ASINH, GFC_STD_GNU);
1068 add_sym_2 ("associated", NOT_ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl,
1069 GFC_STD_F95, gfc_check_associated, NULL, NULL,
1070 pt, BT_UNKNOWN, 0, REQUIRED, tg, BT_UNKNOWN, 0, OPTIONAL);
1072 make_generic ("associated", GFC_ISYM_ASSOCIATED, GFC_STD_F95);
1074 add_sym_1 ("atan", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1075 gfc_check_fn_r, gfc_simplify_atan, gfc_resolve_atan,
1076 x, BT_REAL, dr, REQUIRED);
1078 add_sym_1 ("datan", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1079 NULL, gfc_simplify_atan, gfc_resolve_atan,
1080 x, BT_REAL, dd, REQUIRED);
1082 make_generic ("atan", GFC_ISYM_ATAN, GFC_STD_F77);
1084 add_sym_1 ("atanh", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_GNU,
1085 gfc_check_fn_r, gfc_simplify_atanh, gfc_resolve_atanh,
1086 x, BT_REAL, dr, REQUIRED);
1088 add_sym_1 ("datanh", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_GNU,
1089 NULL, gfc_simplify_atanh, gfc_resolve_atanh,
1090 x, BT_REAL, dd, REQUIRED);
1092 make_generic ("atanh", GFC_ISYM_ATANH, GFC_STD_GNU);
1094 add_sym_2 ("atan2", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1095 gfc_check_atan2, gfc_simplify_atan2, gfc_resolve_atan2,
1096 y, BT_REAL, dr, REQUIRED, x, BT_REAL, dr, REQUIRED);
1098 add_sym_2 ("datan2", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1099 NULL, gfc_simplify_atan2, gfc_resolve_atan2,
1100 y, BT_REAL, dd, REQUIRED, x, BT_REAL, dd, REQUIRED);
1102 make_generic ("atan2", GFC_ISYM_ATAN2, GFC_STD_F77);
1104 /* Bessel and Neumann functions for G77 compatibility. */
1105 add_sym_1 ("besj0", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
1106 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1107 x, BT_REAL, dr, REQUIRED);
1109 add_sym_1 ("dbesj0", ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
1110 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1111 x, BT_REAL, dd, REQUIRED);
1113 make_generic ("besj0", GFC_ISYM_J0, GFC_STD_GNU);
1115 add_sym_1 ("besj1", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
1116 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1117 x, BT_REAL, dr, REQUIRED);
1119 add_sym_1 ("dbesj1", ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
1120 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1121 x, BT_REAL, dd, REQUIRED);
1123 make_generic ("besj1", GFC_ISYM_J1, GFC_STD_GNU);
1125 add_sym_2 ("besjn", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
1126 gfc_check_besn, NULL, gfc_resolve_besn,
1127 n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dr, REQUIRED);
1129 add_sym_2 ("dbesjn", ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
1130 gfc_check_besn, NULL, gfc_resolve_besn,
1131 n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dd, REQUIRED);
1133 make_generic ("besjn", GFC_ISYM_JN, GFC_STD_GNU);
1135 add_sym_1 ("besy0", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
1136 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1137 x, BT_REAL, dr, REQUIRED);
1139 add_sym_1 ("dbesy0", ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
1140 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1141 x, BT_REAL, dd, REQUIRED);
1143 make_generic ("besy0", GFC_ISYM_Y0, GFC_STD_GNU);
1145 add_sym_1 ("besy1", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
1146 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1147 x, BT_REAL, dr, REQUIRED);
1149 add_sym_1 ("dbesy1", ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
1150 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1151 x, BT_REAL, dd, REQUIRED);
1153 make_generic ("besy1", GFC_ISYM_Y1, GFC_STD_GNU);
1155 add_sym_2 ("besyn", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
1156 gfc_check_besn, NULL, gfc_resolve_besn,
1157 n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dr, REQUIRED);
1159 add_sym_2 ("dbesyn", ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
1160 gfc_check_besn, NULL, gfc_resolve_besn,
1161 n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dd, REQUIRED);
1163 make_generic ("besyn", GFC_ISYM_YN, GFC_STD_GNU);
1165 add_sym_1 ("bit_size", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1166 gfc_check_i, gfc_simplify_bit_size, NULL,
1167 i, BT_INTEGER, di, REQUIRED);
1169 make_generic ("bit_size", GFC_ISYM_NONE, GFC_STD_F95);
1171 add_sym_2 ("btest", ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_F95,
1172 gfc_check_btest, gfc_simplify_btest, gfc_resolve_btest,
1173 i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED);
1175 make_generic ("btest", GFC_ISYM_BTEST, GFC_STD_F95);
1177 add_sym_2 ("ceiling", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1178 gfc_check_a_ikind, gfc_simplify_ceiling, gfc_resolve_ceiling,
1179 a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1181 make_generic ("ceiling", GFC_ISYM_CEILING, GFC_STD_F95);
1183 add_sym_2 ("char", 1, 2, BT_CHARACTER, dc, GFC_STD_F77,
1184 gfc_check_char, gfc_simplify_char, gfc_resolve_char,
1185 i, BT_INTEGER, di, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1187 make_generic ("char", GFC_ISYM_CHAR, GFC_STD_F77);
1189 add_sym_1 ("chdir", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1190 gfc_check_chdir, NULL, gfc_resolve_chdir,
1191 a, BT_CHARACTER, dc, REQUIRED);
1193 make_generic ("chdir", GFC_ISYM_CHDIR, GFC_STD_GNU);
1195 add_sym_2 ("chmod", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1196 gfc_check_chmod, NULL, gfc_resolve_chmod,
1197 nm, BT_CHARACTER, dc, REQUIRED, md, BT_CHARACTER, dc, REQUIRED);
1199 make_generic ("chmod", GFC_ISYM_CHMOD, GFC_STD_GNU);
1201 add_sym_3 ("cmplx", ELEMENTAL, ACTUAL_NO, BT_COMPLEX, dz, GFC_STD_F77,
1202 gfc_check_cmplx, gfc_simplify_cmplx, gfc_resolve_cmplx,
1203 x, BT_UNKNOWN, dr, REQUIRED, y, BT_UNKNOWN, dr, OPTIONAL,
1204 kind, BT_INTEGER, di, OPTIONAL);
1206 make_generic ("cmplx", GFC_ISYM_CMPLX, GFC_STD_F77);
1208 add_sym_0 ("command_argument_count", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di,
1209 GFC_STD_F2003, NULL, NULL, NULL);
1211 make_generic ("command_argument_count", GFC_ISYM_COMMAND_ARGUMENT_COUNT,
1212 GFC_STD_F2003);
1214 add_sym_2 ("complex", ELEMENTAL, ACTUAL_NO, BT_COMPLEX, dz, GFC_STD_GNU,
1215 gfc_check_complex, gfc_simplify_complex, gfc_resolve_complex,
1216 x, BT_UNKNOWN, dr, REQUIRED, y, BT_UNKNOWN, dr, REQUIRED);
1218 make_generic ("complex", GFC_ISYM_COMPLEX, GFC_STD_GNU);
1220 /* Making dcmplx a specific of cmplx causes cmplx to return a double
1221 complex instead of the default complex. */
1223 add_sym_2 ("dcmplx", ELEMENTAL, ACTUAL_NO, BT_COMPLEX, dd, GFC_STD_GNU,
1224 gfc_check_dcmplx, gfc_simplify_dcmplx, gfc_resolve_dcmplx,
1225 x, BT_REAL, dd, REQUIRED, y, BT_REAL, dd, OPTIONAL);
1227 make_generic ("dcmplx", GFC_ISYM_CMPLX, GFC_STD_GNU);
1229 add_sym_1 ("conjg", ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dz, GFC_STD_F77,
1230 gfc_check_fn_c, gfc_simplify_conjg, gfc_resolve_conjg,
1231 z, BT_COMPLEX, dz, REQUIRED);
1233 add_sym_1 ("dconjg", ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dd, GFC_STD_GNU,
1234 NULL, gfc_simplify_conjg, gfc_resolve_conjg,
1235 z, BT_COMPLEX, dd, REQUIRED);
1237 make_generic ("conjg", GFC_ISYM_CONJG, GFC_STD_F77);
1239 add_sym_1 ("cos", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1240 gfc_check_fn_rc, gfc_simplify_cos, gfc_resolve_cos,
1241 x, BT_REAL, dr, REQUIRED);
1243 add_sym_1 ("dcos", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1244 gfc_check_fn_rc, gfc_simplify_cos, gfc_resolve_cos,
1245 x, BT_REAL, dd, REQUIRED);
1247 add_sym_1 ("ccos", ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dz, GFC_STD_F77,
1248 NULL, gfc_simplify_cos, gfc_resolve_cos,
1249 x, BT_COMPLEX, dz, REQUIRED);
1251 add_sym_1 ("zcos", ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dd, GFC_STD_GNU,
1252 NULL, gfc_simplify_cos, gfc_resolve_cos,
1253 x, BT_COMPLEX, dd, REQUIRED);
1255 make_alias ("cdcos", GFC_STD_GNU);
1257 make_generic ("cos", GFC_ISYM_COS, GFC_STD_F77);
1259 add_sym_1 ("cosh", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1260 gfc_check_fn_r, gfc_simplify_cosh, gfc_resolve_cosh,
1261 x, BT_REAL, dr, REQUIRED);
1263 add_sym_1 ("dcosh", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1264 NULL, gfc_simplify_cosh, gfc_resolve_cosh,
1265 x, BT_REAL, dd, REQUIRED);
1267 make_generic ("cosh", GFC_ISYM_COSH, GFC_STD_F77);
1269 add_sym_2 ("count", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1270 gfc_check_count, NULL, gfc_resolve_count,
1271 msk, BT_LOGICAL, dl, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL);
1273 make_generic ("count", GFC_ISYM_COUNT, GFC_STD_F95);
1275 add_sym_3 ("cshift", NOT_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
1276 gfc_check_cshift, NULL, gfc_resolve_cshift,
1277 ar, BT_REAL, dr, REQUIRED, sh, BT_INTEGER, di, REQUIRED,
1278 dm, BT_INTEGER, ii, OPTIONAL);
1280 make_generic ("cshift", GFC_ISYM_CSHIFT, GFC_STD_F95);
1282 add_sym_1 ("ctime", NOT_ELEMENTAL, ACTUAL_NO, BT_CHARACTER, 0, GFC_STD_GNU,
1283 gfc_check_ctime, NULL, gfc_resolve_ctime,
1284 tm, BT_INTEGER, di, REQUIRED);
1286 make_generic ("ctime", GFC_ISYM_CTIME, GFC_STD_GNU);
1288 add_sym_1 ("dble", ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_F77,
1289 gfc_check_dble, gfc_simplify_dble, gfc_resolve_dble,
1290 a, BT_REAL, dr, REQUIRED);
1292 make_alias ("dfloat", GFC_STD_GNU);
1294 make_generic ("dble", GFC_ISYM_DBLE, GFC_STD_F77);
1296 add_sym_1 ("digits", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1297 gfc_check_digits, gfc_simplify_digits, NULL,
1298 x, BT_UNKNOWN, dr, REQUIRED);
1300 make_generic ("digits", GFC_ISYM_NONE, GFC_STD_F95);
1302 add_sym_2 ("dim", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1303 gfc_check_a_p, gfc_simplify_dim, gfc_resolve_dim,
1304 x, BT_REAL, dr, REQUIRED, y, BT_UNKNOWN, dr, REQUIRED);
1306 add_sym_2 ("idim", ELEMENTAL, ACTUAL_YES, BT_INTEGER, di, GFC_STD_F77,
1307 NULL, gfc_simplify_dim, gfc_resolve_dim,
1308 x, BT_INTEGER, di, REQUIRED, y, BT_INTEGER, di, REQUIRED);
1310 add_sym_2 ("ddim", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1311 NULL, gfc_simplify_dim, gfc_resolve_dim,
1312 x, BT_REAL, dd, REQUIRED, y, BT_REAL, dd, REQUIRED);
1314 make_generic ("dim", GFC_ISYM_DIM, GFC_STD_F77);
1316 add_sym_2 ("dot_product", NOT_ELEMENTAL, ACTUAL_NO, BT_UNKNOWN, 0,
1317 GFC_STD_F95, gfc_check_dot_product, NULL, gfc_resolve_dot_product,
1318 va, BT_REAL, dr, REQUIRED, vb, BT_REAL, dr, REQUIRED);
1320 make_generic ("dot_product", GFC_ISYM_DOT_PRODUCT, GFC_STD_F95);
1322 add_sym_2 ("dprod", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1323 NULL, gfc_simplify_dprod, gfc_resolve_dprod,
1324 x, BT_REAL, dr, REQUIRED, y, BT_REAL, dr, REQUIRED);
1326 make_generic ("dprod", GFC_ISYM_DPROD, GFC_STD_F77);
1328 add_sym_1 ("dreal", ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
1329 NULL, NULL, NULL,
1330 a, BT_COMPLEX, dd, REQUIRED);
1332 make_generic ("dreal", GFC_ISYM_REAL, GFC_STD_GNU);
1334 add_sym_4 ("eoshift", NOT_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
1335 gfc_check_eoshift, NULL, gfc_resolve_eoshift,
1336 ar, BT_REAL, dr, 0, sh, BT_INTEGER, ii, REQUIRED,
1337 bd, BT_REAL, dr, 1, dm, BT_INTEGER, ii, OPTIONAL);
1339 make_generic ("eoshift", GFC_ISYM_EOSHIFT, GFC_STD_F95);
1341 add_sym_1 ("epsilon", NOT_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
1342 gfc_check_x, gfc_simplify_epsilon, NULL,
1343 x, BT_REAL, dr, REQUIRED);
1345 make_generic ("epsilon", GFC_ISYM_NONE, GFC_STD_F95);
1347 /* G77 compatibility for the ERF() and ERFC() functions. */
1348 add_sym_1 ("erf", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
1349 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1350 x, BT_REAL, dr, REQUIRED);
1352 add_sym_1 ("derf", ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
1353 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1354 x, BT_REAL, dd, REQUIRED);
1356 make_generic ("erf", GFC_ISYM_ERF, GFC_STD_GNU);
1358 add_sym_1 ("erfc", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
1359 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1360 x, BT_REAL, dr, REQUIRED);
1362 add_sym_1 ("derfc", ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
1363 gfc_check_g77_math1, NULL, gfc_resolve_g77_math1,
1364 x, BT_REAL, dd, REQUIRED);
1366 make_generic ("erfc", GFC_ISYM_ERFC, GFC_STD_GNU);
1368 /* G77 compatibility */
1369 add_sym_1 ("etime", NOT_ELEMENTAL, ACTUAL_NO, BT_REAL, 4, GFC_STD_GNU,
1370 gfc_check_etime, NULL, NULL,
1371 x, BT_REAL, 4, REQUIRED);
1373 make_alias ("dtime", GFC_STD_GNU);
1375 make_generic ("etime", GFC_ISYM_ETIME, GFC_STD_GNU);
1377 add_sym_1 ("exp", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1378 gfc_check_fn_rc, gfc_simplify_exp, gfc_resolve_exp,
1379 x, BT_REAL, dr, REQUIRED);
1381 add_sym_1 ("dexp", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1382 NULL, gfc_simplify_exp, gfc_resolve_exp,
1383 x, BT_REAL, dd, REQUIRED);
1385 add_sym_1 ("cexp", ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dz, GFC_STD_F77,
1386 NULL, gfc_simplify_exp, gfc_resolve_exp,
1387 x, BT_COMPLEX, dz, REQUIRED);
1389 add_sym_1 ("zexp", ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dd, GFC_STD_GNU,
1390 NULL, gfc_simplify_exp, gfc_resolve_exp,
1391 x, BT_COMPLEX, dd, REQUIRED);
1393 make_alias ("cdexp", GFC_STD_GNU);
1395 make_generic ("exp", GFC_ISYM_EXP, GFC_STD_F77);
1397 add_sym_1 ("exponent", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1398 gfc_check_x, gfc_simplify_exponent, gfc_resolve_exponent,
1399 x, BT_REAL, dr, REQUIRED);
1401 make_generic ("exponent", GFC_ISYM_EXPONENT, GFC_STD_F95);
1403 add_sym_0 ("fdate", ELEMENTAL, ACTUAL_NO, BT_CHARACTER, dc, GFC_STD_GNU,
1404 NULL, NULL, gfc_resolve_fdate);
1406 make_generic ("fdate", GFC_ISYM_FDATE, GFC_STD_GNU);
1408 add_sym_2 ("floor", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1409 gfc_check_a_ikind, gfc_simplify_floor, gfc_resolve_floor,
1410 a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1412 make_generic ("floor", GFC_ISYM_FLOOR, GFC_STD_F95);
1414 /* G77 compatible fnum */
1415 add_sym_1 ("fnum", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1416 gfc_check_fnum, NULL, gfc_resolve_fnum,
1417 ut, BT_INTEGER, di, REQUIRED);
1419 make_generic ("fnum", GFC_ISYM_FNUM, GFC_STD_GNU);
1421 add_sym_1 ("fraction", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
1422 gfc_check_x, gfc_simplify_fraction, gfc_resolve_fraction,
1423 x, BT_REAL, dr, REQUIRED);
1425 make_generic ("fraction", GFC_ISYM_FRACTION, GFC_STD_F95);
1427 add_sym_2 ("fstat", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1428 gfc_check_fstat, NULL, gfc_resolve_fstat,
1429 a, BT_INTEGER, di, REQUIRED, b, BT_INTEGER, di, REQUIRED);
1431 make_generic ("fstat", GFC_ISYM_FSTAT, GFC_STD_GNU);
1433 add_sym_1 ("ftell", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, ii, GFC_STD_GNU,
1434 gfc_check_ftell, NULL, gfc_resolve_ftell,
1435 ut, BT_INTEGER, di, REQUIRED);
1437 make_generic ("ftell", GFC_ISYM_FTELL, GFC_STD_GNU);
1439 add_sym_2 ("fgetc", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1440 gfc_check_fgetputc, NULL, gfc_resolve_fgetc,
1441 ut, BT_INTEGER, di, REQUIRED, c, BT_CHARACTER, dc, REQUIRED);
1443 make_generic ("fgetc", GFC_ISYM_FGETC, GFC_STD_GNU);
1445 add_sym_1 ("fget", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1446 gfc_check_fgetput, NULL, gfc_resolve_fget,
1447 c, BT_CHARACTER, dc, REQUIRED);
1449 make_generic ("fget", GFC_ISYM_FGET, GFC_STD_GNU);
1451 add_sym_2 ("fputc", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1452 gfc_check_fgetputc, NULL, gfc_resolve_fputc,
1453 ut, BT_INTEGER, di, REQUIRED, c, BT_CHARACTER, dc, REQUIRED);
1455 make_generic ("fputc", GFC_ISYM_FPUTC, GFC_STD_GNU);
1457 add_sym_1 ("fput", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1458 gfc_check_fgetput, NULL, gfc_resolve_fput,
1459 c, BT_CHARACTER, dc, REQUIRED);
1461 make_generic ("fput", GFC_ISYM_FPUT, GFC_STD_GNU);
1463 /* Unix IDs (g77 compatibility) */
1464 add_sym_1 ("getcwd", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1465 NULL, NULL, gfc_resolve_getcwd,
1466 c, BT_CHARACTER, dc, REQUIRED);
1468 make_generic ("getcwd", GFC_ISYM_GETCWD, GFC_STD_GNU);
1470 add_sym_0 ("getgid", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1471 NULL, NULL, gfc_resolve_getgid);
1473 make_generic ("getgid", GFC_ISYM_GETGID, GFC_STD_GNU);
1475 add_sym_0 ("getpid", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1476 NULL, NULL, gfc_resolve_getpid);
1478 make_generic ("getpid", GFC_ISYM_GETPID, GFC_STD_GNU);
1480 add_sym_0 ("getuid", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1481 NULL, NULL, gfc_resolve_getuid);
1483 make_generic ("getuid", GFC_ISYM_GETUID, GFC_STD_GNU);
1485 add_sym_1 ("hostnm", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1486 gfc_check_hostnm, NULL, gfc_resolve_hostnm,
1487 a, BT_CHARACTER, dc, REQUIRED);
1489 make_generic ("hostnm", GFC_ISYM_HOSTNM, GFC_STD_GNU);
1491 add_sym_1 ("huge", NOT_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
1492 gfc_check_huge, gfc_simplify_huge, NULL,
1493 x, BT_UNKNOWN, dr, REQUIRED);
1495 make_generic ("huge", GFC_ISYM_NONE, GFC_STD_F95);
1497 add_sym_1 ("iachar", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1498 gfc_check_ichar_iachar, gfc_simplify_iachar, NULL,
1499 c, BT_CHARACTER, dc, REQUIRED);
1501 make_generic ("iachar", GFC_ISYM_IACHAR, GFC_STD_F95);
1503 add_sym_2 ("iand", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1504 gfc_check_iand, gfc_simplify_iand, gfc_resolve_iand,
1505 i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED);
1507 make_generic ("iand", GFC_ISYM_IAND, GFC_STD_F95);
1509 add_sym_2 ("and", ELEMENTAL, ACTUAL_NO, BT_UNKNOWN, 0, GFC_STD_GNU,
1510 gfc_check_and, gfc_simplify_and, gfc_resolve_and,
1511 i, BT_UNKNOWN, 0, REQUIRED, j, BT_UNKNOWN, 0, REQUIRED);
1513 make_generic ("and", GFC_ISYM_AND, GFC_STD_GNU);
1515 add_sym_0 ("iargc", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1516 NULL, NULL, NULL);
1518 make_generic ("iargc", GFC_ISYM_IARGC, GFC_STD_GNU);
1520 add_sym_2 ("ibclr", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1521 gfc_check_ibclr, gfc_simplify_ibclr, gfc_resolve_ibclr,
1522 i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED);
1524 make_generic ("ibclr", GFC_ISYM_IBCLR, GFC_STD_F95);
1526 add_sym_3 ("ibits", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1527 gfc_check_ibits, gfc_simplify_ibits, gfc_resolve_ibits,
1528 i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED,
1529 ln, BT_INTEGER, di, REQUIRED);
1531 make_generic ("ibits", GFC_ISYM_IBITS, GFC_STD_F95);
1533 add_sym_2 ("ibset", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1534 gfc_check_ibset, gfc_simplify_ibset, gfc_resolve_ibset,
1535 i, BT_INTEGER, di, REQUIRED, pos, BT_INTEGER, di, REQUIRED);
1537 make_generic ("ibset", GFC_ISYM_IBSET, GFC_STD_F95);
1539 add_sym_1 ("ichar", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F77,
1540 gfc_check_ichar_iachar, gfc_simplify_ichar, gfc_resolve_ichar,
1541 c, BT_CHARACTER, dc, REQUIRED);
1543 make_generic ("ichar", GFC_ISYM_ICHAR, GFC_STD_F77);
1545 add_sym_2 ("ieor", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1546 gfc_check_ieor, gfc_simplify_ieor, gfc_resolve_ieor,
1547 i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED);
1549 make_generic ("ieor", GFC_ISYM_IEOR, GFC_STD_F95);
1551 add_sym_2 ("xor", ELEMENTAL, ACTUAL_NO, BT_UNKNOWN, 0, GFC_STD_GNU,
1552 gfc_check_and, gfc_simplify_xor, gfc_resolve_xor,
1553 i, BT_UNKNOWN, 0, REQUIRED, j, BT_UNKNOWN, 0, REQUIRED);
1555 make_generic ("xor", GFC_ISYM_XOR, GFC_STD_GNU);
1557 add_sym_0 ("ierrno", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1558 NULL, NULL, gfc_resolve_ierrno);
1560 make_generic ("ierrno", GFC_ISYM_IERRNO, GFC_STD_GNU);
1562 /* The resolution function for INDEX is called gfc_resolve_index_func
1563 because the name gfc_resolve_index is already used in resolve.c. */
1564 add_sym_3 ("index", ELEMENTAL, ACTUAL_YES, BT_INTEGER, di, GFC_STD_F77,
1565 gfc_check_index, gfc_simplify_index, gfc_resolve_index_func,
1566 stg, BT_CHARACTER, dc, REQUIRED, ssg, BT_CHARACTER, dc, REQUIRED,
1567 bck, BT_LOGICAL, dl, OPTIONAL);
1569 make_generic ("index", GFC_ISYM_INDEX, GFC_STD_F77);
1571 add_sym_2 ("int", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F77,
1572 gfc_check_int, gfc_simplify_int, gfc_resolve_int,
1573 a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1575 add_sym_1 ("ifix", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F77,
1576 NULL, gfc_simplify_ifix, NULL,
1577 a, BT_REAL, dr, REQUIRED);
1579 add_sym_1 ("idint", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F77,
1580 NULL, gfc_simplify_idint, NULL,
1581 a, BT_REAL, dd, REQUIRED);
1583 make_generic ("int", GFC_ISYM_INT, GFC_STD_F77);
1585 add_sym_1 ("int2", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1586 gfc_check_intconv, gfc_simplify_int2, gfc_resolve_int2,
1587 a, BT_REAL, dr, REQUIRED);
1589 make_alias ("short", GFC_STD_GNU);
1591 make_generic ("int2", GFC_ISYM_INT2, GFC_STD_GNU);
1593 add_sym_1 ("int8", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1594 gfc_check_intconv, gfc_simplify_int8, gfc_resolve_int8,
1595 a, BT_REAL, dr, REQUIRED);
1597 make_generic ("int8", GFC_ISYM_INT8, GFC_STD_GNU);
1599 add_sym_1 ("long", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1600 gfc_check_intconv, gfc_simplify_long, gfc_resolve_long,
1601 a, BT_REAL, dr, REQUIRED);
1603 make_generic ("long", GFC_ISYM_LONG, GFC_STD_GNU);
1605 add_sym_2 ("ior", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1606 gfc_check_ior, gfc_simplify_ior, gfc_resolve_ior,
1607 i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED);
1609 make_generic ("ior", GFC_ISYM_IOR, GFC_STD_F95);
1611 add_sym_2 ("or", ELEMENTAL, ACTUAL_NO, BT_UNKNOWN, 0, GFC_STD_GNU,
1612 gfc_check_and, gfc_simplify_or, gfc_resolve_or,
1613 i, BT_UNKNOWN, 0, REQUIRED, j, BT_UNKNOWN, 0, REQUIRED);
1615 make_generic ("or", GFC_ISYM_OR, GFC_STD_GNU);
1617 /* The following function is for G77 compatibility. */
1618 add_sym_1 ("irand", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, 4, GFC_STD_GNU,
1619 gfc_check_irand, NULL, NULL,
1620 i, BT_INTEGER, 4, OPTIONAL);
1622 make_generic ("irand", GFC_ISYM_IRAND, GFC_STD_GNU);
1624 add_sym_1 ("isatty", NOT_ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_GNU,
1625 gfc_check_isatty, NULL, gfc_resolve_isatty,
1626 ut, BT_INTEGER, di, REQUIRED);
1628 make_generic ("isatty", GFC_ISYM_ISATTY, GFC_STD_GNU);
1630 add_sym_2 ("rshift", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1631 gfc_check_ishft, NULL, gfc_resolve_rshift,
1632 i, BT_INTEGER, di, REQUIRED, sh, BT_INTEGER, di, REQUIRED);
1634 make_generic ("rshift", GFC_ISYM_RSHIFT, GFC_STD_GNU);
1636 add_sym_2 ("lshift", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1637 gfc_check_ishft, NULL, gfc_resolve_lshift,
1638 i, BT_INTEGER, di, REQUIRED, sh, BT_INTEGER, di, REQUIRED);
1640 make_generic ("lshift", GFC_ISYM_LSHIFT, GFC_STD_GNU);
1642 add_sym_2 ("ishft", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1643 gfc_check_ishft, gfc_simplify_ishft, gfc_resolve_ishft,
1644 i, BT_INTEGER, di, REQUIRED, sh, BT_INTEGER, di, REQUIRED);
1646 make_generic ("ishft", GFC_ISYM_ISHFT, GFC_STD_F95);
1648 add_sym_3 ("ishftc", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1649 gfc_check_ishftc, gfc_simplify_ishftc, gfc_resolve_ishftc,
1650 i, BT_INTEGER, di, REQUIRED, sh, BT_INTEGER, di, REQUIRED,
1651 sz, BT_INTEGER, di, OPTIONAL);
1653 make_generic ("ishftc", GFC_ISYM_ISHFTC, GFC_STD_F95);
1655 add_sym_2 ("kill", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1656 gfc_check_kill, NULL, gfc_resolve_kill,
1657 a, BT_INTEGER, di, REQUIRED, b, BT_INTEGER, di, REQUIRED);
1659 make_generic ("kill", GFC_ISYM_KILL, GFC_STD_GNU);
1661 add_sym_1 ("kind", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1662 gfc_check_kind, gfc_simplify_kind, NULL,
1663 x, BT_REAL, dr, REQUIRED);
1665 make_generic ("kind", GFC_ISYM_NONE, GFC_STD_F95);
1667 add_sym_2 ("lbound", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1668 gfc_check_lbound, gfc_simplify_lbound, gfc_resolve_lbound,
1669 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, di, OPTIONAL);
1671 make_generic ("lbound", GFC_ISYM_LBOUND, GFC_STD_F95);
1673 add_sym_1 ("len", NOT_ELEMENTAL, ACTUAL_YES, BT_INTEGER, di, GFC_STD_F77,
1674 NULL, gfc_simplify_len, gfc_resolve_len,
1675 stg, BT_CHARACTER, dc, REQUIRED);
1677 make_generic ("len", GFC_ISYM_LEN, GFC_STD_F77);
1679 add_sym_1 ("len_trim", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1680 NULL, gfc_simplify_len_trim, gfc_resolve_len_trim,
1681 stg, BT_CHARACTER, dc, REQUIRED);
1683 make_alias ("lnblnk", GFC_STD_GNU);
1685 make_generic ("len_trim", GFC_ISYM_LEN_TRIM, GFC_STD_F95);
1687 add_sym_2 ("lge", ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_F77,
1688 NULL, gfc_simplify_lge, NULL,
1689 sta, BT_CHARACTER, dc, REQUIRED, stb, BT_CHARACTER, dc, REQUIRED);
1691 make_generic ("lge", GFC_ISYM_LGE, GFC_STD_F77);
1693 add_sym_2 ("lgt", ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_F77,
1694 NULL, gfc_simplify_lgt, NULL,
1695 sta, BT_CHARACTER, dc, REQUIRED, stb, BT_CHARACTER, dc, REQUIRED);
1697 make_generic ("lgt", GFC_ISYM_LGT, GFC_STD_F77);
1699 add_sym_2 ("lle", ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_F77,
1700 NULL, gfc_simplify_lle, NULL,
1701 sta, BT_CHARACTER, dc, REQUIRED, stb, BT_CHARACTER, dc, REQUIRED);
1703 make_generic ("lle", GFC_ISYM_LLE, GFC_STD_F77);
1705 add_sym_2 ("llt", ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_F77,
1706 NULL, gfc_simplify_llt, NULL,
1707 sta, BT_CHARACTER, dc, REQUIRED, stb, BT_CHARACTER, dc, REQUIRED);
1709 make_generic ("llt", GFC_ISYM_LLT, GFC_STD_F77);
1711 add_sym_2 ("link", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1712 gfc_check_link, NULL, gfc_resolve_link,
1713 a, BT_CHARACTER, dc, REQUIRED, b, BT_CHARACTER, dc, REQUIRED);
1715 make_generic ("link", GFC_ISYM_LINK, GFC_STD_GNU);
1717 add_sym_1 ("log", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
1718 gfc_check_fn_rc, gfc_simplify_log, gfc_resolve_log,
1719 x, BT_REAL, dr, REQUIRED);
1721 add_sym_1 ("alog", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1722 NULL, gfc_simplify_log, gfc_resolve_log,
1723 x, BT_REAL, dr, REQUIRED);
1725 add_sym_1 ("dlog", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1726 NULL, gfc_simplify_log, gfc_resolve_log,
1727 x, BT_REAL, dd, REQUIRED);
1729 add_sym_1 ("clog", ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dz, GFC_STD_F77,
1730 NULL, gfc_simplify_log, gfc_resolve_log,
1731 x, BT_COMPLEX, dz, REQUIRED);
1733 add_sym_1 ("zlog", ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dd, GFC_STD_GNU,
1734 NULL, gfc_simplify_log, gfc_resolve_log,
1735 x, BT_COMPLEX, dd, REQUIRED);
1737 make_alias ("cdlog", GFC_STD_GNU);
1739 make_generic ("log", GFC_ISYM_LOG, GFC_STD_F77);
1741 add_sym_1 ("log10", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
1742 gfc_check_fn_r, gfc_simplify_log10, gfc_resolve_log10,
1743 x, BT_REAL, dr, REQUIRED);
1745 add_sym_1 ("alog10", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1746 NULL, gfc_simplify_log10, gfc_resolve_log10,
1747 x, BT_REAL, dr, REQUIRED);
1749 add_sym_1 ("dlog10", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1750 NULL, gfc_simplify_log10, gfc_resolve_log10,
1751 x, BT_REAL, dd, REQUIRED);
1753 make_generic ("log10", GFC_ISYM_LOG10, GFC_STD_F77);
1755 add_sym_2 ("logical", ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_F95,
1756 gfc_check_logical, gfc_simplify_logical, gfc_resolve_logical,
1757 l, BT_LOGICAL, dl, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1759 make_generic ("logical", GFC_ISYM_LOGICAL, GFC_STD_F95);
1761 add_sym_2 ("lstat", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1762 gfc_check_stat, NULL, gfc_resolve_lstat,
1763 a, BT_CHARACTER, dc, REQUIRED, b, BT_INTEGER, di, REQUIRED);
1765 make_generic ("lstat", GFC_ISYM_LSTAT, GFC_STD_GNU);
1767 add_sym_1 ("malloc", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, ii, GFC_STD_GNU,
1768 gfc_check_malloc, NULL, gfc_resolve_malloc, a, BT_INTEGER, di,
1769 REQUIRED);
1771 make_generic ("malloc", GFC_ISYM_MALLOC, GFC_STD_GNU);
1773 add_sym_2 ("matmul", NOT_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
1774 gfc_check_matmul, NULL, gfc_resolve_matmul,
1775 ma, BT_REAL, dr, REQUIRED, mb, BT_REAL, dr, REQUIRED);
1777 make_generic ("matmul", GFC_ISYM_MATMUL, GFC_STD_F95);
1779 /* Note: amax0 is equivalent to real(max), max1 is equivalent to
1780 int(max). The max function must take at least two arguments. */
1782 add_sym_1m ("max", ELEMENTAL, ACTUAL_NO, BT_UNKNOWN, 0, GFC_STD_F77,
1783 gfc_check_min_max, gfc_simplify_max, gfc_resolve_max,
1784 a1, BT_UNKNOWN, dr, REQUIRED, a2, BT_UNKNOWN, dr, REQUIRED);
1786 add_sym_1m ("max0", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F77,
1787 gfc_check_min_max_integer, gfc_simplify_max, NULL,
1788 a1, BT_INTEGER, di, REQUIRED, a2, BT_INTEGER, di, REQUIRED);
1790 add_sym_1m ("amax0", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
1791 gfc_check_min_max_integer, gfc_simplify_max, NULL,
1792 a1, BT_INTEGER, di, REQUIRED, a2, BT_INTEGER, di, REQUIRED);
1794 add_sym_1m ("amax1", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
1795 gfc_check_min_max_real, gfc_simplify_max, NULL,
1796 a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED);
1798 add_sym_1m ("max1", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F77,
1799 gfc_check_min_max_real, gfc_simplify_max, NULL,
1800 a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED);
1802 add_sym_1m ("dmax1", ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_F77,
1803 gfc_check_min_max_double, gfc_simplify_max, NULL,
1804 a1, BT_REAL, dd, REQUIRED, a2, BT_REAL, dd, REQUIRED);
1806 make_generic ("max", GFC_ISYM_MAX, GFC_STD_F77);
1808 add_sym_1 ("maxexponent", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di,
1809 GFC_STD_F95, gfc_check_x, gfc_simplify_maxexponent, NULL,
1810 x, BT_UNKNOWN, dr, REQUIRED);
1812 make_generic ("maxexponent", GFC_ISYM_NONE, GFC_STD_F95);
1814 add_sym_3ml ("maxloc", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1815 gfc_check_minloc_maxloc, NULL, gfc_resolve_maxloc,
1816 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
1817 msk, BT_LOGICAL, dl, OPTIONAL);
1819 make_generic ("maxloc", GFC_ISYM_MAXLOC, GFC_STD_F95);
1821 add_sym_3red ("maxval", NOT_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
1822 gfc_check_minval_maxval, NULL, gfc_resolve_maxval,
1823 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
1824 msk, BT_LOGICAL, dl, OPTIONAL);
1826 make_generic ("maxval", GFC_ISYM_MAXVAL, GFC_STD_F95);
1828 add_sym_0 ("mclock", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1829 NULL, NULL, gfc_resolve_mclock);
1831 make_generic ("mclock", GFC_ISYM_MCLOCK, GFC_STD_GNU);
1833 add_sym_0 ("mclock8", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
1834 NULL, NULL, gfc_resolve_mclock8);
1836 make_generic ("mclock8", GFC_ISYM_MCLOCK8, GFC_STD_GNU);
1838 add_sym_3 ("merge", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
1839 gfc_check_merge, NULL, gfc_resolve_merge,
1840 ts, BT_REAL, dr, REQUIRED, fs, BT_REAL, dr, REQUIRED,
1841 msk, BT_LOGICAL, dl, REQUIRED);
1843 make_generic ("merge", GFC_ISYM_MERGE, GFC_STD_F95);
1845 /* Note: amin0 is equivalent to real(min), min1 is equivalent to
1846 int(min). */
1848 add_sym_1m ("min", ELEMENTAL, ACTUAL_NO, BT_UNKNOWN, 0, GFC_STD_F77,
1849 gfc_check_min_max, gfc_simplify_min, gfc_resolve_min,
1850 a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED);
1852 add_sym_1m ("min0", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F77,
1853 gfc_check_min_max_integer, gfc_simplify_min, NULL,
1854 a1, BT_INTEGER, di, REQUIRED, a2, BT_INTEGER, di, REQUIRED);
1856 add_sym_1m ("amin0", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
1857 gfc_check_min_max_integer, gfc_simplify_min, NULL,
1858 a1, BT_INTEGER, di, REQUIRED, a2, BT_INTEGER, di, REQUIRED);
1860 add_sym_1m ("amin1", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
1861 gfc_check_min_max_real, gfc_simplify_min, NULL,
1862 a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED);
1864 add_sym_1m ("min1", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F77,
1865 gfc_check_min_max_real, gfc_simplify_min, NULL,
1866 a1, BT_REAL, dr, REQUIRED, a2, BT_REAL, dr, REQUIRED);
1868 add_sym_1m ("dmin1", ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_F77,
1869 gfc_check_min_max_double, gfc_simplify_min, NULL,
1870 a1, BT_REAL, dd, REQUIRED, a2, BT_REAL, dd, REQUIRED);
1872 make_generic ("min", GFC_ISYM_MIN, GFC_STD_F77);
1874 add_sym_1 ("minexponent", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di,
1875 GFC_STD_F95, gfc_check_x, gfc_simplify_minexponent, NULL,
1876 x, BT_UNKNOWN, dr, REQUIRED);
1878 make_generic ("minexponent", GFC_ISYM_NONE, GFC_STD_F95);
1880 add_sym_3ml ("minloc", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1881 gfc_check_minloc_maxloc, NULL, gfc_resolve_minloc,
1882 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
1883 msk, BT_LOGICAL, dl, OPTIONAL);
1885 make_generic ("minloc", GFC_ISYM_MINLOC, GFC_STD_F95);
1887 add_sym_3red ("minval", NOT_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
1888 gfc_check_minval_maxval, NULL, gfc_resolve_minval,
1889 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
1890 msk, BT_LOGICAL, dl, OPTIONAL);
1892 make_generic ("minval", GFC_ISYM_MINVAL, GFC_STD_F95);
1894 add_sym_2 ("mod", ELEMENTAL, ACTUAL_YES, BT_INTEGER, di, GFC_STD_F77,
1895 gfc_check_a_p, gfc_simplify_mod, gfc_resolve_mod,
1896 a, BT_INTEGER, di, REQUIRED, p, BT_INTEGER, di, REQUIRED);
1898 add_sym_2 ("amod", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
1899 NULL, gfc_simplify_mod, gfc_resolve_mod,
1900 a, BT_REAL, dr, REQUIRED, p, BT_REAL, dr, REQUIRED);
1902 add_sym_2 ("dmod", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
1903 NULL, gfc_simplify_mod, gfc_resolve_mod,
1904 a, BT_REAL, dd, REQUIRED, p, BT_REAL, dd, REQUIRED);
1906 make_generic ("mod", GFC_ISYM_MOD, GFC_STD_F77);
1908 add_sym_2 ("modulo", ELEMENTAL, ACTUAL_NO, BT_REAL, di, GFC_STD_F95,
1909 gfc_check_a_p, gfc_simplify_modulo, gfc_resolve_modulo,
1910 a, BT_REAL, di, REQUIRED, p, BT_REAL, di, REQUIRED);
1912 make_generic ("modulo", GFC_ISYM_MODULO, GFC_STD_F95);
1914 add_sym_2 ("nearest", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
1915 gfc_check_nearest, gfc_simplify_nearest, gfc_resolve_nearest,
1916 x, BT_REAL, dr, REQUIRED, s, BT_REAL, dr, REQUIRED);
1918 make_generic ("nearest", GFC_ISYM_NEAREST, GFC_STD_F95);
1920 add_sym_1 ("new_line", NOT_ELEMENTAL, ACTUAL_NO, BT_CHARACTER, dc,
1921 GFC_STD_F2003, gfc_check_new_line, gfc_simplify_new_line, NULL,
1922 i, BT_CHARACTER, dc, REQUIRED);
1924 add_sym_2 ("nint", ELEMENTAL, ACTUAL_YES, BT_INTEGER, di, GFC_STD_F77,
1925 gfc_check_a_ikind, gfc_simplify_nint, gfc_resolve_nint,
1926 a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1928 add_sym_1 ("idnint", ELEMENTAL, ACTUAL_YES, BT_INTEGER, di, GFC_STD_F77,
1929 gfc_check_idnint, gfc_simplify_idnint, gfc_resolve_idnint,
1930 a, BT_REAL, dd, REQUIRED);
1932 make_generic ("nint", GFC_ISYM_NINT, GFC_STD_F77);
1934 add_sym_1 ("not", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1935 gfc_check_i, gfc_simplify_not, gfc_resolve_not,
1936 i, BT_INTEGER, di, REQUIRED);
1938 make_generic ("not", GFC_ISYM_NOT, GFC_STD_F95);
1940 add_sym_1 ("null", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1941 gfc_check_null, gfc_simplify_null, NULL,
1942 mo, BT_INTEGER, di, OPTIONAL);
1944 make_generic ("null", GFC_ISYM_NONE, GFC_STD_F95);
1946 add_sym_3 ("pack", NOT_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
1947 gfc_check_pack, NULL, gfc_resolve_pack,
1948 ar, BT_REAL, dr, REQUIRED, msk, BT_LOGICAL, dl, REQUIRED,
1949 v, BT_REAL, dr, OPTIONAL);
1951 make_generic ("pack", GFC_ISYM_PACK, GFC_STD_F95);
1953 add_sym_1 ("precision", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1954 gfc_check_precision, gfc_simplify_precision, NULL,
1955 x, BT_UNKNOWN, 0, REQUIRED);
1957 make_generic ("precision", GFC_ISYM_NONE, GFC_STD_F95);
1959 add_sym_1 ("present", NOT_ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_F95,
1960 gfc_check_present, NULL, NULL,
1961 a, BT_REAL, dr, REQUIRED);
1963 make_generic ("present", GFC_ISYM_PRESENT, GFC_STD_F95);
1965 add_sym_3red ("product", NOT_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
1966 gfc_check_product_sum, NULL, gfc_resolve_product,
1967 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
1968 msk, BT_LOGICAL, dl, OPTIONAL);
1970 make_generic ("product", GFC_ISYM_PRODUCT, GFC_STD_F95);
1972 add_sym_1 ("radix", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1973 gfc_check_radix, gfc_simplify_radix, NULL,
1974 x, BT_UNKNOWN, 0, REQUIRED);
1976 make_generic ("radix", GFC_ISYM_NONE, GFC_STD_F95);
1978 /* The following function is for G77 compatibility. */
1979 add_sym_1 ("rand", NOT_ELEMENTAL, ACTUAL_NO, BT_REAL, 4, GFC_STD_GNU,
1980 gfc_check_rand, NULL, NULL,
1981 i, BT_INTEGER, 4, OPTIONAL);
1983 /* Compatibility with HP FORTRAN 77/iX Reference. Note, rand() and ran()
1984 use slightly different shoddy multiplicative congruential PRNG. */
1985 make_alias ("ran", GFC_STD_GNU);
1987 make_generic ("rand", GFC_ISYM_RAND, GFC_STD_GNU);
1989 add_sym_1 ("range", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
1990 gfc_check_range, gfc_simplify_range, NULL,
1991 x, BT_REAL, dr, REQUIRED);
1993 make_generic ("range", GFC_ISYM_NONE, GFC_STD_F95);
1995 add_sym_2 ("real", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
1996 gfc_check_real, gfc_simplify_real, gfc_resolve_real,
1997 a, BT_UNKNOWN, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
1999 /* This provides compatibility with g77. */
2000 add_sym_1 ("realpart", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
2001 gfc_check_fn_c, gfc_simplify_realpart, gfc_resolve_realpart,
2002 a, BT_UNKNOWN, dr, REQUIRED);
2004 add_sym_1 ("float", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
2005 gfc_check_i, gfc_simplify_float, NULL,
2006 a, BT_INTEGER, di, REQUIRED);
2008 add_sym_1 ("sngl", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
2009 NULL, gfc_simplify_sngl, NULL,
2010 a, BT_REAL, dd, REQUIRED);
2012 make_generic ("real", GFC_ISYM_REAL, GFC_STD_F77);
2014 add_sym_2 ("rename", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
2015 gfc_check_rename, NULL, gfc_resolve_rename,
2016 a, BT_CHARACTER, dc, REQUIRED, b, BT_CHARACTER, dc, REQUIRED);
2018 make_generic ("rename", GFC_ISYM_RENAME, GFC_STD_GNU);
2020 add_sym_2 ("repeat", NOT_ELEMENTAL, ACTUAL_NO, BT_CHARACTER, dc, GFC_STD_F95,
2021 gfc_check_repeat, gfc_simplify_repeat, gfc_resolve_repeat,
2022 stg, BT_CHARACTER, dc, REQUIRED, n, BT_INTEGER, di, REQUIRED);
2024 make_generic ("repeat", GFC_ISYM_REPEAT, GFC_STD_F95);
2026 add_sym_4 ("reshape", NOT_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2027 gfc_check_reshape, gfc_simplify_reshape, gfc_resolve_reshape,
2028 src, BT_REAL, dr, REQUIRED, shp, BT_INTEGER, ii, REQUIRED,
2029 pad, BT_REAL, dr, OPTIONAL, ord, BT_INTEGER, ii, OPTIONAL);
2031 make_generic ("reshape", GFC_ISYM_RESHAPE, GFC_STD_F95);
2033 add_sym_1 ("rrspacing", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2034 gfc_check_x, gfc_simplify_rrspacing, gfc_resolve_rrspacing,
2035 x, BT_REAL, dr, REQUIRED);
2037 make_generic ("rrspacing", GFC_ISYM_RRSPACING, GFC_STD_F95);
2039 add_sym_2 ("scale", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2040 gfc_check_scale, gfc_simplify_scale, gfc_resolve_scale,
2041 x, BT_REAL, dr, REQUIRED, i, BT_INTEGER, di, REQUIRED);
2043 make_generic ("scale", GFC_ISYM_SCALE, GFC_STD_F95);
2045 add_sym_3 ("scan", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
2046 gfc_check_scan, gfc_simplify_scan, gfc_resolve_scan,
2047 stg, BT_CHARACTER, dc, REQUIRED, set, BT_CHARACTER, dc, REQUIRED,
2048 bck, BT_LOGICAL, dl, OPTIONAL);
2050 make_generic ("scan", GFC_ISYM_SCAN, GFC_STD_F95);
2052 /* Added for G77 compatibility garbage. */
2053 add_sym_0 ("second", NOT_ELEMENTAL, ACTUAL_NO, BT_REAL, 4, GFC_STD_GNU,
2054 NULL, NULL, NULL);
2056 make_generic ("second", GFC_ISYM_SECOND, GFC_STD_GNU);
2058 /* Added for G77 compatibility. */
2059 add_sym_1 ("secnds", NOT_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
2060 gfc_check_secnds, NULL, gfc_resolve_secnds,
2061 x, BT_REAL, dr, REQUIRED);
2063 make_generic ("secnds", GFC_ISYM_SECNDS, GFC_STD_GNU);
2065 add_sym_1 ("selected_int_kind", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di,
2066 GFC_STD_F95, gfc_check_selected_int_kind,
2067 gfc_simplify_selected_int_kind, NULL, r, BT_INTEGER, di, REQUIRED);
2069 make_generic ("selected_int_kind", GFC_ISYM_SI_KIND, GFC_STD_F95);
2071 add_sym_2 ("selected_real_kind", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di,
2072 GFC_STD_F95, gfc_check_selected_real_kind,
2073 gfc_simplify_selected_real_kind, NULL,
2074 p, BT_INTEGER, di, OPTIONAL, r, BT_INTEGER, di, OPTIONAL);
2076 make_generic ("selected_real_kind", GFC_ISYM_SR_KIND, GFC_STD_F95);
2078 add_sym_2 ("set_exponent", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2079 gfc_check_set_exponent, gfc_simplify_set_exponent,
2080 gfc_resolve_set_exponent,
2081 x, BT_REAL, dr, REQUIRED, i, BT_INTEGER, di, REQUIRED);
2083 make_generic ("set_exponent", GFC_ISYM_SET_EXPONENT, GFC_STD_F95);
2085 add_sym_1 ("shape", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
2086 gfc_check_shape, gfc_simplify_shape, gfc_resolve_shape,
2087 src, BT_REAL, dr, REQUIRED);
2089 make_generic ("shape", GFC_ISYM_SHAPE, GFC_STD_F95);
2091 add_sym_2 ("sign", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
2092 gfc_check_sign, gfc_simplify_sign, gfc_resolve_sign,
2093 a, BT_REAL, dr, REQUIRED, b, BT_REAL, dr, REQUIRED);
2095 add_sym_2 ("isign", ELEMENTAL, ACTUAL_YES, BT_INTEGER, di, GFC_STD_F77,
2096 NULL, gfc_simplify_sign, gfc_resolve_sign,
2097 a, BT_INTEGER, di, REQUIRED, b, BT_INTEGER, di, REQUIRED);
2099 add_sym_2 ("dsign", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
2100 NULL, gfc_simplify_sign, gfc_resolve_sign,
2101 a, BT_REAL, dd, REQUIRED, b, BT_REAL, dd, REQUIRED);
2103 make_generic ("sign", GFC_ISYM_SIGN, GFC_STD_F77);
2105 add_sym_2 ("signal", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
2106 gfc_check_signal, NULL, gfc_resolve_signal,
2107 num, BT_INTEGER, di, REQUIRED, han, BT_UNKNOWN, 0, REQUIRED);
2109 make_generic ("signal", GFC_ISYM_SIGNAL, GFC_STD_GNU);
2111 add_sym_1 ("sin", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
2112 gfc_check_fn_rc, gfc_simplify_sin, gfc_resolve_sin,
2113 x, BT_REAL, dr, REQUIRED);
2115 add_sym_1 ("dsin", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
2116 NULL, gfc_simplify_sin, gfc_resolve_sin,
2117 x, BT_REAL, dd, REQUIRED);
2119 add_sym_1 ("csin", ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dz, GFC_STD_F77,
2120 NULL, gfc_simplify_sin, gfc_resolve_sin,
2121 x, BT_COMPLEX, dz, REQUIRED);
2123 add_sym_1 ("zsin", ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dd, GFC_STD_GNU,
2124 NULL, gfc_simplify_sin, gfc_resolve_sin,
2125 x, BT_COMPLEX, dd, REQUIRED);
2127 make_alias ("cdsin", GFC_STD_GNU);
2129 make_generic ("sin", GFC_ISYM_SIN, GFC_STD_F77);
2131 add_sym_1 ("sinh", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
2132 gfc_check_fn_r, gfc_simplify_sinh, gfc_resolve_sinh,
2133 x, BT_REAL, dr, REQUIRED);
2135 add_sym_1 ("dsinh", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
2136 NULL, gfc_simplify_sinh, gfc_resolve_sinh,
2137 x, BT_REAL, dd, REQUIRED);
2139 make_generic ("sinh", GFC_ISYM_SINH, GFC_STD_F77);
2141 add_sym_2 ("size", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
2142 gfc_check_size, gfc_simplify_size, NULL,
2143 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL);
2145 make_generic ("size", GFC_ISYM_SIZE, GFC_STD_F95);
2147 add_sym_1 ("spacing", ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2148 gfc_check_x, gfc_simplify_spacing, gfc_resolve_spacing,
2149 x, BT_REAL, dr, REQUIRED);
2151 make_generic ("spacing", GFC_ISYM_SPACING, GFC_STD_F95);
2153 add_sym_3 ("spread", NOT_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2154 gfc_check_spread, NULL, gfc_resolve_spread,
2155 src, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, REQUIRED,
2156 n, BT_INTEGER, di, REQUIRED);
2158 make_generic ("spread", GFC_ISYM_SPREAD, GFC_STD_F95);
2160 add_sym_1 ("sqrt", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
2161 gfc_check_fn_rc, gfc_simplify_sqrt, gfc_resolve_sqrt,
2162 x, BT_REAL, dr, REQUIRED);
2164 add_sym_1 ("dsqrt", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
2165 NULL, gfc_simplify_sqrt, gfc_resolve_sqrt,
2166 x, BT_REAL, dd, REQUIRED);
2168 add_sym_1 ("csqrt", ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dz, GFC_STD_F77,
2169 NULL, gfc_simplify_sqrt, gfc_resolve_sqrt,
2170 x, BT_COMPLEX, dz, REQUIRED);
2172 add_sym_1 ("zsqrt", ELEMENTAL, ACTUAL_YES, BT_COMPLEX, dd, GFC_STD_GNU,
2173 NULL, gfc_simplify_sqrt, gfc_resolve_sqrt,
2174 x, BT_COMPLEX, dd, REQUIRED);
2176 make_alias ("cdsqrt", GFC_STD_GNU);
2178 make_generic ("sqrt", GFC_ISYM_SQRT, GFC_STD_F77);
2180 add_sym_2 ("stat", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
2181 gfc_check_stat, NULL, gfc_resolve_stat,
2182 a, BT_CHARACTER, dc, REQUIRED, b, BT_INTEGER, di, REQUIRED);
2184 make_generic ("stat", GFC_ISYM_STAT, GFC_STD_GNU);
2186 add_sym_3red ("sum", NOT_ELEMENTAL, ACTUAL_NO, BT_UNKNOWN, 0, GFC_STD_F95,
2187 gfc_check_product_sum, NULL, gfc_resolve_sum,
2188 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL,
2189 msk, BT_LOGICAL, dl, OPTIONAL);
2191 make_generic ("sum", GFC_ISYM_SUM, GFC_STD_F95);
2193 add_sym_2 ("symlnk", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
2194 gfc_check_symlnk, NULL, gfc_resolve_symlnk,
2195 a, BT_CHARACTER, dc, REQUIRED, b, BT_CHARACTER, dc, REQUIRED);
2197 make_generic ("symlnk", GFC_ISYM_SYMLNK, GFC_STD_GNU);
2199 add_sym_1 ("system", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
2200 NULL, NULL, NULL,
2201 c, BT_CHARACTER, dc, REQUIRED);
2203 make_generic ("system", GFC_ISYM_SYSTEM, GFC_STD_GNU);
2205 add_sym_1 ("tan", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
2206 gfc_check_fn_r, gfc_simplify_tan, gfc_resolve_tan,
2207 x, BT_REAL, dr, REQUIRED);
2209 add_sym_1 ("dtan", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
2210 NULL, gfc_simplify_tan, gfc_resolve_tan,
2211 x, BT_REAL, dd, REQUIRED);
2213 make_generic ("tan", GFC_ISYM_TAN, GFC_STD_F77);
2215 add_sym_1 ("tanh", ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
2216 gfc_check_fn_r, gfc_simplify_tanh, gfc_resolve_tanh,
2217 x, BT_REAL, dr, REQUIRED);
2219 add_sym_1 ("dtanh", ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
2220 NULL, gfc_simplify_tanh, gfc_resolve_tanh,
2221 x, BT_REAL, dd, REQUIRED);
2223 make_generic ("tanh", GFC_ISYM_TANH, GFC_STD_F77);
2225 add_sym_0 ("time", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
2226 NULL, NULL, gfc_resolve_time);
2228 make_generic ("time", GFC_ISYM_TIME, GFC_STD_GNU);
2230 add_sym_0 ("time8", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
2231 NULL, NULL, gfc_resolve_time8);
2233 make_generic ("time8", GFC_ISYM_TIME8, GFC_STD_GNU);
2235 add_sym_1 ("tiny", NOT_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2236 gfc_check_x, gfc_simplify_tiny, NULL,
2237 x, BT_REAL, dr, REQUIRED);
2239 make_generic ("tiny", GFC_ISYM_NONE, GFC_STD_F95);
2241 add_sym_3 ("transfer", NOT_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2242 gfc_check_transfer, gfc_simplify_transfer, gfc_resolve_transfer,
2243 src, BT_REAL, dr, REQUIRED, mo, BT_REAL, dr, REQUIRED,
2244 sz, BT_INTEGER, di, OPTIONAL);
2246 make_generic ("transfer", GFC_ISYM_TRANSFER, GFC_STD_F95);
2248 add_sym_1 ("transpose", NOT_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2249 gfc_check_transpose, NULL, gfc_resolve_transpose,
2250 m, BT_REAL, dr, REQUIRED);
2252 make_generic ("transpose", GFC_ISYM_TRANSPOSE, GFC_STD_F95);
2254 add_sym_1 ("trim", NOT_ELEMENTAL, ACTUAL_NO, BT_CHARACTER, dc, GFC_STD_F95,
2255 gfc_check_trim, gfc_simplify_trim, gfc_resolve_trim,
2256 stg, BT_CHARACTER, dc, REQUIRED);
2258 make_generic ("trim", GFC_ISYM_TRIM, GFC_STD_F95);
2260 add_sym_1 ("ttynam", NOT_ELEMENTAL, ACTUAL_NO, BT_CHARACTER, 0, GFC_STD_GNU,
2261 gfc_check_ttynam, NULL, gfc_resolve_ttynam,
2262 ut, BT_INTEGER, di, REQUIRED);
2264 make_generic ("ttynam", GFC_ISYM_TTYNAM, GFC_STD_GNU);
2266 add_sym_2 ("ubound", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
2267 gfc_check_ubound, gfc_simplify_ubound, gfc_resolve_ubound,
2268 ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL);
2270 make_generic ("ubound", GFC_ISYM_UBOUND, GFC_STD_F95);
2272 /* g77 compatibility for UMASK. */
2273 add_sym_1 ("umask", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
2274 gfc_check_umask, NULL, gfc_resolve_umask,
2275 a, BT_INTEGER, di, REQUIRED);
2277 make_generic ("umask", GFC_ISYM_UMASK, GFC_STD_GNU);
2279 /* g77 compatibility for UNLINK. */
2280 add_sym_1 ("unlink", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_GNU,
2281 gfc_check_unlink, NULL, gfc_resolve_unlink,
2282 a, BT_CHARACTER, dc, REQUIRED);
2284 make_generic ("unlink", GFC_ISYM_UNLINK, GFC_STD_GNU);
2286 add_sym_3 ("unpack", NOT_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F95,
2287 gfc_check_unpack, NULL, gfc_resolve_unpack,
2288 v, BT_REAL, dr, REQUIRED, msk, BT_LOGICAL, dl, REQUIRED,
2289 f, BT_REAL, dr, REQUIRED);
2291 make_generic ("unpack", GFC_ISYM_UNPACK, GFC_STD_F95);
2293 add_sym_3 ("verify", ELEMENTAL, ACTUAL_NO, BT_INTEGER, di, GFC_STD_F95,
2294 gfc_check_verify, gfc_simplify_verify, gfc_resolve_verify,
2295 stg, BT_CHARACTER, dc, REQUIRED, set, BT_CHARACTER, dc, REQUIRED,
2296 bck, BT_LOGICAL, dl, OPTIONAL);
2298 make_generic ("verify", GFC_ISYM_VERIFY, GFC_STD_F95);
2300 add_sym_1 ("loc", NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, ii, GFC_STD_GNU,
2301 gfc_check_loc, NULL, gfc_resolve_loc,
2302 ar, BT_UNKNOWN, 0, REQUIRED);
2304 make_generic ("loc", GFC_ISYM_LOC, GFC_STD_GNU);
2309 /* Add intrinsic subroutines. */
2311 static void
2312 add_subroutines (void)
2314 /* Argument names as in the standard (to be used as argument keywords). */
2315 const char
2316 *h = "harvest", *dt = "date", *vl = "values", *pt = "put",
2317 *c = "count", *tm = "time", *tp = "topos", *gt = "get",
2318 *t = "to", *zn = "zone", *fp = "frompos", *cm = "count_max",
2319 *f = "from", *sz = "size", *ln = "len", *cr = "count_rate",
2320 *com = "command", *length = "length", *st = "status",
2321 *val = "value", *num = "number", *name = "name",
2322 *trim_name = "trim_name", *ut = "unit", *han = "handler",
2323 *sec = "seconds", *res = "result", *of = "offset", *md = "mode";
2325 int di, dr, dc, dl, ii;
2327 di = gfc_default_integer_kind;
2328 dr = gfc_default_real_kind;
2329 dc = gfc_default_character_kind;
2330 dl = gfc_default_logical_kind;
2331 ii = gfc_index_integer_kind;
2333 add_sym_0s ("abort", GFC_STD_GNU, NULL);
2335 if ((gfc_option.allow_std & GFC_STD_GNU) || gfc_option.flag_all_intrinsics)
2336 make_noreturn();
2338 add_sym_1s ("cpu_time", 0, BT_UNKNOWN, 0, GFC_STD_F95,
2339 gfc_check_cpu_time, NULL, gfc_resolve_cpu_time,
2340 tm, BT_REAL, dr, REQUIRED);
2342 /* More G77 compatibility garbage. */
2343 add_sym_2s ("ctime", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2344 gfc_check_ctime_sub, NULL, gfc_resolve_ctime_sub,
2345 tm, BT_INTEGER, di, REQUIRED, res, BT_CHARACTER, dc, REQUIRED);
2347 add_sym_1s ("idate", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2348 gfc_check_itime_idate, NULL, gfc_resolve_idate,
2349 vl, BT_INTEGER, 4, REQUIRED);
2351 add_sym_1s ("itime", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2352 gfc_check_itime_idate, NULL, gfc_resolve_itime,
2353 vl, BT_INTEGER, 4, REQUIRED);
2355 add_sym_2s ("ltime", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2356 gfc_check_ltime_gmtime, NULL, gfc_resolve_ltime,
2357 tm, BT_INTEGER, di, REQUIRED, vl, BT_INTEGER, di, REQUIRED);
2359 add_sym_2s ("gmtime", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2360 gfc_check_ltime_gmtime, NULL, gfc_resolve_gmtime,
2361 tm, BT_INTEGER, di, REQUIRED, vl, BT_INTEGER, di, REQUIRED);
2363 add_sym_1s ("second", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2364 gfc_check_second_sub, NULL, gfc_resolve_second_sub,
2365 tm, BT_REAL, dr, REQUIRED);
2367 add_sym_2s ("chdir", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2368 gfc_check_chdir_sub, NULL, gfc_resolve_chdir_sub,
2369 name, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2371 add_sym_3s ("chmod", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2372 gfc_check_chmod_sub, NULL, gfc_resolve_chmod_sub,
2373 name, BT_CHARACTER, dc, REQUIRED, md, BT_CHARACTER, dc, REQUIRED,
2374 st, BT_INTEGER, di, OPTIONAL);
2376 add_sym_4s ("date_and_time", 0, BT_UNKNOWN, 0, GFC_STD_F95,
2377 gfc_check_date_and_time, NULL, NULL,
2378 dt, BT_CHARACTER, dc, OPTIONAL, tm, BT_CHARACTER, dc, OPTIONAL,
2379 zn, BT_CHARACTER, dc, OPTIONAL, vl, BT_INTEGER, di, OPTIONAL);
2381 /* More G77 compatibility garbage. */
2382 add_sym_2s ("etime", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2383 gfc_check_etime_sub, NULL, gfc_resolve_etime_sub,
2384 vl, BT_REAL, 4, REQUIRED, tm, BT_REAL, 4, REQUIRED);
2386 add_sym_2s ("dtime", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2387 gfc_check_etime_sub, NULL, gfc_resolve_etime_sub,
2388 vl, BT_REAL, 4, REQUIRED, tm, BT_REAL, 4, REQUIRED);
2390 add_sym_1s ("fdate", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2391 gfc_check_fdate_sub, NULL, gfc_resolve_fdate_sub,
2392 dt, BT_CHARACTER, dc, REQUIRED);
2394 add_sym_1s ("gerror", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2395 gfc_check_gerror, NULL, gfc_resolve_gerror, c, BT_CHARACTER,
2396 dc, REQUIRED);
2398 add_sym_2s ("getcwd", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2399 gfc_check_getcwd_sub, NULL, gfc_resolve_getcwd_sub,
2400 c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2402 add_sym_2s ("getenv", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2403 NULL, NULL, NULL,
2404 name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER, dc, REQUIRED);
2406 add_sym_2s ("getarg", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2407 NULL, NULL, gfc_resolve_getarg,
2408 c, BT_INTEGER, di, REQUIRED, vl, BT_CHARACTER, dc, REQUIRED);
2410 add_sym_1s ("getlog", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2411 gfc_check_getlog, NULL, gfc_resolve_getlog, c, BT_CHARACTER,
2412 dc, REQUIRED);
2414 /* F2003 commandline routines. */
2416 add_sym_3s ("get_command", 0, BT_UNKNOWN, 0, GFC_STD_F2003,
2417 NULL, NULL, gfc_resolve_get_command,
2418 com, BT_CHARACTER, dc, OPTIONAL, length, BT_INTEGER, di, OPTIONAL,
2419 st, BT_INTEGER, di, OPTIONAL);
2421 add_sym_4s ("get_command_argument", 0, BT_UNKNOWN, 0, GFC_STD_F2003,
2422 NULL, NULL, gfc_resolve_get_command_argument,
2423 num, BT_INTEGER, di, REQUIRED, val, BT_CHARACTER, dc, OPTIONAL,
2424 length, BT_INTEGER, di, OPTIONAL, st, BT_INTEGER, di, OPTIONAL);
2426 /* F2003 subroutine to get environment variables. */
2428 add_sym_5s ("get_environment_variable", 0, BT_UNKNOWN, 0, GFC_STD_F2003,
2429 NULL, NULL, gfc_resolve_get_environment_variable,
2430 name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER, dc, OPTIONAL,
2431 length, BT_INTEGER, di, OPTIONAL, st, BT_INTEGER, di, OPTIONAL,
2432 trim_name, BT_LOGICAL, dl, OPTIONAL);
2434 add_sym_2s ("move_alloc", 0, BT_UNKNOWN, 0, GFC_STD_F2003,
2435 gfc_check_move_alloc, NULL, NULL,
2436 f, BT_UNKNOWN, 0, REQUIRED,
2437 t, BT_UNKNOWN, 0, REQUIRED);
2439 add_sym_5s ("mvbits", 1, BT_UNKNOWN, 0, GFC_STD_F95,
2440 gfc_check_mvbits, gfc_simplify_mvbits, gfc_resolve_mvbits,
2441 f, BT_INTEGER, di, REQUIRED, fp, BT_INTEGER, di, REQUIRED,
2442 ln, BT_INTEGER, di, REQUIRED, t, BT_INTEGER, di, REQUIRED,
2443 tp, BT_INTEGER, di, REQUIRED);
2445 add_sym_1s ("random_number", 0, BT_UNKNOWN, 0, GFC_STD_F95,
2446 gfc_check_random_number, NULL, gfc_resolve_random_number,
2447 h, BT_REAL, dr, REQUIRED);
2449 add_sym_3s ("random_seed", 0, BT_UNKNOWN, 0, GFC_STD_F95,
2450 gfc_check_random_seed, NULL, NULL,
2451 sz, BT_INTEGER, di, OPTIONAL, pt, BT_INTEGER, di, OPTIONAL,
2452 gt, BT_INTEGER, di, OPTIONAL);
2454 /* More G77 compatibility garbage. */
2455 add_sym_3s ("alarm", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2456 gfc_check_alarm_sub, NULL, gfc_resolve_alarm_sub,
2457 sec, BT_INTEGER, di, REQUIRED, han, BT_UNKNOWN, 0, REQUIRED,
2458 st, BT_INTEGER, di, OPTIONAL);
2460 add_sym_1s ("srand", 0, BT_UNKNOWN, di, GFC_STD_GNU,
2461 gfc_check_srand, NULL, gfc_resolve_srand,
2462 c, BT_INTEGER, 4, REQUIRED);
2464 add_sym_1s ("exit", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2465 gfc_check_exit, NULL, gfc_resolve_exit,
2466 c, BT_INTEGER, di, OPTIONAL);
2468 if ((gfc_option.allow_std & GFC_STD_GNU) || gfc_option.flag_all_intrinsics)
2469 make_noreturn();
2471 add_sym_3s ("fgetc", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2472 gfc_check_fgetputc_sub, NULL, gfc_resolve_fgetc_sub,
2473 ut, BT_INTEGER, di, REQUIRED, c, BT_CHARACTER, dc, REQUIRED,
2474 st, BT_INTEGER, di, OPTIONAL);
2476 add_sym_2s ("fget", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2477 gfc_check_fgetput_sub, NULL, gfc_resolve_fget_sub,
2478 c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2480 add_sym_1s ("flush", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2481 gfc_check_flush, NULL, gfc_resolve_flush,
2482 c, BT_INTEGER, di, OPTIONAL);
2484 add_sym_3s ("fputc", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2485 gfc_check_fgetputc_sub, NULL, gfc_resolve_fputc_sub,
2486 ut, BT_INTEGER, di, REQUIRED, c, BT_CHARACTER, dc, REQUIRED,
2487 st, BT_INTEGER, di, OPTIONAL);
2489 add_sym_2s ("fput", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2490 gfc_check_fgetput_sub, NULL, gfc_resolve_fput_sub,
2491 c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2493 add_sym_1s ("free", 0, BT_UNKNOWN, 0, GFC_STD_GNU, gfc_check_free,
2494 NULL, gfc_resolve_free, c, BT_INTEGER, ii, REQUIRED);
2496 add_sym_2s ("ftell", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2497 gfc_check_ftell_sub, NULL, gfc_resolve_ftell_sub,
2498 ut, BT_INTEGER, di, REQUIRED, of, BT_INTEGER, ii, REQUIRED);
2500 add_sym_2s ("hostnm", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2501 gfc_check_hostnm_sub, NULL, gfc_resolve_hostnm_sub,
2502 c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2504 add_sym_3s ("kill", 0, BT_UNKNOWN, 0, GFC_STD_GNU, gfc_check_kill_sub,
2505 NULL, gfc_resolve_kill_sub, c, BT_INTEGER, di, REQUIRED,
2506 val, BT_INTEGER, di, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2508 add_sym_3s ("link", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2509 gfc_check_link_sub, NULL, gfc_resolve_link_sub,
2510 name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER,
2511 dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2513 add_sym_1s ("perror", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2514 gfc_check_perror, NULL, gfc_resolve_perror,
2515 c, BT_CHARACTER, dc, REQUIRED);
2517 add_sym_3s ("rename", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2518 gfc_check_rename_sub, NULL, gfc_resolve_rename_sub,
2519 name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER,
2520 dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2522 add_sym_1s ("sleep", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2523 gfc_check_sleep_sub, NULL, gfc_resolve_sleep_sub,
2524 val, BT_CHARACTER, dc, REQUIRED);
2526 add_sym_3s ("fstat", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2527 gfc_check_fstat_sub, NULL, gfc_resolve_fstat_sub,
2528 ut, BT_INTEGER, di, REQUIRED, vl, BT_INTEGER, di, REQUIRED,
2529 st, BT_INTEGER, di, OPTIONAL);
2531 add_sym_3s ("lstat", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2532 gfc_check_stat_sub, NULL, gfc_resolve_lstat_sub,
2533 name, BT_CHARACTER, dc, REQUIRED, vl, BT_INTEGER, di, REQUIRED,
2534 st, BT_INTEGER, di, OPTIONAL);
2536 add_sym_3s ("stat", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2537 gfc_check_stat_sub, NULL, gfc_resolve_stat_sub,
2538 name, BT_CHARACTER, dc, REQUIRED, vl, BT_INTEGER, di, REQUIRED,
2539 st, BT_INTEGER, di, OPTIONAL);
2541 add_sym_3s ("signal", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2542 gfc_check_signal_sub, NULL, gfc_resolve_signal_sub,
2543 num, BT_INTEGER, di, REQUIRED, han, BT_UNKNOWN, 0, REQUIRED,
2544 st, BT_INTEGER, di, OPTIONAL);
2546 add_sym_3s ("symlnk", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2547 gfc_check_symlnk_sub, NULL, gfc_resolve_symlnk_sub,
2548 name, BT_CHARACTER, dc, REQUIRED, val, BT_CHARACTER,
2549 dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2551 add_sym_2s ("system", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2552 NULL, NULL, gfc_resolve_system_sub,
2553 c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2555 add_sym_3s ("system_clock", 0, BT_UNKNOWN, 0, GFC_STD_F95,
2556 gfc_check_system_clock, NULL, gfc_resolve_system_clock,
2557 c, BT_INTEGER, di, OPTIONAL, cr, BT_INTEGER, di, OPTIONAL,
2558 cm, BT_INTEGER, di, OPTIONAL);
2560 add_sym_2s ("ttynam", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2561 gfc_check_ttynam_sub, NULL, gfc_resolve_ttynam_sub,
2562 ut, BT_INTEGER, di, REQUIRED, c, BT_CHARACTER, dc, REQUIRED);
2564 add_sym_2s ("umask", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2565 gfc_check_umask_sub, NULL, gfc_resolve_umask_sub,
2566 val, BT_INTEGER, di, REQUIRED, num, BT_INTEGER, di, OPTIONAL);
2568 add_sym_2s ("unlink", 0, BT_UNKNOWN, 0, GFC_STD_GNU,
2569 gfc_check_unlink_sub, NULL, gfc_resolve_unlink_sub,
2570 c, BT_CHARACTER, dc, REQUIRED, st, BT_INTEGER, di, OPTIONAL);
2575 /* Add a function to the list of conversion symbols. */
2577 static void
2578 add_conv (bt from_type, int from_kind, bt to_type, int to_kind, int standard)
2581 gfc_typespec from, to;
2582 gfc_intrinsic_sym *sym;
2584 if (sizing == SZ_CONVS)
2586 nconv++;
2587 return;
2590 gfc_clear_ts (&from);
2591 from.type = from_type;
2592 from.kind = from_kind;
2594 gfc_clear_ts (&to);
2595 to.type = to_type;
2596 to.kind = to_kind;
2598 sym = conversion + nconv;
2600 sym->name = conv_name (&from, &to);
2601 sym->lib_name = sym->name;
2602 sym->simplify.cc = gfc_convert_constant;
2603 sym->standard = standard;
2604 sym->elemental = 1;
2605 sym->ts = to;
2606 sym->generic_id = GFC_ISYM_CONVERSION;
2608 nconv++;
2612 /* Create gfc_intrinsic_sym nodes for all intrinsic conversion
2613 functions by looping over the kind tables. */
2615 static void
2616 add_conversions (void)
2618 int i, j;
2620 /* Integer-Integer conversions. */
2621 for (i = 0; gfc_integer_kinds[i].kind != 0; i++)
2622 for (j = 0; gfc_integer_kinds[j].kind != 0; j++)
2624 if (i == j)
2625 continue;
2627 add_conv (BT_INTEGER, gfc_integer_kinds[i].kind,
2628 BT_INTEGER, gfc_integer_kinds[j].kind, GFC_STD_F77);
2631 /* Integer-Real/Complex conversions. */
2632 for (i = 0; gfc_integer_kinds[i].kind != 0; i++)
2633 for (j = 0; gfc_real_kinds[j].kind != 0; j++)
2635 add_conv (BT_INTEGER, gfc_integer_kinds[i].kind,
2636 BT_REAL, gfc_real_kinds[j].kind, GFC_STD_F77);
2638 add_conv (BT_REAL, gfc_real_kinds[j].kind,
2639 BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_F77);
2641 add_conv (BT_INTEGER, gfc_integer_kinds[i].kind,
2642 BT_COMPLEX, gfc_real_kinds[j].kind, GFC_STD_F77);
2644 add_conv (BT_COMPLEX, gfc_real_kinds[j].kind,
2645 BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_F77);
2648 if ((gfc_option.allow_std & GFC_STD_LEGACY) != 0)
2650 /* Hollerith-Integer conversions. */
2651 for (i = 0; gfc_integer_kinds[i].kind != 0; i++)
2652 add_conv (BT_HOLLERITH, gfc_default_character_kind,
2653 BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_LEGACY);
2654 /* Hollerith-Real conversions. */
2655 for (i = 0; gfc_real_kinds[i].kind != 0; i++)
2656 add_conv (BT_HOLLERITH, gfc_default_character_kind,
2657 BT_REAL, gfc_real_kinds[i].kind, GFC_STD_LEGACY);
2658 /* Hollerith-Complex conversions. */
2659 for (i = 0; gfc_real_kinds[i].kind != 0; i++)
2660 add_conv (BT_HOLLERITH, gfc_default_character_kind,
2661 BT_COMPLEX, gfc_real_kinds[i].kind, GFC_STD_LEGACY);
2663 /* Hollerith-Character conversions. */
2664 add_conv (BT_HOLLERITH, gfc_default_character_kind, BT_CHARACTER,
2665 gfc_default_character_kind, GFC_STD_LEGACY);
2667 /* Hollerith-Logical conversions. */
2668 for (i = 0; gfc_logical_kinds[i].kind != 0; i++)
2669 add_conv (BT_HOLLERITH, gfc_default_character_kind,
2670 BT_LOGICAL, gfc_logical_kinds[i].kind, GFC_STD_LEGACY);
2673 /* Real/Complex - Real/Complex conversions. */
2674 for (i = 0; gfc_real_kinds[i].kind != 0; i++)
2675 for (j = 0; gfc_real_kinds[j].kind != 0; j++)
2677 if (i != j)
2679 add_conv (BT_REAL, gfc_real_kinds[i].kind,
2680 BT_REAL, gfc_real_kinds[j].kind, GFC_STD_F77);
2682 add_conv (BT_COMPLEX, gfc_real_kinds[i].kind,
2683 BT_COMPLEX, gfc_real_kinds[j].kind, GFC_STD_F77);
2686 add_conv (BT_REAL, gfc_real_kinds[i].kind,
2687 BT_COMPLEX, gfc_real_kinds[j].kind, GFC_STD_F77);
2689 add_conv (BT_COMPLEX, gfc_real_kinds[i].kind,
2690 BT_REAL, gfc_real_kinds[j].kind, GFC_STD_F77);
2693 /* Logical/Logical kind conversion. */
2694 for (i = 0; gfc_logical_kinds[i].kind; i++)
2695 for (j = 0; gfc_logical_kinds[j].kind; j++)
2697 if (i == j)
2698 continue;
2700 add_conv (BT_LOGICAL, gfc_logical_kinds[i].kind,
2701 BT_LOGICAL, gfc_logical_kinds[j].kind, GFC_STD_F77);
2704 /* Integer-Logical and Logical-Integer conversions. */
2705 if ((gfc_option.allow_std & GFC_STD_LEGACY) != 0)
2706 for (i=0; gfc_integer_kinds[i].kind; i++)
2707 for (j=0; gfc_logical_kinds[j].kind; j++)
2709 add_conv (BT_INTEGER, gfc_integer_kinds[i].kind,
2710 BT_LOGICAL, gfc_logical_kinds[j].kind, GFC_STD_LEGACY);
2711 add_conv (BT_LOGICAL, gfc_logical_kinds[j].kind,
2712 BT_INTEGER, gfc_integer_kinds[i].kind, GFC_STD_LEGACY);
2717 /* Initialize the table of intrinsics. */
2718 void
2719 gfc_intrinsic_init_1 (void)
2721 int i;
2723 nargs = nfunc = nsub = nconv = 0;
2725 /* Create a namespace to hold the resolved intrinsic symbols. */
2726 gfc_intrinsic_namespace = gfc_get_namespace (NULL, 0);
2728 sizing = SZ_FUNCS;
2729 add_functions ();
2730 sizing = SZ_SUBS;
2731 add_subroutines ();
2732 sizing = SZ_CONVS;
2733 add_conversions ();
2735 functions = gfc_getmem (sizeof (gfc_intrinsic_sym) * (nfunc + nsub)
2736 + sizeof (gfc_intrinsic_arg) * nargs);
2738 next_sym = functions;
2739 subroutines = functions + nfunc;
2741 conversion = gfc_getmem (sizeof (gfc_intrinsic_sym) * nconv);
2743 next_arg = ((gfc_intrinsic_arg *) (subroutines + nsub)) - 1;
2745 sizing = SZ_NOTHING;
2746 nconv = 0;
2748 add_functions ();
2749 add_subroutines ();
2750 add_conversions ();
2752 /* Set the pure flag. All intrinsic functions are pure, and
2753 intrinsic subroutines are pure if they are elemental. */
2755 for (i = 0; i < nfunc; i++)
2756 functions[i].pure = 1;
2758 for (i = 0; i < nsub; i++)
2759 subroutines[i].pure = subroutines[i].elemental;
2763 void
2764 gfc_intrinsic_done_1 (void)
2766 gfc_free (functions);
2767 gfc_free (conversion);
2768 gfc_free_namespace (gfc_intrinsic_namespace);
2772 /******** Subroutines to check intrinsic interfaces ***********/
2774 /* Given a formal argument list, remove any NULL arguments that may
2775 have been left behind by a sort against some formal argument list. */
2777 static void
2778 remove_nullargs (gfc_actual_arglist ** ap)
2780 gfc_actual_arglist *head, *tail, *next;
2782 tail = NULL;
2784 for (head = *ap; head; head = next)
2786 next = head->next;
2788 if (head->expr == NULL)
2790 head->next = NULL;
2791 gfc_free_actual_arglist (head);
2793 else
2795 if (tail == NULL)
2796 *ap = head;
2797 else
2798 tail->next = head;
2800 tail = head;
2801 tail->next = NULL;
2805 if (tail == NULL)
2806 *ap = NULL;
2810 /* Given an actual arglist and a formal arglist, sort the actual
2811 arglist so that its arguments are in a one-to-one correspondence
2812 with the format arglist. Arguments that are not present are given
2813 a blank gfc_actual_arglist structure. If something is obviously
2814 wrong (say, a missing required argument) we abort sorting and
2815 return FAILURE. */
2817 static try
2818 sort_actual (const char *name, gfc_actual_arglist ** ap,
2819 gfc_intrinsic_arg * formal, locus * where)
2822 gfc_actual_arglist *actual, *a;
2823 gfc_intrinsic_arg *f;
2825 remove_nullargs (ap);
2826 actual = *ap;
2828 for (f = formal; f; f = f->next)
2829 f->actual = NULL;
2831 f = formal;
2832 a = actual;
2834 if (f == NULL && a == NULL) /* No arguments */
2835 return SUCCESS;
2837 for (;;)
2838 { /* Put the nonkeyword arguments in a 1:1 correspondence */
2839 if (f == NULL)
2840 break;
2841 if (a == NULL)
2842 goto optional;
2844 if (a->name != NULL)
2845 goto keywords;
2847 f->actual = a;
2849 f = f->next;
2850 a = a->next;
2853 if (a == NULL)
2854 goto do_sort;
2856 gfc_error ("Too many arguments in call to '%s' at %L", name, where);
2857 return FAILURE;
2859 keywords:
2860 /* Associate the remaining actual arguments, all of which have
2861 to be keyword arguments. */
2862 for (; a; a = a->next)
2864 for (f = formal; f; f = f->next)
2865 if (strcmp (a->name, f->name) == 0)
2866 break;
2868 if (f == NULL)
2870 gfc_error ("Can't find keyword named '%s' in call to '%s' at %L",
2871 a->name, name, where);
2872 return FAILURE;
2875 if (f->actual != NULL)
2877 gfc_error ("Argument '%s' is appears twice in call to '%s' at %L",
2878 f->name, name, where);
2879 return FAILURE;
2882 f->actual = a;
2885 optional:
2886 /* At this point, all unmatched formal args must be optional. */
2887 for (f = formal; f; f = f->next)
2889 if (f->actual == NULL && f->optional == 0)
2891 gfc_error ("Missing actual argument '%s' in call to '%s' at %L",
2892 f->name, name, where);
2893 return FAILURE;
2897 do_sort:
2898 /* Using the formal argument list, string the actual argument list
2899 together in a way that corresponds with the formal list. */
2900 actual = NULL;
2902 for (f = formal; f; f = f->next)
2904 if (f->actual == NULL)
2906 a = gfc_get_actual_arglist ();
2907 a->missing_arg_type = f->ts.type;
2909 else
2910 a = f->actual;
2912 if (actual == NULL)
2913 *ap = a;
2914 else
2915 actual->next = a;
2917 actual = a;
2919 actual->next = NULL; /* End the sorted argument list. */
2921 return SUCCESS;
2925 /* Compare an actual argument list with an intrinsic's formal argument
2926 list. The lists are checked for agreement of type. We don't check
2927 for arrayness here. */
2929 static try
2930 check_arglist (gfc_actual_arglist ** ap, gfc_intrinsic_sym * sym,
2931 int error_flag)
2933 gfc_actual_arglist *actual;
2934 gfc_intrinsic_arg *formal;
2935 int i;
2937 formal = sym->formal;
2938 actual = *ap;
2940 i = 0;
2941 for (; formal; formal = formal->next, actual = actual->next, i++)
2943 if (actual->expr == NULL)
2944 continue;
2946 if (!gfc_compare_types (&formal->ts, &actual->expr->ts))
2948 if (error_flag)
2949 gfc_error
2950 ("Type of argument '%s' in call to '%s' at %L should be "
2951 "%s, not %s", gfc_current_intrinsic_arg[i],
2952 gfc_current_intrinsic, &actual->expr->where,
2953 gfc_typename (&formal->ts), gfc_typename (&actual->expr->ts));
2954 return FAILURE;
2958 return SUCCESS;
2962 /* Given a pointer to an intrinsic symbol and an expression node that
2963 represent the function call to that subroutine, figure out the type
2964 of the result. This may involve calling a resolution subroutine. */
2966 static void
2967 resolve_intrinsic (gfc_intrinsic_sym * specific, gfc_expr * e)
2969 gfc_expr *a1, *a2, *a3, *a4, *a5;
2970 gfc_actual_arglist *arg;
2972 if (specific->resolve.f1 == NULL)
2974 if (e->value.function.name == NULL)
2975 e->value.function.name = specific->lib_name;
2977 if (e->ts.type == BT_UNKNOWN)
2978 e->ts = specific->ts;
2979 return;
2982 arg = e->value.function.actual;
2984 /* Special case hacks for MIN and MAX. */
2985 if (specific->resolve.f1m == gfc_resolve_max
2986 || specific->resolve.f1m == gfc_resolve_min)
2988 (*specific->resolve.f1m) (e, arg);
2989 return;
2992 if (arg == NULL)
2994 (*specific->resolve.f0) (e);
2995 return;
2998 a1 = arg->expr;
2999 arg = arg->next;
3001 if (arg == NULL)
3003 (*specific->resolve.f1) (e, a1);
3004 return;
3007 a2 = arg->expr;
3008 arg = arg->next;
3010 if (arg == NULL)
3012 (*specific->resolve.f2) (e, a1, a2);
3013 return;
3016 a3 = arg->expr;
3017 arg = arg->next;
3019 if (arg == NULL)
3021 (*specific->resolve.f3) (e, a1, a2, a3);
3022 return;
3025 a4 = arg->expr;
3026 arg = arg->next;
3028 if (arg == NULL)
3030 (*specific->resolve.f4) (e, a1, a2, a3, a4);
3031 return;
3034 a5 = arg->expr;
3035 arg = arg->next;
3037 if (arg == NULL)
3039 (*specific->resolve.f5) (e, a1, a2, a3, a4, a5);
3040 return;
3043 gfc_internal_error ("resolve_intrinsic(): Too many args for intrinsic");
3047 /* Given an intrinsic symbol node and an expression node, call the
3048 simplification function (if there is one), perhaps replacing the
3049 expression with something simpler. We return FAILURE on an error
3050 of the simplification, SUCCESS if the simplification worked, even
3051 if nothing has changed in the expression itself. */
3053 static try
3054 do_simplify (gfc_intrinsic_sym * specific, gfc_expr * e)
3056 gfc_expr *result, *a1, *a2, *a3, *a4, *a5;
3057 gfc_actual_arglist *arg;
3059 /* Check the arguments if there are Hollerith constants. We deal with
3060 them at run-time. */
3061 for (arg = e->value.function.actual; arg != NULL; arg = arg->next)
3063 if (arg->expr && arg->expr->from_H)
3065 result = NULL;
3066 goto finish;
3069 /* Max and min require special handling due to the variable number
3070 of args. */
3071 if (specific->simplify.f1 == gfc_simplify_min)
3073 result = gfc_simplify_min (e);
3074 goto finish;
3077 if (specific->simplify.f1 == gfc_simplify_max)
3079 result = gfc_simplify_max (e);
3080 goto finish;
3083 if (specific->simplify.f1 == NULL)
3085 result = NULL;
3086 goto finish;
3089 arg = e->value.function.actual;
3091 if (arg == NULL)
3093 result = (*specific->simplify.f0) ();
3094 goto finish;
3097 a1 = arg->expr;
3098 arg = arg->next;
3100 if (specific->simplify.cc == gfc_convert_constant)
3102 result = gfc_convert_constant (a1, specific->ts.type, specific->ts.kind);
3103 goto finish;
3106 /* TODO: Warn if -pedantic and initialization expression and arg
3107 types not integer or character */
3109 if (arg == NULL)
3110 result = (*specific->simplify.f1) (a1);
3111 else
3113 a2 = arg->expr;
3114 arg = arg->next;
3116 if (arg == NULL)
3117 result = (*specific->simplify.f2) (a1, a2);
3118 else
3120 a3 = arg->expr;
3121 arg = arg->next;
3123 if (arg == NULL)
3124 result = (*specific->simplify.f3) (a1, a2, a3);
3125 else
3127 a4 = arg->expr;
3128 arg = arg->next;
3130 if (arg == NULL)
3131 result = (*specific->simplify.f4) (a1, a2, a3, a4);
3132 else
3134 a5 = arg->expr;
3135 arg = arg->next;
3137 if (arg == NULL)
3138 result = (*specific->simplify.f5) (a1, a2, a3, a4, a5);
3139 else
3140 gfc_internal_error
3141 ("do_simplify(): Too many args for intrinsic");
3147 finish:
3148 if (result == &gfc_bad_expr)
3149 return FAILURE;
3151 if (result == NULL)
3152 resolve_intrinsic (specific, e); /* Must call at run-time */
3153 else
3155 result->where = e->where;
3156 gfc_replace_expr (e, result);
3159 return SUCCESS;
3163 /* Initialize the gfc_current_intrinsic_arg[] array for the benefit of
3164 error messages. This subroutine returns FAILURE if a subroutine
3165 has more than MAX_INTRINSIC_ARGS, in which case the actual argument
3166 list cannot match any intrinsic. */
3168 static void
3169 init_arglist (gfc_intrinsic_sym * isym)
3171 gfc_intrinsic_arg *formal;
3172 int i;
3174 gfc_current_intrinsic = isym->name;
3176 i = 0;
3177 for (formal = isym->formal; formal; formal = formal->next)
3179 if (i >= MAX_INTRINSIC_ARGS)
3180 gfc_internal_error ("init_arglist(): too many arguments");
3181 gfc_current_intrinsic_arg[i++] = formal->name;
3186 /* Given a pointer to an intrinsic symbol and an expression consisting
3187 of a function call, see if the function call is consistent with the
3188 intrinsic's formal argument list. Return SUCCESS if the expression
3189 and intrinsic match, FAILURE otherwise. */
3191 static try
3192 check_specific (gfc_intrinsic_sym * specific, gfc_expr * expr, int error_flag)
3194 gfc_actual_arglist *arg, **ap;
3195 int r;
3196 try t;
3198 ap = &expr->value.function.actual;
3200 init_arglist (specific);
3202 /* Don't attempt to sort the argument list for min or max. */
3203 if (specific->check.f1m == gfc_check_min_max
3204 || specific->check.f1m == gfc_check_min_max_integer
3205 || specific->check.f1m == gfc_check_min_max_real
3206 || specific->check.f1m == gfc_check_min_max_double)
3207 return (*specific->check.f1m) (*ap);
3209 if (sort_actual (specific->name, ap, specific->formal,
3210 &expr->where) == FAILURE)
3211 return FAILURE;
3213 if (specific->check.f3ml == gfc_check_minloc_maxloc)
3214 /* This is special because we might have to reorder the argument
3215 list. */
3216 t = gfc_check_minloc_maxloc (*ap);
3217 else if (specific->check.f3red == gfc_check_minval_maxval)
3218 /* This is also special because we also might have to reorder the
3219 argument list. */
3220 t = gfc_check_minval_maxval (*ap);
3221 else if (specific->check.f3red == gfc_check_product_sum)
3222 /* Same here. The difference to the previous case is that we allow a
3223 general numeric type. */
3224 t = gfc_check_product_sum (*ap);
3225 else
3227 if (specific->check.f1 == NULL)
3229 t = check_arglist (ap, specific, error_flag);
3230 if (t == SUCCESS)
3231 expr->ts = specific->ts;
3233 else
3234 t = do_check (specific, *ap);
3237 /* Check ranks for elemental intrinsics. */
3238 if (t == SUCCESS && specific->elemental)
3240 r = 0;
3241 for (arg = expr->value.function.actual; arg; arg = arg->next)
3243 if (arg->expr == NULL || arg->expr->rank == 0)
3244 continue;
3245 if (r == 0)
3247 r = arg->expr->rank;
3248 continue;
3251 if (arg->expr->rank != r)
3253 gfc_error
3254 ("Ranks of arguments to elemental intrinsic '%s' differ "
3255 "at %L", specific->name, &arg->expr->where);
3256 return FAILURE;
3261 if (t == FAILURE)
3262 remove_nullargs (ap);
3264 return t;
3268 /* See if an intrinsic is one of the intrinsics we evaluate
3269 as an extension. */
3271 static int
3272 gfc_init_expr_extensions (gfc_intrinsic_sym *isym)
3274 /* FIXME: This should be moved into the intrinsic definitions. */
3275 static const char * const init_expr_extensions[] = {
3276 "digits", "epsilon", "huge", "kind", "maxexponent", "minexponent",
3277 "precision", "present", "radix", "range", "selected_real_kind",
3278 "tiny", NULL
3281 int i;
3283 for (i = 0; init_expr_extensions[i]; i++)
3284 if (strcmp (init_expr_extensions[i], isym->name) == 0)
3285 return 0;
3287 return 1;
3291 /* Check whether an intrinsic belongs to whatever standard the user
3292 has chosen. */
3294 static void
3295 check_intrinsic_standard (const char *name, int standard, locus * where)
3297 if (!gfc_option.warn_nonstd_intrinsics)
3298 return;
3300 gfc_notify_std (standard, "Intrinsic '%s' at %L is not included "
3301 "in the selected standard", name, where);
3305 /* See if a function call corresponds to an intrinsic function call.
3306 We return:
3308 MATCH_YES if the call corresponds to an intrinsic, simplification
3309 is done if possible.
3311 MATCH_NO if the call does not correspond to an intrinsic
3313 MATCH_ERROR if the call corresponds to an intrinsic but there was an
3314 error during the simplification process.
3316 The error_flag parameter enables an error reporting. */
3318 match
3319 gfc_intrinsic_func_interface (gfc_expr * expr, int error_flag)
3321 gfc_intrinsic_sym *isym, *specific;
3322 gfc_actual_arglist *actual;
3323 const char *name;
3324 int flag;
3326 if (expr->value.function.isym != NULL)
3327 return (do_simplify (expr->value.function.isym, expr) == FAILURE)
3328 ? MATCH_ERROR : MATCH_YES;
3330 gfc_suppress_error = !error_flag;
3331 flag = 0;
3333 for (actual = expr->value.function.actual; actual; actual = actual->next)
3334 if (actual->expr != NULL)
3335 flag |= (actual->expr->ts.type != BT_INTEGER
3336 && actual->expr->ts.type != BT_CHARACTER);
3338 name = expr->symtree->n.sym->name;
3340 isym = specific = gfc_find_function (name);
3341 if (isym == NULL)
3343 gfc_suppress_error = 0;
3344 return MATCH_NO;
3347 gfc_current_intrinsic_where = &expr->where;
3349 /* Bypass the generic list for min and max. */
3350 if (isym->check.f1m == gfc_check_min_max)
3352 init_arglist (isym);
3354 if (gfc_check_min_max (expr->value.function.actual) == SUCCESS)
3355 goto got_specific;
3357 gfc_suppress_error = 0;
3358 return MATCH_NO;
3361 /* If the function is generic, check all of its specific
3362 incarnations. If the generic name is also a specific, we check
3363 that name last, so that any error message will correspond to the
3364 specific. */
3365 gfc_suppress_error = 1;
3367 if (isym->generic)
3369 for (specific = isym->specific_head; specific;
3370 specific = specific->next)
3372 if (specific == isym)
3373 continue;
3374 if (check_specific (specific, expr, 0) == SUCCESS)
3375 goto got_specific;
3379 gfc_suppress_error = !error_flag;
3381 if (check_specific (isym, expr, error_flag) == FAILURE)
3383 gfc_suppress_error = 0;
3384 return MATCH_NO;
3387 specific = isym;
3389 got_specific:
3390 expr->value.function.isym = specific;
3391 gfc_intrinsic_symbol (expr->symtree->n.sym);
3393 gfc_suppress_error = 0;
3394 if (do_simplify (specific, expr) == FAILURE)
3395 return MATCH_ERROR;
3397 /* TODO: We should probably only allow elemental functions here. */
3398 flag |= (expr->ts.type != BT_INTEGER && expr->ts.type != BT_CHARACTER);
3400 if (pedantic && gfc_init_expr
3401 && flag && gfc_init_expr_extensions (specific))
3403 if (gfc_notify_std (GFC_STD_GNU, "Extension: Evaluation of "
3404 "nonstandard initialization expression at %L", &expr->where)
3405 == FAILURE)
3407 return MATCH_ERROR;
3411 check_intrinsic_standard (name, isym->standard, &expr->where);
3413 return MATCH_YES;
3417 /* See if a CALL statement corresponds to an intrinsic subroutine.
3418 Returns MATCH_YES if the subroutine corresponds to an intrinsic,
3419 MATCH_NO if not, and MATCH_ERROR if there was an error (but did
3420 correspond). */
3422 match
3423 gfc_intrinsic_sub_interface (gfc_code * c, int error_flag)
3425 gfc_intrinsic_sym *isym;
3426 const char *name;
3428 name = c->symtree->n.sym->name;
3430 isym = find_subroutine (name);
3431 if (isym == NULL)
3432 return MATCH_NO;
3434 gfc_suppress_error = !error_flag;
3436 init_arglist (isym);
3438 if (sort_actual (name, &c->ext.actual, isym->formal, &c->loc) == FAILURE)
3439 goto fail;
3441 if (isym->check.f1 != NULL)
3443 if (do_check (isym, c->ext.actual) == FAILURE)
3444 goto fail;
3446 else
3448 if (check_arglist (&c->ext.actual, isym, 1) == FAILURE)
3449 goto fail;
3452 /* The subroutine corresponds to an intrinsic. Allow errors to be
3453 seen at this point. */
3454 gfc_suppress_error = 0;
3456 if (isym->resolve.s1 != NULL)
3457 isym->resolve.s1 (c);
3458 else
3459 c->resolved_sym = gfc_get_intrinsic_sub_symbol (isym->lib_name);
3461 if (gfc_pure (NULL) && !isym->elemental)
3463 gfc_error ("Subroutine call to intrinsic '%s' at %L is not PURE", name,
3464 &c->loc);
3465 return MATCH_ERROR;
3468 c->resolved_sym->attr.noreturn = isym->noreturn;
3469 check_intrinsic_standard (name, isym->standard, &c->loc);
3471 return MATCH_YES;
3473 fail:
3474 gfc_suppress_error = 0;
3475 return MATCH_NO;
3479 /* Call gfc_convert_type() with warning enabled. */
3482 gfc_convert_type (gfc_expr * expr, gfc_typespec * ts, int eflag)
3484 return gfc_convert_type_warn (expr, ts, eflag, 1);
3488 /* Try to convert an expression (in place) from one type to another.
3489 'eflag' controls the behavior on error.
3491 The possible values are:
3493 1 Generate a gfc_error()
3494 2 Generate a gfc_internal_error().
3496 'wflag' controls the warning related to conversion. */
3499 gfc_convert_type_warn (gfc_expr * expr, gfc_typespec * ts, int eflag,
3500 int wflag)
3502 gfc_intrinsic_sym *sym;
3503 gfc_typespec from_ts;
3504 locus old_where;
3505 gfc_expr *new;
3506 int rank;
3507 mpz_t *shape;
3509 from_ts = expr->ts; /* expr->ts gets clobbered */
3511 if (ts->type == BT_UNKNOWN)
3512 goto bad;
3514 /* NULL and zero size arrays get their type here. */
3515 if (expr->expr_type == EXPR_NULL
3516 || (expr->expr_type == EXPR_ARRAY
3517 && expr->value.constructor == NULL))
3519 /* Sometimes the RHS acquire the type. */
3520 expr->ts = *ts;
3521 return SUCCESS;
3524 if (expr->ts.type == BT_UNKNOWN)
3525 goto bad;
3527 if (expr->ts.type == BT_DERIVED
3528 && ts->type == BT_DERIVED
3529 && gfc_compare_types (&expr->ts, ts))
3530 return SUCCESS;
3532 sym = find_conv (&expr->ts, ts);
3533 if (sym == NULL)
3534 goto bad;
3536 /* At this point, a conversion is necessary. A warning may be needed. */
3537 if ((gfc_option.warn_std & sym->standard) != 0)
3538 gfc_warning_now ("Extension: Conversion from %s to %s at %L",
3539 gfc_typename (&from_ts), gfc_typename (ts), &expr->where);
3540 else if (wflag && gfc_option.warn_conversion)
3541 gfc_warning_now ("Conversion from %s to %s at %L",
3542 gfc_typename (&from_ts), gfc_typename (ts), &expr->where);
3544 /* Insert a pre-resolved function call to the right function. */
3545 old_where = expr->where;
3546 rank = expr->rank;
3547 shape = expr->shape;
3549 new = gfc_get_expr ();
3550 *new = *expr;
3552 new = gfc_build_conversion (new);
3553 new->value.function.name = sym->lib_name;
3554 new->value.function.isym = sym;
3555 new->where = old_where;
3556 new->rank = rank;
3557 new->shape = gfc_copy_shape (shape, rank);
3559 gfc_get_ha_sym_tree (sym->name, &new->symtree);
3560 new->symtree->n.sym->ts = *ts;
3561 new->symtree->n.sym->attr.flavor = FL_PROCEDURE;
3562 new->symtree->n.sym->attr.function = 1;
3563 new->symtree->n.sym->attr.intrinsic = 1;
3564 new->symtree->n.sym->attr.elemental = 1;
3565 new->symtree->n.sym->attr.pure = 1;
3566 new->symtree->n.sym->attr.referenced = 1;
3567 gfc_intrinsic_symbol(new->symtree->n.sym);
3568 gfc_commit_symbol (new->symtree->n.sym);
3570 *expr = *new;
3572 gfc_free (new);
3573 expr->ts = *ts;
3575 if (gfc_is_constant_expr (expr->value.function.actual->expr)
3576 && do_simplify (sym, expr) == FAILURE)
3579 if (eflag == 2)
3580 goto bad;
3581 return FAILURE; /* Error already generated in do_simplify() */
3584 return SUCCESS;
3586 bad:
3587 if (eflag == 1)
3589 gfc_error ("Can't convert %s to %s at %L",
3590 gfc_typename (&from_ts), gfc_typename (ts), &expr->where);
3591 return FAILURE;
3594 gfc_internal_error ("Can't convert %s to %s at %L",
3595 gfc_typename (&from_ts), gfc_typename (ts),
3596 &expr->where);
3597 /* Not reached */