2 Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
3 Contributed by Andy Vaught & Katherine Holcomb
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
23 /* These functions check to see if an argument list is compatible with
24 a particular intrinsic function or subroutine. Presence of
25 required arguments has already been established, the argument list
26 has been sorted into the right order and has NULL arguments in the
27 correct places for missing optional arguments. */
33 #include "intrinsic.h"
36 /* Check the type of an expression. */
39 type_check (gfc_expr * e, int n, bt type)
41 if (e->ts.type == type)
44 gfc_error ("'%s' argument of '%s' intrinsic at %L must be %s",
45 gfc_current_intrinsic_arg[n], gfc_current_intrinsic, &e->where,
46 gfc_basic_typename (type));
52 /* Check that the expression is a numeric type. */
55 numeric_check (gfc_expr * e, int n)
57 if (gfc_numeric_ts (&e->ts))
60 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a numeric type",
61 gfc_current_intrinsic_arg[n], gfc_current_intrinsic, &e->where);
67 /* Check that an expression is integer or real. */
70 int_or_real_check (gfc_expr * e, int n)
72 if (e->ts.type != BT_INTEGER && e->ts.type != BT_REAL)
75 "'%s' argument of '%s' intrinsic at %L must be INTEGER or REAL",
76 gfc_current_intrinsic_arg[n], gfc_current_intrinsic, &e->where);
84 /* Check that an expression is real or complex. */
87 real_or_complex_check (gfc_expr * e, int n)
89 if (e->ts.type != BT_REAL && e->ts.type != BT_COMPLEX)
92 "'%s' argument of '%s' intrinsic at %L must be REAL or COMPLEX",
93 gfc_current_intrinsic_arg[n], gfc_current_intrinsic, &e->where);
101 /* Check that the expression is an optional constant integer
102 and that it specifies a valid kind for that type. */
105 kind_check (gfc_expr * k, int n, bt type)
112 if (type_check (k, n, BT_INTEGER) == FAILURE)
115 if (k->expr_type != EXPR_CONSTANT)
118 "'%s' argument of '%s' intrinsic at %L must be a constant",
119 gfc_current_intrinsic_arg[n], gfc_current_intrinsic, &k->where);
123 if (gfc_extract_int (k, &kind) != NULL
124 || gfc_validate_kind (type, kind, true) < 0)
126 gfc_error ("Invalid kind for %s at %L", gfc_basic_typename (type),
135 /* Make sure the expression is a double precision real. */
138 double_check (gfc_expr * d, int n)
140 if (type_check (d, n, BT_REAL) == FAILURE)
143 if (d->ts.kind != gfc_default_double_kind)
146 "'%s' argument of '%s' intrinsic at %L must be double precision",
147 gfc_current_intrinsic_arg[n], gfc_current_intrinsic, &d->where);
155 /* Make sure the expression is a logical array. */
158 logical_array_check (gfc_expr * array, int n)
160 if (array->ts.type != BT_LOGICAL || array->rank == 0)
163 "'%s' argument of '%s' intrinsic at %L must be a logical array",
164 gfc_current_intrinsic_arg[n], gfc_current_intrinsic, &array->where);
172 /* Make sure an expression is an array. */
175 array_check (gfc_expr * e, int n)
180 gfc_error ("'%s' argument of '%s' intrinsic at %L must be an array",
181 gfc_current_intrinsic_arg[n], gfc_current_intrinsic, &e->where);
187 /* Make sure an expression is a scalar. */
190 scalar_check (gfc_expr * e, int n)
195 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a scalar",
196 gfc_current_intrinsic_arg[n], gfc_current_intrinsic, &e->where);
202 /* Make sure two expression have the same type. */
205 same_type_check (gfc_expr * e, int n, gfc_expr * f, int m)
207 if (gfc_compare_types (&e->ts, &f->ts))
210 gfc_error ("'%s' argument of '%s' intrinsic at %L must be the same type "
211 "and kind as '%s'", gfc_current_intrinsic_arg[m],
212 gfc_current_intrinsic, &f->where, gfc_current_intrinsic_arg[n]);
217 /* Make sure that an expression has a certain (nonzero) rank. */
220 rank_check (gfc_expr * e, int n, int rank)
225 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of rank %d",
226 gfc_current_intrinsic_arg[n], gfc_current_intrinsic,
232 /* Make sure a variable expression is not an optional dummy argument. */
235 nonoptional_check (gfc_expr * e, int n)
237 if (e->expr_type == EXPR_VARIABLE && e->symtree->n.sym->attr.optional)
239 gfc_error ("'%s' argument of '%s' intrinsic at %L must not be OPTIONAL",
240 gfc_current_intrinsic_arg[n], gfc_current_intrinsic,
245 /* TODO: Recursive check on nonoptional variables? */
251 /* Check that an expression has a particular kind. */
254 kind_value_check (gfc_expr * e, int n, int k)
259 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of kind %d",
260 gfc_current_intrinsic_arg[n], gfc_current_intrinsic,
266 /* Make sure an expression is a variable. */
269 variable_check (gfc_expr * e, int n)
271 if ((e->expr_type == EXPR_VARIABLE
272 && e->symtree->n.sym->attr.flavor != FL_PARAMETER)
273 || (e->expr_type == EXPR_FUNCTION
274 && e->symtree->n.sym->result == e->symtree->n.sym))
277 if (e->expr_type == EXPR_VARIABLE
278 && e->symtree->n.sym->attr.intent == INTENT_IN)
280 gfc_error ("'%s' argument of '%s' intrinsic at %L cannot be INTENT(IN)",
281 gfc_current_intrinsic_arg[n], gfc_current_intrinsic,
286 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a variable",
287 gfc_current_intrinsic_arg[n], gfc_current_intrinsic, &e->where);
293 /* Check the common DIM parameter for correctness. */
296 dim_check (gfc_expr * dim, int n, int optional)
303 if (nonoptional_check (dim, n) == FAILURE)
311 gfc_error ("Missing DIM parameter in intrinsic '%s' at %L",
312 gfc_current_intrinsic, gfc_current_intrinsic_where);
316 if (type_check (dim, n, BT_INTEGER) == FAILURE)
319 if (scalar_check (dim, n) == FAILURE)
326 /* If a DIM parameter is a constant, make sure that it is greater than
327 zero and less than or equal to the rank of the given array. If
328 allow_assumed is zero then dim must be less than the rank of the array
329 for assumed size arrays. */
332 dim_rank_check (gfc_expr * dim, gfc_expr * array, int allow_assumed)
337 if (dim->expr_type != EXPR_CONSTANT || array->expr_type != EXPR_VARIABLE)
340 ar = gfc_find_array_ref (array);
342 if (ar->as->type == AS_ASSUMED_SIZE && !allow_assumed)
345 if (mpz_cmp_ui (dim->value.integer, 1) < 0
346 || mpz_cmp_ui (dim->value.integer, rank) > 0)
348 gfc_error ("'dim' argument of '%s' intrinsic at %L is not a valid "
349 "dimension index", gfc_current_intrinsic, &dim->where);
358 /***** Check functions *****/
360 /* Check subroutine suitable for intrinsics taking a real argument and
361 a kind argument for the result. */
364 check_a_kind (gfc_expr * a, gfc_expr * kind, bt type)
366 if (type_check (a, 0, BT_REAL) == FAILURE)
368 if (kind_check (kind, 1, type) == FAILURE)
374 /* Check subroutine suitable for ceiling, floor and nint. */
377 gfc_check_a_ikind (gfc_expr * a, gfc_expr * kind)
379 return check_a_kind (a, kind, BT_INTEGER);
382 /* Check subroutine suitable for aint, anint. */
385 gfc_check_a_xkind (gfc_expr * a, gfc_expr * kind)
387 return check_a_kind (a, kind, BT_REAL);
391 gfc_check_abs (gfc_expr * a)
393 if (numeric_check (a, 0) == FAILURE)
400 gfc_check_achar (gfc_expr * a)
403 if (type_check (a, 0, BT_INTEGER) == FAILURE)
411 gfc_check_all_any (gfc_expr * mask, gfc_expr * dim)
413 if (logical_array_check (mask, 0) == FAILURE)
416 if (dim_check (dim, 1, 1) == FAILURE)
424 gfc_check_allocated (gfc_expr * array)
426 if (variable_check (array, 0) == FAILURE)
429 if (array_check (array, 0) == FAILURE)
432 if (!array->symtree->n.sym->attr.allocatable)
434 gfc_error ("'%s' argument of '%s' intrinsic at %L must be ALLOCATABLE",
435 gfc_current_intrinsic_arg[0], gfc_current_intrinsic,
444 /* Common check function where the first argument must be real or
445 integer and the second argument must be the same as the first. */
448 gfc_check_a_p (gfc_expr * a, gfc_expr * p)
450 if (int_or_real_check (a, 0) == FAILURE)
453 if (same_type_check (a, 0, p, 1) == FAILURE)
461 gfc_check_associated (gfc_expr * pointer, gfc_expr * target)
463 symbol_attribute attr;
467 if (variable_check (pointer, 0) == FAILURE)
470 attr = gfc_variable_attr (pointer, NULL);
473 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a POINTER",
474 gfc_current_intrinsic_arg[0], gfc_current_intrinsic,
482 /* Target argument is optional. */
483 if (target->expr_type == EXPR_NULL)
485 gfc_error ("NULL pointer at %L is not permitted as actual argument "
486 "of '%s' intrinsic function",
487 &target->where, gfc_current_intrinsic);
491 attr = gfc_variable_attr (target, NULL);
492 if (!attr.pointer && !attr.target)
494 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a POINTER "
495 "or a TARGET", gfc_current_intrinsic_arg[1],
496 gfc_current_intrinsic, &target->where);
501 if (same_type_check (pointer, 0, target, 1) == FAILURE)
503 if (rank_check (target, 0, pointer->rank) == FAILURE)
505 if (target->rank > 0)
507 for (i = 0; i < target->rank; i++)
508 if (target->ref->u.ar.dimen_type[i] == DIMEN_VECTOR)
510 gfc_error ("Array section with a vector subscript at %L shall not "
511 "be the target of a pointer",
522 gfc_check_atan2 (gfc_expr * y, gfc_expr * x)
524 if (type_check (y, 0, BT_REAL) == FAILURE)
526 if (same_type_check (y, 0, x, 1) == FAILURE)
533 /* BESJN and BESYN functions. */
536 gfc_check_besn (gfc_expr * n, gfc_expr * x)
538 if (scalar_check (n, 0) == FAILURE)
541 if (type_check (n, 0, BT_INTEGER) == FAILURE)
544 if (scalar_check (x, 1) == FAILURE)
547 if (type_check (x, 1, BT_REAL) == FAILURE)
555 gfc_check_btest (gfc_expr * i, gfc_expr * pos)
557 if (type_check (i, 0, BT_INTEGER) == FAILURE)
559 if (type_check (pos, 1, BT_INTEGER) == FAILURE)
567 gfc_check_char (gfc_expr * i, gfc_expr * kind)
569 if (type_check (i, 0, BT_INTEGER) == FAILURE)
571 if (kind_check (kind, 1, BT_CHARACTER) == FAILURE)
579 gfc_check_chdir (gfc_expr * dir)
581 if (type_check (dir, 0, BT_CHARACTER) == FAILURE)
589 gfc_check_chdir_sub (gfc_expr * dir, gfc_expr * status)
591 if (type_check (dir, 0, BT_CHARACTER) == FAILURE)
597 if (type_check (status, 1, BT_INTEGER) == FAILURE)
600 if (scalar_check (status, 1) == FAILURE)
608 gfc_check_cmplx (gfc_expr * x, gfc_expr * y, gfc_expr * kind)
610 if (numeric_check (x, 0) == FAILURE)
615 if (numeric_check (y, 1) == FAILURE)
618 if (x->ts.type == BT_COMPLEX)
620 gfc_error ("'%s' argument of '%s' intrinsic at %L must not be "
621 "present if 'x' is COMPLEX", gfc_current_intrinsic_arg[1],
622 gfc_current_intrinsic, &y->where);
627 if (kind_check (kind, 2, BT_COMPLEX) == FAILURE)
635 gfc_check_complex (gfc_expr * x, gfc_expr * y)
637 if (x->ts.type != BT_INTEGER && x->ts.type != BT_REAL)
640 "'%s' argument of '%s' intrinsic at %L must be INTEGER or REAL",
641 gfc_current_intrinsic_arg[0], gfc_current_intrinsic, &x->where);
644 if (scalar_check (x, 0) == FAILURE)
647 if (y->ts.type != BT_INTEGER && y->ts.type != BT_REAL)
650 "'%s' argument of '%s' intrinsic at %L must be INTEGER or REAL",
651 gfc_current_intrinsic_arg[1], gfc_current_intrinsic, &y->where);
654 if (scalar_check (y, 1) == FAILURE)
662 gfc_check_count (gfc_expr * mask, gfc_expr * dim)
664 if (logical_array_check (mask, 0) == FAILURE)
666 if (dim_check (dim, 1, 1) == FAILURE)
674 gfc_check_cshift (gfc_expr * array, gfc_expr * shift, gfc_expr * dim)
676 if (array_check (array, 0) == FAILURE)
679 if (array->rank == 1)
681 if (scalar_check (shift, 1) == FAILURE)
686 /* TODO: more requirements on shift parameter. */
689 if (dim_check (dim, 2, 1) == FAILURE)
697 gfc_check_ctime (gfc_expr * time)
699 if (scalar_check (time, 0) == FAILURE)
702 if (type_check (time, 0, BT_INTEGER) == FAILURE)
710 gfc_check_dcmplx (gfc_expr * x, gfc_expr * y)
712 if (numeric_check (x, 0) == FAILURE)
717 if (numeric_check (y, 1) == FAILURE)
720 if (x->ts.type == BT_COMPLEX)
722 gfc_error ("'%s' argument of '%s' intrinsic at %L must not be "
723 "present if 'x' is COMPLEX", gfc_current_intrinsic_arg[1],
724 gfc_current_intrinsic, &y->where);
734 gfc_check_dble (gfc_expr * x)
736 if (numeric_check (x, 0) == FAILURE)
744 gfc_check_digits (gfc_expr * x)
746 if (int_or_real_check (x, 0) == FAILURE)
754 gfc_check_dot_product (gfc_expr * vector_a, gfc_expr * vector_b)
756 switch (vector_a->ts.type)
759 if (type_check (vector_b, 1, BT_LOGICAL) == FAILURE)
766 if (numeric_check (vector_b, 1) == FAILURE)
771 gfc_error ("'%s' argument of '%s' intrinsic at %L must be numeric "
772 "or LOGICAL", gfc_current_intrinsic_arg[0],
773 gfc_current_intrinsic, &vector_a->where);
777 if (rank_check (vector_a, 0, 1) == FAILURE)
780 if (rank_check (vector_b, 1, 1) == FAILURE)
788 gfc_check_eoshift (gfc_expr * array, gfc_expr * shift, gfc_expr * boundary,
791 if (array_check (array, 0) == FAILURE)
794 if (type_check (shift, 1, BT_INTEGER) == FAILURE)
797 if (array->rank == 1)
799 if (scalar_check (shift, 2) == FAILURE)
804 /* TODO: more weird restrictions on shift. */
807 if (boundary != NULL)
809 if (same_type_check (array, 0, boundary, 2) == FAILURE)
812 /* TODO: more restrictions on boundary. */
815 if (dim_check (dim, 1, 1) == FAILURE)
822 /* A single complex argument. */
825 gfc_check_fn_c (gfc_expr * a)
827 if (type_check (a, 0, BT_COMPLEX) == FAILURE)
834 /* A single real argument. */
837 gfc_check_fn_r (gfc_expr * a)
839 if (type_check (a, 0, BT_REAL) == FAILURE)
846 /* A single real or complex argument. */
849 gfc_check_fn_rc (gfc_expr * a)
851 if (real_or_complex_check (a, 0) == FAILURE)
859 gfc_check_fnum (gfc_expr * unit)
861 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
864 if (scalar_check (unit, 0) == FAILURE)
871 /* This is used for the g77 one-argument Bessel functions, and the
875 gfc_check_g77_math1 (gfc_expr * x)
877 if (scalar_check (x, 0) == FAILURE)
880 if (type_check (x, 0, BT_REAL) == FAILURE)
888 gfc_check_huge (gfc_expr * x)
890 if (int_or_real_check (x, 0) == FAILURE)
897 /* Check that the single argument is an integer. */
900 gfc_check_i (gfc_expr * i)
902 if (type_check (i, 0, BT_INTEGER) == FAILURE)
910 gfc_check_iand (gfc_expr * i, gfc_expr * j)
912 if (type_check (i, 0, BT_INTEGER) == FAILURE)
915 if (type_check (j, 1, BT_INTEGER) == FAILURE)
918 if (i->ts.kind != j->ts.kind)
920 if (gfc_notify_std (GFC_STD_GNU, "Extension: Different type kinds at %L",
921 &i->where) == FAILURE)
930 gfc_check_ibclr (gfc_expr * i, gfc_expr * pos)
932 if (type_check (i, 0, BT_INTEGER) == FAILURE)
935 if (type_check (pos, 1, BT_INTEGER) == FAILURE)
943 gfc_check_ibits (gfc_expr * i, gfc_expr * pos, gfc_expr * len)
945 if (type_check (i, 0, BT_INTEGER) == FAILURE)
948 if (type_check (pos, 1, BT_INTEGER) == FAILURE)
951 if (type_check (len, 2, BT_INTEGER) == FAILURE)
959 gfc_check_ibset (gfc_expr * i, gfc_expr * pos)
961 if (type_check (i, 0, BT_INTEGER) == FAILURE)
964 if (type_check (pos, 1, BT_INTEGER) == FAILURE)
972 gfc_check_ichar_iachar (gfc_expr * c)
976 if (type_check (c, 0, BT_CHARACTER) == FAILURE)
979 if (c->expr_type == EXPR_VARIABLE || c->expr_type == EXPR_SUBSTRING)
985 /* Substring references don't have the charlength set. */
987 while (ref && ref->type != REF_SUBSTRING)
990 gcc_assert (ref == NULL || ref->type == REF_SUBSTRING);
994 /* Check that the argument is length one. Non-constant lengths
995 can't be checked here, so assume thay are ok. */
996 if (c->ts.cl && c->ts.cl->length)
998 /* If we already have a length for this expression then use it. */
999 if (c->ts.cl->length->expr_type != EXPR_CONSTANT)
1001 i = mpz_get_si (c->ts.cl->length->value.integer);
1008 start = ref->u.ss.start;
1009 end = ref->u.ss.end;
1012 if (end == NULL || end->expr_type != EXPR_CONSTANT
1013 || start->expr_type != EXPR_CONSTANT)
1016 i = mpz_get_si (end->value.integer) + 1
1017 - mpz_get_si (start->value.integer);
1025 gfc_error ("Argument of %s at %L must be of length one",
1026 gfc_current_intrinsic, &c->where);
1035 gfc_check_idnint (gfc_expr * a)
1037 if (double_check (a, 0) == FAILURE)
1045 gfc_check_ieor (gfc_expr * i, gfc_expr * j)
1047 if (type_check (i, 0, BT_INTEGER) == FAILURE)
1050 if (type_check (j, 1, BT_INTEGER) == FAILURE)
1053 if (i->ts.kind != j->ts.kind)
1055 if (gfc_notify_std (GFC_STD_GNU, "Extension: Different type kinds at %L",
1056 &i->where) == FAILURE)
1065 gfc_check_index (gfc_expr * string, gfc_expr * substring, gfc_expr * back)
1067 if (type_check (string, 0, BT_CHARACTER) == FAILURE
1068 || type_check (substring, 1, BT_CHARACTER) == FAILURE)
1072 if (back != NULL && type_check (back, 2, BT_LOGICAL) == FAILURE)
1075 if (string->ts.kind != substring->ts.kind)
1077 gfc_error ("'%s' argument of '%s' intrinsic at %L must be the same "
1078 "kind as '%s'", gfc_current_intrinsic_arg[1],
1079 gfc_current_intrinsic, &substring->where,
1080 gfc_current_intrinsic_arg[0]);
1089 gfc_check_int (gfc_expr * x, gfc_expr * kind)
1091 if (numeric_check (x, 0) == FAILURE)
1096 if (type_check (kind, 1, BT_INTEGER) == FAILURE)
1099 if (scalar_check (kind, 1) == FAILURE)
1108 gfc_check_ior (gfc_expr * i, gfc_expr * j)
1110 if (type_check (i, 0, BT_INTEGER) == FAILURE)
1113 if (type_check (j, 1, BT_INTEGER) == FAILURE)
1116 if (i->ts.kind != j->ts.kind)
1118 if (gfc_notify_std (GFC_STD_GNU, "Extension: Different type kinds at %L",
1119 &i->where) == FAILURE)
1128 gfc_check_ishft (gfc_expr * i, gfc_expr * shift)
1130 if (type_check (i, 0, BT_INTEGER) == FAILURE
1131 || type_check (shift, 1, BT_INTEGER) == FAILURE)
1139 gfc_check_ishftc (gfc_expr * i, gfc_expr * shift, gfc_expr * size)
1141 if (type_check (i, 0, BT_INTEGER) == FAILURE
1142 || type_check (shift, 1, BT_INTEGER) == FAILURE)
1145 if (size != NULL && type_check (size, 2, BT_INTEGER) == FAILURE)
1153 gfc_check_kill (gfc_expr * pid, gfc_expr * sig)
1155 if (type_check (pid, 0, BT_INTEGER) == FAILURE)
1158 if (type_check (sig, 1, BT_INTEGER) == FAILURE)
1166 gfc_check_kill_sub (gfc_expr * pid, gfc_expr * sig, gfc_expr * status)
1168 if (type_check (pid, 0, BT_INTEGER) == FAILURE)
1171 if (type_check (sig, 1, BT_INTEGER) == FAILURE)
1177 if (type_check (status, 2, BT_INTEGER) == FAILURE)
1180 if (scalar_check (status, 2) == FAILURE)
1188 gfc_check_kind (gfc_expr * x)
1190 if (x->ts.type == BT_DERIVED)
1192 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a "
1193 "non-derived type", gfc_current_intrinsic_arg[0],
1194 gfc_current_intrinsic, &x->where);
1203 gfc_check_lbound (gfc_expr * array, gfc_expr * dim)
1205 if (array_check (array, 0) == FAILURE)
1210 if (dim_check (dim, 1, 1) == FAILURE)
1213 if (dim_rank_check (dim, array, 1) == FAILURE)
1221 gfc_check_link (gfc_expr * path1, gfc_expr * path2)
1223 if (type_check (path1, 0, BT_CHARACTER) == FAILURE)
1226 if (type_check (path2, 1, BT_CHARACTER) == FAILURE)
1234 gfc_check_link_sub (gfc_expr * path1, gfc_expr * path2, gfc_expr * status)
1236 if (type_check (path1, 0, BT_CHARACTER) == FAILURE)
1239 if (type_check (path2, 1, BT_CHARACTER) == FAILURE)
1245 if (type_check (status, 2, BT_INTEGER) == FAILURE)
1248 if (scalar_check (status, 2) == FAILURE)
1255 gfc_check_loc (gfc_expr *expr)
1257 return variable_check (expr, 0);
1262 gfc_check_symlnk (gfc_expr * path1, gfc_expr * path2)
1264 if (type_check (path1, 0, BT_CHARACTER) == FAILURE)
1267 if (type_check (path2, 1, BT_CHARACTER) == FAILURE)
1275 gfc_check_symlnk_sub (gfc_expr * path1, gfc_expr * path2, gfc_expr * status)
1277 if (type_check (path1, 0, BT_CHARACTER) == FAILURE)
1280 if (type_check (path2, 1, BT_CHARACTER) == FAILURE)
1286 if (type_check (status, 2, BT_INTEGER) == FAILURE)
1289 if (scalar_check (status, 2) == FAILURE)
1297 gfc_check_logical (gfc_expr * a, gfc_expr * kind)
1299 if (type_check (a, 0, BT_LOGICAL) == FAILURE)
1301 if (kind_check (kind, 1, BT_LOGICAL) == FAILURE)
1308 /* Min/max family. */
1311 min_max_args (gfc_actual_arglist * arg)
1313 if (arg == NULL || arg->next == NULL)
1315 gfc_error ("Intrinsic '%s' at %L must have at least two arguments",
1316 gfc_current_intrinsic, gfc_current_intrinsic_where);
1325 check_rest (bt type, int kind, gfc_actual_arglist * arg)
1330 if (min_max_args (arg) == FAILURE)
1335 for (; arg; arg = arg->next, n++)
1338 if (x->ts.type != type || x->ts.kind != kind)
1340 if (x->ts.type == type)
1342 if (gfc_notify_std (GFC_STD_GNU,
1343 "Extension: Different type kinds at %L", &x->where)
1349 gfc_error ("'a%d' argument of '%s' intrinsic at %L must be %s(%d)",
1350 n, gfc_current_intrinsic, &x->where,
1351 gfc_basic_typename (type), kind);
1362 gfc_check_min_max (gfc_actual_arglist * arg)
1366 if (min_max_args (arg) == FAILURE)
1371 if (x->ts.type != BT_INTEGER && x->ts.type != BT_REAL)
1374 ("'a1' argument of '%s' intrinsic at %L must be INTEGER or REAL",
1375 gfc_current_intrinsic, &x->where);
1379 return check_rest (x->ts.type, x->ts.kind, arg);
1384 gfc_check_min_max_integer (gfc_actual_arglist * arg)
1386 return check_rest (BT_INTEGER, gfc_default_integer_kind, arg);
1391 gfc_check_min_max_real (gfc_actual_arglist * arg)
1393 return check_rest (BT_REAL, gfc_default_real_kind, arg);
1398 gfc_check_min_max_double (gfc_actual_arglist * arg)
1400 return check_rest (BT_REAL, gfc_default_double_kind, arg);
1403 /* End of min/max family. */
1406 gfc_check_malloc (gfc_expr * size)
1408 if (type_check (size, 0, BT_INTEGER) == FAILURE)
1411 if (scalar_check (size, 0) == FAILURE)
1419 gfc_check_matmul (gfc_expr * matrix_a, gfc_expr * matrix_b)
1421 if ((matrix_a->ts.type != BT_LOGICAL) && !gfc_numeric_ts (&matrix_b->ts))
1423 gfc_error ("'%s' argument of '%s' intrinsic at %L must be numeric "
1424 "or LOGICAL", gfc_current_intrinsic_arg[0],
1425 gfc_current_intrinsic, &matrix_a->where);
1429 if ((matrix_b->ts.type != BT_LOGICAL) && !gfc_numeric_ts (&matrix_a->ts))
1431 gfc_error ("'%s' argument of '%s' intrinsic at %L must be numeric "
1432 "or LOGICAL", gfc_current_intrinsic_arg[1],
1433 gfc_current_intrinsic, &matrix_b->where);
1437 switch (matrix_a->rank)
1440 if (rank_check (matrix_b, 1, 2) == FAILURE)
1445 if (matrix_b->rank == 2)
1447 if (rank_check (matrix_b, 1, 1) == FAILURE)
1452 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of rank "
1453 "1 or 2", gfc_current_intrinsic_arg[0],
1454 gfc_current_intrinsic, &matrix_a->where);
1462 /* Whoever came up with this interface was probably on something.
1463 The possibilities for the occupation of the second and third
1470 NULL MASK minloc(array, mask=m)
1473 I.e. in the case of minloc(array,mask), mask will be in the second
1474 position of the argument list and we'll have to fix that up. */
1477 gfc_check_minloc_maxloc (gfc_actual_arglist * ap)
1479 gfc_expr *a, *m, *d;
1482 if (int_or_real_check (a, 0) == FAILURE
1483 || array_check (a, 0) == FAILURE)
1487 m = ap->next->next->expr;
1489 if (m == NULL && d != NULL && d->ts.type == BT_LOGICAL
1490 && ap->next->name == NULL)
1495 ap->next->expr = NULL;
1496 ap->next->next->expr = m;
1500 && (scalar_check (d, 1) == FAILURE
1501 || type_check (d, 1, BT_INTEGER) == FAILURE))
1504 if (m != NULL && type_check (m, 2, BT_LOGICAL) == FAILURE)
1511 /* Similar to minloc/maxloc, the argument list might need to be
1512 reordered for the MINVAL, MAXVAL, PRODUCT, and SUM intrinsics. The
1513 difference is that MINLOC/MAXLOC take an additional KIND argument.
1514 The possibilities are:
1520 NULL MASK minval(array, mask=m)
1523 I.e. in the case of minval(array,mask), mask will be in the second
1524 position of the argument list and we'll have to fix that up. */
1527 check_reduction (gfc_actual_arglist * ap)
1532 m = ap->next->next->expr;
1534 if (m == NULL && d != NULL && d->ts.type == BT_LOGICAL
1535 && ap->next->name == NULL)
1540 ap->next->expr = NULL;
1541 ap->next->next->expr = m;
1545 && (scalar_check (d, 1) == FAILURE
1546 || type_check (d, 1, BT_INTEGER) == FAILURE))
1549 if (m != NULL && type_check (m, 2, BT_LOGICAL) == FAILURE)
1557 gfc_check_minval_maxval (gfc_actual_arglist * ap)
1559 if (int_or_real_check (ap->expr, 0) == FAILURE
1560 || array_check (ap->expr, 0) == FAILURE)
1563 return check_reduction (ap);
1568 gfc_check_product_sum (gfc_actual_arglist * ap)
1570 if (numeric_check (ap->expr, 0) == FAILURE
1571 || array_check (ap->expr, 0) == FAILURE)
1574 return check_reduction (ap);
1579 gfc_check_merge (gfc_expr * tsource, gfc_expr * fsource, gfc_expr * mask)
1581 if (same_type_check (tsource, 0, fsource, 1) == FAILURE)
1584 if (type_check (mask, 2, BT_LOGICAL) == FAILURE)
1592 gfc_check_nearest (gfc_expr * x, gfc_expr * s)
1594 if (type_check (x, 0, BT_REAL) == FAILURE)
1597 if (type_check (s, 1, BT_REAL) == FAILURE)
1605 gfc_check_null (gfc_expr * mold)
1607 symbol_attribute attr;
1612 if (variable_check (mold, 0) == FAILURE)
1615 attr = gfc_variable_attr (mold, NULL);
1619 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a POINTER",
1620 gfc_current_intrinsic_arg[0],
1621 gfc_current_intrinsic, &mold->where);
1630 gfc_check_pack (gfc_expr * array, gfc_expr * mask, gfc_expr * vector)
1632 if (array_check (array, 0) == FAILURE)
1635 if (type_check (mask, 1, BT_LOGICAL) == FAILURE)
1638 if (mask->rank != 0 && mask->rank != array->rank)
1640 gfc_error ("'%s' argument of '%s' intrinsic at %L must be conformable "
1641 "with '%s' argument", gfc_current_intrinsic_arg[0],
1642 gfc_current_intrinsic, &array->where,
1643 gfc_current_intrinsic_arg[1]);
1649 if (same_type_check (array, 0, vector, 2) == FAILURE)
1652 if (rank_check (vector, 2, 1) == FAILURE)
1655 /* TODO: More constraints here. */
1663 gfc_check_precision (gfc_expr * x)
1665 if (x->ts.type != BT_REAL && x->ts.type != BT_COMPLEX)
1667 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of type "
1668 "REAL or COMPLEX", gfc_current_intrinsic_arg[0],
1669 gfc_current_intrinsic, &x->where);
1678 gfc_check_present (gfc_expr * a)
1682 if (variable_check (a, 0) == FAILURE)
1685 sym = a->symtree->n.sym;
1686 if (!sym->attr.dummy)
1688 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of a "
1689 "dummy variable", gfc_current_intrinsic_arg[0],
1690 gfc_current_intrinsic, &a->where);
1694 if (!sym->attr.optional)
1696 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of "
1697 "an OPTIONAL dummy variable", gfc_current_intrinsic_arg[0],
1698 gfc_current_intrinsic, &a->where);
1707 gfc_check_radix (gfc_expr * x)
1709 if (int_or_real_check (x, 0) == FAILURE)
1717 gfc_check_range (gfc_expr * x)
1719 if (numeric_check (x, 0) == FAILURE)
1726 /* real, float, sngl. */
1728 gfc_check_real (gfc_expr * a, gfc_expr * kind)
1730 if (numeric_check (a, 0) == FAILURE)
1733 if (kind_check (kind, 1, BT_REAL) == FAILURE)
1741 gfc_check_rename (gfc_expr * path1, gfc_expr * path2)
1743 if (type_check (path1, 0, BT_CHARACTER) == FAILURE)
1746 if (type_check (path2, 1, BT_CHARACTER) == FAILURE)
1754 gfc_check_rename_sub (gfc_expr * path1, gfc_expr * path2, gfc_expr * status)
1756 if (type_check (path1, 0, BT_CHARACTER) == FAILURE)
1759 if (type_check (path2, 1, BT_CHARACTER) == FAILURE)
1765 if (type_check (status, 2, BT_INTEGER) == FAILURE)
1768 if (scalar_check (status, 2) == FAILURE)
1776 gfc_check_repeat (gfc_expr * x, gfc_expr * y)
1778 if (type_check (x, 0, BT_CHARACTER) == FAILURE)
1781 if (scalar_check (x, 0) == FAILURE)
1784 if (type_check (y, 0, BT_INTEGER) == FAILURE)
1787 if (scalar_check (y, 1) == FAILURE)
1795 gfc_check_reshape (gfc_expr * source, gfc_expr * shape,
1796 gfc_expr * pad, gfc_expr * order)
1801 if (array_check (source, 0) == FAILURE)
1804 if (rank_check (shape, 1, 1) == FAILURE)
1807 if (type_check (shape, 1, BT_INTEGER) == FAILURE)
1810 if (gfc_array_size (shape, &size) != SUCCESS)
1812 gfc_error ("'shape' argument of 'reshape' intrinsic at %L must be an "
1813 "array of constant size", &shape->where);
1817 m = mpz_cmp_ui (size, GFC_MAX_DIMENSIONS);
1822 gfc_error ("'shape' argument of 'reshape' intrinsic at %L has more "
1823 "than %d elements", &shape->where, GFC_MAX_DIMENSIONS);
1829 if (same_type_check (source, 0, pad, 2) == FAILURE)
1831 if (array_check (pad, 2) == FAILURE)
1835 if (order != NULL && array_check (order, 3) == FAILURE)
1843 gfc_check_scale (gfc_expr * x, gfc_expr * i)
1845 if (type_check (x, 0, BT_REAL) == FAILURE)
1848 if (type_check (i, 1, BT_INTEGER) == FAILURE)
1856 gfc_check_scan (gfc_expr * x, gfc_expr * y, gfc_expr * z)
1858 if (type_check (x, 0, BT_CHARACTER) == FAILURE)
1861 if (type_check (y, 1, BT_CHARACTER) == FAILURE)
1864 if (z != NULL && type_check (z, 2, BT_LOGICAL) == FAILURE)
1867 if (same_type_check (x, 0, y, 1) == FAILURE)
1875 gfc_check_secnds (gfc_expr * r)
1878 if (type_check (r, 0, BT_REAL) == FAILURE)
1881 if (kind_value_check (r, 0, 4) == FAILURE)
1884 if (scalar_check (r, 0) == FAILURE)
1892 gfc_check_selected_int_kind (gfc_expr * r)
1895 if (type_check (r, 0, BT_INTEGER) == FAILURE)
1898 if (scalar_check (r, 0) == FAILURE)
1906 gfc_check_selected_real_kind (gfc_expr * p, gfc_expr * r)
1908 if (p == NULL && r == NULL)
1910 gfc_error ("Missing arguments to %s intrinsic at %L",
1911 gfc_current_intrinsic, gfc_current_intrinsic_where);
1916 if (p != NULL && type_check (p, 0, BT_INTEGER) == FAILURE)
1919 if (r != NULL && type_check (r, 1, BT_INTEGER) == FAILURE)
1927 gfc_check_set_exponent (gfc_expr * x, gfc_expr * i)
1929 if (type_check (x, 0, BT_REAL) == FAILURE)
1932 if (type_check (i, 1, BT_INTEGER) == FAILURE)
1940 gfc_check_shape (gfc_expr * source)
1944 if (source->rank == 0 || source->expr_type != EXPR_VARIABLE)
1947 ar = gfc_find_array_ref (source);
1949 if (ar->as && ar->as->type == AS_ASSUMED_SIZE)
1951 gfc_error ("'source' argument of 'shape' intrinsic at %L must not be "
1952 "an assumed size array", &source->where);
1961 gfc_check_sign (gfc_expr * a, gfc_expr * b)
1963 if (int_or_real_check (a, 0) == FAILURE)
1966 if (same_type_check (a, 0, b, 1) == FAILURE)
1974 gfc_check_size (gfc_expr * array, gfc_expr * dim)
1976 if (array_check (array, 0) == FAILURE)
1981 if (type_check (dim, 1, BT_INTEGER) == FAILURE)
1984 if (kind_value_check (dim, 1, gfc_default_integer_kind) == FAILURE)
1987 if (dim_rank_check (dim, array, 0) == FAILURE)
1996 gfc_check_sleep_sub (gfc_expr * seconds)
1998 if (type_check (seconds, 0, BT_INTEGER) == FAILURE)
2001 if (scalar_check (seconds, 0) == FAILURE)
2009 gfc_check_spread (gfc_expr * source, gfc_expr * dim, gfc_expr * ncopies)
2011 if (source->rank >= GFC_MAX_DIMENSIONS)
2013 gfc_error ("'%s' argument of '%s' intrinsic at %L must be less "
2014 "than rank %d", gfc_current_intrinsic_arg[0],
2015 gfc_current_intrinsic, &source->where, GFC_MAX_DIMENSIONS);
2020 if (dim_check (dim, 1, 0) == FAILURE)
2023 if (type_check (ncopies, 2, BT_INTEGER) == FAILURE)
2026 if (scalar_check (ncopies, 2) == FAILURE)
2033 /* Functions for checking FGETC, FPUTC, FGET and FPUT (subroutines and
2036 gfc_check_fgetputc_sub (gfc_expr * unit, gfc_expr * c, gfc_expr * status)
2038 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
2041 if (scalar_check (unit, 0) == FAILURE)
2044 if (type_check (c, 1, BT_CHARACTER) == FAILURE)
2050 if (type_check (status, 2, BT_INTEGER) == FAILURE
2051 || kind_value_check (status, 2, gfc_default_integer_kind) == FAILURE
2052 || scalar_check (status, 2) == FAILURE)
2060 gfc_check_fgetputc (gfc_expr * unit, gfc_expr * c)
2062 return gfc_check_fgetputc_sub (unit, c, NULL);
2067 gfc_check_fgetput_sub (gfc_expr * c, gfc_expr * status)
2069 if (type_check (c, 0, BT_CHARACTER) == FAILURE)
2075 if (type_check (status, 1, BT_INTEGER) == FAILURE
2076 || kind_value_check (status, 1, gfc_default_integer_kind) == FAILURE
2077 || scalar_check (status, 1) == FAILURE)
2085 gfc_check_fgetput (gfc_expr * c)
2087 return gfc_check_fgetput_sub (c, NULL);
2092 gfc_check_fstat (gfc_expr * unit, gfc_expr * array)
2094 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
2097 if (scalar_check (unit, 0) == FAILURE)
2100 if (type_check (array, 1, BT_INTEGER) == FAILURE
2101 || kind_value_check (unit, 0, gfc_default_integer_kind) == FAILURE)
2104 if (array_check (array, 1) == FAILURE)
2112 gfc_check_fstat_sub (gfc_expr * unit, gfc_expr * array, gfc_expr * status)
2114 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
2117 if (scalar_check (unit, 0) == FAILURE)
2120 if (type_check (array, 1, BT_INTEGER) == FAILURE
2121 || kind_value_check (array, 1, gfc_default_integer_kind) == FAILURE)
2124 if (array_check (array, 1) == FAILURE)
2130 if (type_check (status, 2, BT_INTEGER) == FAILURE
2131 || kind_value_check (status, 2, gfc_default_integer_kind) == FAILURE)
2134 if (scalar_check (status, 2) == FAILURE)
2142 gfc_check_ftell (gfc_expr * unit)
2144 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
2147 if (scalar_check (unit, 0) == FAILURE)
2155 gfc_check_ftell_sub (gfc_expr * unit, gfc_expr * offset)
2157 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
2160 if (scalar_check (unit, 0) == FAILURE)
2163 if (type_check (offset, 1, BT_INTEGER) == FAILURE)
2166 if (scalar_check (offset, 1) == FAILURE)
2174 gfc_check_stat (gfc_expr * name, gfc_expr * array)
2176 if (type_check (name, 0, BT_CHARACTER) == FAILURE)
2179 if (type_check (array, 1, BT_INTEGER) == FAILURE
2180 || kind_value_check (array, 1, gfc_default_integer_kind) == FAILURE)
2183 if (array_check (array, 1) == FAILURE)
2191 gfc_check_stat_sub (gfc_expr * name, gfc_expr * array, gfc_expr * status)
2193 if (type_check (name, 0, BT_CHARACTER) == FAILURE)
2196 if (type_check (array, 1, BT_INTEGER) == FAILURE
2197 || kind_value_check (array, 1, gfc_default_integer_kind) == FAILURE)
2200 if (array_check (array, 1) == FAILURE)
2206 if (type_check (status, 2, BT_INTEGER) == FAILURE
2207 || kind_value_check (array, 1, gfc_default_integer_kind) == FAILURE)
2210 if (scalar_check (status, 2) == FAILURE)
2218 gfc_check_transfer (gfc_expr * source ATTRIBUTE_UNUSED,
2219 gfc_expr * mold ATTRIBUTE_UNUSED,
2224 if (type_check (size, 2, BT_INTEGER) == FAILURE)
2227 if (scalar_check (size, 2) == FAILURE)
2230 if (nonoptional_check (size, 2) == FAILURE)
2239 gfc_check_transpose (gfc_expr * matrix)
2241 if (rank_check (matrix, 0, 2) == FAILURE)
2249 gfc_check_ubound (gfc_expr * array, gfc_expr * dim)
2251 if (array_check (array, 0) == FAILURE)
2256 if (dim_check (dim, 1, 1) == FAILURE)
2259 if (dim_rank_check (dim, array, 0) == FAILURE)
2268 gfc_check_unpack (gfc_expr * vector, gfc_expr * mask, gfc_expr * field)
2270 if (rank_check (vector, 0, 1) == FAILURE)
2273 if (array_check (mask, 1) == FAILURE)
2276 if (type_check (mask, 1, BT_LOGICAL) == FAILURE)
2279 if (same_type_check (vector, 0, field, 2) == FAILURE)
2287 gfc_check_verify (gfc_expr * x, gfc_expr * y, gfc_expr * z)
2289 if (type_check (x, 0, BT_CHARACTER) == FAILURE)
2292 if (same_type_check (x, 0, y, 1) == FAILURE)
2295 if (z != NULL && type_check (z, 2, BT_LOGICAL) == FAILURE)
2303 gfc_check_trim (gfc_expr * x)
2305 if (type_check (x, 0, BT_CHARACTER) == FAILURE)
2308 if (scalar_check (x, 0) == FAILURE)
2316 gfc_check_ttynam (gfc_expr * unit)
2318 if (scalar_check (unit, 0) == FAILURE)
2321 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
2328 /* Common check function for the half a dozen intrinsics that have a
2329 single real argument. */
2332 gfc_check_x (gfc_expr * x)
2334 if (type_check (x, 0, BT_REAL) == FAILURE)
2341 /************* Check functions for intrinsic subroutines *************/
2344 gfc_check_cpu_time (gfc_expr * time)
2346 if (scalar_check (time, 0) == FAILURE)
2349 if (type_check (time, 0, BT_REAL) == FAILURE)
2352 if (variable_check (time, 0) == FAILURE)
2360 gfc_check_date_and_time (gfc_expr * date, gfc_expr * time,
2361 gfc_expr * zone, gfc_expr * values)
2365 if (type_check (date, 0, BT_CHARACTER) == FAILURE)
2367 if (scalar_check (date, 0) == FAILURE)
2369 if (variable_check (date, 0) == FAILURE)
2375 if (type_check (time, 1, BT_CHARACTER) == FAILURE)
2377 if (scalar_check (time, 1) == FAILURE)
2379 if (variable_check (time, 1) == FAILURE)
2385 if (type_check (zone, 2, BT_CHARACTER) == FAILURE)
2387 if (scalar_check (zone, 2) == FAILURE)
2389 if (variable_check (zone, 2) == FAILURE)
2395 if (type_check (values, 3, BT_INTEGER) == FAILURE)
2397 if (array_check (values, 3) == FAILURE)
2399 if (rank_check (values, 3, 1) == FAILURE)
2401 if (variable_check (values, 3) == FAILURE)
2410 gfc_check_mvbits (gfc_expr * from, gfc_expr * frompos, gfc_expr * len,
2411 gfc_expr * to, gfc_expr * topos)
2413 if (type_check (from, 0, BT_INTEGER) == FAILURE)
2416 if (type_check (frompos, 1, BT_INTEGER) == FAILURE)
2419 if (type_check (len, 2, BT_INTEGER) == FAILURE)
2422 if (same_type_check (from, 0, to, 3) == FAILURE)
2425 if (variable_check (to, 3) == FAILURE)
2428 if (type_check (topos, 4, BT_INTEGER) == FAILURE)
2436 gfc_check_random_number (gfc_expr * harvest)
2438 if (type_check (harvest, 0, BT_REAL) == FAILURE)
2441 if (variable_check (harvest, 0) == FAILURE)
2449 gfc_check_random_seed (gfc_expr * size, gfc_expr * put, gfc_expr * get)
2453 if (scalar_check (size, 0) == FAILURE)
2456 if (type_check (size, 0, BT_INTEGER) == FAILURE)
2459 if (variable_check (size, 0) == FAILURE)
2462 if (kind_value_check (size, 0, gfc_default_integer_kind) == FAILURE)
2470 gfc_error ("Too many arguments to %s at %L", gfc_current_intrinsic,
2473 if (array_check (put, 1) == FAILURE)
2476 if (rank_check (put, 1, 1) == FAILURE)
2479 if (type_check (put, 1, BT_INTEGER) == FAILURE)
2482 if (kind_value_check (put, 1, gfc_default_integer_kind) == FAILURE)
2489 if (size != NULL || put != NULL)
2490 gfc_error ("Too many arguments to %s at %L", gfc_current_intrinsic,
2493 if (array_check (get, 2) == FAILURE)
2496 if (rank_check (get, 2, 1) == FAILURE)
2499 if (type_check (get, 2, BT_INTEGER) == FAILURE)
2502 if (variable_check (get, 2) == FAILURE)
2505 if (kind_value_check (get, 2, gfc_default_integer_kind) == FAILURE)
2513 gfc_check_second_sub (gfc_expr * time)
2515 if (scalar_check (time, 0) == FAILURE)
2518 if (type_check (time, 0, BT_REAL) == FAILURE)
2521 if (kind_value_check(time, 0, 4) == FAILURE)
2528 /* The arguments of SYSTEM_CLOCK are scalar, integer variables. Note,
2529 count, count_rate, and count_max are all optional arguments */
2532 gfc_check_system_clock (gfc_expr * count, gfc_expr * count_rate,
2533 gfc_expr * count_max)
2537 if (scalar_check (count, 0) == FAILURE)
2540 if (type_check (count, 0, BT_INTEGER) == FAILURE)
2543 if (variable_check (count, 0) == FAILURE)
2547 if (count_rate != NULL)
2549 if (scalar_check (count_rate, 1) == FAILURE)
2552 if (type_check (count_rate, 1, BT_INTEGER) == FAILURE)
2555 if (variable_check (count_rate, 1) == FAILURE)
2559 && same_type_check (count, 0, count_rate, 1) == FAILURE)
2564 if (count_max != NULL)
2566 if (scalar_check (count_max, 2) == FAILURE)
2569 if (type_check (count_max, 2, BT_INTEGER) == FAILURE)
2572 if (variable_check (count_max, 2) == FAILURE)
2576 && same_type_check (count, 0, count_max, 2) == FAILURE)
2579 if (count_rate != NULL
2580 && same_type_check (count_rate, 1, count_max, 2) == FAILURE)
2588 gfc_check_irand (gfc_expr * x)
2593 if (scalar_check (x, 0) == FAILURE)
2596 if (type_check (x, 0, BT_INTEGER) == FAILURE)
2599 if (kind_value_check(x, 0, 4) == FAILURE)
2607 gfc_check_alarm_sub (gfc_expr * seconds, gfc_expr * handler, gfc_expr * status)
2609 if (scalar_check (seconds, 0) == FAILURE)
2612 if (type_check (seconds, 0, BT_INTEGER) == FAILURE)
2615 if (handler->ts.type != BT_INTEGER && handler->ts.type != BT_PROCEDURE)
2618 "'%s' argument of '%s' intrinsic at %L must be INTEGER or PROCEDURE",
2619 gfc_current_intrinsic_arg[1], gfc_current_intrinsic, &handler->where);
2623 if (handler->ts.type == BT_INTEGER && scalar_check (handler, 1) == FAILURE)
2629 if (scalar_check (status, 2) == FAILURE)
2632 if (type_check (status, 2, BT_INTEGER) == FAILURE)
2640 gfc_check_rand (gfc_expr * x)
2645 if (scalar_check (x, 0) == FAILURE)
2648 if (type_check (x, 0, BT_INTEGER) == FAILURE)
2651 if (kind_value_check(x, 0, 4) == FAILURE)
2658 gfc_check_srand (gfc_expr * x)
2660 if (scalar_check (x, 0) == FAILURE)
2663 if (type_check (x, 0, BT_INTEGER) == FAILURE)
2666 if (kind_value_check(x, 0, 4) == FAILURE)
2673 gfc_check_ctime_sub (gfc_expr * time, gfc_expr * result)
2675 if (scalar_check (time, 0) == FAILURE)
2678 if (type_check (time, 0, BT_INTEGER) == FAILURE)
2681 if (type_check (result, 1, BT_CHARACTER) == FAILURE)
2688 gfc_check_etime (gfc_expr * x)
2690 if (array_check (x, 0) == FAILURE)
2693 if (rank_check (x, 0, 1) == FAILURE)
2696 if (variable_check (x, 0) == FAILURE)
2699 if (type_check (x, 0, BT_REAL) == FAILURE)
2702 if (kind_value_check(x, 0, 4) == FAILURE)
2709 gfc_check_etime_sub (gfc_expr * values, gfc_expr * time)
2711 if (array_check (values, 0) == FAILURE)
2714 if (rank_check (values, 0, 1) == FAILURE)
2717 if (variable_check (values, 0) == FAILURE)
2720 if (type_check (values, 0, BT_REAL) == FAILURE)
2723 if (kind_value_check(values, 0, 4) == FAILURE)
2726 if (scalar_check (time, 1) == FAILURE)
2729 if (type_check (time, 1, BT_REAL) == FAILURE)
2732 if (kind_value_check(time, 1, 4) == FAILURE)
2740 gfc_check_fdate_sub (gfc_expr * date)
2742 if (type_check (date, 0, BT_CHARACTER) == FAILURE)
2750 gfc_check_gerror (gfc_expr * msg)
2752 if (type_check (msg, 0, BT_CHARACTER) == FAILURE)
2760 gfc_check_getcwd_sub (gfc_expr * cwd, gfc_expr * status)
2762 if (type_check (cwd, 0, BT_CHARACTER) == FAILURE)
2768 if (scalar_check (status, 1) == FAILURE)
2771 if (type_check (status, 1, BT_INTEGER) == FAILURE)
2779 gfc_check_getlog (gfc_expr * msg)
2781 if (type_check (msg, 0, BT_CHARACTER) == FAILURE)
2789 gfc_check_exit (gfc_expr * status)
2794 if (type_check (status, 0, BT_INTEGER) == FAILURE)
2797 if (scalar_check (status, 0) == FAILURE)
2805 gfc_check_flush (gfc_expr * unit)
2810 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
2813 if (scalar_check (unit, 0) == FAILURE)
2821 gfc_check_free (gfc_expr * i)
2823 if (type_check (i, 0, BT_INTEGER) == FAILURE)
2826 if (scalar_check (i, 0) == FAILURE)
2834 gfc_check_hostnm (gfc_expr * name)
2836 if (type_check (name, 0, BT_CHARACTER) == FAILURE)
2844 gfc_check_hostnm_sub (gfc_expr * name, gfc_expr * status)
2846 if (type_check (name, 0, BT_CHARACTER) == FAILURE)
2852 if (scalar_check (status, 1) == FAILURE)
2855 if (type_check (status, 1, BT_INTEGER) == FAILURE)
2863 gfc_check_ttynam_sub (gfc_expr * unit, gfc_expr * name)
2865 if (scalar_check (unit, 0) == FAILURE)
2868 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
2871 if (type_check (name, 1, BT_CHARACTER) == FAILURE)
2879 gfc_check_isatty (gfc_expr * unit)
2884 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
2887 if (scalar_check (unit, 0) == FAILURE)
2895 gfc_check_perror (gfc_expr * string)
2897 if (type_check (string, 0, BT_CHARACTER) == FAILURE)
2905 gfc_check_umask (gfc_expr * mask)
2907 if (type_check (mask, 0, BT_INTEGER) == FAILURE)
2910 if (scalar_check (mask, 0) == FAILURE)
2918 gfc_check_umask_sub (gfc_expr * mask, gfc_expr * old)
2920 if (type_check (mask, 0, BT_INTEGER) == FAILURE)
2923 if (scalar_check (mask, 0) == FAILURE)
2929 if (scalar_check (old, 1) == FAILURE)
2932 if (type_check (old, 1, BT_INTEGER) == FAILURE)
2940 gfc_check_unlink (gfc_expr * name)
2942 if (type_check (name, 0, BT_CHARACTER) == FAILURE)
2950 gfc_check_unlink_sub (gfc_expr * name, gfc_expr * status)
2952 if (type_check (name, 0, BT_CHARACTER) == FAILURE)
2958 if (scalar_check (status, 1) == FAILURE)
2961 if (type_check (status, 1, BT_INTEGER) == FAILURE)
2969 gfc_check_signal (gfc_expr * number, gfc_expr * handler)
2971 if (scalar_check (number, 0) == FAILURE)
2974 if (type_check (number, 0, BT_INTEGER) == FAILURE)
2977 if (handler->ts.type != BT_INTEGER && handler->ts.type != BT_PROCEDURE)
2980 "'%s' argument of '%s' intrinsic at %L must be INTEGER or PROCEDURE",
2981 gfc_current_intrinsic_arg[1], gfc_current_intrinsic, &handler->where);
2985 if (handler->ts.type == BT_INTEGER && scalar_check (handler, 1) == FAILURE)
2993 gfc_check_signal_sub (gfc_expr * number, gfc_expr * handler, gfc_expr * status)
2995 if (scalar_check (number, 0) == FAILURE)
2998 if (type_check (number, 0, BT_INTEGER) == FAILURE)
3001 if (handler->ts.type != BT_INTEGER && handler->ts.type != BT_PROCEDURE)
3004 "'%s' argument of '%s' intrinsic at %L must be INTEGER or PROCEDURE",
3005 gfc_current_intrinsic_arg[1], gfc_current_intrinsic, &handler->where);
3009 if (handler->ts.type == BT_INTEGER && scalar_check (handler, 1) == FAILURE)
3015 if (type_check (status, 2, BT_INTEGER) == FAILURE)
3018 if (scalar_check (status, 2) == FAILURE)
3026 gfc_check_system_sub (gfc_expr * cmd, gfc_expr * status)
3028 if (type_check (cmd, 0, BT_CHARACTER) == FAILURE)
3031 if (scalar_check (status, 1) == FAILURE)
3034 if (type_check (status, 1, BT_INTEGER) == FAILURE)
3037 if (kind_value_check (status, 1, gfc_default_integer_kind) == FAILURE)
3044 /* This is used for the GNU intrinsics AND, OR and XOR. */
3046 gfc_check_and (gfc_expr * i, gfc_expr * j)
3048 if (i->ts.type != BT_INTEGER && i->ts.type != BT_LOGICAL)
3051 "'%s' argument of '%s' intrinsic at %L must be INTEGER or LOGICAL",
3052 gfc_current_intrinsic_arg[0], gfc_current_intrinsic, &i->where);
3056 if (j->ts.type != BT_INTEGER && j->ts.type != BT_LOGICAL)
3059 "'%s' argument of '%s' intrinsic at %L must be INTEGER or LOGICAL",
3060 gfc_current_intrinsic_arg[1], gfc_current_intrinsic, &j->where);
3064 if (i->ts.type != j->ts.type)
3066 gfc_error ("'%s' and '%s' arguments of '%s' intrinsic at %L must "
3067 "have the same type", gfc_current_intrinsic_arg[0],
3068 gfc_current_intrinsic_arg[1], gfc_current_intrinsic,
3073 if (scalar_check (i, 0) == FAILURE)
3076 if (scalar_check (j, 1) == FAILURE)