2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
3 Free Software Foundation, Inc.
4 Contributed by Andy Vaught & Katherine Holcomb
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
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 /* If the expression has not got a type, check if its namespace can
61 offer a default type. */
62 if ((e->expr_type == EXPR_VARIABLE || e->expr_type == EXPR_VARIABLE)
63 && e->symtree->n.sym->ts.type == BT_UNKNOWN
64 && gfc_set_default_type (e->symtree->n.sym, 0,
65 e->symtree->n.sym->ns) == SUCCESS
66 && gfc_numeric_ts (&e->symtree->n.sym->ts))
68 e->ts = e->symtree->n.sym->ts;
72 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a numeric type",
73 gfc_current_intrinsic_arg[n], gfc_current_intrinsic, &e->where);
79 /* Check that an expression is integer or real. */
82 int_or_real_check (gfc_expr *e, int n)
84 if (e->ts.type != BT_INTEGER && e->ts.type != BT_REAL)
86 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
87 "or REAL", gfc_current_intrinsic_arg[n],
88 gfc_current_intrinsic, &e->where);
96 /* Check that an expression is real or complex. */
99 real_or_complex_check (gfc_expr *e, int n)
101 if (e->ts.type != BT_REAL && e->ts.type != BT_COMPLEX)
103 gfc_error ("'%s' argument of '%s' intrinsic at %L must be REAL "
104 "or COMPLEX", gfc_current_intrinsic_arg[n],
105 gfc_current_intrinsic, &e->where);
113 /* Check that the expression is an optional constant integer
114 and that it specifies a valid kind for that type. */
117 kind_check (gfc_expr *k, int n, bt type)
124 if (type_check (k, n, BT_INTEGER) == FAILURE)
127 if (k->expr_type != EXPR_CONSTANT)
129 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a constant",
130 gfc_current_intrinsic_arg[n], gfc_current_intrinsic,
135 if (gfc_extract_int (k, &kind) != NULL
136 || gfc_validate_kind (type, kind, true) < 0)
138 gfc_error ("Invalid kind for %s at %L", gfc_basic_typename (type),
147 /* Make sure the expression is a double precision real. */
150 double_check (gfc_expr *d, int n)
152 if (type_check (d, n, BT_REAL) == FAILURE)
155 if (d->ts.kind != gfc_default_double_kind)
157 gfc_error ("'%s' argument of '%s' intrinsic at %L must be double "
158 "precision", gfc_current_intrinsic_arg[n],
159 gfc_current_intrinsic, &d->where);
167 /* Make sure the expression is a logical array. */
170 logical_array_check (gfc_expr *array, int n)
172 if (array->ts.type != BT_LOGICAL || array->rank == 0)
174 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a logical "
175 "array", gfc_current_intrinsic_arg[n], gfc_current_intrinsic,
184 /* Make sure an expression is an array. */
187 array_check (gfc_expr *e, int n)
192 gfc_error ("'%s' argument of '%s' intrinsic at %L must be an array",
193 gfc_current_intrinsic_arg[n], gfc_current_intrinsic, &e->where);
199 /* Make sure an expression is a scalar. */
202 scalar_check (gfc_expr *e, int n)
207 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a scalar",
208 gfc_current_intrinsic_arg[n], gfc_current_intrinsic, &e->where);
214 /* Make sure two expressions have the same type. */
217 same_type_check (gfc_expr *e, int n, gfc_expr *f, int m)
219 if (gfc_compare_types (&e->ts, &f->ts))
222 gfc_error ("'%s' argument of '%s' intrinsic at %L must be the same type "
223 "and kind as '%s'", gfc_current_intrinsic_arg[m],
224 gfc_current_intrinsic, &f->where, gfc_current_intrinsic_arg[n]);
230 /* Make sure that an expression has a certain (nonzero) rank. */
233 rank_check (gfc_expr *e, int n, int rank)
238 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of rank %d",
239 gfc_current_intrinsic_arg[n], gfc_current_intrinsic,
246 /* Make sure a variable expression is not an optional dummy argument. */
249 nonoptional_check (gfc_expr *e, int n)
251 if (e->expr_type == EXPR_VARIABLE && e->symtree->n.sym->attr.optional)
253 gfc_error ("'%s' argument of '%s' intrinsic at %L must not be OPTIONAL",
254 gfc_current_intrinsic_arg[n], gfc_current_intrinsic,
258 /* TODO: Recursive check on nonoptional variables? */
264 /* Check that an expression has a particular kind. */
267 kind_value_check (gfc_expr *e, int n, int k)
272 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of kind %d",
273 gfc_current_intrinsic_arg[n], gfc_current_intrinsic,
280 /* Make sure an expression is a variable. */
283 variable_check (gfc_expr *e, int n)
285 if ((e->expr_type == EXPR_VARIABLE
286 && e->symtree->n.sym->attr.flavor != FL_PARAMETER)
287 || (e->expr_type == EXPR_FUNCTION
288 && e->symtree->n.sym->result == e->symtree->n.sym))
291 if (e->expr_type == EXPR_VARIABLE
292 && e->symtree->n.sym->attr.intent == INTENT_IN)
294 gfc_error ("'%s' argument of '%s' intrinsic at %L cannot be INTENT(IN)",
295 gfc_current_intrinsic_arg[n], gfc_current_intrinsic,
300 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a variable",
301 gfc_current_intrinsic_arg[n], gfc_current_intrinsic, &e->where);
307 /* Check the common DIM parameter for correctness. */
310 dim_check (gfc_expr *dim, int n, int optional)
312 if (optional && dim == NULL)
317 gfc_error ("Missing DIM parameter in intrinsic '%s' at %L",
318 gfc_current_intrinsic, gfc_current_intrinsic_where);
322 if (type_check (dim, n, BT_INTEGER) == FAILURE)
325 if (scalar_check (dim, n) == FAILURE)
328 if (nonoptional_check (dim, n) == FAILURE)
335 /* If a DIM parameter is a constant, make sure that it is greater than
336 zero and less than or equal to the rank of the given array. If
337 allow_assumed is zero then dim must be less than the rank of the array
338 for assumed size arrays. */
341 dim_rank_check (gfc_expr *dim, gfc_expr *array, int allow_assumed)
346 if (dim->expr_type != EXPR_CONSTANT || array->expr_type != EXPR_VARIABLE)
349 ar = gfc_find_array_ref (array);
351 if (ar->as->type == AS_ASSUMED_SIZE
353 && ar->type != AR_ELEMENT
354 && ar->type != AR_SECTION)
357 if (mpz_cmp_ui (dim->value.integer, 1) < 0
358 || mpz_cmp_ui (dim->value.integer, rank) > 0)
360 gfc_error ("'dim' argument of '%s' intrinsic at %L is not a valid "
361 "dimension index", gfc_current_intrinsic, &dim->where);
370 /* Compare the size of a along dimension ai with the size of b along
371 dimension bi, returning 0 if they are known not to be identical,
372 and 1 if they are identical, or if this cannot be determined. */
375 identical_dimen_shape (gfc_expr *a, int ai, gfc_expr *b, int bi)
377 mpz_t a_size, b_size;
380 gcc_assert (a->rank > ai);
381 gcc_assert (b->rank > bi);
385 if (gfc_array_dimen_size (a, ai, &a_size) == SUCCESS)
387 if (gfc_array_dimen_size (b, bi, &b_size) == SUCCESS)
389 if (mpz_cmp (a_size, b_size) != 0)
400 /***** Check functions *****/
402 /* Check subroutine suitable for intrinsics taking a real argument and
403 a kind argument for the result. */
406 check_a_kind (gfc_expr *a, gfc_expr *kind, bt type)
408 if (type_check (a, 0, BT_REAL) == FAILURE)
410 if (kind_check (kind, 1, type) == FAILURE)
417 /* Check subroutine suitable for ceiling, floor and nint. */
420 gfc_check_a_ikind (gfc_expr *a, gfc_expr *kind)
422 return check_a_kind (a, kind, BT_INTEGER);
426 /* Check subroutine suitable for aint, anint. */
429 gfc_check_a_xkind (gfc_expr *a, gfc_expr *kind)
431 return check_a_kind (a, kind, BT_REAL);
436 gfc_check_abs (gfc_expr *a)
438 if (numeric_check (a, 0) == FAILURE)
446 gfc_check_achar (gfc_expr *a)
448 if (type_check (a, 0, BT_INTEGER) == FAILURE)
456 gfc_check_access_func (gfc_expr *name, gfc_expr *mode)
458 if (type_check (name, 0, BT_CHARACTER) == FAILURE
459 || scalar_check (name, 0) == FAILURE)
462 if (type_check (mode, 1, BT_CHARACTER) == FAILURE
463 || scalar_check (mode, 1) == FAILURE)
471 gfc_check_all_any (gfc_expr *mask, gfc_expr *dim)
473 if (logical_array_check (mask, 0) == FAILURE)
476 if (dim_check (dim, 1, 1) == FAILURE)
484 gfc_check_allocated (gfc_expr *array)
486 symbol_attribute attr;
488 if (variable_check (array, 0) == FAILURE)
491 attr = gfc_variable_attr (array, NULL);
492 if (!attr.allocatable)
494 gfc_error ("'%s' argument of '%s' intrinsic at %L must be ALLOCATABLE",
495 gfc_current_intrinsic_arg[0], gfc_current_intrinsic,
500 if (array_check (array, 0) == FAILURE)
507 /* Common check function where the first argument must be real or
508 integer and the second argument must be the same as the first. */
511 gfc_check_a_p (gfc_expr *a, gfc_expr *p)
513 if (int_or_real_check (a, 0) == FAILURE)
516 if (a->ts.type != p->ts.type)
518 gfc_error ("'%s' and '%s' arguments of '%s' intrinsic at %L must "
519 "have the same type", gfc_current_intrinsic_arg[0],
520 gfc_current_intrinsic_arg[1], gfc_current_intrinsic,
525 if (a->ts.kind != p->ts.kind)
527 if (gfc_notify_std (GFC_STD_GNU, "Extension: Different type kinds at %L",
528 &p->where) == FAILURE)
537 gfc_check_associated (gfc_expr *pointer, gfc_expr *target)
539 symbol_attribute attr;
544 where = &pointer->where;
546 if (pointer->expr_type == EXPR_VARIABLE)
547 attr = gfc_variable_attr (pointer, NULL);
548 else if (pointer->expr_type == EXPR_FUNCTION)
549 attr = pointer->symtree->n.sym->attr;
550 else if (pointer->expr_type == EXPR_NULL)
553 gcc_assert (0); /* Pointer must be a variable or a function. */
557 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a POINTER",
558 gfc_current_intrinsic_arg[0], gfc_current_intrinsic,
563 /* Target argument is optional. */
567 where = &target->where;
568 if (target->expr_type == EXPR_NULL)
571 if (target->expr_type == EXPR_VARIABLE)
572 attr = gfc_variable_attr (target, NULL);
573 else if (target->expr_type == EXPR_FUNCTION)
574 attr = target->symtree->n.sym->attr;
577 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a pointer "
578 "or target VARIABLE or FUNCTION", gfc_current_intrinsic_arg[1],
579 gfc_current_intrinsic, &target->where);
583 if (!attr.pointer && !attr.target)
585 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a POINTER "
586 "or a TARGET", gfc_current_intrinsic_arg[1],
587 gfc_current_intrinsic, &target->where);
592 if (same_type_check (pointer, 0, target, 1) == FAILURE)
594 if (rank_check (target, 0, pointer->rank) == FAILURE)
596 if (target->rank > 0)
598 for (i = 0; i < target->rank; i++)
599 if (target->ref->u.ar.dimen_type[i] == DIMEN_VECTOR)
601 gfc_error ("Array section with a vector subscript at %L shall not "
602 "be the target of a pointer",
612 gfc_error ("NULL pointer at %L is not permitted as actual argument "
613 "of '%s' intrinsic function", where, gfc_current_intrinsic);
620 gfc_check_atan2 (gfc_expr *y, gfc_expr *x)
622 if (type_check (y, 0, BT_REAL) == FAILURE)
624 if (same_type_check (y, 0, x, 1) == FAILURE)
631 /* BESJN and BESYN functions. */
634 gfc_check_besn (gfc_expr *n, gfc_expr *x)
636 if (type_check (n, 0, BT_INTEGER) == FAILURE)
639 if (type_check (x, 1, BT_REAL) == FAILURE)
647 gfc_check_btest (gfc_expr *i, gfc_expr *pos)
649 if (type_check (i, 0, BT_INTEGER) == FAILURE)
651 if (type_check (pos, 1, BT_INTEGER) == FAILURE)
659 gfc_check_char (gfc_expr *i, gfc_expr *kind)
661 if (type_check (i, 0, BT_INTEGER) == FAILURE)
663 if (kind_check (kind, 1, BT_CHARACTER) == FAILURE)
671 gfc_check_chdir (gfc_expr *dir)
673 if (type_check (dir, 0, BT_CHARACTER) == FAILURE)
681 gfc_check_chdir_sub (gfc_expr *dir, gfc_expr *status)
683 if (type_check (dir, 0, BT_CHARACTER) == FAILURE)
689 if (type_check (status, 1, BT_INTEGER) == FAILURE)
692 if (scalar_check (status, 1) == FAILURE)
700 gfc_check_chmod (gfc_expr *name, gfc_expr *mode)
702 if (type_check (name, 0, BT_CHARACTER) == FAILURE)
705 if (type_check (mode, 1, BT_CHARACTER) == FAILURE)
713 gfc_check_chmod_sub (gfc_expr *name, gfc_expr *mode, gfc_expr *status)
715 if (type_check (name, 0, BT_CHARACTER) == FAILURE)
718 if (type_check (mode, 1, BT_CHARACTER) == FAILURE)
724 if (type_check (status, 2, BT_INTEGER) == FAILURE)
727 if (scalar_check (status, 2) == FAILURE)
735 gfc_check_cmplx (gfc_expr *x, gfc_expr *y, gfc_expr *kind)
737 if (numeric_check (x, 0) == FAILURE)
742 if (numeric_check (y, 1) == FAILURE)
745 if (x->ts.type == BT_COMPLEX)
747 gfc_error ("'%s' argument of '%s' intrinsic at %L must not be "
748 "present if 'x' is COMPLEX", gfc_current_intrinsic_arg[1],
749 gfc_current_intrinsic, &y->where);
754 if (kind_check (kind, 2, BT_COMPLEX) == FAILURE)
762 gfc_check_complex (gfc_expr *x, gfc_expr *y)
764 if (x->ts.type != BT_INTEGER && x->ts.type != BT_REAL)
766 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
767 "or REAL", gfc_current_intrinsic_arg[0],
768 gfc_current_intrinsic, &x->where);
771 if (scalar_check (x, 0) == FAILURE)
774 if (y->ts.type != BT_INTEGER && y->ts.type != BT_REAL)
776 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
777 "or REAL", gfc_current_intrinsic_arg[1],
778 gfc_current_intrinsic, &y->where);
781 if (scalar_check (y, 1) == FAILURE)
789 gfc_check_count (gfc_expr *mask, gfc_expr *dim, gfc_expr *kind)
791 if (logical_array_check (mask, 0) == FAILURE)
793 if (dim_check (dim, 1, 1) == FAILURE)
795 if (kind_check (kind, 2, BT_INTEGER) == FAILURE)
797 if (kind && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: '%s' intrinsic "
798 "with KIND argument at %L",
799 gfc_current_intrinsic, &kind->where) == FAILURE)
807 gfc_check_cshift (gfc_expr *array, gfc_expr *shift, gfc_expr *dim)
809 if (array_check (array, 0) == FAILURE)
812 if (array->rank == 1)
814 if (scalar_check (shift, 1) == FAILURE)
819 /* TODO: more requirements on shift parameter. */
822 if (dim_check (dim, 2, 1) == FAILURE)
830 gfc_check_ctime (gfc_expr *time)
832 if (scalar_check (time, 0) == FAILURE)
835 if (type_check (time, 0, BT_INTEGER) == FAILURE)
843 gfc_check_dcmplx (gfc_expr *x, gfc_expr *y)
845 if (numeric_check (x, 0) == FAILURE)
850 if (numeric_check (y, 1) == FAILURE)
853 if (x->ts.type == BT_COMPLEX)
855 gfc_error ("'%s' argument of '%s' intrinsic at %L must not be "
856 "present if 'x' is COMPLEX", gfc_current_intrinsic_arg[1],
857 gfc_current_intrinsic, &y->where);
867 gfc_check_dble (gfc_expr *x)
869 if (numeric_check (x, 0) == FAILURE)
877 gfc_check_digits (gfc_expr *x)
879 if (int_or_real_check (x, 0) == FAILURE)
887 gfc_check_dot_product (gfc_expr *vector_a, gfc_expr *vector_b)
889 switch (vector_a->ts.type)
892 if (type_check (vector_b, 1, BT_LOGICAL) == FAILURE)
899 if (numeric_check (vector_b, 1) == FAILURE)
904 gfc_error ("'%s' argument of '%s' intrinsic at %L must be numeric "
905 "or LOGICAL", gfc_current_intrinsic_arg[0],
906 gfc_current_intrinsic, &vector_a->where);
910 if (rank_check (vector_a, 0, 1) == FAILURE)
913 if (rank_check (vector_b, 1, 1) == FAILURE)
916 if (! identical_dimen_shape (vector_a, 0, vector_b, 0))
918 gfc_error ("different shape for arguments '%s' and '%s' at %L for "
919 "intrinsic 'dot_product'", gfc_current_intrinsic_arg[0],
920 gfc_current_intrinsic_arg[1], &vector_a->where);
929 gfc_check_eoshift (gfc_expr *array, gfc_expr *shift, gfc_expr *boundary,
932 if (array_check (array, 0) == FAILURE)
935 if (type_check (shift, 1, BT_INTEGER) == FAILURE)
938 if (array->rank == 1)
940 if (scalar_check (shift, 2) == FAILURE)
945 /* TODO: more weird restrictions on shift. */
948 if (boundary != NULL)
950 if (same_type_check (array, 0, boundary, 2) == FAILURE)
953 /* TODO: more restrictions on boundary. */
956 if (dim_check (dim, 1, 1) == FAILURE)
963 /* A single complex argument. */
966 gfc_check_fn_c (gfc_expr *a)
968 if (type_check (a, 0, BT_COMPLEX) == FAILURE)
975 /* A single real argument. */
978 gfc_check_fn_r (gfc_expr *a)
980 if (type_check (a, 0, BT_REAL) == FAILURE)
987 /* A single real or complex argument. */
990 gfc_check_fn_rc (gfc_expr *a)
992 if (real_or_complex_check (a, 0) == FAILURE)
1000 gfc_check_fnum (gfc_expr *unit)
1002 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
1005 if (scalar_check (unit, 0) == FAILURE)
1013 gfc_check_huge (gfc_expr *x)
1015 if (int_or_real_check (x, 0) == FAILURE)
1022 /* Check that the single argument is an integer. */
1025 gfc_check_i (gfc_expr *i)
1027 if (type_check (i, 0, BT_INTEGER) == FAILURE)
1035 gfc_check_iand (gfc_expr *i, gfc_expr *j)
1037 if (type_check (i, 0, BT_INTEGER) == FAILURE)
1040 if (type_check (j, 1, BT_INTEGER) == FAILURE)
1043 if (i->ts.kind != j->ts.kind)
1045 if (gfc_notify_std (GFC_STD_GNU, "Extension: Different type kinds at %L",
1046 &i->where) == FAILURE)
1055 gfc_check_ibclr (gfc_expr *i, gfc_expr *pos)
1057 if (type_check (i, 0, BT_INTEGER) == FAILURE)
1060 if (type_check (pos, 1, BT_INTEGER) == FAILURE)
1068 gfc_check_ibits (gfc_expr *i, gfc_expr *pos, gfc_expr *len)
1070 if (type_check (i, 0, BT_INTEGER) == FAILURE)
1073 if (type_check (pos, 1, BT_INTEGER) == FAILURE)
1076 if (type_check (len, 2, BT_INTEGER) == FAILURE)
1084 gfc_check_ibset (gfc_expr *i, gfc_expr *pos)
1086 if (type_check (i, 0, BT_INTEGER) == FAILURE)
1089 if (type_check (pos, 1, BT_INTEGER) == FAILURE)
1097 gfc_check_ichar_iachar (gfc_expr *c, gfc_expr *kind)
1101 if (type_check (c, 0, BT_CHARACTER) == FAILURE)
1104 if (kind_check (kind, 1, BT_INTEGER) == FAILURE)
1107 if (kind && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: '%s' intrinsic "
1108 "with KIND argument at %L",
1109 gfc_current_intrinsic, &kind->where) == FAILURE)
1112 if (c->expr_type == EXPR_VARIABLE || c->expr_type == EXPR_SUBSTRING)
1118 /* Substring references don't have the charlength set. */
1120 while (ref && ref->type != REF_SUBSTRING)
1123 gcc_assert (ref == NULL || ref->type == REF_SUBSTRING);
1127 /* Check that the argument is length one. Non-constant lengths
1128 can't be checked here, so assume they are ok. */
1129 if (c->ts.cl && c->ts.cl->length)
1131 /* If we already have a length for this expression then use it. */
1132 if (c->ts.cl->length->expr_type != EXPR_CONSTANT)
1134 i = mpz_get_si (c->ts.cl->length->value.integer);
1141 start = ref->u.ss.start;
1142 end = ref->u.ss.end;
1145 if (end == NULL || end->expr_type != EXPR_CONSTANT
1146 || start->expr_type != EXPR_CONSTANT)
1149 i = mpz_get_si (end->value.integer) + 1
1150 - mpz_get_si (start->value.integer);
1158 gfc_error ("Argument of %s at %L must be of length one",
1159 gfc_current_intrinsic, &c->where);
1168 gfc_check_idnint (gfc_expr *a)
1170 if (double_check (a, 0) == FAILURE)
1178 gfc_check_ieor (gfc_expr *i, gfc_expr *j)
1180 if (type_check (i, 0, BT_INTEGER) == FAILURE)
1183 if (type_check (j, 1, BT_INTEGER) == FAILURE)
1186 if (i->ts.kind != j->ts.kind)
1188 if (gfc_notify_std (GFC_STD_GNU, "Extension: Different type kinds at %L",
1189 &i->where) == FAILURE)
1198 gfc_check_index (gfc_expr *string, gfc_expr *substring, gfc_expr *back,
1201 if (type_check (string, 0, BT_CHARACTER) == FAILURE
1202 || type_check (substring, 1, BT_CHARACTER) == FAILURE)
1205 if (back != NULL && type_check (back, 2, BT_LOGICAL) == FAILURE)
1208 if (kind_check (kind, 3, BT_INTEGER) == FAILURE)
1210 if (kind && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: '%s' intrinsic "
1211 "with KIND argument at %L",
1212 gfc_current_intrinsic, &kind->where) == FAILURE)
1215 if (string->ts.kind != substring->ts.kind)
1217 gfc_error ("'%s' argument of '%s' intrinsic at %L must be the same "
1218 "kind as '%s'", gfc_current_intrinsic_arg[1],
1219 gfc_current_intrinsic, &substring->where,
1220 gfc_current_intrinsic_arg[0]);
1229 gfc_check_int (gfc_expr *x, gfc_expr *kind)
1231 if (numeric_check (x, 0) == FAILURE)
1236 if (type_check (kind, 1, BT_INTEGER) == FAILURE)
1239 if (scalar_check (kind, 1) == FAILURE)
1248 gfc_check_intconv (gfc_expr *x)
1250 if (numeric_check (x, 0) == FAILURE)
1258 gfc_check_ior (gfc_expr *i, gfc_expr *j)
1260 if (type_check (i, 0, BT_INTEGER) == FAILURE)
1263 if (type_check (j, 1, BT_INTEGER) == FAILURE)
1266 if (i->ts.kind != j->ts.kind)
1268 if (gfc_notify_std (GFC_STD_GNU, "Extension: Different type kinds at %L",
1269 &i->where) == FAILURE)
1278 gfc_check_ishft (gfc_expr *i, gfc_expr *shift)
1280 if (type_check (i, 0, BT_INTEGER) == FAILURE
1281 || type_check (shift, 1, BT_INTEGER) == FAILURE)
1289 gfc_check_ishftc (gfc_expr *i, gfc_expr *shift, gfc_expr *size)
1291 if (type_check (i, 0, BT_INTEGER) == FAILURE
1292 || type_check (shift, 1, BT_INTEGER) == FAILURE)
1295 if (size != NULL && type_check (size, 2, BT_INTEGER) == FAILURE)
1303 gfc_check_kill (gfc_expr *pid, gfc_expr *sig)
1305 if (type_check (pid, 0, BT_INTEGER) == FAILURE)
1308 if (type_check (sig, 1, BT_INTEGER) == FAILURE)
1316 gfc_check_kill_sub (gfc_expr *pid, gfc_expr *sig, gfc_expr *status)
1318 if (type_check (pid, 0, BT_INTEGER) == FAILURE)
1321 if (scalar_check (pid, 0) == FAILURE)
1324 if (type_check (sig, 1, BT_INTEGER) == FAILURE)
1327 if (scalar_check (sig, 1) == FAILURE)
1333 if (type_check (status, 2, BT_INTEGER) == FAILURE)
1336 if (scalar_check (status, 2) == FAILURE)
1344 gfc_check_kind (gfc_expr *x)
1346 if (x->ts.type == BT_DERIVED)
1348 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a "
1349 "non-derived type", gfc_current_intrinsic_arg[0],
1350 gfc_current_intrinsic, &x->where);
1359 gfc_check_lbound (gfc_expr *array, gfc_expr *dim, gfc_expr *kind)
1361 if (array_check (array, 0) == FAILURE)
1366 if (dim_check (dim, 1, 1) == FAILURE)
1369 if (dim_rank_check (dim, array, 1) == FAILURE)
1373 if (kind_check (kind, 2, BT_INTEGER) == FAILURE)
1375 if (kind && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: '%s' intrinsic "
1376 "with KIND argument at %L",
1377 gfc_current_intrinsic, &kind->where) == FAILURE)
1385 gfc_check_len_lentrim (gfc_expr *s, gfc_expr *kind)
1387 if (type_check (s, 0, BT_CHARACTER) == FAILURE)
1390 if (kind_check (kind, 1, BT_INTEGER) == FAILURE)
1392 if (kind && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: '%s' intrinsic "
1393 "with KIND argument at %L",
1394 gfc_current_intrinsic, &kind->where) == FAILURE)
1402 gfc_check_link (gfc_expr *path1, gfc_expr *path2)
1404 if (type_check (path1, 0, BT_CHARACTER) == FAILURE)
1407 if (type_check (path2, 1, BT_CHARACTER) == FAILURE)
1415 gfc_check_link_sub (gfc_expr *path1, gfc_expr *path2, gfc_expr *status)
1417 if (type_check (path1, 0, BT_CHARACTER) == FAILURE)
1420 if (type_check (path2, 1, BT_CHARACTER) == FAILURE)
1426 if (type_check (status, 2, BT_INTEGER) == FAILURE)
1429 if (scalar_check (status, 2) == FAILURE)
1437 gfc_check_loc (gfc_expr *expr)
1439 return variable_check (expr, 0);
1444 gfc_check_symlnk (gfc_expr *path1, gfc_expr *path2)
1446 if (type_check (path1, 0, BT_CHARACTER) == FAILURE)
1449 if (type_check (path2, 1, BT_CHARACTER) == FAILURE)
1457 gfc_check_symlnk_sub (gfc_expr *path1, gfc_expr *path2, gfc_expr *status)
1459 if (type_check (path1, 0, BT_CHARACTER) == FAILURE)
1462 if (type_check (path2, 1, BT_CHARACTER) == FAILURE)
1468 if (type_check (status, 2, BT_INTEGER) == FAILURE)
1471 if (scalar_check (status, 2) == FAILURE)
1479 gfc_check_logical (gfc_expr *a, gfc_expr *kind)
1481 if (type_check (a, 0, BT_LOGICAL) == FAILURE)
1483 if (kind_check (kind, 1, BT_LOGICAL) == FAILURE)
1490 /* Min/max family. */
1493 min_max_args (gfc_actual_arglist *arg)
1495 if (arg == NULL || arg->next == NULL)
1497 gfc_error ("Intrinsic '%s' at %L must have at least two arguments",
1498 gfc_current_intrinsic, gfc_current_intrinsic_where);
1507 check_rest (bt type, int kind, gfc_actual_arglist *arglist)
1509 gfc_actual_arglist *arg, *tmp;
1514 if (min_max_args (arglist) == FAILURE)
1517 for (arg = arglist, n=1; arg; arg = arg->next, n++)
1520 if (x->ts.type != type || x->ts.kind != kind)
1522 if (x->ts.type == type)
1524 if (gfc_notify_std (GFC_STD_GNU, "Extension: Different type "
1525 "kinds at %L", &x->where) == FAILURE)
1530 gfc_error ("'a%d' argument of '%s' intrinsic at %L must be "
1531 "%s(%d)", n, gfc_current_intrinsic, &x->where,
1532 gfc_basic_typename (type), kind);
1537 for (tmp = arglist, m=1; tmp != arg; tmp = tmp->next, m++)
1540 snprintf (buffer, 80, "arguments 'a%d' and 'a%d' for intrinsic '%s'",
1541 m, n, gfc_current_intrinsic);
1542 if (gfc_check_conformance (buffer, tmp->expr, x) == FAILURE)
1552 gfc_check_min_max (gfc_actual_arglist *arg)
1556 if (min_max_args (arg) == FAILURE)
1561 if (x->ts.type == BT_CHARACTER)
1563 if (gfc_notify_std (GFC_STD_F2003, "Fortran 2003: '%s' intrinsic "
1564 "with CHARACTER argument at %L",
1565 gfc_current_intrinsic, &x->where) == FAILURE)
1568 else if (x->ts.type != BT_INTEGER && x->ts.type != BT_REAL)
1570 gfc_error ("'a1' argument of '%s' intrinsic at %L must be INTEGER, "
1571 "REAL or CHARACTER", gfc_current_intrinsic, &x->where);
1575 return check_rest (x->ts.type, x->ts.kind, arg);
1580 gfc_check_min_max_integer (gfc_actual_arglist *arg)
1582 return check_rest (BT_INTEGER, gfc_default_integer_kind, arg);
1587 gfc_check_min_max_real (gfc_actual_arglist *arg)
1589 return check_rest (BT_REAL, gfc_default_real_kind, arg);
1594 gfc_check_min_max_double (gfc_actual_arglist *arg)
1596 return check_rest (BT_REAL, gfc_default_double_kind, arg);
1600 /* End of min/max family. */
1603 gfc_check_malloc (gfc_expr *size)
1605 if (type_check (size, 0, BT_INTEGER) == FAILURE)
1608 if (scalar_check (size, 0) == FAILURE)
1616 gfc_check_matmul (gfc_expr *matrix_a, gfc_expr *matrix_b)
1618 if ((matrix_a->ts.type != BT_LOGICAL) && !gfc_numeric_ts (&matrix_b->ts))
1620 gfc_error ("'%s' argument of '%s' intrinsic at %L must be numeric "
1621 "or LOGICAL", gfc_current_intrinsic_arg[0],
1622 gfc_current_intrinsic, &matrix_a->where);
1626 if ((matrix_b->ts.type != BT_LOGICAL) && !gfc_numeric_ts (&matrix_a->ts))
1628 gfc_error ("'%s' argument of '%s' intrinsic at %L must be numeric "
1629 "or LOGICAL", gfc_current_intrinsic_arg[1],
1630 gfc_current_intrinsic, &matrix_b->where);
1634 switch (matrix_a->rank)
1637 if (rank_check (matrix_b, 1, 2) == FAILURE)
1639 /* Check for case matrix_a has shape(m), matrix_b has shape (m, k). */
1640 if (!identical_dimen_shape (matrix_a, 0, matrix_b, 0))
1642 gfc_error ("different shape on dimension 1 for arguments '%s' "
1643 "and '%s' at %L for intrinsic matmul",
1644 gfc_current_intrinsic_arg[0],
1645 gfc_current_intrinsic_arg[1], &matrix_a->where);
1651 if (matrix_b->rank != 2)
1653 if (rank_check (matrix_b, 1, 1) == FAILURE)
1656 /* matrix_b has rank 1 or 2 here. Common check for the cases
1657 - matrix_a has shape (n,m) and matrix_b has shape (m, k)
1658 - matrix_a has shape (n,m) and matrix_b has shape (m). */
1659 if (!identical_dimen_shape (matrix_a, 1, matrix_b, 0))
1661 gfc_error ("different shape on dimension 2 for argument '%s' and "
1662 "dimension 1 for argument '%s' at %L for intrinsic "
1663 "matmul", gfc_current_intrinsic_arg[0],
1664 gfc_current_intrinsic_arg[1], &matrix_a->where);
1670 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of rank "
1671 "1 or 2", gfc_current_intrinsic_arg[0],
1672 gfc_current_intrinsic, &matrix_a->where);
1680 /* Whoever came up with this interface was probably on something.
1681 The possibilities for the occupation of the second and third
1688 NULL MASK minloc(array, mask=m)
1691 I.e. in the case of minloc(array,mask), mask will be in the second
1692 position of the argument list and we'll have to fix that up. */
1695 gfc_check_minloc_maxloc (gfc_actual_arglist *ap)
1697 gfc_expr *a, *m, *d;
1700 if (int_or_real_check (a, 0) == FAILURE || array_check (a, 0) == FAILURE)
1704 m = ap->next->next->expr;
1706 if (m == NULL && d != NULL && d->ts.type == BT_LOGICAL
1707 && ap->next->name == NULL)
1711 ap->next->expr = NULL;
1712 ap->next->next->expr = m;
1715 if (dim_check (d, 1, 1) == FAILURE)
1718 if (d && dim_rank_check (d, a, 0) == FAILURE)
1721 if (m != NULL && type_check (m, 2, BT_LOGICAL) == FAILURE)
1727 snprintf (buffer, 80, "arguments '%s' and '%s' for intrinsic %s",
1728 gfc_current_intrinsic_arg[0], gfc_current_intrinsic_arg[2],
1729 gfc_current_intrinsic);
1730 if (gfc_check_conformance (buffer, a, m) == FAILURE)
1738 /* Similar to minloc/maxloc, the argument list might need to be
1739 reordered for the MINVAL, MAXVAL, PRODUCT, and SUM intrinsics. The
1740 difference is that MINLOC/MAXLOC take an additional KIND argument.
1741 The possibilities are:
1747 NULL MASK minval(array, mask=m)
1750 I.e. in the case of minval(array,mask), mask will be in the second
1751 position of the argument list and we'll have to fix that up. */
1754 check_reduction (gfc_actual_arglist *ap)
1756 gfc_expr *a, *m, *d;
1760 m = ap->next->next->expr;
1762 if (m == NULL && d != NULL && d->ts.type == BT_LOGICAL
1763 && ap->next->name == NULL)
1767 ap->next->expr = NULL;
1768 ap->next->next->expr = m;
1771 if (dim_check (d, 1, 1) == FAILURE)
1774 if (d && dim_rank_check (d, a, 0) == FAILURE)
1777 if (m != NULL && type_check (m, 2, BT_LOGICAL) == FAILURE)
1783 snprintf (buffer, 80, "arguments '%s' and '%s' for intrinsic %s",
1784 gfc_current_intrinsic_arg[0], gfc_current_intrinsic_arg[2],
1785 gfc_current_intrinsic);
1786 if (gfc_check_conformance (buffer, a, m) == FAILURE)
1795 gfc_check_minval_maxval (gfc_actual_arglist *ap)
1797 if (int_or_real_check (ap->expr, 0) == FAILURE
1798 || array_check (ap->expr, 0) == FAILURE)
1801 return check_reduction (ap);
1806 gfc_check_product_sum (gfc_actual_arglist *ap)
1808 if (numeric_check (ap->expr, 0) == FAILURE
1809 || array_check (ap->expr, 0) == FAILURE)
1812 return check_reduction (ap);
1817 gfc_check_merge (gfc_expr *tsource, gfc_expr *fsource, gfc_expr *mask)
1819 if (same_type_check (tsource, 0, fsource, 1) == FAILURE)
1822 if (type_check (mask, 2, BT_LOGICAL) == FAILURE)
1829 gfc_check_move_alloc (gfc_expr *from, gfc_expr *to)
1831 symbol_attribute attr;
1833 if (variable_check (from, 0) == FAILURE)
1836 if (array_check (from, 0) == FAILURE)
1839 attr = gfc_variable_attr (from, NULL);
1840 if (!attr.allocatable)
1842 gfc_error ("'%s' argument of '%s' intrinsic at %L must be ALLOCATABLE",
1843 gfc_current_intrinsic_arg[0], gfc_current_intrinsic,
1848 if (variable_check (to, 0) == FAILURE)
1851 if (array_check (to, 0) == FAILURE)
1854 attr = gfc_variable_attr (to, NULL);
1855 if (!attr.allocatable)
1857 gfc_error ("'%s' argument of '%s' intrinsic at %L must be ALLOCATABLE",
1858 gfc_current_intrinsic_arg[0], gfc_current_intrinsic,
1863 if (same_type_check (from, 0, to, 1) == FAILURE)
1866 if (to->rank != from->rank)
1868 gfc_error ("the '%s' and '%s' arguments of '%s' intrinsic at %L must "
1869 "have the same rank %d/%d", gfc_current_intrinsic_arg[0],
1870 gfc_current_intrinsic_arg[1], gfc_current_intrinsic,
1871 &to->where, from->rank, to->rank);
1875 if (to->ts.kind != from->ts.kind)
1877 gfc_error ("the '%s' and '%s' arguments of '%s' intrinsic at %L must "
1878 "be of the same kind %d/%d", gfc_current_intrinsic_arg[0],
1879 gfc_current_intrinsic_arg[1], gfc_current_intrinsic,
1880 &to->where, from->ts.kind, to->ts.kind);
1889 gfc_check_nearest (gfc_expr *x, gfc_expr *s)
1891 if (type_check (x, 0, BT_REAL) == FAILURE)
1894 if (type_check (s, 1, BT_REAL) == FAILURE)
1902 gfc_check_new_line (gfc_expr *a)
1904 if (type_check (a, 0, BT_CHARACTER) == FAILURE)
1912 gfc_check_null (gfc_expr *mold)
1914 symbol_attribute attr;
1919 if (variable_check (mold, 0) == FAILURE)
1922 attr = gfc_variable_attr (mold, NULL);
1926 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a POINTER",
1927 gfc_current_intrinsic_arg[0],
1928 gfc_current_intrinsic, &mold->where);
1937 gfc_check_pack (gfc_expr *array, gfc_expr *mask, gfc_expr *vector)
1941 if (array_check (array, 0) == FAILURE)
1944 if (type_check (mask, 1, BT_LOGICAL) == FAILURE)
1947 snprintf (buffer, 80, "arguments '%s' and '%s' for intrinsic '%s'",
1948 gfc_current_intrinsic_arg[0], gfc_current_intrinsic_arg[1],
1949 gfc_current_intrinsic);
1950 if (gfc_check_conformance (buffer, array, mask) == FAILURE)
1955 if (same_type_check (array, 0, vector, 2) == FAILURE)
1958 if (rank_check (vector, 2, 1) == FAILURE)
1961 /* TODO: More constraints here. */
1969 gfc_check_precision (gfc_expr *x)
1971 if (x->ts.type != BT_REAL && x->ts.type != BT_COMPLEX)
1973 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of type "
1974 "REAL or COMPLEX", gfc_current_intrinsic_arg[0],
1975 gfc_current_intrinsic, &x->where);
1984 gfc_check_present (gfc_expr *a)
1988 if (variable_check (a, 0) == FAILURE)
1991 sym = a->symtree->n.sym;
1992 if (!sym->attr.dummy)
1994 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of a "
1995 "dummy variable", gfc_current_intrinsic_arg[0],
1996 gfc_current_intrinsic, &a->where);
2000 if (!sym->attr.optional)
2002 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of "
2003 "an OPTIONAL dummy variable", gfc_current_intrinsic_arg[0],
2004 gfc_current_intrinsic, &a->where);
2008 /* 13.14.82 PRESENT(A)
2010 Argument. A shall be the name of an optional dummy argument that is
2011 accessible in the subprogram in which the PRESENT function reference
2015 && !(a->ref->next == NULL && a->ref->type == REF_ARRAY
2016 && a->ref->u.ar.type == AR_FULL))
2018 gfc_error ("'%s' argument of '%s' intrinsic at %L must not be a "
2019 "subobject of '%s'", gfc_current_intrinsic_arg[0],
2020 gfc_current_intrinsic, &a->where, sym->name);
2029 gfc_check_radix (gfc_expr *x)
2031 if (int_or_real_check (x, 0) == FAILURE)
2039 gfc_check_range (gfc_expr *x)
2041 if (numeric_check (x, 0) == FAILURE)
2048 /* real, float, sngl. */
2050 gfc_check_real (gfc_expr *a, gfc_expr *kind)
2052 if (numeric_check (a, 0) == FAILURE)
2055 if (kind_check (kind, 1, BT_REAL) == FAILURE)
2063 gfc_check_rename (gfc_expr *path1, gfc_expr *path2)
2065 if (type_check (path1, 0, BT_CHARACTER) == FAILURE)
2068 if (type_check (path2, 1, BT_CHARACTER) == FAILURE)
2076 gfc_check_rename_sub (gfc_expr *path1, gfc_expr *path2, gfc_expr *status)
2078 if (type_check (path1, 0, BT_CHARACTER) == FAILURE)
2081 if (type_check (path2, 1, BT_CHARACTER) == FAILURE)
2087 if (type_check (status, 2, BT_INTEGER) == FAILURE)
2090 if (scalar_check (status, 2) == FAILURE)
2098 gfc_check_repeat (gfc_expr *x, gfc_expr *y)
2100 if (type_check (x, 0, BT_CHARACTER) == FAILURE)
2103 if (scalar_check (x, 0) == FAILURE)
2106 if (type_check (y, 0, BT_INTEGER) == FAILURE)
2109 if (scalar_check (y, 1) == FAILURE)
2117 gfc_check_reshape (gfc_expr *source, gfc_expr *shape,
2118 gfc_expr *pad, gfc_expr *order)
2124 if (array_check (source, 0) == FAILURE)
2127 if (rank_check (shape, 1, 1) == FAILURE)
2130 if (type_check (shape, 1, BT_INTEGER) == FAILURE)
2133 if (gfc_array_size (shape, &size) != SUCCESS)
2135 gfc_error ("'shape' argument of 'reshape' intrinsic at %L must be an "
2136 "array of constant size", &shape->where);
2140 m = mpz_cmp_ui (size, GFC_MAX_DIMENSIONS);
2145 gfc_error ("'shape' argument of 'reshape' intrinsic at %L has more "
2146 "than %d elements", &shape->where, GFC_MAX_DIMENSIONS);
2152 if (same_type_check (source, 0, pad, 2) == FAILURE)
2154 if (array_check (pad, 2) == FAILURE)
2158 if (order != NULL && array_check (order, 3) == FAILURE)
2161 if (pad == NULL && shape->expr_type == EXPR_ARRAY
2162 && gfc_is_constant_expr (shape)
2163 && !(source->expr_type == EXPR_VARIABLE && source->symtree->n.sym->as
2164 && source->symtree->n.sym->as->type == AS_ASSUMED_SIZE))
2166 /* Check the match in size between source and destination. */
2167 if (gfc_array_size (source, &nelems) == SUCCESS)
2172 c = shape->value.constructor;
2173 mpz_init_set_ui (size, 1);
2174 for (; c; c = c->next)
2175 mpz_mul (size, size, c->expr->value.integer);
2177 test = mpz_cmp (nelems, size) < 0 && mpz_cmp_ui (size, 0) > 0;
2183 gfc_error ("Without padding, there are not enough elements "
2184 "in the intrinsic RESHAPE source at %L to match "
2185 "the shape", &source->where);
2196 gfc_check_scale (gfc_expr *x, gfc_expr *i)
2198 if (type_check (x, 0, BT_REAL) == FAILURE)
2201 if (type_check (i, 1, BT_INTEGER) == FAILURE)
2209 gfc_check_scan (gfc_expr *x, gfc_expr *y, gfc_expr *z, gfc_expr *kind)
2211 if (type_check (x, 0, BT_CHARACTER) == FAILURE)
2214 if (type_check (y, 1, BT_CHARACTER) == FAILURE)
2217 if (z != NULL && type_check (z, 2, BT_LOGICAL) == FAILURE)
2220 if (kind_check (kind, 3, BT_INTEGER) == FAILURE)
2222 if (kind && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: '%s' intrinsic "
2223 "with KIND argument at %L",
2224 gfc_current_intrinsic, &kind->where) == FAILURE)
2227 if (same_type_check (x, 0, y, 1) == FAILURE)
2235 gfc_check_secnds (gfc_expr *r)
2237 if (type_check (r, 0, BT_REAL) == FAILURE)
2240 if (kind_value_check (r, 0, 4) == FAILURE)
2243 if (scalar_check (r, 0) == FAILURE)
2251 gfc_check_selected_int_kind (gfc_expr *r)
2253 if (type_check (r, 0, BT_INTEGER) == FAILURE)
2256 if (scalar_check (r, 0) == FAILURE)
2264 gfc_check_selected_real_kind (gfc_expr *p, gfc_expr *r)
2266 if (p == NULL && r == NULL)
2268 gfc_error ("Missing arguments to %s intrinsic at %L",
2269 gfc_current_intrinsic, gfc_current_intrinsic_where);
2274 if (p != NULL && type_check (p, 0, BT_INTEGER) == FAILURE)
2277 if (r != NULL && type_check (r, 1, BT_INTEGER) == FAILURE)
2285 gfc_check_set_exponent (gfc_expr *x, gfc_expr *i)
2287 if (type_check (x, 0, BT_REAL) == FAILURE)
2290 if (type_check (i, 1, BT_INTEGER) == FAILURE)
2298 gfc_check_shape (gfc_expr *source)
2302 if (source->rank == 0 || source->expr_type != EXPR_VARIABLE)
2305 ar = gfc_find_array_ref (source);
2307 if (ar->as && ar->as->type == AS_ASSUMED_SIZE)
2309 gfc_error ("'source' argument of 'shape' intrinsic at %L must not be "
2310 "an assumed size array", &source->where);
2319 gfc_check_sign (gfc_expr *a, gfc_expr *b)
2321 if (int_or_real_check (a, 0) == FAILURE)
2324 if (same_type_check (a, 0, b, 1) == FAILURE)
2332 gfc_check_size (gfc_expr *array, gfc_expr *dim, gfc_expr *kind)
2334 if (array_check (array, 0) == FAILURE)
2339 if (type_check (dim, 1, BT_INTEGER) == FAILURE)
2342 if (kind_value_check (dim, 1, gfc_default_integer_kind) == FAILURE)
2345 if (dim_rank_check (dim, array, 0) == FAILURE)
2349 if (kind_check (kind, 2, BT_INTEGER) == FAILURE)
2351 if (kind && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: '%s' intrinsic "
2352 "with KIND argument at %L",
2353 gfc_current_intrinsic, &kind->where) == FAILURE)
2362 gfc_check_sizeof (gfc_expr *arg __attribute__((unused)))
2369 gfc_check_sleep_sub (gfc_expr *seconds)
2371 if (type_check (seconds, 0, BT_INTEGER) == FAILURE)
2374 if (scalar_check (seconds, 0) == FAILURE)
2382 gfc_check_spread (gfc_expr *source, gfc_expr *dim, gfc_expr *ncopies)
2384 if (source->rank >= GFC_MAX_DIMENSIONS)
2386 gfc_error ("'%s' argument of '%s' intrinsic at %L must be less "
2387 "than rank %d", gfc_current_intrinsic_arg[0],
2388 gfc_current_intrinsic, &source->where, GFC_MAX_DIMENSIONS);
2393 if (dim_check (dim, 1, 0) == FAILURE)
2396 if (type_check (ncopies, 2, BT_INTEGER) == FAILURE)
2399 if (scalar_check (ncopies, 2) == FAILURE)
2406 /* Functions for checking FGETC, FPUTC, FGET and FPUT (subroutines and
2410 gfc_check_fgetputc_sub (gfc_expr *unit, gfc_expr *c, gfc_expr *status)
2412 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
2415 if (scalar_check (unit, 0) == FAILURE)
2418 if (type_check (c, 1, BT_CHARACTER) == FAILURE)
2424 if (type_check (status, 2, BT_INTEGER) == FAILURE
2425 || kind_value_check (status, 2, gfc_default_integer_kind) == FAILURE
2426 || scalar_check (status, 2) == FAILURE)
2434 gfc_check_fgetputc (gfc_expr *unit, gfc_expr *c)
2436 return gfc_check_fgetputc_sub (unit, c, NULL);
2441 gfc_check_fgetput_sub (gfc_expr *c, gfc_expr *status)
2443 if (type_check (c, 0, BT_CHARACTER) == FAILURE)
2449 if (type_check (status, 1, BT_INTEGER) == FAILURE
2450 || kind_value_check (status, 1, gfc_default_integer_kind) == FAILURE
2451 || scalar_check (status, 1) == FAILURE)
2459 gfc_check_fgetput (gfc_expr *c)
2461 return gfc_check_fgetput_sub (c, NULL);
2466 gfc_check_fseek_sub (gfc_expr *unit, gfc_expr *offset, gfc_expr *whence, gfc_expr *status)
2468 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
2471 if (scalar_check (unit, 0) == FAILURE)
2474 if (type_check (offset, 1, BT_INTEGER) == FAILURE)
2477 if (scalar_check (offset, 1) == FAILURE)
2480 if (type_check (whence, 2, BT_INTEGER) == FAILURE)
2483 if (scalar_check (whence, 2) == FAILURE)
2489 if (type_check (status, 3, BT_INTEGER) == FAILURE)
2492 if (kind_value_check (status, 3, 4) == FAILURE)
2495 if (scalar_check (status, 3) == FAILURE)
2504 gfc_check_fstat (gfc_expr *unit, gfc_expr *array)
2506 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
2509 if (scalar_check (unit, 0) == FAILURE)
2512 if (type_check (array, 1, BT_INTEGER) == FAILURE
2513 || kind_value_check (unit, 0, gfc_default_integer_kind) == FAILURE)
2516 if (array_check (array, 1) == FAILURE)
2524 gfc_check_fstat_sub (gfc_expr *unit, gfc_expr *array, gfc_expr *status)
2526 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
2529 if (scalar_check (unit, 0) == FAILURE)
2532 if (type_check (array, 1, BT_INTEGER) == FAILURE
2533 || kind_value_check (array, 1, gfc_default_integer_kind) == FAILURE)
2536 if (array_check (array, 1) == FAILURE)
2542 if (type_check (status, 2, BT_INTEGER) == FAILURE
2543 || kind_value_check (status, 2, gfc_default_integer_kind) == FAILURE)
2546 if (scalar_check (status, 2) == FAILURE)
2554 gfc_check_ftell (gfc_expr *unit)
2556 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
2559 if (scalar_check (unit, 0) == FAILURE)
2567 gfc_check_ftell_sub (gfc_expr *unit, gfc_expr *offset)
2569 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
2572 if (scalar_check (unit, 0) == FAILURE)
2575 if (type_check (offset, 1, BT_INTEGER) == FAILURE)
2578 if (scalar_check (offset, 1) == FAILURE)
2586 gfc_check_stat (gfc_expr *name, gfc_expr *array)
2588 if (type_check (name, 0, BT_CHARACTER) == FAILURE)
2591 if (type_check (array, 1, BT_INTEGER) == FAILURE
2592 || kind_value_check (array, 1, gfc_default_integer_kind) == FAILURE)
2595 if (array_check (array, 1) == FAILURE)
2603 gfc_check_stat_sub (gfc_expr *name, gfc_expr *array, gfc_expr *status)
2605 if (type_check (name, 0, BT_CHARACTER) == FAILURE)
2608 if (type_check (array, 1, BT_INTEGER) == FAILURE
2609 || kind_value_check (array, 1, gfc_default_integer_kind) == FAILURE)
2612 if (array_check (array, 1) == FAILURE)
2618 if (type_check (status, 2, BT_INTEGER) == FAILURE
2619 || kind_value_check (array, 1, gfc_default_integer_kind) == FAILURE)
2622 if (scalar_check (status, 2) == FAILURE)
2630 gfc_check_transfer (gfc_expr *source ATTRIBUTE_UNUSED,
2631 gfc_expr *mold ATTRIBUTE_UNUSED, gfc_expr *size)
2633 if (mold->ts.type == BT_HOLLERITH)
2635 gfc_error ("'MOLD' argument of 'TRANSFER' intrinsic at %L must not be %s",
2636 &mold->where, gfc_basic_typename (BT_HOLLERITH));
2642 if (type_check (size, 2, BT_INTEGER) == FAILURE)
2645 if (scalar_check (size, 2) == FAILURE)
2648 if (nonoptional_check (size, 2) == FAILURE)
2657 gfc_check_transpose (gfc_expr *matrix)
2659 if (rank_check (matrix, 0, 2) == FAILURE)
2667 gfc_check_ubound (gfc_expr *array, gfc_expr *dim, gfc_expr *kind)
2669 if (array_check (array, 0) == FAILURE)
2674 if (dim_check (dim, 1, 1) == FAILURE)
2677 if (dim_rank_check (dim, array, 0) == FAILURE)
2681 if (kind_check (kind, 2, BT_INTEGER) == FAILURE)
2683 if (kind && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: '%s' intrinsic "
2684 "with KIND argument at %L",
2685 gfc_current_intrinsic, &kind->where) == FAILURE)
2693 gfc_check_unpack (gfc_expr *vector, gfc_expr *mask, gfc_expr *field)
2695 if (rank_check (vector, 0, 1) == FAILURE)
2698 if (array_check (mask, 1) == FAILURE)
2701 if (type_check (mask, 1, BT_LOGICAL) == FAILURE)
2704 if (same_type_check (vector, 0, field, 2) == FAILURE)
2712 gfc_check_verify (gfc_expr *x, gfc_expr *y, gfc_expr *z, gfc_expr *kind)
2714 if (type_check (x, 0, BT_CHARACTER) == FAILURE)
2717 if (same_type_check (x, 0, y, 1) == FAILURE)
2720 if (z != NULL && type_check (z, 2, BT_LOGICAL) == FAILURE)
2723 if (kind_check (kind, 3, BT_INTEGER) == FAILURE)
2725 if (kind && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: '%s' intrinsic "
2726 "with KIND argument at %L",
2727 gfc_current_intrinsic, &kind->where) == FAILURE)
2735 gfc_check_trim (gfc_expr *x)
2737 if (type_check (x, 0, BT_CHARACTER) == FAILURE)
2740 if (scalar_check (x, 0) == FAILURE)
2748 gfc_check_ttynam (gfc_expr *unit)
2750 if (scalar_check (unit, 0) == FAILURE)
2753 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
2760 /* Common check function for the half a dozen intrinsics that have a
2761 single real argument. */
2764 gfc_check_x (gfc_expr *x)
2766 if (type_check (x, 0, BT_REAL) == FAILURE)
2773 /************* Check functions for intrinsic subroutines *************/
2776 gfc_check_cpu_time (gfc_expr *time)
2778 if (scalar_check (time, 0) == FAILURE)
2781 if (type_check (time, 0, BT_REAL) == FAILURE)
2784 if (variable_check (time, 0) == FAILURE)
2792 gfc_check_date_and_time (gfc_expr *date, gfc_expr *time,
2793 gfc_expr *zone, gfc_expr *values)
2797 if (type_check (date, 0, BT_CHARACTER) == FAILURE)
2799 if (scalar_check (date, 0) == FAILURE)
2801 if (variable_check (date, 0) == FAILURE)
2807 if (type_check (time, 1, BT_CHARACTER) == FAILURE)
2809 if (scalar_check (time, 1) == FAILURE)
2811 if (variable_check (time, 1) == FAILURE)
2817 if (type_check (zone, 2, BT_CHARACTER) == FAILURE)
2819 if (scalar_check (zone, 2) == FAILURE)
2821 if (variable_check (zone, 2) == FAILURE)
2827 if (type_check (values, 3, BT_INTEGER) == FAILURE)
2829 if (array_check (values, 3) == FAILURE)
2831 if (rank_check (values, 3, 1) == FAILURE)
2833 if (variable_check (values, 3) == FAILURE)
2842 gfc_check_mvbits (gfc_expr *from, gfc_expr *frompos, gfc_expr *len,
2843 gfc_expr *to, gfc_expr *topos)
2845 if (type_check (from, 0, BT_INTEGER) == FAILURE)
2848 if (type_check (frompos, 1, BT_INTEGER) == FAILURE)
2851 if (type_check (len, 2, BT_INTEGER) == FAILURE)
2854 if (same_type_check (from, 0, to, 3) == FAILURE)
2857 if (variable_check (to, 3) == FAILURE)
2860 if (type_check (topos, 4, BT_INTEGER) == FAILURE)
2868 gfc_check_random_number (gfc_expr *harvest)
2870 if (type_check (harvest, 0, BT_REAL) == FAILURE)
2873 if (variable_check (harvest, 0) == FAILURE)
2881 gfc_check_random_seed (gfc_expr *size, gfc_expr *put, gfc_expr *get)
2883 unsigned int nargs = 0;
2884 locus *where = NULL;
2888 if (size->expr_type != EXPR_VARIABLE
2889 || !size->symtree->n.sym->attr.optional)
2892 if (scalar_check (size, 0) == FAILURE)
2895 if (type_check (size, 0, BT_INTEGER) == FAILURE)
2898 if (variable_check (size, 0) == FAILURE)
2901 if (kind_value_check (size, 0, gfc_default_integer_kind) == FAILURE)
2907 if (put->expr_type != EXPR_VARIABLE
2908 || !put->symtree->n.sym->attr.optional)
2911 where = &put->where;
2914 if (array_check (put, 1) == FAILURE)
2917 if (rank_check (put, 1, 1) == FAILURE)
2920 if (type_check (put, 1, BT_INTEGER) == FAILURE)
2923 if (kind_value_check (put, 1, gfc_default_integer_kind) == FAILURE)
2929 if (get->expr_type != EXPR_VARIABLE
2930 || !get->symtree->n.sym->attr.optional)
2933 where = &get->where;
2936 if (array_check (get, 2) == FAILURE)
2939 if (rank_check (get, 2, 1) == FAILURE)
2942 if (type_check (get, 2, BT_INTEGER) == FAILURE)
2945 if (variable_check (get, 2) == FAILURE)
2948 if (kind_value_check (get, 2, gfc_default_integer_kind) == FAILURE)
2952 /* RANDOM_SEED may not have more than one non-optional argument. */
2954 gfc_error ("Too many arguments to %s at %L", gfc_current_intrinsic, where);
2961 gfc_check_second_sub (gfc_expr *time)
2963 if (scalar_check (time, 0) == FAILURE)
2966 if (type_check (time, 0, BT_REAL) == FAILURE)
2969 if (kind_value_check(time, 0, 4) == FAILURE)
2976 /* The arguments of SYSTEM_CLOCK are scalar, integer variables. Note,
2977 count, count_rate, and count_max are all optional arguments */
2980 gfc_check_system_clock (gfc_expr *count, gfc_expr *count_rate,
2981 gfc_expr *count_max)
2985 if (scalar_check (count, 0) == FAILURE)
2988 if (type_check (count, 0, BT_INTEGER) == FAILURE)
2991 if (variable_check (count, 0) == FAILURE)
2995 if (count_rate != NULL)
2997 if (scalar_check (count_rate, 1) == FAILURE)
3000 if (type_check (count_rate, 1, BT_INTEGER) == FAILURE)
3003 if (variable_check (count_rate, 1) == FAILURE)
3007 && same_type_check (count, 0, count_rate, 1) == FAILURE)
3012 if (count_max != NULL)
3014 if (scalar_check (count_max, 2) == FAILURE)
3017 if (type_check (count_max, 2, BT_INTEGER) == FAILURE)
3020 if (variable_check (count_max, 2) == FAILURE)
3024 && same_type_check (count, 0, count_max, 2) == FAILURE)
3027 if (count_rate != NULL
3028 && same_type_check (count_rate, 1, count_max, 2) == FAILURE)
3037 gfc_check_irand (gfc_expr *x)
3042 if (scalar_check (x, 0) == FAILURE)
3045 if (type_check (x, 0, BT_INTEGER) == FAILURE)
3048 if (kind_value_check(x, 0, 4) == FAILURE)
3056 gfc_check_alarm_sub (gfc_expr *seconds, gfc_expr *handler, gfc_expr *status)
3058 if (scalar_check (seconds, 0) == FAILURE)
3061 if (type_check (seconds, 0, BT_INTEGER) == FAILURE)
3064 if (handler->ts.type != BT_INTEGER && handler->ts.type != BT_PROCEDURE)
3066 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
3067 "or PROCEDURE", gfc_current_intrinsic_arg[1],
3068 gfc_current_intrinsic, &handler->where);
3072 if (handler->ts.type == BT_INTEGER && scalar_check (handler, 1) == FAILURE)
3078 if (scalar_check (status, 2) == FAILURE)
3081 if (type_check (status, 2, BT_INTEGER) == FAILURE)
3084 if (kind_value_check (status, 2, gfc_default_integer_kind) == FAILURE)
3092 gfc_check_rand (gfc_expr *x)
3097 if (scalar_check (x, 0) == FAILURE)
3100 if (type_check (x, 0, BT_INTEGER) == FAILURE)
3103 if (kind_value_check(x, 0, 4) == FAILURE)
3111 gfc_check_srand (gfc_expr *x)
3113 if (scalar_check (x, 0) == FAILURE)
3116 if (type_check (x, 0, BT_INTEGER) == FAILURE)
3119 if (kind_value_check(x, 0, 4) == FAILURE)
3127 gfc_check_ctime_sub (gfc_expr *time, gfc_expr *result)
3129 if (scalar_check (time, 0) == FAILURE)
3132 if (type_check (time, 0, BT_INTEGER) == FAILURE)
3135 if (type_check (result, 1, BT_CHARACTER) == FAILURE)
3143 gfc_check_etime (gfc_expr *x)
3145 if (array_check (x, 0) == FAILURE)
3148 if (rank_check (x, 0, 1) == FAILURE)
3151 if (variable_check (x, 0) == FAILURE)
3154 if (type_check (x, 0, BT_REAL) == FAILURE)
3157 if (kind_value_check(x, 0, 4) == FAILURE)
3165 gfc_check_etime_sub (gfc_expr *values, gfc_expr *time)
3167 if (array_check (values, 0) == FAILURE)
3170 if (rank_check (values, 0, 1) == FAILURE)
3173 if (variable_check (values, 0) == FAILURE)
3176 if (type_check (values, 0, BT_REAL) == FAILURE)
3179 if (kind_value_check(values, 0, 4) == FAILURE)
3182 if (scalar_check (time, 1) == FAILURE)
3185 if (type_check (time, 1, BT_REAL) == FAILURE)
3188 if (kind_value_check(time, 1, 4) == FAILURE)
3196 gfc_check_fdate_sub (gfc_expr *date)
3198 if (type_check (date, 0, BT_CHARACTER) == FAILURE)
3206 gfc_check_gerror (gfc_expr *msg)
3208 if (type_check (msg, 0, BT_CHARACTER) == FAILURE)
3216 gfc_check_getcwd_sub (gfc_expr *cwd, gfc_expr *status)
3218 if (type_check (cwd, 0, BT_CHARACTER) == FAILURE)
3224 if (scalar_check (status, 1) == FAILURE)
3227 if (type_check (status, 1, BT_INTEGER) == FAILURE)
3235 gfc_check_getlog (gfc_expr *msg)
3237 if (type_check (msg, 0, BT_CHARACTER) == FAILURE)
3245 gfc_check_exit (gfc_expr *status)
3250 if (type_check (status, 0, BT_INTEGER) == FAILURE)
3253 if (scalar_check (status, 0) == FAILURE)
3261 gfc_check_flush (gfc_expr *unit)
3266 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
3269 if (scalar_check (unit, 0) == FAILURE)
3277 gfc_check_free (gfc_expr *i)
3279 if (type_check (i, 0, BT_INTEGER) == FAILURE)
3282 if (scalar_check (i, 0) == FAILURE)
3290 gfc_check_hostnm (gfc_expr *name)
3292 if (type_check (name, 0, BT_CHARACTER) == FAILURE)
3300 gfc_check_hostnm_sub (gfc_expr *name, gfc_expr *status)
3302 if (type_check (name, 0, BT_CHARACTER) == FAILURE)
3308 if (scalar_check (status, 1) == FAILURE)
3311 if (type_check (status, 1, BT_INTEGER) == FAILURE)
3319 gfc_check_itime_idate (gfc_expr *values)
3321 if (array_check (values, 0) == FAILURE)
3324 if (rank_check (values, 0, 1) == FAILURE)
3327 if (variable_check (values, 0) == FAILURE)
3330 if (type_check (values, 0, BT_INTEGER) == FAILURE)
3333 if (kind_value_check(values, 0, gfc_default_integer_kind) == FAILURE)
3341 gfc_check_ltime_gmtime (gfc_expr *time, gfc_expr *values)
3343 if (type_check (time, 0, BT_INTEGER) == FAILURE)
3346 if (kind_value_check(time, 0, gfc_default_integer_kind) == FAILURE)
3349 if (scalar_check (time, 0) == FAILURE)
3352 if (array_check (values, 1) == FAILURE)
3355 if (rank_check (values, 1, 1) == FAILURE)
3358 if (variable_check (values, 1) == FAILURE)
3361 if (type_check (values, 1, BT_INTEGER) == FAILURE)
3364 if (kind_value_check(values, 1, gfc_default_integer_kind) == FAILURE)
3372 gfc_check_ttynam_sub (gfc_expr *unit, gfc_expr *name)
3374 if (scalar_check (unit, 0) == FAILURE)
3377 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
3380 if (type_check (name, 1, BT_CHARACTER) == FAILURE)
3388 gfc_check_isatty (gfc_expr *unit)
3393 if (type_check (unit, 0, BT_INTEGER) == FAILURE)
3396 if (scalar_check (unit, 0) == FAILURE)
3404 gfc_check_isnan (gfc_expr *x)
3406 if (type_check (x, 0, BT_REAL) == FAILURE)
3414 gfc_check_perror (gfc_expr *string)
3416 if (type_check (string, 0, BT_CHARACTER) == FAILURE)
3424 gfc_check_umask (gfc_expr *mask)
3426 if (type_check (mask, 0, BT_INTEGER) == FAILURE)
3429 if (scalar_check (mask, 0) == FAILURE)
3437 gfc_check_umask_sub (gfc_expr *mask, gfc_expr *old)
3439 if (type_check (mask, 0, BT_INTEGER) == FAILURE)
3442 if (scalar_check (mask, 0) == FAILURE)
3448 if (scalar_check (old, 1) == FAILURE)
3451 if (type_check (old, 1, BT_INTEGER) == FAILURE)
3459 gfc_check_unlink (gfc_expr *name)
3461 if (type_check (name, 0, BT_CHARACTER) == FAILURE)
3469 gfc_check_unlink_sub (gfc_expr *name, gfc_expr *status)
3471 if (type_check (name, 0, BT_CHARACTER) == FAILURE)
3477 if (scalar_check (status, 1) == FAILURE)
3480 if (type_check (status, 1, BT_INTEGER) == FAILURE)
3488 gfc_check_signal (gfc_expr *number, gfc_expr *handler)
3490 if (scalar_check (number, 0) == FAILURE)
3493 if (type_check (number, 0, BT_INTEGER) == FAILURE)
3496 if (handler->ts.type != BT_INTEGER && handler->ts.type != BT_PROCEDURE)
3498 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
3499 "or PROCEDURE", gfc_current_intrinsic_arg[1],
3500 gfc_current_intrinsic, &handler->where);
3504 if (handler->ts.type == BT_INTEGER && scalar_check (handler, 1) == FAILURE)
3512 gfc_check_signal_sub (gfc_expr *number, gfc_expr *handler, gfc_expr *status)
3514 if (scalar_check (number, 0) == FAILURE)
3517 if (type_check (number, 0, BT_INTEGER) == FAILURE)
3520 if (handler->ts.type != BT_INTEGER && handler->ts.type != BT_PROCEDURE)
3522 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
3523 "or PROCEDURE", gfc_current_intrinsic_arg[1],
3524 gfc_current_intrinsic, &handler->where);
3528 if (handler->ts.type == BT_INTEGER && scalar_check (handler, 1) == FAILURE)
3534 if (type_check (status, 2, BT_INTEGER) == FAILURE)
3537 if (scalar_check (status, 2) == FAILURE)
3545 gfc_check_system_sub (gfc_expr *cmd, gfc_expr *status)
3547 if (type_check (cmd, 0, BT_CHARACTER) == FAILURE)
3550 if (scalar_check (status, 1) == FAILURE)
3553 if (type_check (status, 1, BT_INTEGER) == FAILURE)
3556 if (kind_value_check (status, 1, gfc_default_integer_kind) == FAILURE)
3563 /* This is used for the GNU intrinsics AND, OR and XOR. */
3565 gfc_check_and (gfc_expr *i, gfc_expr *j)
3567 if (i->ts.type != BT_INTEGER && i->ts.type != BT_LOGICAL)
3569 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
3570 "or LOGICAL", gfc_current_intrinsic_arg[0],
3571 gfc_current_intrinsic, &i->where);
3575 if (j->ts.type != BT_INTEGER && j->ts.type != BT_LOGICAL)
3577 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
3578 "or LOGICAL", gfc_current_intrinsic_arg[1],
3579 gfc_current_intrinsic, &j->where);
3583 if (i->ts.type != j->ts.type)
3585 gfc_error ("'%s' and '%s' arguments of '%s' intrinsic at %L must "
3586 "have the same type", gfc_current_intrinsic_arg[0],
3587 gfc_current_intrinsic_arg[1], gfc_current_intrinsic,
3592 if (scalar_check (i, 0) == FAILURE)
3595 if (scalar_check (j, 1) == FAILURE)