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 2, 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 COPYING. If not, write to the Free
20 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
24 /* These functions check to see if an argument list is compatible with
25 a particular intrinsic function or subroutine. Presence of
26 required arguments has already been established, the argument list
27 has been sorted into the right order and has NULL arguments in the
28 correct places for missing optional arguments. */
34 #include "intrinsic.h"
37 /* Check the type of an expression. */
40 type_check (gfc_expr
*e
, int n
, bt type
)
42 if (e
->ts
.type
== type
)
45 gfc_error ("'%s' argument of '%s' intrinsic at %L must be %s",
46 gfc_current_intrinsic_arg
[n
], gfc_current_intrinsic
, &e
->where
,
47 gfc_basic_typename (type
));
53 /* Check that the expression is a numeric type. */
56 numeric_check (gfc_expr
*e
, int n
)
58 if (gfc_numeric_ts (&e
->ts
))
61 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a numeric type",
62 gfc_current_intrinsic_arg
[n
], gfc_current_intrinsic
, &e
->where
);
68 /* Check that an expression is integer or real. */
71 int_or_real_check (gfc_expr
*e
, int n
)
73 if (e
->ts
.type
!= BT_INTEGER
&& e
->ts
.type
!= BT_REAL
)
75 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
76 "or REAL", gfc_current_intrinsic_arg
[n
],
77 gfc_current_intrinsic
, &e
->where
);
85 /* Check that an expression is real or complex. */
88 real_or_complex_check (gfc_expr
*e
, int n
)
90 if (e
->ts
.type
!= BT_REAL
&& e
->ts
.type
!= BT_COMPLEX
)
92 gfc_error ("'%s' argument of '%s' intrinsic at %L must be REAL "
93 "or COMPLEX", gfc_current_intrinsic_arg
[n
],
94 gfc_current_intrinsic
, &e
->where
);
102 /* Check that the expression is an optional constant integer
103 and that it specifies a valid kind for that type. */
106 kind_check (gfc_expr
*k
, int n
, bt type
)
113 if (type_check (k
, n
, BT_INTEGER
) == FAILURE
)
116 if (k
->expr_type
!= EXPR_CONSTANT
)
118 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a constant",
119 gfc_current_intrinsic_arg
[n
], gfc_current_intrinsic
,
124 if (gfc_extract_int (k
, &kind
) != NULL
125 || gfc_validate_kind (type
, kind
, true) < 0)
127 gfc_error ("Invalid kind for %s at %L", gfc_basic_typename (type
),
136 /* Make sure the expression is a double precision real. */
139 double_check (gfc_expr
*d
, int n
)
141 if (type_check (d
, n
, BT_REAL
) == FAILURE
)
144 if (d
->ts
.kind
!= gfc_default_double_kind
)
146 gfc_error ("'%s' argument of '%s' intrinsic at %L must be double "
147 "precision", gfc_current_intrinsic_arg
[n
],
148 gfc_current_intrinsic
, &d
->where
);
156 /* Make sure the expression is a logical array. */
159 logical_array_check (gfc_expr
*array
, int n
)
161 if (array
->ts
.type
!= BT_LOGICAL
|| array
->rank
== 0)
163 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a logical "
164 "array", gfc_current_intrinsic_arg
[n
], gfc_current_intrinsic
,
173 /* Make sure an expression is an array. */
176 array_check (gfc_expr
*e
, int n
)
181 gfc_error ("'%s' argument of '%s' intrinsic at %L must be an array",
182 gfc_current_intrinsic_arg
[n
], gfc_current_intrinsic
, &e
->where
);
188 /* Make sure an expression is a scalar. */
191 scalar_check (gfc_expr
*e
, int n
)
196 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a scalar",
197 gfc_current_intrinsic_arg
[n
], gfc_current_intrinsic
, &e
->where
);
203 /* Make sure two expressions have the same type. */
206 same_type_check (gfc_expr
*e
, int n
, gfc_expr
*f
, int m
)
208 if (gfc_compare_types (&e
->ts
, &f
->ts
))
211 gfc_error ("'%s' argument of '%s' intrinsic at %L must be the same type "
212 "and kind as '%s'", gfc_current_intrinsic_arg
[m
],
213 gfc_current_intrinsic
, &f
->where
, gfc_current_intrinsic_arg
[n
]);
219 /* Make sure that an expression has a certain (nonzero) rank. */
222 rank_check (gfc_expr
*e
, int n
, int rank
)
227 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of rank %d",
228 gfc_current_intrinsic_arg
[n
], gfc_current_intrinsic
,
235 /* Make sure a variable expression is not an optional dummy argument. */
238 nonoptional_check (gfc_expr
*e
, int n
)
240 if (e
->expr_type
== EXPR_VARIABLE
&& e
->symtree
->n
.sym
->attr
.optional
)
242 gfc_error ("'%s' argument of '%s' intrinsic at %L must not be OPTIONAL",
243 gfc_current_intrinsic_arg
[n
], gfc_current_intrinsic
,
247 /* TODO: Recursive check on nonoptional variables? */
253 /* Check that an expression has a particular kind. */
256 kind_value_check (gfc_expr
*e
, int n
, int k
)
261 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of kind %d",
262 gfc_current_intrinsic_arg
[n
], gfc_current_intrinsic
,
269 /* Make sure an expression is a variable. */
272 variable_check (gfc_expr
*e
, int n
)
274 if ((e
->expr_type
== EXPR_VARIABLE
275 && e
->symtree
->n
.sym
->attr
.flavor
!= FL_PARAMETER
)
276 || (e
->expr_type
== EXPR_FUNCTION
277 && e
->symtree
->n
.sym
->result
== e
->symtree
->n
.sym
))
280 if (e
->expr_type
== EXPR_VARIABLE
281 && e
->symtree
->n
.sym
->attr
.intent
== INTENT_IN
)
283 gfc_error ("'%s' argument of '%s' intrinsic at %L cannot be INTENT(IN)",
284 gfc_current_intrinsic_arg
[n
], gfc_current_intrinsic
,
289 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a variable",
290 gfc_current_intrinsic_arg
[n
], gfc_current_intrinsic
, &e
->where
);
296 /* Check the common DIM parameter for correctness. */
299 dim_check (gfc_expr
*dim
, int n
, int optional
)
301 if (optional
&& dim
== NULL
)
306 gfc_error ("Missing DIM parameter in intrinsic '%s' at %L",
307 gfc_current_intrinsic
, gfc_current_intrinsic_where
);
311 if (type_check (dim
, n
, BT_INTEGER
) == FAILURE
)
314 if (scalar_check (dim
, n
) == FAILURE
)
317 if (nonoptional_check (dim
, n
) == FAILURE
)
324 /* If a DIM parameter is a constant, make sure that it is greater than
325 zero and less than or equal to the rank of the given array. If
326 allow_assumed is zero then dim must be less than the rank of the array
327 for assumed size arrays. */
330 dim_rank_check (gfc_expr
*dim
, gfc_expr
*array
, int allow_assumed
)
335 if (dim
->expr_type
!= EXPR_CONSTANT
|| array
->expr_type
!= EXPR_VARIABLE
)
338 ar
= gfc_find_array_ref (array
);
340 if (ar
->as
->type
== AS_ASSUMED_SIZE
&& !allow_assumed
)
343 if (mpz_cmp_ui (dim
->value
.integer
, 1) < 0
344 || mpz_cmp_ui (dim
->value
.integer
, rank
) > 0)
346 gfc_error ("'dim' argument of '%s' intrinsic at %L is not a valid "
347 "dimension index", gfc_current_intrinsic
, &dim
->where
);
356 /* Compare the size of a along dimension ai with the size of b along
357 dimension bi, returning 0 if they are known not to be identical,
358 and 1 if they are identical, or if this cannot be determined. */
361 identical_dimen_shape (gfc_expr
*a
, int ai
, gfc_expr
*b
, int bi
)
363 mpz_t a_size
, b_size
;
366 gcc_assert (a
->rank
> ai
);
367 gcc_assert (b
->rank
> bi
);
371 if (gfc_array_dimen_size (a
, ai
, &a_size
) == SUCCESS
)
373 if (gfc_array_dimen_size (b
, bi
, &b_size
) == SUCCESS
)
375 if (mpz_cmp (a_size
, b_size
) != 0)
386 /* Error return for transformational intrinsics not allowed in
387 initialization expressions. */
390 non_init_transformational (void)
392 gfc_error ("transformational intrinsic '%s' at %L is not permitted "
393 "in an initialization expression", gfc_current_intrinsic
,
394 gfc_current_intrinsic_where
);
398 /***** Check functions *****/
400 /* Check subroutine suitable for intrinsics taking a real argument and
401 a kind argument for the result. */
404 check_a_kind (gfc_expr
*a
, gfc_expr
*kind
, bt type
)
406 if (type_check (a
, 0, BT_REAL
) == FAILURE
)
408 if (kind_check (kind
, 1, type
) == FAILURE
)
415 /* Check subroutine suitable for ceiling, floor and nint. */
418 gfc_check_a_ikind (gfc_expr
*a
, gfc_expr
*kind
)
420 return check_a_kind (a
, kind
, BT_INTEGER
);
424 /* Check subroutine suitable for aint, anint. */
427 gfc_check_a_xkind (gfc_expr
*a
, gfc_expr
*kind
)
429 return check_a_kind (a
, kind
, BT_REAL
);
434 gfc_check_abs (gfc_expr
*a
)
436 if (numeric_check (a
, 0) == FAILURE
)
444 gfc_check_achar (gfc_expr
*a
)
446 if (type_check (a
, 0, BT_INTEGER
) == FAILURE
)
454 gfc_check_access_func (gfc_expr
*name
, gfc_expr
*mode
)
456 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
457 || scalar_check (name
, 0) == FAILURE
)
460 if (type_check (mode
, 1, BT_CHARACTER
) == FAILURE
461 || scalar_check (mode
, 1) == FAILURE
)
469 gfc_check_all_any (gfc_expr
*mask
, gfc_expr
*dim
)
471 if (logical_array_check (mask
, 0) == FAILURE
)
474 if (dim_check (dim
, 1, 1) == FAILURE
)
478 return non_init_transformational ();
485 gfc_check_allocated (gfc_expr
*array
)
487 symbol_attribute attr
;
489 if (variable_check (array
, 0) == FAILURE
)
492 if (array_check (array
, 0) == FAILURE
)
495 attr
= gfc_variable_attr (array
, NULL
);
496 if (!attr
.allocatable
)
498 gfc_error ("'%s' argument of '%s' intrinsic at %L must be ALLOCATABLE",
499 gfc_current_intrinsic_arg
[0], gfc_current_intrinsic
,
508 /* Common check function where the first argument must be real or
509 integer and the second argument must be the same as the first. */
512 gfc_check_a_p (gfc_expr
*a
, gfc_expr
*p
)
514 if (int_or_real_check (a
, 0) == FAILURE
)
517 if (a
->ts
.type
!= p
->ts
.type
)
519 gfc_error ("'%s' and '%s' arguments of '%s' intrinsic at %L must "
520 "have the same type", gfc_current_intrinsic_arg
[0],
521 gfc_current_intrinsic_arg
[1], gfc_current_intrinsic
,
526 if (a
->ts
.kind
!= p
->ts
.kind
)
528 if (gfc_notify_std (GFC_STD_GNU
, "Extension: Different type kinds at %L",
529 &p
->where
) == FAILURE
)
538 gfc_check_associated (gfc_expr
*pointer
, gfc_expr
*target
)
540 symbol_attribute attr
;
545 where
= &pointer
->where
;
547 if (pointer
->expr_type
== EXPR_VARIABLE
)
548 attr
= gfc_variable_attr (pointer
, NULL
);
549 else if (pointer
->expr_type
== EXPR_FUNCTION
)
550 attr
= pointer
->symtree
->n
.sym
->attr
;
551 else if (pointer
->expr_type
== EXPR_NULL
)
554 gcc_assert (0); /* Pointer must be a variable or a function. */
558 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a POINTER",
559 gfc_current_intrinsic_arg
[0], gfc_current_intrinsic
,
564 /* Target argument is optional. */
568 where
= &target
->where
;
569 if (target
->expr_type
== EXPR_NULL
)
572 if (target
->expr_type
== EXPR_VARIABLE
)
573 attr
= gfc_variable_attr (target
, NULL
);
574 else if (target
->expr_type
== EXPR_FUNCTION
)
575 attr
= target
->symtree
->n
.sym
->attr
;
578 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a pointer "
579 "or target VARIABLE or FUNCTION", gfc_current_intrinsic_arg
[1],
580 gfc_current_intrinsic
, &target
->where
);
584 if (!attr
.pointer
&& !attr
.target
)
586 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a POINTER "
587 "or a TARGET", gfc_current_intrinsic_arg
[1],
588 gfc_current_intrinsic
, &target
->where
);
593 if (same_type_check (pointer
, 0, target
, 1) == FAILURE
)
595 if (rank_check (target
, 0, pointer
->rank
) == FAILURE
)
597 if (target
->rank
> 0)
599 for (i
= 0; i
< target
->rank
; i
++)
600 if (target
->ref
->u
.ar
.dimen_type
[i
] == DIMEN_VECTOR
)
602 gfc_error ("Array section with a vector subscript at %L shall not "
603 "be the target of a pointer",
613 gfc_error ("NULL pointer at %L is not permitted as actual argument "
614 "of '%s' intrinsic function", where
, gfc_current_intrinsic
);
621 gfc_check_atan2 (gfc_expr
*y
, gfc_expr
*x
)
623 if (type_check (y
, 0, BT_REAL
) == FAILURE
)
625 if (same_type_check (y
, 0, x
, 1) == FAILURE
)
632 /* BESJN and BESYN functions. */
635 gfc_check_besn (gfc_expr
*n
, gfc_expr
*x
)
637 if (scalar_check (n
, 0) == FAILURE
)
640 if (type_check (n
, 0, BT_INTEGER
) == FAILURE
)
643 if (scalar_check (x
, 1) == FAILURE
)
646 if (type_check (x
, 1, BT_REAL
) == FAILURE
)
654 gfc_check_btest (gfc_expr
*i
, gfc_expr
*pos
)
656 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
658 if (type_check (pos
, 1, BT_INTEGER
) == FAILURE
)
666 gfc_check_char (gfc_expr
*i
, gfc_expr
*kind
)
668 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
670 if (kind_check (kind
, 1, BT_CHARACTER
) == FAILURE
)
678 gfc_check_chdir (gfc_expr
*dir
)
680 if (type_check (dir
, 0, BT_CHARACTER
) == FAILURE
)
688 gfc_check_chdir_sub (gfc_expr
*dir
, gfc_expr
*status
)
690 if (type_check (dir
, 0, BT_CHARACTER
) == FAILURE
)
696 if (type_check (status
, 1, BT_INTEGER
) == FAILURE
)
699 if (scalar_check (status
, 1) == FAILURE
)
707 gfc_check_chmod (gfc_expr
*name
, gfc_expr
*mode
)
709 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
712 if (type_check (mode
, 1, BT_CHARACTER
) == FAILURE
)
720 gfc_check_chmod_sub (gfc_expr
*name
, gfc_expr
*mode
, gfc_expr
*status
)
722 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
725 if (type_check (mode
, 1, BT_CHARACTER
) == FAILURE
)
731 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
734 if (scalar_check (status
, 2) == FAILURE
)
742 gfc_check_cmplx (gfc_expr
*x
, gfc_expr
*y
, gfc_expr
*kind
)
744 if (numeric_check (x
, 0) == FAILURE
)
749 if (numeric_check (y
, 1) == FAILURE
)
752 if (x
->ts
.type
== BT_COMPLEX
)
754 gfc_error ("'%s' argument of '%s' intrinsic at %L must not be "
755 "present if 'x' is COMPLEX", gfc_current_intrinsic_arg
[1],
756 gfc_current_intrinsic
, &y
->where
);
761 if (kind_check (kind
, 2, BT_COMPLEX
) == FAILURE
)
769 gfc_check_complex (gfc_expr
*x
, gfc_expr
*y
)
771 if (x
->ts
.type
!= BT_INTEGER
&& x
->ts
.type
!= BT_REAL
)
773 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
774 "or REAL", gfc_current_intrinsic_arg
[0],
775 gfc_current_intrinsic
, &x
->where
);
778 if (scalar_check (x
, 0) == FAILURE
)
781 if (y
->ts
.type
!= BT_INTEGER
&& y
->ts
.type
!= BT_REAL
)
783 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
784 "or REAL", gfc_current_intrinsic_arg
[1],
785 gfc_current_intrinsic
, &y
->where
);
788 if (scalar_check (y
, 1) == FAILURE
)
796 gfc_check_count (gfc_expr
*mask
, gfc_expr
*dim
)
798 if (logical_array_check (mask
, 0) == FAILURE
)
800 if (dim_check (dim
, 1, 1) == FAILURE
)
804 return non_init_transformational ();
811 gfc_check_cshift (gfc_expr
*array
, gfc_expr
*shift
, gfc_expr
*dim
)
813 if (array_check (array
, 0) == FAILURE
)
816 if (array
->rank
== 1)
818 if (scalar_check (shift
, 1) == FAILURE
)
823 /* TODO: more requirements on shift parameter. */
826 if (dim_check (dim
, 2, 1) == FAILURE
)
830 return non_init_transformational ();
837 gfc_check_ctime (gfc_expr
*time
)
839 if (scalar_check (time
, 0) == FAILURE
)
842 if (type_check (time
, 0, BT_INTEGER
) == FAILURE
)
850 gfc_check_dcmplx (gfc_expr
*x
, gfc_expr
*y
)
852 if (numeric_check (x
, 0) == FAILURE
)
857 if (numeric_check (y
, 1) == FAILURE
)
860 if (x
->ts
.type
== BT_COMPLEX
)
862 gfc_error ("'%s' argument of '%s' intrinsic at %L must not be "
863 "present if 'x' is COMPLEX", gfc_current_intrinsic_arg
[1],
864 gfc_current_intrinsic
, &y
->where
);
874 gfc_check_dble (gfc_expr
*x
)
876 if (numeric_check (x
, 0) == FAILURE
)
884 gfc_check_digits (gfc_expr
*x
)
886 if (int_or_real_check (x
, 0) == FAILURE
)
894 gfc_check_dot_product (gfc_expr
*vector_a
, gfc_expr
*vector_b
)
896 switch (vector_a
->ts
.type
)
899 if (type_check (vector_b
, 1, BT_LOGICAL
) == FAILURE
)
906 if (numeric_check (vector_b
, 1) == FAILURE
)
911 gfc_error ("'%s' argument of '%s' intrinsic at %L must be numeric "
912 "or LOGICAL", gfc_current_intrinsic_arg
[0],
913 gfc_current_intrinsic
, &vector_a
->where
);
917 if (rank_check (vector_a
, 0, 1) == FAILURE
)
920 if (rank_check (vector_b
, 1, 1) == FAILURE
)
923 if (! identical_dimen_shape (vector_a
, 0, vector_b
, 0))
925 gfc_error ("different shape for arguments '%s' and '%s' at %L for "
926 "intrinsic 'dot_product'", gfc_current_intrinsic_arg
[0],
927 gfc_current_intrinsic_arg
[1], &vector_a
->where
);
932 return non_init_transformational ();
939 gfc_check_eoshift (gfc_expr
*array
, gfc_expr
*shift
, gfc_expr
*boundary
,
942 if (array_check (array
, 0) == FAILURE
)
945 if (type_check (shift
, 1, BT_INTEGER
) == FAILURE
)
948 if (array
->rank
== 1)
950 if (scalar_check (shift
, 2) == FAILURE
)
955 /* TODO: more weird restrictions on shift. */
958 if (boundary
!= NULL
)
960 if (same_type_check (array
, 0, boundary
, 2) == FAILURE
)
963 /* TODO: more restrictions on boundary. */
966 if (dim_check (dim
, 1, 1) == FAILURE
)
970 return non_init_transformational ();
976 /* A single complex argument. */
979 gfc_check_fn_c (gfc_expr
*a
)
981 if (type_check (a
, 0, BT_COMPLEX
) == FAILURE
)
988 /* A single real argument. */
991 gfc_check_fn_r (gfc_expr
*a
)
993 if (type_check (a
, 0, BT_REAL
) == FAILURE
)
1000 /* A single real or complex argument. */
1003 gfc_check_fn_rc (gfc_expr
*a
)
1005 if (real_or_complex_check (a
, 0) == FAILURE
)
1013 gfc_check_fnum (gfc_expr
*unit
)
1015 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
1018 if (scalar_check (unit
, 0) == FAILURE
)
1025 /* This is used for the g77 one-argument Bessel functions, and the
1029 gfc_check_g77_math1 (gfc_expr
*x
)
1031 if (scalar_check (x
, 0) == FAILURE
)
1034 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
1042 gfc_check_huge (gfc_expr
*x
)
1044 if (int_or_real_check (x
, 0) == FAILURE
)
1051 /* Check that the single argument is an integer. */
1054 gfc_check_i (gfc_expr
*i
)
1056 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1064 gfc_check_iand (gfc_expr
*i
, gfc_expr
*j
)
1066 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1069 if (type_check (j
, 1, BT_INTEGER
) == FAILURE
)
1072 if (i
->ts
.kind
!= j
->ts
.kind
)
1074 if (gfc_notify_std (GFC_STD_GNU
, "Extension: Different type kinds at %L",
1075 &i
->where
) == FAILURE
)
1084 gfc_check_ibclr (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_ibits (gfc_expr
*i
, gfc_expr
*pos
, gfc_expr
*len
)
1099 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1102 if (type_check (pos
, 1, BT_INTEGER
) == FAILURE
)
1105 if (type_check (len
, 2, BT_INTEGER
) == FAILURE
)
1113 gfc_check_ibset (gfc_expr
*i
, gfc_expr
*pos
)
1115 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1118 if (type_check (pos
, 1, BT_INTEGER
) == FAILURE
)
1126 gfc_check_ichar_iachar (gfc_expr
*c
)
1130 if (type_check (c
, 0, BT_CHARACTER
) == FAILURE
)
1133 if (c
->expr_type
== EXPR_VARIABLE
|| c
->expr_type
== EXPR_SUBSTRING
)
1139 /* Substring references don't have the charlength set. */
1141 while (ref
&& ref
->type
!= REF_SUBSTRING
)
1144 gcc_assert (ref
== NULL
|| ref
->type
== REF_SUBSTRING
);
1148 /* Check that the argument is length one. Non-constant lengths
1149 can't be checked here, so assume they are ok. */
1150 if (c
->ts
.cl
&& c
->ts
.cl
->length
)
1152 /* If we already have a length for this expression then use it. */
1153 if (c
->ts
.cl
->length
->expr_type
!= EXPR_CONSTANT
)
1155 i
= mpz_get_si (c
->ts
.cl
->length
->value
.integer
);
1162 start
= ref
->u
.ss
.start
;
1163 end
= ref
->u
.ss
.end
;
1166 if (end
== NULL
|| end
->expr_type
!= EXPR_CONSTANT
1167 || start
->expr_type
!= EXPR_CONSTANT
)
1170 i
= mpz_get_si (end
->value
.integer
) + 1
1171 - mpz_get_si (start
->value
.integer
);
1179 gfc_error ("Argument of %s at %L must be of length one",
1180 gfc_current_intrinsic
, &c
->where
);
1189 gfc_check_idnint (gfc_expr
*a
)
1191 if (double_check (a
, 0) == FAILURE
)
1199 gfc_check_ieor (gfc_expr
*i
, gfc_expr
*j
)
1201 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1204 if (type_check (j
, 1, BT_INTEGER
) == FAILURE
)
1207 if (i
->ts
.kind
!= j
->ts
.kind
)
1209 if (gfc_notify_std (GFC_STD_GNU
, "Extension: Different type kinds at %L",
1210 &i
->where
) == FAILURE
)
1219 gfc_check_index (gfc_expr
*string
, gfc_expr
*substring
, gfc_expr
*back
)
1221 if (type_check (string
, 0, BT_CHARACTER
) == FAILURE
1222 || type_check (substring
, 1, BT_CHARACTER
) == FAILURE
)
1226 if (back
!= NULL
&& type_check (back
, 2, BT_LOGICAL
) == FAILURE
)
1229 if (string
->ts
.kind
!= substring
->ts
.kind
)
1231 gfc_error ("'%s' argument of '%s' intrinsic at %L must be the same "
1232 "kind as '%s'", gfc_current_intrinsic_arg
[1],
1233 gfc_current_intrinsic
, &substring
->where
,
1234 gfc_current_intrinsic_arg
[0]);
1243 gfc_check_int (gfc_expr
*x
, gfc_expr
*kind
)
1245 if (numeric_check (x
, 0) == FAILURE
)
1250 if (type_check (kind
, 1, BT_INTEGER
) == FAILURE
)
1253 if (scalar_check (kind
, 1) == FAILURE
)
1262 gfc_check_intconv (gfc_expr
*x
)
1264 if (numeric_check (x
, 0) == FAILURE
)
1272 gfc_check_ior (gfc_expr
*i
, gfc_expr
*j
)
1274 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1277 if (type_check (j
, 1, BT_INTEGER
) == FAILURE
)
1280 if (i
->ts
.kind
!= j
->ts
.kind
)
1282 if (gfc_notify_std (GFC_STD_GNU
, "Extension: Different type kinds at %L",
1283 &i
->where
) == FAILURE
)
1292 gfc_check_ishft (gfc_expr
*i
, gfc_expr
*shift
)
1294 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
1295 || type_check (shift
, 1, BT_INTEGER
) == FAILURE
)
1303 gfc_check_ishftc (gfc_expr
*i
, gfc_expr
*shift
, gfc_expr
*size
)
1305 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
1306 || type_check (shift
, 1, BT_INTEGER
) == FAILURE
)
1309 if (size
!= NULL
&& type_check (size
, 2, BT_INTEGER
) == FAILURE
)
1317 gfc_check_kill (gfc_expr
*pid
, gfc_expr
*sig
)
1319 if (type_check (pid
, 0, BT_INTEGER
) == FAILURE
)
1322 if (type_check (sig
, 1, BT_INTEGER
) == FAILURE
)
1330 gfc_check_kill_sub (gfc_expr
*pid
, gfc_expr
*sig
, gfc_expr
*status
)
1332 if (type_check (pid
, 0, BT_INTEGER
) == FAILURE
)
1335 if (scalar_check (pid
, 0) == FAILURE
)
1338 if (type_check (sig
, 1, BT_INTEGER
) == FAILURE
)
1341 if (scalar_check (sig
, 1) == FAILURE
)
1347 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
1350 if (scalar_check (status
, 2) == FAILURE
)
1358 gfc_check_kind (gfc_expr
*x
)
1360 if (x
->ts
.type
== BT_DERIVED
)
1362 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a "
1363 "non-derived type", gfc_current_intrinsic_arg
[0],
1364 gfc_current_intrinsic
, &x
->where
);
1373 gfc_check_lbound (gfc_expr
*array
, gfc_expr
*dim
)
1375 if (array_check (array
, 0) == FAILURE
)
1380 if (dim_check (dim
, 1, 1) == FAILURE
)
1383 if (dim_rank_check (dim
, array
, 1) == FAILURE
)
1391 gfc_check_link (gfc_expr
*path1
, gfc_expr
*path2
)
1393 if (type_check (path1
, 0, BT_CHARACTER
) == FAILURE
)
1396 if (type_check (path2
, 1, BT_CHARACTER
) == FAILURE
)
1404 gfc_check_link_sub (gfc_expr
*path1
, gfc_expr
*path2
, gfc_expr
*status
)
1406 if (type_check (path1
, 0, BT_CHARACTER
) == FAILURE
)
1409 if (type_check (path2
, 1, BT_CHARACTER
) == FAILURE
)
1415 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
1418 if (scalar_check (status
, 2) == FAILURE
)
1426 gfc_check_loc (gfc_expr
*expr
)
1428 return variable_check (expr
, 0);
1433 gfc_check_symlnk (gfc_expr
*path1
, gfc_expr
*path2
)
1435 if (type_check (path1
, 0, BT_CHARACTER
) == FAILURE
)
1438 if (type_check (path2
, 1, BT_CHARACTER
) == FAILURE
)
1446 gfc_check_symlnk_sub (gfc_expr
*path1
, gfc_expr
*path2
, gfc_expr
*status
)
1448 if (type_check (path1
, 0, BT_CHARACTER
) == FAILURE
)
1451 if (type_check (path2
, 1, BT_CHARACTER
) == FAILURE
)
1457 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
1460 if (scalar_check (status
, 2) == FAILURE
)
1468 gfc_check_logical (gfc_expr
*a
, gfc_expr
*kind
)
1470 if (type_check (a
, 0, BT_LOGICAL
) == FAILURE
)
1472 if (kind_check (kind
, 1, BT_LOGICAL
) == FAILURE
)
1479 /* Min/max family. */
1482 min_max_args (gfc_actual_arglist
*arg
)
1484 if (arg
== NULL
|| arg
->next
== NULL
)
1486 gfc_error ("Intrinsic '%s' at %L must have at least two arguments",
1487 gfc_current_intrinsic
, gfc_current_intrinsic_where
);
1496 check_rest (bt type
, int kind
, gfc_actual_arglist
*arg
)
1501 if (min_max_args (arg
) == FAILURE
)
1506 for (; arg
; arg
= arg
->next
, n
++)
1509 if (x
->ts
.type
!= type
|| x
->ts
.kind
!= kind
)
1511 if (x
->ts
.type
== type
)
1513 if (gfc_notify_std (GFC_STD_GNU
, "Extension: Different type "
1514 "kinds at %L", &x
->where
) == FAILURE
)
1519 gfc_error ("'a%d' argument of '%s' intrinsic at %L must be "
1520 "%s(%d)", n
, gfc_current_intrinsic
, &x
->where
,
1521 gfc_basic_typename (type
), kind
);
1532 gfc_check_min_max (gfc_actual_arglist
*arg
)
1536 if (min_max_args (arg
) == FAILURE
)
1541 if (x
->ts
.type
!= BT_INTEGER
&& x
->ts
.type
!= BT_REAL
)
1543 gfc_error ("'a1' argument of '%s' intrinsic at %L must be INTEGER "
1544 "or REAL", gfc_current_intrinsic
, &x
->where
);
1548 return check_rest (x
->ts
.type
, x
->ts
.kind
, arg
);
1553 gfc_check_min_max_integer (gfc_actual_arglist
*arg
)
1555 return check_rest (BT_INTEGER
, gfc_default_integer_kind
, arg
);
1560 gfc_check_min_max_real (gfc_actual_arglist
*arg
)
1562 return check_rest (BT_REAL
, gfc_default_real_kind
, arg
);
1567 gfc_check_min_max_double (gfc_actual_arglist
*arg
)
1569 return check_rest (BT_REAL
, gfc_default_double_kind
, arg
);
1573 /* End of min/max family. */
1576 gfc_check_malloc (gfc_expr
*size
)
1578 if (type_check (size
, 0, BT_INTEGER
) == FAILURE
)
1581 if (scalar_check (size
, 0) == FAILURE
)
1589 gfc_check_matmul (gfc_expr
*matrix_a
, gfc_expr
*matrix_b
)
1591 if ((matrix_a
->ts
.type
!= BT_LOGICAL
) && !gfc_numeric_ts (&matrix_b
->ts
))
1593 gfc_error ("'%s' argument of '%s' intrinsic at %L must be numeric "
1594 "or LOGICAL", gfc_current_intrinsic_arg
[0],
1595 gfc_current_intrinsic
, &matrix_a
->where
);
1599 if ((matrix_b
->ts
.type
!= BT_LOGICAL
) && !gfc_numeric_ts (&matrix_a
->ts
))
1601 gfc_error ("'%s' argument of '%s' intrinsic at %L must be numeric "
1602 "or LOGICAL", gfc_current_intrinsic_arg
[1],
1603 gfc_current_intrinsic
, &matrix_b
->where
);
1607 switch (matrix_a
->rank
)
1610 if (rank_check (matrix_b
, 1, 2) == FAILURE
)
1612 /* Check for case matrix_a has shape(m), matrix_b has shape (m, k). */
1613 if (!identical_dimen_shape (matrix_a
, 0, matrix_b
, 0))
1615 gfc_error ("different shape on dimension 1 for arguments '%s' "
1616 "and '%s' at %L for intrinsic matmul",
1617 gfc_current_intrinsic_arg
[0],
1618 gfc_current_intrinsic_arg
[1], &matrix_a
->where
);
1624 if (matrix_b
->rank
!= 2)
1626 if (rank_check (matrix_b
, 1, 1) == FAILURE
)
1629 /* matrix_b has rank 1 or 2 here. Common check for the cases
1630 - matrix_a has shape (n,m) and matrix_b has shape (m, k)
1631 - matrix_a has shape (n,m) and matrix_b has shape (m). */
1632 if (!identical_dimen_shape (matrix_a
, 1, matrix_b
, 0))
1634 gfc_error ("different shape on dimension 2 for argument '%s' and "
1635 "dimension 1 for argument '%s' at %L for intrinsic "
1636 "matmul", gfc_current_intrinsic_arg
[0],
1637 gfc_current_intrinsic_arg
[1], &matrix_a
->where
);
1643 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of rank "
1644 "1 or 2", gfc_current_intrinsic_arg
[0],
1645 gfc_current_intrinsic
, &matrix_a
->where
);
1650 return non_init_transformational ();
1656 /* Whoever came up with this interface was probably on something.
1657 The possibilities for the occupation of the second and third
1664 NULL MASK minloc(array, mask=m)
1667 I.e. in the case of minloc(array,mask), mask will be in the second
1668 position of the argument list and we'll have to fix that up. */
1671 gfc_check_minloc_maxloc (gfc_actual_arglist
*ap
)
1673 gfc_expr
*a
, *m
, *d
;
1676 if (int_or_real_check (a
, 0) == FAILURE
|| array_check (a
, 0) == FAILURE
)
1680 m
= ap
->next
->next
->expr
;
1682 if (m
== NULL
&& d
!= NULL
&& d
->ts
.type
== BT_LOGICAL
1683 && ap
->next
->name
== NULL
)
1687 ap
->next
->expr
= NULL
;
1688 ap
->next
->next
->expr
= m
;
1691 if (dim_check (d
, 1, 1) == FAILURE
)
1694 if (d
&& dim_rank_check (d
, a
, 0) == FAILURE
)
1697 if (m
!= NULL
&& type_check (m
, 2, BT_LOGICAL
) == FAILURE
)
1703 snprintf (buffer
, 80, "arguments '%s' and '%s' for intrinsic %s",
1704 gfc_current_intrinsic_arg
[0], gfc_current_intrinsic_arg
[2],
1705 gfc_current_intrinsic
);
1706 if (gfc_check_conformance (buffer
, a
, m
) == FAILURE
)
1711 return non_init_transformational ();
1717 /* Similar to minloc/maxloc, the argument list might need to be
1718 reordered for the MINVAL, MAXVAL, PRODUCT, and SUM intrinsics. The
1719 difference is that MINLOC/MAXLOC take an additional KIND argument.
1720 The possibilities are:
1726 NULL MASK minval(array, mask=m)
1729 I.e. in the case of minval(array,mask), mask will be in the second
1730 position of the argument list and we'll have to fix that up. */
1733 check_reduction (gfc_actual_arglist
*ap
)
1735 gfc_expr
*a
, *m
, *d
;
1739 m
= ap
->next
->next
->expr
;
1741 if (m
== NULL
&& d
!= NULL
&& d
->ts
.type
== BT_LOGICAL
1742 && ap
->next
->name
== NULL
)
1746 ap
->next
->expr
= NULL
;
1747 ap
->next
->next
->expr
= m
;
1750 if (dim_check (d
, 1, 1) == FAILURE
)
1753 if (d
&& dim_rank_check (d
, a
, 0) == FAILURE
)
1756 if (m
!= NULL
&& type_check (m
, 2, BT_LOGICAL
) == FAILURE
)
1762 snprintf (buffer
, 80, "arguments '%s' and '%s' for intrinsic %s",
1763 gfc_current_intrinsic_arg
[0], gfc_current_intrinsic_arg
[2],
1764 gfc_current_intrinsic
);
1765 if (gfc_check_conformance (buffer
, a
, m
) == FAILURE
)
1774 gfc_check_minval_maxval (gfc_actual_arglist
*ap
)
1776 if (int_or_real_check (ap
->expr
, 0) == FAILURE
1777 || array_check (ap
->expr
, 0) == FAILURE
)
1781 return non_init_transformational ();
1783 return check_reduction (ap
);
1788 gfc_check_product_sum (gfc_actual_arglist
*ap
)
1790 if (numeric_check (ap
->expr
, 0) == FAILURE
1791 || array_check (ap
->expr
, 0) == FAILURE
)
1795 return non_init_transformational ();
1797 return check_reduction (ap
);
1802 gfc_check_merge (gfc_expr
*tsource
, gfc_expr
*fsource
, gfc_expr
*mask
)
1806 if (same_type_check (tsource
, 0, fsource
, 1) == FAILURE
)
1809 if (type_check (mask
, 2, BT_LOGICAL
) == FAILURE
)
1812 snprintf (buffer
, 80, "arguments '%s' and '%s' for intrinsic '%s'",
1813 gfc_current_intrinsic_arg
[0], gfc_current_intrinsic_arg
[1],
1814 gfc_current_intrinsic
);
1815 if (gfc_check_conformance (buffer
, tsource
, fsource
) == FAILURE
)
1818 snprintf (buffer
, 80, "arguments '%s' and '%s' for intrinsic '%s'",
1819 gfc_current_intrinsic_arg
[0], gfc_current_intrinsic_arg
[2],
1820 gfc_current_intrinsic
);
1821 if (gfc_check_conformance (buffer
, tsource
, mask
) == FAILURE
)
1828 gfc_check_move_alloc (gfc_expr
*from
, gfc_expr
*to
)
1830 symbol_attribute attr
;
1832 if (variable_check (from
, 0) == FAILURE
)
1835 if (array_check (from
, 0) == FAILURE
)
1838 attr
= gfc_variable_attr (from
, NULL
);
1839 if (!attr
.allocatable
)
1841 gfc_error ("'%s' argument of '%s' intrinsic at %L must be ALLOCATABLE",
1842 gfc_current_intrinsic_arg
[0], gfc_current_intrinsic
,
1847 if (variable_check (to
, 0) == FAILURE
)
1850 if (array_check (to
, 0) == FAILURE
)
1853 attr
= gfc_variable_attr (to
, NULL
);
1854 if (!attr
.allocatable
)
1856 gfc_error ("'%s' argument of '%s' intrinsic at %L must be ALLOCATABLE",
1857 gfc_current_intrinsic_arg
[0], gfc_current_intrinsic
,
1862 if (same_type_check (from
, 0, to
, 1) == FAILURE
)
1865 if (to
->rank
!= from
->rank
)
1867 gfc_error ("the '%s' and '%s' arguments of '%s' intrinsic at %L must "
1868 "have the same rank %d/%d", gfc_current_intrinsic_arg
[0],
1869 gfc_current_intrinsic_arg
[1], gfc_current_intrinsic
,
1870 &to
->where
, from
->rank
, to
->rank
);
1874 if (to
->ts
.kind
!= from
->ts
.kind
)
1876 gfc_error ("the '%s' and '%s' arguments of '%s' intrinsic at %L must "
1877 "be of the same kind %d/%d", gfc_current_intrinsic_arg
[0],
1878 gfc_current_intrinsic_arg
[1], gfc_current_intrinsic
,
1879 &to
->where
, from
->ts
.kind
, to
->ts
.kind
);
1888 gfc_check_nearest (gfc_expr
*x
, gfc_expr
*s
)
1890 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
1893 if (type_check (s
, 1, BT_REAL
) == FAILURE
)
1901 gfc_check_new_line (gfc_expr
*a
)
1903 if (type_check (a
, 0, BT_CHARACTER
) == FAILURE
)
1911 gfc_check_null (gfc_expr
*mold
)
1913 symbol_attribute attr
;
1918 if (variable_check (mold
, 0) == FAILURE
)
1921 attr
= gfc_variable_attr (mold
, NULL
);
1925 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a POINTER",
1926 gfc_current_intrinsic_arg
[0],
1927 gfc_current_intrinsic
, &mold
->where
);
1936 gfc_check_pack (gfc_expr
*array
, gfc_expr
*mask
, gfc_expr
*vector
)
1940 if (array_check (array
, 0) == FAILURE
)
1943 if (type_check (mask
, 1, BT_LOGICAL
) == FAILURE
)
1946 snprintf (buffer
, 80, "arguments '%s' and '%s' for intrinsic '%s'",
1947 gfc_current_intrinsic_arg
[0], gfc_current_intrinsic_arg
[1],
1948 gfc_current_intrinsic
);
1949 if (gfc_check_conformance (buffer
, array
, mask
) == FAILURE
)
1954 if (same_type_check (array
, 0, vector
, 2) == FAILURE
)
1957 if (rank_check (vector
, 2, 1) == FAILURE
)
1960 /* TODO: More constraints here. */
1964 return non_init_transformational ();
1971 gfc_check_precision (gfc_expr
*x
)
1973 if (x
->ts
.type
!= BT_REAL
&& x
->ts
.type
!= BT_COMPLEX
)
1975 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of type "
1976 "REAL or COMPLEX", gfc_current_intrinsic_arg
[0],
1977 gfc_current_intrinsic
, &x
->where
);
1986 gfc_check_present (gfc_expr
*a
)
1990 if (variable_check (a
, 0) == FAILURE
)
1993 sym
= a
->symtree
->n
.sym
;
1994 if (!sym
->attr
.dummy
)
1996 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of a "
1997 "dummy variable", gfc_current_intrinsic_arg
[0],
1998 gfc_current_intrinsic
, &a
->where
);
2002 if (!sym
->attr
.optional
)
2004 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of "
2005 "an OPTIONAL dummy variable", gfc_current_intrinsic_arg
[0],
2006 gfc_current_intrinsic
, &a
->where
);
2010 /* 13.14.82 PRESENT(A)
2012 Argument. A shall be the name of an optional dummy argument that is
2013 accessible in the subprogram in which the PRESENT function reference
2017 && !(a
->ref
->next
== NULL
&& a
->ref
->type
== REF_ARRAY
2018 && a
->ref
->u
.ar
.type
== AR_FULL
))
2020 gfc_error ("'%s' argument of '%s' intrinsic at %L must not be a "
2021 "subobject of '%s'", gfc_current_intrinsic_arg
[0],
2022 gfc_current_intrinsic
, &a
->where
, sym
->name
);
2031 gfc_check_radix (gfc_expr
*x
)
2033 if (int_or_real_check (x
, 0) == FAILURE
)
2041 gfc_check_range (gfc_expr
*x
)
2043 if (numeric_check (x
, 0) == FAILURE
)
2050 /* real, float, sngl. */
2052 gfc_check_real (gfc_expr
*a
, gfc_expr
*kind
)
2054 if (numeric_check (a
, 0) == FAILURE
)
2057 if (kind_check (kind
, 1, BT_REAL
) == FAILURE
)
2065 gfc_check_rename (gfc_expr
*path1
, gfc_expr
*path2
)
2067 if (type_check (path1
, 0, BT_CHARACTER
) == FAILURE
)
2070 if (type_check (path2
, 1, BT_CHARACTER
) == FAILURE
)
2078 gfc_check_rename_sub (gfc_expr
*path1
, gfc_expr
*path2
, gfc_expr
*status
)
2080 if (type_check (path1
, 0, BT_CHARACTER
) == FAILURE
)
2083 if (type_check (path2
, 1, BT_CHARACTER
) == FAILURE
)
2089 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
2092 if (scalar_check (status
, 2) == FAILURE
)
2100 gfc_check_repeat (gfc_expr
*x
, gfc_expr
*y
)
2102 if (type_check (x
, 0, BT_CHARACTER
) == FAILURE
)
2105 if (scalar_check (x
, 0) == FAILURE
)
2108 if (type_check (y
, 0, BT_INTEGER
) == FAILURE
)
2111 if (scalar_check (y
, 1) == FAILURE
)
2119 gfc_check_reshape (gfc_expr
*source
, gfc_expr
*shape
,
2120 gfc_expr
*pad
, gfc_expr
*order
)
2126 if (array_check (source
, 0) == FAILURE
)
2129 if (rank_check (shape
, 1, 1) == FAILURE
)
2132 if (type_check (shape
, 1, BT_INTEGER
) == FAILURE
)
2135 if (gfc_array_size (shape
, &size
) != SUCCESS
)
2137 gfc_error ("'shape' argument of 'reshape' intrinsic at %L must be an "
2138 "array of constant size", &shape
->where
);
2142 m
= mpz_cmp_ui (size
, GFC_MAX_DIMENSIONS
);
2147 gfc_error ("'shape' argument of 'reshape' intrinsic at %L has more "
2148 "than %d elements", &shape
->where
, GFC_MAX_DIMENSIONS
);
2154 if (same_type_check (source
, 0, pad
, 2) == FAILURE
)
2156 if (array_check (pad
, 2) == FAILURE
)
2160 if (order
!= NULL
&& array_check (order
, 3) == FAILURE
)
2163 if (pad
== NULL
&& shape
->expr_type
== EXPR_ARRAY
2164 && gfc_is_constant_expr (shape
)
2165 && !(source
->expr_type
== EXPR_VARIABLE
&& source
->symtree
->n
.sym
->as
2166 && source
->symtree
->n
.sym
->as
->type
== AS_ASSUMED_SIZE
))
2168 /* Check the match in size between source and destination. */
2169 if (gfc_array_size (source
, &nelems
) == SUCCESS
)
2174 c
= shape
->value
.constructor
;
2175 mpz_init_set_ui (size
, 1);
2176 for (; c
; c
= c
->next
)
2177 mpz_mul (size
, size
, c
->expr
->value
.integer
);
2179 test
= mpz_cmp (nelems
, size
) < 0 && mpz_cmp_ui (size
, 0) > 0;
2185 gfc_error ("Without padding, there are not enough elements "
2186 "in the intrinsic RESHAPE source at %L to match "
2187 "the shape", &source
->where
);
2198 gfc_check_scale (gfc_expr
*x
, gfc_expr
*i
)
2200 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
2203 if (type_check (i
, 1, BT_INTEGER
) == FAILURE
)
2211 gfc_check_scan (gfc_expr
*x
, gfc_expr
*y
, gfc_expr
*z
)
2213 if (type_check (x
, 0, BT_CHARACTER
) == FAILURE
)
2216 if (type_check (y
, 1, BT_CHARACTER
) == FAILURE
)
2219 if (z
!= NULL
&& type_check (z
, 2, BT_LOGICAL
) == FAILURE
)
2222 if (same_type_check (x
, 0, y
, 1) == FAILURE
)
2230 gfc_check_secnds (gfc_expr
*r
)
2232 if (type_check (r
, 0, BT_REAL
) == FAILURE
)
2235 if (kind_value_check (r
, 0, 4) == FAILURE
)
2238 if (scalar_check (r
, 0) == FAILURE
)
2246 gfc_check_selected_int_kind (gfc_expr
*r
)
2248 if (type_check (r
, 0, BT_INTEGER
) == FAILURE
)
2251 if (scalar_check (r
, 0) == FAILURE
)
2259 gfc_check_selected_real_kind (gfc_expr
*p
, gfc_expr
*r
)
2261 if (p
== NULL
&& r
== NULL
)
2263 gfc_error ("Missing arguments to %s intrinsic at %L",
2264 gfc_current_intrinsic
, gfc_current_intrinsic_where
);
2269 if (p
!= NULL
&& type_check (p
, 0, BT_INTEGER
) == FAILURE
)
2272 if (r
!= NULL
&& type_check (r
, 1, BT_INTEGER
) == FAILURE
)
2280 gfc_check_set_exponent (gfc_expr
*x
, gfc_expr
*i
)
2282 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
2285 if (type_check (i
, 1, BT_INTEGER
) == FAILURE
)
2293 gfc_check_shape (gfc_expr
*source
)
2297 if (source
->rank
== 0 || source
->expr_type
!= EXPR_VARIABLE
)
2300 ar
= gfc_find_array_ref (source
);
2302 if (ar
->as
&& ar
->as
->type
== AS_ASSUMED_SIZE
)
2304 gfc_error ("'source' argument of 'shape' intrinsic at %L must not be "
2305 "an assumed size array", &source
->where
);
2314 gfc_check_sign (gfc_expr
*a
, gfc_expr
*b
)
2316 if (int_or_real_check (a
, 0) == FAILURE
)
2319 if (same_type_check (a
, 0, b
, 1) == FAILURE
)
2327 gfc_check_size (gfc_expr
*array
, gfc_expr
*dim
)
2329 if (array_check (array
, 0) == FAILURE
)
2334 if (type_check (dim
, 1, BT_INTEGER
) == FAILURE
)
2337 if (kind_value_check (dim
, 1, gfc_default_integer_kind
) == FAILURE
)
2340 if (dim_rank_check (dim
, array
, 0) == FAILURE
)
2349 gfc_check_sleep_sub (gfc_expr
*seconds
)
2351 if (type_check (seconds
, 0, BT_INTEGER
) == FAILURE
)
2354 if (scalar_check (seconds
, 0) == FAILURE
)
2362 gfc_check_spread (gfc_expr
*source
, gfc_expr
*dim
, gfc_expr
*ncopies
)
2364 if (source
->rank
>= GFC_MAX_DIMENSIONS
)
2366 gfc_error ("'%s' argument of '%s' intrinsic at %L must be less "
2367 "than rank %d", gfc_current_intrinsic_arg
[0],
2368 gfc_current_intrinsic
, &source
->where
, GFC_MAX_DIMENSIONS
);
2373 if (dim_check (dim
, 1, 0) == FAILURE
)
2376 if (type_check (ncopies
, 2, BT_INTEGER
) == FAILURE
)
2379 if (scalar_check (ncopies
, 2) == FAILURE
)
2383 return non_init_transformational ();
2389 /* Functions for checking FGETC, FPUTC, FGET and FPUT (subroutines and
2393 gfc_check_fgetputc_sub (gfc_expr
*unit
, gfc_expr
*c
, gfc_expr
*status
)
2395 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
2398 if (scalar_check (unit
, 0) == FAILURE
)
2401 if (type_check (c
, 1, BT_CHARACTER
) == FAILURE
)
2407 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
2408 || kind_value_check (status
, 2, gfc_default_integer_kind
) == FAILURE
2409 || scalar_check (status
, 2) == FAILURE
)
2417 gfc_check_fgetputc (gfc_expr
*unit
, gfc_expr
*c
)
2419 return gfc_check_fgetputc_sub (unit
, c
, NULL
);
2424 gfc_check_fgetput_sub (gfc_expr
*c
, gfc_expr
*status
)
2426 if (type_check (c
, 0, BT_CHARACTER
) == FAILURE
)
2432 if (type_check (status
, 1, BT_INTEGER
) == FAILURE
2433 || kind_value_check (status
, 1, gfc_default_integer_kind
) == FAILURE
2434 || scalar_check (status
, 1) == FAILURE
)
2442 gfc_check_fgetput (gfc_expr
*c
)
2444 return gfc_check_fgetput_sub (c
, NULL
);
2449 gfc_check_fstat (gfc_expr
*unit
, gfc_expr
*array
)
2451 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
2454 if (scalar_check (unit
, 0) == FAILURE
)
2457 if (type_check (array
, 1, BT_INTEGER
) == FAILURE
2458 || kind_value_check (unit
, 0, gfc_default_integer_kind
) == FAILURE
)
2461 if (array_check (array
, 1) == FAILURE
)
2469 gfc_check_fstat_sub (gfc_expr
*unit
, gfc_expr
*array
, gfc_expr
*status
)
2471 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
2474 if (scalar_check (unit
, 0) == FAILURE
)
2477 if (type_check (array
, 1, BT_INTEGER
) == FAILURE
2478 || kind_value_check (array
, 1, gfc_default_integer_kind
) == FAILURE
)
2481 if (array_check (array
, 1) == FAILURE
)
2487 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
2488 || kind_value_check (status
, 2, gfc_default_integer_kind
) == FAILURE
)
2491 if (scalar_check (status
, 2) == FAILURE
)
2499 gfc_check_ftell (gfc_expr
*unit
)
2501 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
2504 if (scalar_check (unit
, 0) == FAILURE
)
2512 gfc_check_ftell_sub (gfc_expr
*unit
, gfc_expr
*offset
)
2514 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
2517 if (scalar_check (unit
, 0) == FAILURE
)
2520 if (type_check (offset
, 1, BT_INTEGER
) == FAILURE
)
2523 if (scalar_check (offset
, 1) == FAILURE
)
2531 gfc_check_stat (gfc_expr
*name
, gfc_expr
*array
)
2533 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
2536 if (type_check (array
, 1, BT_INTEGER
) == FAILURE
2537 || kind_value_check (array
, 1, gfc_default_integer_kind
) == FAILURE
)
2540 if (array_check (array
, 1) == FAILURE
)
2548 gfc_check_stat_sub (gfc_expr
*name
, gfc_expr
*array
, gfc_expr
*status
)
2550 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
2553 if (type_check (array
, 1, BT_INTEGER
) == FAILURE
2554 || kind_value_check (array
, 1, gfc_default_integer_kind
) == FAILURE
)
2557 if (array_check (array
, 1) == FAILURE
)
2563 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
2564 || kind_value_check (array
, 1, gfc_default_integer_kind
) == FAILURE
)
2567 if (scalar_check (status
, 2) == FAILURE
)
2575 gfc_check_transfer (gfc_expr
*source ATTRIBUTE_UNUSED
,
2576 gfc_expr
*mold ATTRIBUTE_UNUSED
, gfc_expr
*size
)
2580 if (type_check (size
, 2, BT_INTEGER
) == FAILURE
)
2583 if (scalar_check (size
, 2) == FAILURE
)
2586 if (nonoptional_check (size
, 2) == FAILURE
)
2595 gfc_check_transpose (gfc_expr
*matrix
)
2597 if (rank_check (matrix
, 0, 2) == FAILURE
)
2601 return non_init_transformational ();
2608 gfc_check_ubound (gfc_expr
*array
, gfc_expr
*dim
)
2610 if (array_check (array
, 0) == FAILURE
)
2615 if (dim_check (dim
, 1, 1) == FAILURE
)
2618 if (dim_rank_check (dim
, array
, 0) == FAILURE
)
2627 gfc_check_unpack (gfc_expr
*vector
, gfc_expr
*mask
, gfc_expr
*field
)
2629 if (rank_check (vector
, 0, 1) == FAILURE
)
2632 if (array_check (mask
, 1) == FAILURE
)
2635 if (type_check (mask
, 1, BT_LOGICAL
) == FAILURE
)
2638 if (same_type_check (vector
, 0, field
, 2) == FAILURE
)
2642 return non_init_transformational ();
2649 gfc_check_verify (gfc_expr
*x
, gfc_expr
*y
, gfc_expr
*z
)
2651 if (type_check (x
, 0, BT_CHARACTER
) == FAILURE
)
2654 if (same_type_check (x
, 0, y
, 1) == FAILURE
)
2657 if (z
!= NULL
&& type_check (z
, 2, BT_LOGICAL
) == FAILURE
)
2665 gfc_check_trim (gfc_expr
*x
)
2667 if (type_check (x
, 0, BT_CHARACTER
) == FAILURE
)
2670 if (scalar_check (x
, 0) == FAILURE
)
2678 gfc_check_ttynam (gfc_expr
*unit
)
2680 if (scalar_check (unit
, 0) == FAILURE
)
2683 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
2690 /* Common check function for the half a dozen intrinsics that have a
2691 single real argument. */
2694 gfc_check_x (gfc_expr
*x
)
2696 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
2703 /************* Check functions for intrinsic subroutines *************/
2706 gfc_check_cpu_time (gfc_expr
*time
)
2708 if (scalar_check (time
, 0) == FAILURE
)
2711 if (type_check (time
, 0, BT_REAL
) == FAILURE
)
2714 if (variable_check (time
, 0) == FAILURE
)
2722 gfc_check_date_and_time (gfc_expr
*date
, gfc_expr
*time
,
2723 gfc_expr
*zone
, gfc_expr
*values
)
2727 if (type_check (date
, 0, BT_CHARACTER
) == FAILURE
)
2729 if (scalar_check (date
, 0) == FAILURE
)
2731 if (variable_check (date
, 0) == FAILURE
)
2737 if (type_check (time
, 1, BT_CHARACTER
) == FAILURE
)
2739 if (scalar_check (time
, 1) == FAILURE
)
2741 if (variable_check (time
, 1) == FAILURE
)
2747 if (type_check (zone
, 2, BT_CHARACTER
) == FAILURE
)
2749 if (scalar_check (zone
, 2) == FAILURE
)
2751 if (variable_check (zone
, 2) == FAILURE
)
2757 if (type_check (values
, 3, BT_INTEGER
) == FAILURE
)
2759 if (array_check (values
, 3) == FAILURE
)
2761 if (rank_check (values
, 3, 1) == FAILURE
)
2763 if (variable_check (values
, 3) == FAILURE
)
2772 gfc_check_mvbits (gfc_expr
*from
, gfc_expr
*frompos
, gfc_expr
*len
,
2773 gfc_expr
*to
, gfc_expr
*topos
)
2775 if (type_check (from
, 0, BT_INTEGER
) == FAILURE
)
2778 if (type_check (frompos
, 1, BT_INTEGER
) == FAILURE
)
2781 if (type_check (len
, 2, BT_INTEGER
) == FAILURE
)
2784 if (same_type_check (from
, 0, to
, 3) == FAILURE
)
2787 if (variable_check (to
, 3) == FAILURE
)
2790 if (type_check (topos
, 4, BT_INTEGER
) == FAILURE
)
2798 gfc_check_random_number (gfc_expr
*harvest
)
2800 if (type_check (harvest
, 0, BT_REAL
) == FAILURE
)
2803 if (variable_check (harvest
, 0) == FAILURE
)
2811 gfc_check_random_seed (gfc_expr
*size
, gfc_expr
*put
, gfc_expr
*get
)
2815 if (scalar_check (size
, 0) == FAILURE
)
2818 if (type_check (size
, 0, BT_INTEGER
) == FAILURE
)
2821 if (variable_check (size
, 0) == FAILURE
)
2824 if (kind_value_check (size
, 0, gfc_default_integer_kind
) == FAILURE
)
2832 gfc_error ("Too many arguments to %s at %L", gfc_current_intrinsic
,
2835 if (array_check (put
, 1) == FAILURE
)
2838 if (rank_check (put
, 1, 1) == FAILURE
)
2841 if (type_check (put
, 1, BT_INTEGER
) == FAILURE
)
2844 if (kind_value_check (put
, 1, gfc_default_integer_kind
) == FAILURE
)
2851 if (size
!= NULL
|| put
!= NULL
)
2852 gfc_error ("Too many arguments to %s at %L", gfc_current_intrinsic
,
2855 if (array_check (get
, 2) == FAILURE
)
2858 if (rank_check (get
, 2, 1) == FAILURE
)
2861 if (type_check (get
, 2, BT_INTEGER
) == FAILURE
)
2864 if (variable_check (get
, 2) == FAILURE
)
2867 if (kind_value_check (get
, 2, gfc_default_integer_kind
) == FAILURE
)
2876 gfc_check_second_sub (gfc_expr
*time
)
2878 if (scalar_check (time
, 0) == FAILURE
)
2881 if (type_check (time
, 0, BT_REAL
) == FAILURE
)
2884 if (kind_value_check(time
, 0, 4) == FAILURE
)
2891 /* The arguments of SYSTEM_CLOCK are scalar, integer variables. Note,
2892 count, count_rate, and count_max are all optional arguments */
2895 gfc_check_system_clock (gfc_expr
*count
, gfc_expr
*count_rate
,
2896 gfc_expr
*count_max
)
2900 if (scalar_check (count
, 0) == FAILURE
)
2903 if (type_check (count
, 0, BT_INTEGER
) == FAILURE
)
2906 if (variable_check (count
, 0) == FAILURE
)
2910 if (count_rate
!= NULL
)
2912 if (scalar_check (count_rate
, 1) == FAILURE
)
2915 if (type_check (count_rate
, 1, BT_INTEGER
) == FAILURE
)
2918 if (variable_check (count_rate
, 1) == FAILURE
)
2922 && same_type_check (count
, 0, count_rate
, 1) == FAILURE
)
2927 if (count_max
!= NULL
)
2929 if (scalar_check (count_max
, 2) == FAILURE
)
2932 if (type_check (count_max
, 2, BT_INTEGER
) == FAILURE
)
2935 if (variable_check (count_max
, 2) == FAILURE
)
2939 && same_type_check (count
, 0, count_max
, 2) == FAILURE
)
2942 if (count_rate
!= NULL
2943 && same_type_check (count_rate
, 1, count_max
, 2) == FAILURE
)
2952 gfc_check_irand (gfc_expr
*x
)
2957 if (scalar_check (x
, 0) == FAILURE
)
2960 if (type_check (x
, 0, BT_INTEGER
) == FAILURE
)
2963 if (kind_value_check(x
, 0, 4) == FAILURE
)
2971 gfc_check_alarm_sub (gfc_expr
*seconds
, gfc_expr
*handler
, gfc_expr
*status
)
2973 if (scalar_check (seconds
, 0) == FAILURE
)
2976 if (type_check (seconds
, 0, BT_INTEGER
) == FAILURE
)
2979 if (handler
->ts
.type
!= BT_INTEGER
&& handler
->ts
.type
!= BT_PROCEDURE
)
2981 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
2982 "or PROCEDURE", gfc_current_intrinsic_arg
[1],
2983 gfc_current_intrinsic
, &handler
->where
);
2987 if (handler
->ts
.type
== BT_INTEGER
&& scalar_check (handler
, 1) == FAILURE
)
2993 if (scalar_check (status
, 2) == FAILURE
)
2996 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
3004 gfc_check_rand (gfc_expr
*x
)
3009 if (scalar_check (x
, 0) == FAILURE
)
3012 if (type_check (x
, 0, BT_INTEGER
) == FAILURE
)
3015 if (kind_value_check(x
, 0, 4) == FAILURE
)
3023 gfc_check_srand (gfc_expr
*x
)
3025 if (scalar_check (x
, 0) == FAILURE
)
3028 if (type_check (x
, 0, BT_INTEGER
) == FAILURE
)
3031 if (kind_value_check(x
, 0, 4) == FAILURE
)
3039 gfc_check_ctime_sub (gfc_expr
*time
, gfc_expr
*result
)
3041 if (scalar_check (time
, 0) == FAILURE
)
3044 if (type_check (time
, 0, BT_INTEGER
) == FAILURE
)
3047 if (type_check (result
, 1, BT_CHARACTER
) == FAILURE
)
3055 gfc_check_etime (gfc_expr
*x
)
3057 if (array_check (x
, 0) == FAILURE
)
3060 if (rank_check (x
, 0, 1) == FAILURE
)
3063 if (variable_check (x
, 0) == FAILURE
)
3066 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
3069 if (kind_value_check(x
, 0, 4) == FAILURE
)
3077 gfc_check_etime_sub (gfc_expr
*values
, gfc_expr
*time
)
3079 if (array_check (values
, 0) == FAILURE
)
3082 if (rank_check (values
, 0, 1) == FAILURE
)
3085 if (variable_check (values
, 0) == FAILURE
)
3088 if (type_check (values
, 0, BT_REAL
) == FAILURE
)
3091 if (kind_value_check(values
, 0, 4) == FAILURE
)
3094 if (scalar_check (time
, 1) == FAILURE
)
3097 if (type_check (time
, 1, BT_REAL
) == FAILURE
)
3100 if (kind_value_check(time
, 1, 4) == FAILURE
)
3108 gfc_check_fdate_sub (gfc_expr
*date
)
3110 if (type_check (date
, 0, BT_CHARACTER
) == FAILURE
)
3118 gfc_check_gerror (gfc_expr
*msg
)
3120 if (type_check (msg
, 0, BT_CHARACTER
) == FAILURE
)
3128 gfc_check_getcwd_sub (gfc_expr
*cwd
, gfc_expr
*status
)
3130 if (type_check (cwd
, 0, BT_CHARACTER
) == FAILURE
)
3136 if (scalar_check (status
, 1) == FAILURE
)
3139 if (type_check (status
, 1, BT_INTEGER
) == FAILURE
)
3147 gfc_check_getlog (gfc_expr
*msg
)
3149 if (type_check (msg
, 0, BT_CHARACTER
) == FAILURE
)
3157 gfc_check_exit (gfc_expr
*status
)
3162 if (type_check (status
, 0, BT_INTEGER
) == FAILURE
)
3165 if (scalar_check (status
, 0) == FAILURE
)
3173 gfc_check_flush (gfc_expr
*unit
)
3178 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
3181 if (scalar_check (unit
, 0) == FAILURE
)
3189 gfc_check_free (gfc_expr
*i
)
3191 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
3194 if (scalar_check (i
, 0) == FAILURE
)
3202 gfc_check_hostnm (gfc_expr
*name
)
3204 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
3212 gfc_check_hostnm_sub (gfc_expr
*name
, gfc_expr
*status
)
3214 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
3220 if (scalar_check (status
, 1) == FAILURE
)
3223 if (type_check (status
, 1, BT_INTEGER
) == FAILURE
)
3231 gfc_check_itime_idate (gfc_expr
*values
)
3233 if (array_check (values
, 0) == FAILURE
)
3236 if (rank_check (values
, 0, 1) == FAILURE
)
3239 if (variable_check (values
, 0) == FAILURE
)
3242 if (type_check (values
, 0, BT_INTEGER
) == FAILURE
)
3245 if (kind_value_check(values
, 0, gfc_default_integer_kind
) == FAILURE
)
3253 gfc_check_ltime_gmtime (gfc_expr
*time
, gfc_expr
*values
)
3255 if (type_check (time
, 0, BT_INTEGER
) == FAILURE
)
3258 if (kind_value_check(time
, 0, gfc_default_integer_kind
) == FAILURE
)
3261 if (scalar_check (time
, 0) == FAILURE
)
3264 if (array_check (values
, 1) == FAILURE
)
3267 if (rank_check (values
, 1, 1) == FAILURE
)
3270 if (variable_check (values
, 1) == FAILURE
)
3273 if (type_check (values
, 1, BT_INTEGER
) == FAILURE
)
3276 if (kind_value_check(values
, 1, gfc_default_integer_kind
) == FAILURE
)
3284 gfc_check_ttynam_sub (gfc_expr
*unit
, gfc_expr
*name
)
3286 if (scalar_check (unit
, 0) == FAILURE
)
3289 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
3292 if (type_check (name
, 1, BT_CHARACTER
) == FAILURE
)
3300 gfc_check_isatty (gfc_expr
*unit
)
3305 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
3308 if (scalar_check (unit
, 0) == FAILURE
)
3316 gfc_check_perror (gfc_expr
*string
)
3318 if (type_check (string
, 0, BT_CHARACTER
) == FAILURE
)
3326 gfc_check_umask (gfc_expr
*mask
)
3328 if (type_check (mask
, 0, BT_INTEGER
) == FAILURE
)
3331 if (scalar_check (mask
, 0) == FAILURE
)
3339 gfc_check_umask_sub (gfc_expr
*mask
, gfc_expr
*old
)
3341 if (type_check (mask
, 0, BT_INTEGER
) == FAILURE
)
3344 if (scalar_check (mask
, 0) == FAILURE
)
3350 if (scalar_check (old
, 1) == FAILURE
)
3353 if (type_check (old
, 1, BT_INTEGER
) == FAILURE
)
3361 gfc_check_unlink (gfc_expr
*name
)
3363 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
3371 gfc_check_unlink_sub (gfc_expr
*name
, gfc_expr
*status
)
3373 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
3379 if (scalar_check (status
, 1) == FAILURE
)
3382 if (type_check (status
, 1, BT_INTEGER
) == FAILURE
)
3390 gfc_check_signal (gfc_expr
*number
, gfc_expr
*handler
)
3392 if (scalar_check (number
, 0) == FAILURE
)
3395 if (type_check (number
, 0, BT_INTEGER
) == FAILURE
)
3398 if (handler
->ts
.type
!= BT_INTEGER
&& handler
->ts
.type
!= BT_PROCEDURE
)
3400 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
3401 "or PROCEDURE", gfc_current_intrinsic_arg
[1],
3402 gfc_current_intrinsic
, &handler
->where
);
3406 if (handler
->ts
.type
== BT_INTEGER
&& scalar_check (handler
, 1) == FAILURE
)
3414 gfc_check_signal_sub (gfc_expr
*number
, gfc_expr
*handler
, gfc_expr
*status
)
3416 if (scalar_check (number
, 0) == FAILURE
)
3419 if (type_check (number
, 0, BT_INTEGER
) == FAILURE
)
3422 if (handler
->ts
.type
!= BT_INTEGER
&& handler
->ts
.type
!= BT_PROCEDURE
)
3424 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
3425 "or PROCEDURE", gfc_current_intrinsic_arg
[1],
3426 gfc_current_intrinsic
, &handler
->where
);
3430 if (handler
->ts
.type
== BT_INTEGER
&& scalar_check (handler
, 1) == FAILURE
)
3436 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
3439 if (scalar_check (status
, 2) == FAILURE
)
3447 gfc_check_system_sub (gfc_expr
*cmd
, gfc_expr
*status
)
3449 if (type_check (cmd
, 0, BT_CHARACTER
) == FAILURE
)
3452 if (scalar_check (status
, 1) == FAILURE
)
3455 if (type_check (status
, 1, BT_INTEGER
) == FAILURE
)
3458 if (kind_value_check (status
, 1, gfc_default_integer_kind
) == FAILURE
)
3465 /* This is used for the GNU intrinsics AND, OR and XOR. */
3467 gfc_check_and (gfc_expr
*i
, gfc_expr
*j
)
3469 if (i
->ts
.type
!= BT_INTEGER
&& i
->ts
.type
!= BT_LOGICAL
)
3471 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
3472 "or LOGICAL", gfc_current_intrinsic_arg
[0],
3473 gfc_current_intrinsic
, &i
->where
);
3477 if (j
->ts
.type
!= BT_INTEGER
&& j
->ts
.type
!= BT_LOGICAL
)
3479 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
3480 "or LOGICAL", gfc_current_intrinsic_arg
[1],
3481 gfc_current_intrinsic
, &j
->where
);
3485 if (i
->ts
.type
!= j
->ts
.type
)
3487 gfc_error ("'%s' and '%s' arguments of '%s' intrinsic at %L must "
3488 "have the same type", gfc_current_intrinsic_arg
[0],
3489 gfc_current_intrinsic_arg
[1], gfc_current_intrinsic
,
3494 if (scalar_check (i
, 0) == FAILURE
)
3497 if (scalar_check (j
, 1) == FAILURE
)