2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
4 Free Software Foundation, Inc.
5 Contributed by Andy Vaught & Katherine Holcomb
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 3, or (at your option) any later
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
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. */
32 #include "coretypes.h"
35 #include "intrinsic.h"
36 #include "constructor.h"
37 #include "target-memory.h"
40 /* Make sure an expression is a scalar. */
43 scalar_check (gfc_expr
*e
, int n
)
48 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a scalar",
49 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
,
56 /* Check the type of an expression. */
59 type_check (gfc_expr
*e
, int n
, bt type
)
61 if (e
->ts
.type
== type
)
64 gfc_error ("'%s' argument of '%s' intrinsic at %L must be %s",
65 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
,
66 &e
->where
, gfc_basic_typename (type
));
72 /* Check that the expression is a numeric type. */
75 numeric_check (gfc_expr
*e
, int n
)
77 if (gfc_numeric_ts (&e
->ts
))
80 /* If the expression has not got a type, check if its namespace can
81 offer a default type. */
82 if ((e
->expr_type
== EXPR_VARIABLE
|| e
->expr_type
== EXPR_FUNCTION
)
83 && e
->symtree
->n
.sym
->ts
.type
== BT_UNKNOWN
84 && gfc_set_default_type (e
->symtree
->n
.sym
, 0,
85 e
->symtree
->n
.sym
->ns
) == SUCCESS
86 && gfc_numeric_ts (&e
->symtree
->n
.sym
->ts
))
88 e
->ts
= e
->symtree
->n
.sym
->ts
;
92 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a numeric type",
93 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
,
100 /* Check that an expression is integer or real. */
103 int_or_real_check (gfc_expr
*e
, int n
)
105 if (e
->ts
.type
!= BT_INTEGER
&& e
->ts
.type
!= BT_REAL
)
107 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
108 "or REAL", gfc_current_intrinsic_arg
[n
]->name
,
109 gfc_current_intrinsic
, &e
->where
);
117 /* Check that an expression is real or complex. */
120 real_or_complex_check (gfc_expr
*e
, int n
)
122 if (e
->ts
.type
!= BT_REAL
&& e
->ts
.type
!= BT_COMPLEX
)
124 gfc_error ("'%s' argument of '%s' intrinsic at %L must be REAL "
125 "or COMPLEX", gfc_current_intrinsic_arg
[n
]->name
,
126 gfc_current_intrinsic
, &e
->where
);
134 /* Check that an expression is INTEGER or PROCEDURE. */
137 int_or_proc_check (gfc_expr
*e
, int n
)
139 if (e
->ts
.type
!= BT_INTEGER
&& e
->ts
.type
!= BT_PROCEDURE
)
141 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
142 "or PROCEDURE", gfc_current_intrinsic_arg
[n
]->name
,
143 gfc_current_intrinsic
, &e
->where
);
151 /* Check that the expression is an optional constant integer
152 and that it specifies a valid kind for that type. */
155 kind_check (gfc_expr
*k
, int n
, bt type
)
162 if (type_check (k
, n
, BT_INTEGER
) == FAILURE
)
165 if (scalar_check (k
, n
) == FAILURE
)
168 if (gfc_check_init_expr (k
) != SUCCESS
)
170 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a constant",
171 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
,
176 if (gfc_extract_int (k
, &kind
) != NULL
177 || gfc_validate_kind (type
, kind
, true) < 0)
179 gfc_error ("Invalid kind for %s at %L", gfc_basic_typename (type
),
188 /* Make sure the expression is a double precision real. */
191 double_check (gfc_expr
*d
, int n
)
193 if (type_check (d
, n
, BT_REAL
) == FAILURE
)
196 if (d
->ts
.kind
!= gfc_default_double_kind
)
198 gfc_error ("'%s' argument of '%s' intrinsic at %L must be double "
199 "precision", gfc_current_intrinsic_arg
[n
]->name
,
200 gfc_current_intrinsic
, &d
->where
);
209 coarray_check (gfc_expr
*e
, int n
)
211 if (e
->ts
.type
== BT_CLASS
&& gfc_expr_attr (e
).class_ok
212 && CLASS_DATA (e
)->attr
.codimension
213 && CLASS_DATA (e
)->as
->corank
)
215 gfc_add_class_array_ref (e
);
219 if (!gfc_is_coarray (e
))
221 gfc_error ("Expected coarray variable as '%s' argument to the %s "
222 "intrinsic at %L", gfc_current_intrinsic_arg
[n
]->name
,
223 gfc_current_intrinsic
, &e
->where
);
231 /* Make sure the expression is a logical array. */
234 logical_array_check (gfc_expr
*array
, int n
)
236 if (array
->ts
.type
!= BT_LOGICAL
|| array
->rank
== 0)
238 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a logical "
239 "array", gfc_current_intrinsic_arg
[n
]->name
,
240 gfc_current_intrinsic
, &array
->where
);
248 /* Make sure an expression is an array. */
251 array_check (gfc_expr
*e
, int n
)
253 if (e
->ts
.type
== BT_CLASS
&& gfc_expr_attr (e
).class_ok
254 && CLASS_DATA (e
)->attr
.dimension
255 && CLASS_DATA (e
)->as
->rank
)
257 gfc_add_class_array_ref (e
);
264 gfc_error ("'%s' argument of '%s' intrinsic at %L must be an array",
265 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
,
272 /* If expr is a constant, then check to ensure that it is greater than
276 nonnegative_check (const char *arg
, gfc_expr
*expr
)
280 if (expr
->expr_type
== EXPR_CONSTANT
)
282 gfc_extract_int (expr
, &i
);
285 gfc_error ("'%s' at %L must be nonnegative", arg
, &expr
->where
);
294 /* If expr2 is constant, then check that the value is less than
295 (less than or equal to, if 'or_equal' is true) bit_size(expr1). */
298 less_than_bitsize1 (const char *arg1
, gfc_expr
*expr1
, const char *arg2
,
299 gfc_expr
*expr2
, bool or_equal
)
303 if (expr2
->expr_type
== EXPR_CONSTANT
)
305 gfc_extract_int (expr2
, &i2
);
306 i3
= gfc_validate_kind (BT_INTEGER
, expr1
->ts
.kind
, false);
308 /* For ISHFT[C], check that |shift| <= bit_size(i). */
314 if (i2
> gfc_integer_kinds
[i3
].bit_size
)
316 gfc_error ("The absolute value of SHIFT at %L must be less "
317 "than or equal to BIT_SIZE('%s')",
318 &expr2
->where
, arg1
);
325 if (i2
> gfc_integer_kinds
[i3
].bit_size
)
327 gfc_error ("'%s' at %L must be less than "
328 "or equal to BIT_SIZE('%s')",
329 arg2
, &expr2
->where
, arg1
);
335 if (i2
>= gfc_integer_kinds
[i3
].bit_size
)
337 gfc_error ("'%s' at %L must be less than BIT_SIZE('%s')",
338 arg2
, &expr2
->where
, arg1
);
348 /* If expr is constant, then check that the value is less than or equal
349 to the bit_size of the kind k. */
352 less_than_bitsizekind (const char *arg
, gfc_expr
*expr
, int k
)
356 if (expr
->expr_type
!= EXPR_CONSTANT
)
359 i
= gfc_validate_kind (BT_INTEGER
, k
, false);
360 gfc_extract_int (expr
, &val
);
362 if (val
> gfc_integer_kinds
[i
].bit_size
)
364 gfc_error ("'%s' at %L must be less than or equal to the BIT_SIZE of "
365 "INTEGER(KIND=%d)", arg
, &expr
->where
, k
);
373 /* If expr2 and expr3 are constants, then check that the value is less than
374 or equal to bit_size(expr1). */
377 less_than_bitsize2 (const char *arg1
, gfc_expr
*expr1
, const char *arg2
,
378 gfc_expr
*expr2
, const char *arg3
, gfc_expr
*expr3
)
382 if (expr2
->expr_type
== EXPR_CONSTANT
&& expr3
->expr_type
== EXPR_CONSTANT
)
384 gfc_extract_int (expr2
, &i2
);
385 gfc_extract_int (expr3
, &i3
);
387 i3
= gfc_validate_kind (BT_INTEGER
, expr1
->ts
.kind
, false);
388 if (i2
> gfc_integer_kinds
[i3
].bit_size
)
390 gfc_error ("'%s + %s' at %L must be less than or equal "
392 arg2
, arg3
, &expr2
->where
, arg1
);
400 /* Make sure two expressions have the same type. */
403 same_type_check (gfc_expr
*e
, int n
, gfc_expr
*f
, int m
)
405 if (gfc_compare_types (&e
->ts
, &f
->ts
))
408 gfc_error ("'%s' argument of '%s' intrinsic at %L must be the same type "
409 "and kind as '%s'", gfc_current_intrinsic_arg
[m
]->name
,
410 gfc_current_intrinsic
, &f
->where
,
411 gfc_current_intrinsic_arg
[n
]->name
);
417 /* Make sure that an expression has a certain (nonzero) rank. */
420 rank_check (gfc_expr
*e
, int n
, int rank
)
425 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of rank %d",
426 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
,
433 /* Make sure a variable expression is not an optional dummy argument. */
436 nonoptional_check (gfc_expr
*e
, int n
)
438 if (e
->expr_type
== EXPR_VARIABLE
&& e
->symtree
->n
.sym
->attr
.optional
)
440 gfc_error ("'%s' argument of '%s' intrinsic at %L must not be OPTIONAL",
441 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
,
445 /* TODO: Recursive check on nonoptional variables? */
451 /* Check for ALLOCATABLE attribute. */
454 allocatable_check (gfc_expr
*e
, int n
)
456 symbol_attribute attr
;
458 attr
= gfc_variable_attr (e
, NULL
);
459 if (!attr
.allocatable
)
461 gfc_error ("'%s' argument of '%s' intrinsic at %L must be ALLOCATABLE",
462 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
,
471 /* Check that an expression has a particular kind. */
474 kind_value_check (gfc_expr
*e
, int n
, int k
)
479 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of kind %d",
480 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
,
487 /* Make sure an expression is a variable. */
490 variable_check (gfc_expr
*e
, int n
, bool allow_proc
)
492 if (e
->expr_type
== EXPR_VARIABLE
493 && e
->symtree
->n
.sym
->attr
.intent
== INTENT_IN
494 && (gfc_current_intrinsic_arg
[n
]->intent
== INTENT_OUT
495 || gfc_current_intrinsic_arg
[n
]->intent
== INTENT_INOUT
))
498 bool pointer
= e
->symtree
->n
.sym
->ts
.type
== BT_CLASS
499 && CLASS_DATA (e
->symtree
->n
.sym
)
500 ? CLASS_DATA (e
->symtree
->n
.sym
)->attr
.class_pointer
501 : e
->symtree
->n
.sym
->attr
.pointer
;
503 for (ref
= e
->ref
; ref
; ref
= ref
->next
)
505 if (pointer
&& ref
->type
== REF_COMPONENT
)
507 if (ref
->type
== REF_COMPONENT
508 && ((ref
->u
.c
.component
->ts
.type
== BT_CLASS
509 && CLASS_DATA (ref
->u
.c
.component
)->attr
.class_pointer
)
510 || (ref
->u
.c
.component
->ts
.type
!= BT_CLASS
511 && ref
->u
.c
.component
->attr
.pointer
)))
517 gfc_error ("'%s' argument of '%s' intrinsic at %L cannot be "
518 "INTENT(IN)", gfc_current_intrinsic_arg
[n
]->name
,
519 gfc_current_intrinsic
, &e
->where
);
524 if (e
->expr_type
== EXPR_VARIABLE
525 && e
->symtree
->n
.sym
->attr
.flavor
!= FL_PARAMETER
526 && (allow_proc
|| !e
->symtree
->n
.sym
->attr
.function
))
529 if (e
->expr_type
== EXPR_VARIABLE
&& e
->symtree
->n
.sym
->attr
.function
530 && e
->symtree
->n
.sym
== e
->symtree
->n
.sym
->result
)
533 for (ns
= gfc_current_ns
; ns
; ns
= ns
->parent
)
534 if (ns
->proc_name
== e
->symtree
->n
.sym
)
538 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a variable",
539 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
, &e
->where
);
545 /* Check the common DIM parameter for correctness. */
548 dim_check (gfc_expr
*dim
, int n
, bool optional
)
553 if (type_check (dim
, n
, BT_INTEGER
) == FAILURE
)
556 if (scalar_check (dim
, n
) == FAILURE
)
559 if (!optional
&& nonoptional_check (dim
, n
) == FAILURE
)
566 /* If a coarray DIM parameter is a constant, make sure that it is greater than
567 zero and less than or equal to the corank of the given array. */
570 dim_corank_check (gfc_expr
*dim
, gfc_expr
*array
)
574 gcc_assert (array
->expr_type
== EXPR_VARIABLE
);
576 if (dim
->expr_type
!= EXPR_CONSTANT
)
579 if (array
->ts
.type
== BT_CLASS
)
582 corank
= gfc_get_corank (array
);
584 if (mpz_cmp_ui (dim
->value
.integer
, 1) < 0
585 || mpz_cmp_ui (dim
->value
.integer
, corank
) > 0)
587 gfc_error ("'dim' argument of '%s' intrinsic at %L is not a valid "
588 "codimension index", gfc_current_intrinsic
, &dim
->where
);
597 /* If a DIM parameter is a constant, make sure that it is greater than
598 zero and less than or equal to the rank of the given array. If
599 allow_assumed is zero then dim must be less than the rank of the array
600 for assumed size arrays. */
603 dim_rank_check (gfc_expr
*dim
, gfc_expr
*array
, int allow_assumed
)
611 if (dim
->expr_type
!= EXPR_CONSTANT
)
614 if (array
->ts
.type
== BT_CLASS
)
617 if (array
->expr_type
== EXPR_FUNCTION
&& array
->value
.function
.isym
618 && array
->value
.function
.isym
->id
== GFC_ISYM_SPREAD
)
619 rank
= array
->rank
+ 1;
623 /* Assumed-rank array. */
625 rank
= GFC_MAX_DIMENSIONS
;
627 if (array
->expr_type
== EXPR_VARIABLE
)
629 ar
= gfc_find_array_ref (array
);
630 if (ar
->as
->type
== AS_ASSUMED_SIZE
632 && ar
->type
!= AR_ELEMENT
633 && ar
->type
!= AR_SECTION
)
637 if (mpz_cmp_ui (dim
->value
.integer
, 1) < 0
638 || mpz_cmp_ui (dim
->value
.integer
, rank
) > 0)
640 gfc_error ("'dim' argument of '%s' intrinsic at %L is not a valid "
641 "dimension index", gfc_current_intrinsic
, &dim
->where
);
650 /* Compare the size of a along dimension ai with the size of b along
651 dimension bi, returning 0 if they are known not to be identical,
652 and 1 if they are identical, or if this cannot be determined. */
655 identical_dimen_shape (gfc_expr
*a
, int ai
, gfc_expr
*b
, int bi
)
657 mpz_t a_size
, b_size
;
660 gcc_assert (a
->rank
> ai
);
661 gcc_assert (b
->rank
> bi
);
665 if (gfc_array_dimen_size (a
, ai
, &a_size
) == SUCCESS
)
667 if (gfc_array_dimen_size (b
, bi
, &b_size
) == SUCCESS
)
669 if (mpz_cmp (a_size
, b_size
) != 0)
679 /* Calculate the length of a character variable, including substrings.
680 Strip away parentheses if necessary. Return -1 if no length could
684 gfc_var_strlen (const gfc_expr
*a
)
688 while (a
->expr_type
== EXPR_OP
&& a
->value
.op
.op
== INTRINSIC_PARENTHESES
)
691 for (ra
= a
->ref
; ra
!= NULL
&& ra
->type
!= REF_SUBSTRING
; ra
= ra
->next
)
698 if (ra
->u
.ss
.start
->expr_type
== EXPR_CONSTANT
699 && ra
->u
.ss
.end
->expr_type
== EXPR_CONSTANT
)
701 start_a
= mpz_get_si (ra
->u
.ss
.start
->value
.integer
);
702 end_a
= mpz_get_si (ra
->u
.ss
.end
->value
.integer
);
703 return end_a
- start_a
+ 1;
705 else if (gfc_dep_compare_expr (ra
->u
.ss
.start
, ra
->u
.ss
.end
) == 0)
711 if (a
->ts
.u
.cl
&& a
->ts
.u
.cl
->length
712 && a
->ts
.u
.cl
->length
->expr_type
== EXPR_CONSTANT
)
713 return mpz_get_si (a
->ts
.u
.cl
->length
->value
.integer
);
714 else if (a
->expr_type
== EXPR_CONSTANT
715 && (a
->ts
.u
.cl
== NULL
|| a
->ts
.u
.cl
->length
== NULL
))
716 return a
->value
.character
.length
;
722 /* Check whether two character expressions have the same length;
723 returns SUCCESS if they have or if the length cannot be determined,
724 otherwise return FAILURE and raise a gfc_error. */
727 gfc_check_same_strlen (const gfc_expr
*a
, const gfc_expr
*b
, const char *name
)
731 len_a
= gfc_var_strlen(a
);
732 len_b
= gfc_var_strlen(b
);
734 if (len_a
== -1 || len_b
== -1 || len_a
== len_b
)
738 gfc_error ("Unequal character lengths (%ld/%ld) in %s at %L",
739 len_a
, len_b
, name
, &a
->where
);
745 /***** Check functions *****/
747 /* Check subroutine suitable for intrinsics taking a real argument and
748 a kind argument for the result. */
751 check_a_kind (gfc_expr
*a
, gfc_expr
*kind
, bt type
)
753 if (type_check (a
, 0, BT_REAL
) == FAILURE
)
755 if (kind_check (kind
, 1, type
) == FAILURE
)
762 /* Check subroutine suitable for ceiling, floor and nint. */
765 gfc_check_a_ikind (gfc_expr
*a
, gfc_expr
*kind
)
767 return check_a_kind (a
, kind
, BT_INTEGER
);
771 /* Check subroutine suitable for aint, anint. */
774 gfc_check_a_xkind (gfc_expr
*a
, gfc_expr
*kind
)
776 return check_a_kind (a
, kind
, BT_REAL
);
781 gfc_check_abs (gfc_expr
*a
)
783 if (numeric_check (a
, 0) == FAILURE
)
791 gfc_check_achar (gfc_expr
*a
, gfc_expr
*kind
)
793 if (type_check (a
, 0, BT_INTEGER
) == FAILURE
)
795 if (kind_check (kind
, 1, BT_CHARACTER
) == FAILURE
)
803 gfc_check_access_func (gfc_expr
*name
, gfc_expr
*mode
)
805 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
806 || scalar_check (name
, 0) == FAILURE
)
808 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
811 if (type_check (mode
, 1, BT_CHARACTER
) == FAILURE
812 || scalar_check (mode
, 1) == FAILURE
)
814 if (kind_value_check (mode
, 1, gfc_default_character_kind
) == FAILURE
)
822 gfc_check_all_any (gfc_expr
*mask
, gfc_expr
*dim
)
824 if (logical_array_check (mask
, 0) == FAILURE
)
827 if (dim_check (dim
, 1, false) == FAILURE
)
830 if (dim_rank_check (dim
, mask
, 0) == FAILURE
)
838 gfc_check_allocated (gfc_expr
*array
)
840 if (variable_check (array
, 0, false) == FAILURE
)
842 if (allocatable_check (array
, 0) == FAILURE
)
849 /* Common check function where the first argument must be real or
850 integer and the second argument must be the same as the first. */
853 gfc_check_a_p (gfc_expr
*a
, gfc_expr
*p
)
855 if (int_or_real_check (a
, 0) == FAILURE
)
858 if (a
->ts
.type
!= p
->ts
.type
)
860 gfc_error ("'%s' and '%s' arguments of '%s' intrinsic at %L must "
861 "have the same type", gfc_current_intrinsic_arg
[0]->name
,
862 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
867 if (a
->ts
.kind
!= p
->ts
.kind
)
869 if (gfc_notify_std (GFC_STD_GNU
, "Different type kinds at %L",
870 &p
->where
) == FAILURE
)
879 gfc_check_x_yd (gfc_expr
*x
, gfc_expr
*y
)
881 if (double_check (x
, 0) == FAILURE
|| double_check (y
, 1) == FAILURE
)
889 gfc_check_associated (gfc_expr
*pointer
, gfc_expr
*target
)
891 symbol_attribute attr1
, attr2
;
896 where
= &pointer
->where
;
898 if (pointer
->expr_type
== EXPR_NULL
)
901 attr1
= gfc_expr_attr (pointer
);
903 if (!attr1
.pointer
&& !attr1
.proc_pointer
)
905 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a POINTER",
906 gfc_current_intrinsic_arg
[0]->name
, gfc_current_intrinsic
,
912 if (attr1
.pointer
&& gfc_is_coindexed (pointer
))
914 gfc_error ("'%s' argument of '%s' intrinsic at %L shall not be "
915 "coindexed", gfc_current_intrinsic_arg
[0]->name
,
916 gfc_current_intrinsic
, &pointer
->where
);
920 /* Target argument is optional. */
924 where
= &target
->where
;
925 if (target
->expr_type
== EXPR_NULL
)
928 if (target
->expr_type
== EXPR_VARIABLE
|| target
->expr_type
== EXPR_FUNCTION
)
929 attr2
= gfc_expr_attr (target
);
932 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a pointer "
933 "or target VARIABLE or FUNCTION",
934 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
939 if (attr1
.pointer
&& !attr2
.pointer
&& !attr2
.target
)
941 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a POINTER "
942 "or a TARGET", gfc_current_intrinsic_arg
[1]->name
,
943 gfc_current_intrinsic
, &target
->where
);
948 if (attr1
.pointer
&& gfc_is_coindexed (target
))
950 gfc_error ("'%s' argument of '%s' intrinsic at %L shall not be "
951 "coindexed", gfc_current_intrinsic_arg
[1]->name
,
952 gfc_current_intrinsic
, &target
->where
);
957 if (same_type_check (pointer
, 0, target
, 1) == FAILURE
)
959 if (rank_check (target
, 0, pointer
->rank
) == FAILURE
)
961 if (target
->rank
> 0)
963 for (i
= 0; i
< target
->rank
; i
++)
964 if (target
->ref
->u
.ar
.dimen_type
[i
] == DIMEN_VECTOR
)
966 gfc_error ("Array section with a vector subscript at %L shall not "
967 "be the target of a pointer",
977 gfc_error ("NULL pointer at %L is not permitted as actual argument "
978 "of '%s' intrinsic function", where
, gfc_current_intrinsic
);
985 gfc_check_atan_2 (gfc_expr
*y
, gfc_expr
*x
)
987 /* gfc_notify_std would be a waste of time as the return value
988 is seemingly used only for the generic resolution. The error
989 will be: Too many arguments. */
990 if ((gfc_option
.allow_std
& GFC_STD_F2008
) == 0)
993 return gfc_check_atan2 (y
, x
);
998 gfc_check_atan2 (gfc_expr
*y
, gfc_expr
*x
)
1000 if (type_check (y
, 0, BT_REAL
) == FAILURE
)
1002 if (same_type_check (y
, 0, x
, 1) == FAILURE
)
1010 gfc_check_atomic (gfc_expr
*atom
, gfc_expr
*value
)
1012 if (!(atom
->ts
.type
== BT_INTEGER
&& atom
->ts
.kind
== gfc_atomic_int_kind
)
1013 && !(atom
->ts
.type
== BT_LOGICAL
1014 && atom
->ts
.kind
== gfc_atomic_logical_kind
))
1016 gfc_error ("ATOM argument at %L to intrinsic function %s shall be an "
1017 "integer of ATOMIC_INT_KIND or a logical of "
1018 "ATOMIC_LOGICAL_KIND", &atom
->where
, gfc_current_intrinsic
);
1022 if (!gfc_expr_attr (atom
).codimension
)
1024 gfc_error ("ATOM argument at %L of the %s intrinsic function shall be a "
1025 "coarray or coindexed", &atom
->where
, gfc_current_intrinsic
);
1029 if (atom
->ts
.type
!= value
->ts
.type
)
1031 gfc_error ("ATOM and VALUE argument of the %s intrinsic function shall "
1032 "have the same type at %L", gfc_current_intrinsic
,
1042 gfc_check_atomic_def (gfc_expr
*atom
, gfc_expr
*value
)
1044 if (scalar_check (atom
, 0) == FAILURE
|| scalar_check (value
, 1) == FAILURE
)
1047 if (gfc_check_vardef_context (atom
, false, false, false, NULL
) == FAILURE
)
1049 gfc_error ("ATOM argument of the %s intrinsic function at %L shall be "
1050 "definable", gfc_current_intrinsic
, &atom
->where
);
1054 return gfc_check_atomic (atom
, value
);
1059 gfc_check_atomic_ref (gfc_expr
*value
, gfc_expr
*atom
)
1061 if (scalar_check (value
, 0) == FAILURE
|| scalar_check (atom
, 1) == FAILURE
)
1064 if (gfc_check_vardef_context (value
, false, false, false, NULL
) == FAILURE
)
1066 gfc_error ("VALUE argument of the %s intrinsic function at %L shall be "
1067 "definable", gfc_current_intrinsic
, &value
->where
);
1071 return gfc_check_atomic (atom
, value
);
1075 /* BESJN and BESYN functions. */
1078 gfc_check_besn (gfc_expr
*n
, gfc_expr
*x
)
1080 if (type_check (n
, 0, BT_INTEGER
) == FAILURE
)
1082 if (n
->expr_type
== EXPR_CONSTANT
)
1085 gfc_extract_int (n
, &i
);
1086 if (i
< 0 && gfc_notify_std (GFC_STD_GNU
, "Negative argument "
1087 "N at %L", &n
->where
) == FAILURE
)
1091 if (type_check (x
, 1, BT_REAL
) == FAILURE
)
1098 /* Transformational version of the Bessel JN and YN functions. */
1101 gfc_check_bessel_n2 (gfc_expr
*n1
, gfc_expr
*n2
, gfc_expr
*x
)
1103 if (type_check (n1
, 0, BT_INTEGER
) == FAILURE
)
1105 if (scalar_check (n1
, 0) == FAILURE
)
1107 if (nonnegative_check("N1", n1
) == FAILURE
)
1110 if (type_check (n2
, 1, BT_INTEGER
) == FAILURE
)
1112 if (scalar_check (n2
, 1) == FAILURE
)
1114 if (nonnegative_check("N2", n2
) == FAILURE
)
1117 if (type_check (x
, 2, BT_REAL
) == FAILURE
)
1119 if (scalar_check (x
, 2) == FAILURE
)
1127 gfc_check_bge_bgt_ble_blt (gfc_expr
*i
, gfc_expr
*j
)
1129 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1132 if (type_check (j
, 1, BT_INTEGER
) == FAILURE
)
1140 gfc_check_bitfcn (gfc_expr
*i
, gfc_expr
*pos
)
1142 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1145 if (type_check (pos
, 1, BT_INTEGER
) == FAILURE
)
1148 if (nonnegative_check ("pos", pos
) == FAILURE
)
1151 if (less_than_bitsize1 ("i", i
, "pos", pos
, false) == FAILURE
)
1159 gfc_check_char (gfc_expr
*i
, gfc_expr
*kind
)
1161 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1163 if (kind_check (kind
, 1, BT_CHARACTER
) == FAILURE
)
1171 gfc_check_chdir (gfc_expr
*dir
)
1173 if (type_check (dir
, 0, BT_CHARACTER
) == FAILURE
)
1175 if (kind_value_check (dir
, 0, gfc_default_character_kind
) == FAILURE
)
1183 gfc_check_chdir_sub (gfc_expr
*dir
, gfc_expr
*status
)
1185 if (type_check (dir
, 0, BT_CHARACTER
) == FAILURE
)
1187 if (kind_value_check (dir
, 0, gfc_default_character_kind
) == FAILURE
)
1193 if (type_check (status
, 1, BT_INTEGER
) == FAILURE
)
1195 if (scalar_check (status
, 1) == FAILURE
)
1203 gfc_check_chmod (gfc_expr
*name
, gfc_expr
*mode
)
1205 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
1207 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
1210 if (type_check (mode
, 1, BT_CHARACTER
) == FAILURE
)
1212 if (kind_value_check (mode
, 1, gfc_default_character_kind
) == FAILURE
)
1220 gfc_check_chmod_sub (gfc_expr
*name
, gfc_expr
*mode
, gfc_expr
*status
)
1222 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
1224 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
1227 if (type_check (mode
, 1, BT_CHARACTER
) == FAILURE
)
1229 if (kind_value_check (mode
, 1, gfc_default_character_kind
) == FAILURE
)
1235 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
1238 if (scalar_check (status
, 2) == FAILURE
)
1246 gfc_check_cmplx (gfc_expr
*x
, gfc_expr
*y
, gfc_expr
*kind
)
1248 if (numeric_check (x
, 0) == FAILURE
)
1253 if (numeric_check (y
, 1) == FAILURE
)
1256 if (x
->ts
.type
== BT_COMPLEX
)
1258 gfc_error ("'%s' argument of '%s' intrinsic at %L must not be "
1259 "present if 'x' is COMPLEX",
1260 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
1265 if (y
->ts
.type
== BT_COMPLEX
)
1267 gfc_error ("'%s' argument of '%s' intrinsic at %L must have a type "
1268 "of either REAL or INTEGER",
1269 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
1276 if (kind_check (kind
, 2, BT_COMPLEX
) == FAILURE
)
1279 if (!kind
&& gfc_option
.gfc_warn_conversion
1280 && x
->ts
.type
== BT_REAL
&& x
->ts
.kind
> gfc_default_real_kind
)
1281 gfc_warning_now ("Conversion from %s to default-kind COMPLEX(%d) at %L "
1282 "might loose precision, consider using the KIND argument",
1283 gfc_typename (&x
->ts
), gfc_default_real_kind
, &x
->where
);
1284 else if (y
&& !kind
&& gfc_option
.gfc_warn_conversion
1285 && y
->ts
.type
== BT_REAL
&& y
->ts
.kind
> gfc_default_real_kind
)
1286 gfc_warning_now ("Conversion from %s to default-kind COMPLEX(%d) at %L "
1287 "might loose precision, consider using the KIND argument",
1288 gfc_typename (&y
->ts
), gfc_default_real_kind
, &y
->where
);
1295 gfc_check_complex (gfc_expr
*x
, gfc_expr
*y
)
1297 if (int_or_real_check (x
, 0) == FAILURE
)
1299 if (scalar_check (x
, 0) == FAILURE
)
1302 if (int_or_real_check (y
, 1) == FAILURE
)
1304 if (scalar_check (y
, 1) == FAILURE
)
1312 gfc_check_count (gfc_expr
*mask
, gfc_expr
*dim
, gfc_expr
*kind
)
1314 if (logical_array_check (mask
, 0) == FAILURE
)
1316 if (dim_check (dim
, 1, false) == FAILURE
)
1318 if (dim_rank_check (dim
, mask
, 0) == FAILURE
)
1320 if (kind_check (kind
, 2, BT_INTEGER
) == FAILURE
)
1322 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "'%s' intrinsic "
1323 "with KIND argument at %L",
1324 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
1332 gfc_check_cshift (gfc_expr
*array
, gfc_expr
*shift
, gfc_expr
*dim
)
1334 if (array_check (array
, 0) == FAILURE
)
1337 if (type_check (shift
, 1, BT_INTEGER
) == FAILURE
)
1340 if (dim_check (dim
, 2, true) == FAILURE
)
1343 if (dim_rank_check (dim
, array
, false) == FAILURE
)
1346 if (array
->rank
== 1 || shift
->rank
== 0)
1348 if (scalar_check (shift
, 1) == FAILURE
)
1351 else if (shift
->rank
== array
->rank
- 1)
1356 else if (dim
->expr_type
== EXPR_CONSTANT
)
1357 gfc_extract_int (dim
, &d
);
1364 for (i
= 0, j
= 0; i
< array
->rank
; i
++)
1367 if (!identical_dimen_shape (array
, i
, shift
, j
))
1369 gfc_error ("'%s' argument of '%s' intrinsic at %L has "
1370 "invalid shape in dimension %d (%ld/%ld)",
1371 gfc_current_intrinsic_arg
[1]->name
,
1372 gfc_current_intrinsic
, &shift
->where
, i
+ 1,
1373 mpz_get_si (array
->shape
[i
]),
1374 mpz_get_si (shift
->shape
[j
]));
1384 gfc_error ("'%s' argument of intrinsic '%s' at %L of must have rank "
1385 "%d or be a scalar", gfc_current_intrinsic_arg
[1]->name
,
1386 gfc_current_intrinsic
, &shift
->where
, array
->rank
- 1);
1395 gfc_check_ctime (gfc_expr
*time
)
1397 if (scalar_check (time
, 0) == FAILURE
)
1400 if (type_check (time
, 0, BT_INTEGER
) == FAILURE
)
1407 gfc_try
gfc_check_datan2 (gfc_expr
*y
, gfc_expr
*x
)
1409 if (double_check (y
, 0) == FAILURE
|| double_check (x
, 1) == FAILURE
)
1416 gfc_check_dcmplx (gfc_expr
*x
, gfc_expr
*y
)
1418 if (numeric_check (x
, 0) == FAILURE
)
1423 if (numeric_check (y
, 1) == FAILURE
)
1426 if (x
->ts
.type
== BT_COMPLEX
)
1428 gfc_error ("'%s' argument of '%s' intrinsic at %L must not be "
1429 "present if 'x' is COMPLEX",
1430 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
1435 if (y
->ts
.type
== BT_COMPLEX
)
1437 gfc_error ("'%s' argument of '%s' intrinsic at %L must have a type "
1438 "of either REAL or INTEGER",
1439 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
1450 gfc_check_dble (gfc_expr
*x
)
1452 if (numeric_check (x
, 0) == FAILURE
)
1460 gfc_check_digits (gfc_expr
*x
)
1462 if (int_or_real_check (x
, 0) == FAILURE
)
1470 gfc_check_dot_product (gfc_expr
*vector_a
, gfc_expr
*vector_b
)
1472 switch (vector_a
->ts
.type
)
1475 if (type_check (vector_b
, 1, BT_LOGICAL
) == FAILURE
)
1482 if (numeric_check (vector_b
, 1) == FAILURE
)
1487 gfc_error ("'%s' argument of '%s' intrinsic at %L must be numeric "
1488 "or LOGICAL", gfc_current_intrinsic_arg
[0]->name
,
1489 gfc_current_intrinsic
, &vector_a
->where
);
1493 if (rank_check (vector_a
, 0, 1) == FAILURE
)
1496 if (rank_check (vector_b
, 1, 1) == FAILURE
)
1499 if (! identical_dimen_shape (vector_a
, 0, vector_b
, 0))
1501 gfc_error ("Different shape for arguments '%s' and '%s' at %L for "
1502 "intrinsic 'dot_product'", gfc_current_intrinsic_arg
[0]->name
,
1503 gfc_current_intrinsic_arg
[1]->name
, &vector_a
->where
);
1512 gfc_check_dprod (gfc_expr
*x
, gfc_expr
*y
)
1514 if (type_check (x
, 0, BT_REAL
) == FAILURE
1515 || type_check (y
, 1, BT_REAL
) == FAILURE
)
1518 if (x
->ts
.kind
!= gfc_default_real_kind
)
1520 gfc_error ("'%s' argument of '%s' intrinsic at %L must be default "
1521 "real", gfc_current_intrinsic_arg
[0]->name
,
1522 gfc_current_intrinsic
, &x
->where
);
1526 if (y
->ts
.kind
!= gfc_default_real_kind
)
1528 gfc_error ("'%s' argument of '%s' intrinsic at %L must be default "
1529 "real", gfc_current_intrinsic_arg
[1]->name
,
1530 gfc_current_intrinsic
, &y
->where
);
1539 gfc_check_dshift (gfc_expr
*i
, gfc_expr
*j
, gfc_expr
*shift
)
1541 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1544 if (type_check (j
, 1, BT_INTEGER
) == FAILURE
)
1547 if (i
->is_boz
&& j
->is_boz
)
1549 gfc_error ("'I' at %L and 'J' at %L cannot both be BOZ literal "
1550 "constants", &i
->where
, &j
->where
);
1554 if (!i
->is_boz
&& !j
->is_boz
&& same_type_check (i
, 0, j
, 1) == FAILURE
)
1557 if (type_check (shift
, 2, BT_INTEGER
) == FAILURE
)
1560 if (nonnegative_check ("SHIFT", shift
) == FAILURE
)
1565 if (less_than_bitsize1 ("J", j
, "SHIFT", shift
, true) == FAILURE
)
1567 i
->ts
.kind
= j
->ts
.kind
;
1571 if (less_than_bitsize1 ("I", i
, "SHIFT", shift
, true) == FAILURE
)
1573 j
->ts
.kind
= i
->ts
.kind
;
1581 gfc_check_eoshift (gfc_expr
*array
, gfc_expr
*shift
, gfc_expr
*boundary
,
1584 if (array_check (array
, 0) == FAILURE
)
1587 if (type_check (shift
, 1, BT_INTEGER
) == FAILURE
)
1590 if (dim_check (dim
, 3, true) == FAILURE
)
1593 if (dim_rank_check (dim
, array
, false) == FAILURE
)
1596 if (array
->rank
== 1 || shift
->rank
== 0)
1598 if (scalar_check (shift
, 1) == FAILURE
)
1601 else if (shift
->rank
== array
->rank
- 1)
1606 else if (dim
->expr_type
== EXPR_CONSTANT
)
1607 gfc_extract_int (dim
, &d
);
1614 for (i
= 0, j
= 0; i
< array
->rank
; i
++)
1617 if (!identical_dimen_shape (array
, i
, shift
, j
))
1619 gfc_error ("'%s' argument of '%s' intrinsic at %L has "
1620 "invalid shape in dimension %d (%ld/%ld)",
1621 gfc_current_intrinsic_arg
[1]->name
,
1622 gfc_current_intrinsic
, &shift
->where
, i
+ 1,
1623 mpz_get_si (array
->shape
[i
]),
1624 mpz_get_si (shift
->shape
[j
]));
1634 gfc_error ("'%s' argument of intrinsic '%s' at %L of must have rank "
1635 "%d or be a scalar", gfc_current_intrinsic_arg
[1]->name
,
1636 gfc_current_intrinsic
, &shift
->where
, array
->rank
- 1);
1640 if (boundary
!= NULL
)
1642 if (same_type_check (array
, 0, boundary
, 2) == FAILURE
)
1645 if (array
->rank
== 1 || boundary
->rank
== 0)
1647 if (scalar_check (boundary
, 2) == FAILURE
)
1650 else if (boundary
->rank
== array
->rank
- 1)
1652 if (gfc_check_conformance (shift
, boundary
,
1653 "arguments '%s' and '%s' for "
1655 gfc_current_intrinsic_arg
[1]->name
,
1656 gfc_current_intrinsic_arg
[2]->name
,
1657 gfc_current_intrinsic
) == FAILURE
)
1662 gfc_error ("'%s' argument of intrinsic '%s' at %L of must have "
1663 "rank %d or be a scalar",
1664 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
1665 &shift
->where
, array
->rank
- 1);
1674 gfc_check_float (gfc_expr
*a
)
1676 if (type_check (a
, 0, BT_INTEGER
) == FAILURE
)
1679 if ((a
->ts
.kind
!= gfc_default_integer_kind
)
1680 && gfc_notify_std (GFC_STD_GNU
, "non-default INTEGER "
1681 "kind argument to %s intrinsic at %L",
1682 gfc_current_intrinsic
, &a
->where
) == FAILURE
)
1688 /* A single complex argument. */
1691 gfc_check_fn_c (gfc_expr
*a
)
1693 if (type_check (a
, 0, BT_COMPLEX
) == FAILURE
)
1699 /* A single real argument. */
1702 gfc_check_fn_r (gfc_expr
*a
)
1704 if (type_check (a
, 0, BT_REAL
) == FAILURE
)
1710 /* A single double argument. */
1713 gfc_check_fn_d (gfc_expr
*a
)
1715 if (double_check (a
, 0) == FAILURE
)
1721 /* A single real or complex argument. */
1724 gfc_check_fn_rc (gfc_expr
*a
)
1726 if (real_or_complex_check (a
, 0) == FAILURE
)
1734 gfc_check_fn_rc2008 (gfc_expr
*a
)
1736 if (real_or_complex_check (a
, 0) == FAILURE
)
1739 if (a
->ts
.type
== BT_COMPLEX
1740 && gfc_notify_std (GFC_STD_F2008
, "COMPLEX argument '%s' "
1741 "argument of '%s' intrinsic at %L",
1742 gfc_current_intrinsic_arg
[0]->name
,
1743 gfc_current_intrinsic
, &a
->where
) == FAILURE
)
1751 gfc_check_fnum (gfc_expr
*unit
)
1753 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
1756 if (scalar_check (unit
, 0) == FAILURE
)
1764 gfc_check_huge (gfc_expr
*x
)
1766 if (int_or_real_check (x
, 0) == FAILURE
)
1774 gfc_check_hypot (gfc_expr
*x
, gfc_expr
*y
)
1776 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
1778 if (same_type_check (x
, 0, y
, 1) == FAILURE
)
1785 /* Check that the single argument is an integer. */
1788 gfc_check_i (gfc_expr
*i
)
1790 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1798 gfc_check_iand (gfc_expr
*i
, gfc_expr
*j
)
1800 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1803 if (type_check (j
, 1, BT_INTEGER
) == FAILURE
)
1806 if (i
->ts
.kind
!= j
->ts
.kind
)
1808 if (gfc_notify_std (GFC_STD_GNU
, "Different type kinds at %L",
1809 &i
->where
) == FAILURE
)
1818 gfc_check_ibits (gfc_expr
*i
, gfc_expr
*pos
, gfc_expr
*len
)
1820 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1823 if (type_check (pos
, 1, BT_INTEGER
) == FAILURE
)
1826 if (type_check (len
, 2, BT_INTEGER
) == FAILURE
)
1829 if (nonnegative_check ("pos", pos
) == FAILURE
)
1832 if (nonnegative_check ("len", len
) == FAILURE
)
1835 if (less_than_bitsize2 ("i", i
, "pos", pos
, "len", len
) == FAILURE
)
1843 gfc_check_ichar_iachar (gfc_expr
*c
, gfc_expr
*kind
)
1847 if (type_check (c
, 0, BT_CHARACTER
) == FAILURE
)
1850 if (kind_check (kind
, 1, BT_INTEGER
) == FAILURE
)
1853 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "'%s' intrinsic "
1854 "with KIND argument at %L",
1855 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
1858 if (c
->expr_type
== EXPR_VARIABLE
|| c
->expr_type
== EXPR_SUBSTRING
)
1864 /* Substring references don't have the charlength set. */
1866 while (ref
&& ref
->type
!= REF_SUBSTRING
)
1869 gcc_assert (ref
== NULL
|| ref
->type
== REF_SUBSTRING
);
1873 /* Check that the argument is length one. Non-constant lengths
1874 can't be checked here, so assume they are ok. */
1875 if (c
->ts
.u
.cl
&& c
->ts
.u
.cl
->length
)
1877 /* If we already have a length for this expression then use it. */
1878 if (c
->ts
.u
.cl
->length
->expr_type
!= EXPR_CONSTANT
)
1880 i
= mpz_get_si (c
->ts
.u
.cl
->length
->value
.integer
);
1887 start
= ref
->u
.ss
.start
;
1888 end
= ref
->u
.ss
.end
;
1891 if (end
== NULL
|| end
->expr_type
!= EXPR_CONSTANT
1892 || start
->expr_type
!= EXPR_CONSTANT
)
1895 i
= mpz_get_si (end
->value
.integer
) + 1
1896 - mpz_get_si (start
->value
.integer
);
1904 gfc_error ("Argument of %s at %L must be of length one",
1905 gfc_current_intrinsic
, &c
->where
);
1914 gfc_check_idnint (gfc_expr
*a
)
1916 if (double_check (a
, 0) == FAILURE
)
1924 gfc_check_ieor (gfc_expr
*i
, gfc_expr
*j
)
1926 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1929 if (type_check (j
, 1, BT_INTEGER
) == FAILURE
)
1932 if (i
->ts
.kind
!= j
->ts
.kind
)
1934 if (gfc_notify_std (GFC_STD_GNU
, "Different type kinds at %L",
1935 &i
->where
) == FAILURE
)
1944 gfc_check_index (gfc_expr
*string
, gfc_expr
*substring
, gfc_expr
*back
,
1947 if (type_check (string
, 0, BT_CHARACTER
) == FAILURE
1948 || type_check (substring
, 1, BT_CHARACTER
) == FAILURE
)
1951 if (back
!= NULL
&& type_check (back
, 2, BT_LOGICAL
) == FAILURE
)
1954 if (kind_check (kind
, 3, BT_INTEGER
) == FAILURE
)
1956 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "'%s' intrinsic "
1957 "with KIND argument at %L",
1958 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
1961 if (string
->ts
.kind
!= substring
->ts
.kind
)
1963 gfc_error ("'%s' argument of '%s' intrinsic at %L must be the same "
1964 "kind as '%s'", gfc_current_intrinsic_arg
[1]->name
,
1965 gfc_current_intrinsic
, &substring
->where
,
1966 gfc_current_intrinsic_arg
[0]->name
);
1975 gfc_check_int (gfc_expr
*x
, gfc_expr
*kind
)
1977 if (numeric_check (x
, 0) == FAILURE
)
1980 if (kind_check (kind
, 1, BT_INTEGER
) == FAILURE
)
1988 gfc_check_intconv (gfc_expr
*x
)
1990 if (numeric_check (x
, 0) == FAILURE
)
1998 gfc_check_ior (gfc_expr
*i
, gfc_expr
*j
)
2000 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
2003 if (type_check (j
, 1, BT_INTEGER
) == FAILURE
)
2006 if (i
->ts
.kind
!= j
->ts
.kind
)
2008 if (gfc_notify_std (GFC_STD_GNU
, "Different type kinds at %L",
2009 &i
->where
) == FAILURE
)
2018 gfc_check_ishft (gfc_expr
*i
, gfc_expr
*shift
)
2020 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
2021 || type_check (shift
, 1, BT_INTEGER
) == FAILURE
)
2024 if (less_than_bitsize1 ("I", i
, NULL
, shift
, true) == FAILURE
)
2032 gfc_check_ishftc (gfc_expr
*i
, gfc_expr
*shift
, gfc_expr
*size
)
2034 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
2035 || type_check (shift
, 1, BT_INTEGER
) == FAILURE
)
2042 if (type_check (size
, 2, BT_INTEGER
) == FAILURE
)
2045 if (less_than_bitsize1 ("I", i
, "SIZE", size
, true) == FAILURE
)
2048 if (size
->expr_type
== EXPR_CONSTANT
)
2050 gfc_extract_int (size
, &i3
);
2053 gfc_error ("SIZE at %L must be positive", &size
->where
);
2057 if (shift
->expr_type
== EXPR_CONSTANT
)
2059 gfc_extract_int (shift
, &i2
);
2065 gfc_error ("The absolute value of SHIFT at %L must be less "
2066 "than or equal to SIZE at %L", &shift
->where
,
2073 else if (less_than_bitsize1 ("I", i
, NULL
, shift
, true) == FAILURE
)
2081 gfc_check_kill (gfc_expr
*pid
, gfc_expr
*sig
)
2083 if (type_check (pid
, 0, BT_INTEGER
) == FAILURE
)
2086 if (type_check (sig
, 1, BT_INTEGER
) == FAILURE
)
2094 gfc_check_kill_sub (gfc_expr
*pid
, gfc_expr
*sig
, gfc_expr
*status
)
2096 if (type_check (pid
, 0, BT_INTEGER
) == FAILURE
)
2099 if (scalar_check (pid
, 0) == FAILURE
)
2102 if (type_check (sig
, 1, BT_INTEGER
) == FAILURE
)
2105 if (scalar_check (sig
, 1) == FAILURE
)
2111 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
2114 if (scalar_check (status
, 2) == FAILURE
)
2122 gfc_check_kind (gfc_expr
*x
)
2124 if (x
->ts
.type
== BT_DERIVED
)
2126 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a "
2127 "non-derived type", gfc_current_intrinsic_arg
[0]->name
,
2128 gfc_current_intrinsic
, &x
->where
);
2137 gfc_check_lbound (gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
2139 if (array_check (array
, 0) == FAILURE
)
2142 if (dim_check (dim
, 1, false) == FAILURE
)
2145 if (dim_rank_check (dim
, array
, 1) == FAILURE
)
2148 if (kind_check (kind
, 2, BT_INTEGER
) == FAILURE
)
2150 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "'%s' intrinsic "
2151 "with KIND argument at %L",
2152 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
2160 gfc_check_lcobound (gfc_expr
*coarray
, gfc_expr
*dim
, gfc_expr
*kind
)
2162 if (gfc_option
.coarray
== GFC_FCOARRAY_NONE
)
2164 gfc_fatal_error ("Coarrays disabled at %C, use -fcoarray= to enable");
2168 if (coarray_check (coarray
, 0) == FAILURE
)
2173 if (dim_check (dim
, 1, false) == FAILURE
)
2176 if (dim_corank_check (dim
, coarray
) == FAILURE
)
2180 if (kind_check (kind
, 2, BT_INTEGER
) == FAILURE
)
2188 gfc_check_len_lentrim (gfc_expr
*s
, gfc_expr
*kind
)
2190 if (type_check (s
, 0, BT_CHARACTER
) == FAILURE
)
2193 if (kind_check (kind
, 1, BT_INTEGER
) == FAILURE
)
2195 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "'%s' intrinsic "
2196 "with KIND argument at %L",
2197 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
2205 gfc_check_lge_lgt_lle_llt (gfc_expr
*a
, gfc_expr
*b
)
2207 if (type_check (a
, 0, BT_CHARACTER
) == FAILURE
)
2209 if (kind_value_check (a
, 0, gfc_default_character_kind
) == FAILURE
)
2212 if (type_check (b
, 1, BT_CHARACTER
) == FAILURE
)
2214 if (kind_value_check (b
, 1, gfc_default_character_kind
) == FAILURE
)
2222 gfc_check_link (gfc_expr
*path1
, gfc_expr
*path2
)
2224 if (type_check (path1
, 0, BT_CHARACTER
) == FAILURE
)
2226 if (kind_value_check (path1
, 0, gfc_default_character_kind
) == FAILURE
)
2229 if (type_check (path2
, 1, BT_CHARACTER
) == FAILURE
)
2231 if (kind_value_check (path2
, 1, gfc_default_character_kind
) == FAILURE
)
2239 gfc_check_link_sub (gfc_expr
*path1
, gfc_expr
*path2
, gfc_expr
*status
)
2241 if (type_check (path1
, 0, BT_CHARACTER
) == FAILURE
)
2243 if (kind_value_check (path1
, 0, gfc_default_character_kind
) == FAILURE
)
2246 if (type_check (path2
, 1, BT_CHARACTER
) == FAILURE
)
2248 if (kind_value_check (path2
, 0, gfc_default_character_kind
) == FAILURE
)
2254 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
2257 if (scalar_check (status
, 2) == FAILURE
)
2265 gfc_check_loc (gfc_expr
*expr
)
2267 return variable_check (expr
, 0, true);
2272 gfc_check_symlnk (gfc_expr
*path1
, gfc_expr
*path2
)
2274 if (type_check (path1
, 0, BT_CHARACTER
) == FAILURE
)
2276 if (kind_value_check (path1
, 0, gfc_default_character_kind
) == FAILURE
)
2279 if (type_check (path2
, 1, BT_CHARACTER
) == FAILURE
)
2281 if (kind_value_check (path2
, 1, gfc_default_character_kind
) == FAILURE
)
2289 gfc_check_symlnk_sub (gfc_expr
*path1
, gfc_expr
*path2
, gfc_expr
*status
)
2291 if (type_check (path1
, 0, BT_CHARACTER
) == FAILURE
)
2293 if (kind_value_check (path1
, 0, gfc_default_character_kind
) == FAILURE
)
2296 if (type_check (path2
, 1, BT_CHARACTER
) == FAILURE
)
2298 if (kind_value_check (path2
, 1, gfc_default_character_kind
) == FAILURE
)
2304 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
2307 if (scalar_check (status
, 2) == FAILURE
)
2315 gfc_check_logical (gfc_expr
*a
, gfc_expr
*kind
)
2317 if (type_check (a
, 0, BT_LOGICAL
) == FAILURE
)
2319 if (kind_check (kind
, 1, BT_LOGICAL
) == FAILURE
)
2326 /* Min/max family. */
2329 min_max_args (gfc_actual_arglist
*arg
)
2331 if (arg
== NULL
|| arg
->next
== NULL
)
2333 gfc_error ("Intrinsic '%s' at %L must have at least two arguments",
2334 gfc_current_intrinsic
, gfc_current_intrinsic_where
);
2343 check_rest (bt type
, int kind
, gfc_actual_arglist
*arglist
)
2345 gfc_actual_arglist
*arg
, *tmp
;
2350 if (min_max_args (arglist
) == FAILURE
)
2353 for (arg
= arglist
, n
=1; arg
; arg
= arg
->next
, n
++)
2356 if (x
->ts
.type
!= type
|| x
->ts
.kind
!= kind
)
2358 if (x
->ts
.type
== type
)
2360 if (gfc_notify_std (GFC_STD_GNU
, "Different type "
2361 "kinds at %L", &x
->where
) == FAILURE
)
2366 gfc_error ("'a%d' argument of '%s' intrinsic at %L must be "
2367 "%s(%d)", n
, gfc_current_intrinsic
, &x
->where
,
2368 gfc_basic_typename (type
), kind
);
2373 for (tmp
= arglist
, m
=1; tmp
!= arg
; tmp
= tmp
->next
, m
++)
2374 if (gfc_check_conformance (tmp
->expr
, x
,
2375 "arguments 'a%d' and 'a%d' for "
2376 "intrinsic '%s'", m
, n
,
2377 gfc_current_intrinsic
) == FAILURE
)
2386 gfc_check_min_max (gfc_actual_arglist
*arg
)
2390 if (min_max_args (arg
) == FAILURE
)
2395 if (x
->ts
.type
== BT_CHARACTER
)
2397 if (gfc_notify_std (GFC_STD_F2003
, "'%s' intrinsic "
2398 "with CHARACTER argument at %L",
2399 gfc_current_intrinsic
, &x
->where
) == FAILURE
)
2402 else if (x
->ts
.type
!= BT_INTEGER
&& x
->ts
.type
!= BT_REAL
)
2404 gfc_error ("'a1' argument of '%s' intrinsic at %L must be INTEGER, "
2405 "REAL or CHARACTER", gfc_current_intrinsic
, &x
->where
);
2409 return check_rest (x
->ts
.type
, x
->ts
.kind
, arg
);
2414 gfc_check_min_max_integer (gfc_actual_arglist
*arg
)
2416 return check_rest (BT_INTEGER
, gfc_default_integer_kind
, arg
);
2421 gfc_check_min_max_real (gfc_actual_arglist
*arg
)
2423 return check_rest (BT_REAL
, gfc_default_real_kind
, arg
);
2428 gfc_check_min_max_double (gfc_actual_arglist
*arg
)
2430 return check_rest (BT_REAL
, gfc_default_double_kind
, arg
);
2434 /* End of min/max family. */
2437 gfc_check_malloc (gfc_expr
*size
)
2439 if (type_check (size
, 0, BT_INTEGER
) == FAILURE
)
2442 if (scalar_check (size
, 0) == FAILURE
)
2450 gfc_check_matmul (gfc_expr
*matrix_a
, gfc_expr
*matrix_b
)
2452 if ((matrix_a
->ts
.type
!= BT_LOGICAL
) && !gfc_numeric_ts (&matrix_a
->ts
))
2454 gfc_error ("'%s' argument of '%s' intrinsic at %L must be numeric "
2455 "or LOGICAL", gfc_current_intrinsic_arg
[0]->name
,
2456 gfc_current_intrinsic
, &matrix_a
->where
);
2460 if ((matrix_b
->ts
.type
!= BT_LOGICAL
) && !gfc_numeric_ts (&matrix_b
->ts
))
2462 gfc_error ("'%s' argument of '%s' intrinsic at %L must be numeric "
2463 "or LOGICAL", gfc_current_intrinsic_arg
[1]->name
,
2464 gfc_current_intrinsic
, &matrix_b
->where
);
2468 if ((matrix_a
->ts
.type
== BT_LOGICAL
&& gfc_numeric_ts (&matrix_b
->ts
))
2469 || (gfc_numeric_ts (&matrix_a
->ts
) && matrix_b
->ts
.type
== BT_LOGICAL
))
2471 gfc_error ("Argument types of '%s' intrinsic at %L must match (%s/%s)",
2472 gfc_current_intrinsic
, &matrix_a
->where
,
2473 gfc_typename(&matrix_a
->ts
), gfc_typename(&matrix_b
->ts
));
2477 switch (matrix_a
->rank
)
2480 if (rank_check (matrix_b
, 1, 2) == FAILURE
)
2482 /* Check for case matrix_a has shape(m), matrix_b has shape (m, k). */
2483 if (!identical_dimen_shape (matrix_a
, 0, matrix_b
, 0))
2485 gfc_error ("Different shape on dimension 1 for arguments '%s' "
2486 "and '%s' at %L for intrinsic matmul",
2487 gfc_current_intrinsic_arg
[0]->name
,
2488 gfc_current_intrinsic_arg
[1]->name
, &matrix_a
->where
);
2494 if (matrix_b
->rank
!= 2)
2496 if (rank_check (matrix_b
, 1, 1) == FAILURE
)
2499 /* matrix_b has rank 1 or 2 here. Common check for the cases
2500 - matrix_a has shape (n,m) and matrix_b has shape (m, k)
2501 - matrix_a has shape (n,m) and matrix_b has shape (m). */
2502 if (!identical_dimen_shape (matrix_a
, 1, matrix_b
, 0))
2504 gfc_error ("Different shape on dimension 2 for argument '%s' and "
2505 "dimension 1 for argument '%s' at %L for intrinsic "
2506 "matmul", gfc_current_intrinsic_arg
[0]->name
,
2507 gfc_current_intrinsic_arg
[1]->name
, &matrix_a
->where
);
2513 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of rank "
2514 "1 or 2", gfc_current_intrinsic_arg
[0]->name
,
2515 gfc_current_intrinsic
, &matrix_a
->where
);
2523 /* Whoever came up with this interface was probably on something.
2524 The possibilities for the occupation of the second and third
2531 NULL MASK minloc(array, mask=m)
2534 I.e. in the case of minloc(array,mask), mask will be in the second
2535 position of the argument list and we'll have to fix that up. */
2538 gfc_check_minloc_maxloc (gfc_actual_arglist
*ap
)
2540 gfc_expr
*a
, *m
, *d
;
2543 if (int_or_real_check (a
, 0) == FAILURE
|| array_check (a
, 0) == FAILURE
)
2547 m
= ap
->next
->next
->expr
;
2549 if (m
== NULL
&& d
!= NULL
&& d
->ts
.type
== BT_LOGICAL
2550 && ap
->next
->name
== NULL
)
2554 ap
->next
->expr
= NULL
;
2555 ap
->next
->next
->expr
= m
;
2558 if (dim_check (d
, 1, false) == FAILURE
)
2561 if (dim_rank_check (d
, a
, 0) == FAILURE
)
2564 if (m
!= NULL
&& type_check (m
, 2, BT_LOGICAL
) == FAILURE
)
2568 && gfc_check_conformance (a
, m
,
2569 "arguments '%s' and '%s' for intrinsic %s",
2570 gfc_current_intrinsic_arg
[0]->name
,
2571 gfc_current_intrinsic_arg
[2]->name
,
2572 gfc_current_intrinsic
) == FAILURE
)
2579 /* Similar to minloc/maxloc, the argument list might need to be
2580 reordered for the MINVAL, MAXVAL, PRODUCT, and SUM intrinsics. The
2581 difference is that MINLOC/MAXLOC take an additional KIND argument.
2582 The possibilities are:
2588 NULL MASK minval(array, mask=m)
2591 I.e. in the case of minval(array,mask), mask will be in the second
2592 position of the argument list and we'll have to fix that up. */
2595 check_reduction (gfc_actual_arglist
*ap
)
2597 gfc_expr
*a
, *m
, *d
;
2601 m
= ap
->next
->next
->expr
;
2603 if (m
== NULL
&& d
!= NULL
&& d
->ts
.type
== BT_LOGICAL
2604 && ap
->next
->name
== NULL
)
2608 ap
->next
->expr
= NULL
;
2609 ap
->next
->next
->expr
= m
;
2612 if (dim_check (d
, 1, false) == FAILURE
)
2615 if (dim_rank_check (d
, a
, 0) == FAILURE
)
2618 if (m
!= NULL
&& type_check (m
, 2, BT_LOGICAL
) == FAILURE
)
2622 && gfc_check_conformance (a
, m
,
2623 "arguments '%s' and '%s' for intrinsic %s",
2624 gfc_current_intrinsic_arg
[0]->name
,
2625 gfc_current_intrinsic_arg
[2]->name
,
2626 gfc_current_intrinsic
) == FAILURE
)
2634 gfc_check_minval_maxval (gfc_actual_arglist
*ap
)
2636 if (int_or_real_check (ap
->expr
, 0) == FAILURE
2637 || array_check (ap
->expr
, 0) == FAILURE
)
2640 return check_reduction (ap
);
2645 gfc_check_product_sum (gfc_actual_arglist
*ap
)
2647 if (numeric_check (ap
->expr
, 0) == FAILURE
2648 || array_check (ap
->expr
, 0) == FAILURE
)
2651 return check_reduction (ap
);
2655 /* For IANY, IALL and IPARITY. */
2658 gfc_check_mask (gfc_expr
*i
, gfc_expr
*kind
)
2662 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
2665 if (nonnegative_check ("I", i
) == FAILURE
)
2668 if (kind_check (kind
, 1, BT_INTEGER
) == FAILURE
)
2672 gfc_extract_int (kind
, &k
);
2674 k
= gfc_default_integer_kind
;
2676 if (less_than_bitsizekind ("I", i
, k
) == FAILURE
)
2684 gfc_check_transf_bit_intrins (gfc_actual_arglist
*ap
)
2686 if (ap
->expr
->ts
.type
!= BT_INTEGER
)
2688 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER",
2689 gfc_current_intrinsic_arg
[0]->name
,
2690 gfc_current_intrinsic
, &ap
->expr
->where
);
2694 if (array_check (ap
->expr
, 0) == FAILURE
)
2697 return check_reduction (ap
);
2702 gfc_check_merge (gfc_expr
*tsource
, gfc_expr
*fsource
, gfc_expr
*mask
)
2704 if (same_type_check (tsource
, 0, fsource
, 1) == FAILURE
)
2707 if (type_check (mask
, 2, BT_LOGICAL
) == FAILURE
)
2710 if (tsource
->ts
.type
== BT_CHARACTER
)
2711 return gfc_check_same_strlen (tsource
, fsource
, "MERGE intrinsic");
2718 gfc_check_merge_bits (gfc_expr
*i
, gfc_expr
*j
, gfc_expr
*mask
)
2720 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
2723 if (type_check (j
, 1, BT_INTEGER
) == FAILURE
)
2726 if (type_check (mask
, 2, BT_INTEGER
) == FAILURE
)
2729 if (same_type_check (i
, 0, j
, 1) == FAILURE
)
2732 if (same_type_check (i
, 0, mask
, 2) == FAILURE
)
2740 gfc_check_move_alloc (gfc_expr
*from
, gfc_expr
*to
)
2742 if (variable_check (from
, 0, false) == FAILURE
)
2744 if (allocatable_check (from
, 0) == FAILURE
)
2746 if (gfc_is_coindexed (from
))
2748 gfc_error ("The FROM argument to MOVE_ALLOC at %L shall not be "
2749 "coindexed", &from
->where
);
2753 if (variable_check (to
, 1, false) == FAILURE
)
2755 if (allocatable_check (to
, 1) == FAILURE
)
2757 if (gfc_is_coindexed (to
))
2759 gfc_error ("The TO argument to MOVE_ALLOC at %L shall not be "
2760 "coindexed", &to
->where
);
2764 if (from
->ts
.type
== BT_CLASS
&& to
->ts
.type
== BT_DERIVED
)
2766 gfc_error ("The TO arguments in MOVE_ALLOC at %L must be "
2767 "polymorphic if FROM is polymorphic",
2772 if (same_type_check (to
, 1, from
, 0) == FAILURE
)
2775 if (to
->rank
!= from
->rank
)
2777 gfc_error ("The FROM and TO arguments of the MOVE_ALLOC intrinsic at %L "
2778 "must have the same rank %d/%d", &to
->where
, from
->rank
,
2783 /* IR F08/0040; cf. 12-006A. */
2784 if (gfc_get_corank (to
) != gfc_get_corank (from
))
2786 gfc_error ("The FROM and TO arguments of the MOVE_ALLOC intrinsic at %L "
2787 "must have the same corank %d/%d", &to
->where
,
2788 gfc_get_corank (from
), gfc_get_corank (to
));
2792 /* CLASS arguments: Make sure the vtab of from is present. */
2793 if (to
->ts
.type
== BT_CLASS
&& !UNLIMITED_POLY (from
))
2795 if (from
->ts
.type
== BT_CLASS
|| from
->ts
.type
== BT_DERIVED
)
2796 gfc_find_derived_vtab (from
->ts
.u
.derived
);
2798 gfc_find_intrinsic_vtab (&from
->ts
);
2806 gfc_check_nearest (gfc_expr
*x
, gfc_expr
*s
)
2808 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
2811 if (type_check (s
, 1, BT_REAL
) == FAILURE
)
2814 if (s
->expr_type
== EXPR_CONSTANT
)
2816 if (mpfr_sgn (s
->value
.real
) == 0)
2818 gfc_error ("Argument 'S' of NEAREST at %L shall not be zero",
2829 gfc_check_new_line (gfc_expr
*a
)
2831 if (type_check (a
, 0, BT_CHARACTER
) == FAILURE
)
2839 gfc_check_norm2 (gfc_expr
*array
, gfc_expr
*dim
)
2841 if (type_check (array
, 0, BT_REAL
) == FAILURE
)
2844 if (array_check (array
, 0) == FAILURE
)
2847 if (dim_rank_check (dim
, array
, false) == FAILURE
)
2854 gfc_check_null (gfc_expr
*mold
)
2856 symbol_attribute attr
;
2861 if (variable_check (mold
, 0, true) == FAILURE
)
2864 attr
= gfc_variable_attr (mold
, NULL
);
2866 if (!attr
.pointer
&& !attr
.proc_pointer
&& !attr
.allocatable
)
2868 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a POINTER, "
2869 "ALLOCATABLE or procedure pointer",
2870 gfc_current_intrinsic_arg
[0]->name
,
2871 gfc_current_intrinsic
, &mold
->where
);
2875 if (attr
.allocatable
2876 && gfc_notify_std (GFC_STD_F2003
, "NULL intrinsic with "
2877 "allocatable MOLD at %L", &mold
->where
) == FAILURE
)
2881 if (gfc_is_coindexed (mold
))
2883 gfc_error ("'%s' argument of '%s' intrinsic at %L shall not be "
2884 "coindexed", gfc_current_intrinsic_arg
[0]->name
,
2885 gfc_current_intrinsic
, &mold
->where
);
2894 gfc_check_pack (gfc_expr
*array
, gfc_expr
*mask
, gfc_expr
*vector
)
2896 if (array_check (array
, 0) == FAILURE
)
2899 if (type_check (mask
, 1, BT_LOGICAL
) == FAILURE
)
2902 if (gfc_check_conformance (array
, mask
,
2903 "arguments '%s' and '%s' for intrinsic '%s'",
2904 gfc_current_intrinsic_arg
[0]->name
,
2905 gfc_current_intrinsic_arg
[1]->name
,
2906 gfc_current_intrinsic
) == FAILURE
)
2911 mpz_t array_size
, vector_size
;
2912 bool have_array_size
, have_vector_size
;
2914 if (same_type_check (array
, 0, vector
, 2) == FAILURE
)
2917 if (rank_check (vector
, 2, 1) == FAILURE
)
2920 /* VECTOR requires at least as many elements as MASK
2921 has .TRUE. values. */
2922 have_array_size
= gfc_array_size (array
, &array_size
) == SUCCESS
;
2923 have_vector_size
= gfc_array_size (vector
, &vector_size
) == SUCCESS
;
2925 if (have_vector_size
2926 && (mask
->expr_type
== EXPR_ARRAY
2927 || (mask
->expr_type
== EXPR_CONSTANT
2928 && have_array_size
)))
2930 int mask_true_values
= 0;
2932 if (mask
->expr_type
== EXPR_ARRAY
)
2934 gfc_constructor
*mask_ctor
;
2935 mask_ctor
= gfc_constructor_first (mask
->value
.constructor
);
2938 if (mask_ctor
->expr
->expr_type
!= EXPR_CONSTANT
)
2940 mask_true_values
= 0;
2944 if (mask_ctor
->expr
->value
.logical
)
2947 mask_ctor
= gfc_constructor_next (mask_ctor
);
2950 else if (mask
->expr_type
== EXPR_CONSTANT
&& mask
->value
.logical
)
2951 mask_true_values
= mpz_get_si (array_size
);
2953 if (mpz_get_si (vector_size
) < mask_true_values
)
2955 gfc_error ("'%s' argument of '%s' intrinsic at %L must "
2956 "provide at least as many elements as there "
2957 "are .TRUE. values in '%s' (%ld/%d)",
2958 gfc_current_intrinsic_arg
[2]->name
,
2959 gfc_current_intrinsic
, &vector
->where
,
2960 gfc_current_intrinsic_arg
[1]->name
,
2961 mpz_get_si (vector_size
), mask_true_values
);
2966 if (have_array_size
)
2967 mpz_clear (array_size
);
2968 if (have_vector_size
)
2969 mpz_clear (vector_size
);
2977 gfc_check_parity (gfc_expr
*mask
, gfc_expr
*dim
)
2979 if (type_check (mask
, 0, BT_LOGICAL
) == FAILURE
)
2982 if (array_check (mask
, 0) == FAILURE
)
2985 if (dim_rank_check (dim
, mask
, false) == FAILURE
)
2993 gfc_check_precision (gfc_expr
*x
)
2995 if (real_or_complex_check (x
, 0) == FAILURE
)
3003 gfc_check_present (gfc_expr
*a
)
3007 if (variable_check (a
, 0, true) == FAILURE
)
3010 sym
= a
->symtree
->n
.sym
;
3011 if (!sym
->attr
.dummy
)
3013 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of a "
3014 "dummy variable", gfc_current_intrinsic_arg
[0]->name
,
3015 gfc_current_intrinsic
, &a
->where
);
3019 if (!sym
->attr
.optional
)
3021 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of "
3022 "an OPTIONAL dummy variable",
3023 gfc_current_intrinsic_arg
[0]->name
, gfc_current_intrinsic
,
3028 /* 13.14.82 PRESENT(A)
3030 Argument. A shall be the name of an optional dummy argument that is
3031 accessible in the subprogram in which the PRESENT function reference
3035 && !(a
->ref
->next
== NULL
&& a
->ref
->type
== REF_ARRAY
3036 && (a
->ref
->u
.ar
.type
== AR_FULL
3037 || (a
->ref
->u
.ar
.type
== AR_ELEMENT
3038 && a
->ref
->u
.ar
.as
->rank
== 0))))
3040 gfc_error ("'%s' argument of '%s' intrinsic at %L must not be a "
3041 "subobject of '%s'", gfc_current_intrinsic_arg
[0]->name
,
3042 gfc_current_intrinsic
, &a
->where
, sym
->name
);
3051 gfc_check_radix (gfc_expr
*x
)
3053 if (int_or_real_check (x
, 0) == FAILURE
)
3061 gfc_check_range (gfc_expr
*x
)
3063 if (numeric_check (x
, 0) == FAILURE
)
3071 gfc_check_rank (gfc_expr
*a ATTRIBUTE_UNUSED
)
3073 /* Any data object is allowed; a "data object" is a "constant (4.1.3),
3074 variable (6), or subobject of a constant (2.4.3.2.3)" (F2008, 1.3.45). */
3076 bool is_variable
= true;
3078 /* Functions returning pointers are regarded as variable, cf. F2008, R602. */
3079 if (a
->expr_type
== EXPR_FUNCTION
)
3080 is_variable
= a
->value
.function
.esym
3081 ? a
->value
.function
.esym
->result
->attr
.pointer
3082 : a
->symtree
->n
.sym
->result
->attr
.pointer
;
3084 if (a
->expr_type
== EXPR_OP
|| a
->expr_type
== EXPR_NULL
3085 || a
->expr_type
== EXPR_COMPCALL
|| a
->expr_type
== EXPR_PPC
3088 gfc_error ("The argument of the RANK intrinsic at %L must be a data "
3089 "object", &a
->where
);
3097 /* real, float, sngl. */
3099 gfc_check_real (gfc_expr
*a
, gfc_expr
*kind
)
3101 if (numeric_check (a
, 0) == FAILURE
)
3104 if (kind_check (kind
, 1, BT_REAL
) == FAILURE
)
3112 gfc_check_rename (gfc_expr
*path1
, gfc_expr
*path2
)
3114 if (type_check (path1
, 0, BT_CHARACTER
) == FAILURE
)
3116 if (kind_value_check (path1
, 0, gfc_default_character_kind
) == FAILURE
)
3119 if (type_check (path2
, 1, BT_CHARACTER
) == FAILURE
)
3121 if (kind_value_check (path2
, 1, gfc_default_character_kind
) == FAILURE
)
3129 gfc_check_rename_sub (gfc_expr
*path1
, gfc_expr
*path2
, gfc_expr
*status
)
3131 if (type_check (path1
, 0, BT_CHARACTER
) == FAILURE
)
3133 if (kind_value_check (path1
, 0, gfc_default_character_kind
) == FAILURE
)
3136 if (type_check (path2
, 1, BT_CHARACTER
) == FAILURE
)
3138 if (kind_value_check (path2
, 1, gfc_default_character_kind
) == FAILURE
)
3144 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
3147 if (scalar_check (status
, 2) == FAILURE
)
3155 gfc_check_repeat (gfc_expr
*x
, gfc_expr
*y
)
3157 if (type_check (x
, 0, BT_CHARACTER
) == FAILURE
)
3160 if (scalar_check (x
, 0) == FAILURE
)
3163 if (type_check (y
, 0, BT_INTEGER
) == FAILURE
)
3166 if (scalar_check (y
, 1) == FAILURE
)
3174 gfc_check_reshape (gfc_expr
*source
, gfc_expr
*shape
,
3175 gfc_expr
*pad
, gfc_expr
*order
)
3181 if (array_check (source
, 0) == FAILURE
)
3184 if (rank_check (shape
, 1, 1) == FAILURE
)
3187 if (type_check (shape
, 1, BT_INTEGER
) == FAILURE
)
3190 if (gfc_array_size (shape
, &size
) != SUCCESS
)
3192 gfc_error ("'shape' argument of 'reshape' intrinsic at %L must be an "
3193 "array of constant size", &shape
->where
);
3197 shape_size
= mpz_get_ui (size
);
3200 if (shape_size
<= 0)
3202 gfc_error ("'%s' argument of '%s' intrinsic at %L is empty",
3203 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
3207 else if (shape_size
> GFC_MAX_DIMENSIONS
)
3209 gfc_error ("'shape' argument of 'reshape' intrinsic at %L has more "
3210 "than %d elements", &shape
->where
, GFC_MAX_DIMENSIONS
);
3213 else if (shape
->expr_type
== EXPR_ARRAY
)
3217 for (i
= 0; i
< shape_size
; ++i
)
3219 e
= gfc_constructor_lookup_expr (shape
->value
.constructor
, i
);
3220 if (e
->expr_type
!= EXPR_CONSTANT
)
3223 gfc_extract_int (e
, &extent
);
3226 gfc_error ("'%s' argument of '%s' intrinsic at %L has "
3227 "negative element (%d)",
3228 gfc_current_intrinsic_arg
[1]->name
,
3229 gfc_current_intrinsic
, &e
->where
, extent
);
3237 if (same_type_check (source
, 0, pad
, 2) == FAILURE
)
3240 if (array_check (pad
, 2) == FAILURE
)
3246 if (array_check (order
, 3) == FAILURE
)
3249 if (type_check (order
, 3, BT_INTEGER
) == FAILURE
)
3252 if (order
->expr_type
== EXPR_ARRAY
)
3254 int i
, order_size
, dim
, perm
[GFC_MAX_DIMENSIONS
];
3257 for (i
= 0; i
< GFC_MAX_DIMENSIONS
; ++i
)
3260 gfc_array_size (order
, &size
);
3261 order_size
= mpz_get_ui (size
);
3264 if (order_size
!= shape_size
)
3266 gfc_error ("'%s' argument of '%s' intrinsic at %L "
3267 "has wrong number of elements (%d/%d)",
3268 gfc_current_intrinsic_arg
[3]->name
,
3269 gfc_current_intrinsic
, &order
->where
,
3270 order_size
, shape_size
);
3274 for (i
= 1; i
<= order_size
; ++i
)
3276 e
= gfc_constructor_lookup_expr (order
->value
.constructor
, i
-1);
3277 if (e
->expr_type
!= EXPR_CONSTANT
)
3280 gfc_extract_int (e
, &dim
);
3282 if (dim
< 1 || dim
> order_size
)
3284 gfc_error ("'%s' argument of '%s' intrinsic at %L "
3285 "has out-of-range dimension (%d)",
3286 gfc_current_intrinsic_arg
[3]->name
,
3287 gfc_current_intrinsic
, &e
->where
, dim
);
3291 if (perm
[dim
-1] != 0)
3293 gfc_error ("'%s' argument of '%s' intrinsic at %L has "
3294 "invalid permutation of dimensions (dimension "
3296 gfc_current_intrinsic_arg
[3]->name
,
3297 gfc_current_intrinsic
, &e
->where
, dim
);
3306 if (pad
== NULL
&& shape
->expr_type
== EXPR_ARRAY
3307 && gfc_is_constant_expr (shape
)
3308 && !(source
->expr_type
== EXPR_VARIABLE
&& source
->symtree
->n
.sym
->as
3309 && source
->symtree
->n
.sym
->as
->type
== AS_ASSUMED_SIZE
))
3311 /* Check the match in size between source and destination. */
3312 if (gfc_array_size (source
, &nelems
) == SUCCESS
)
3318 mpz_init_set_ui (size
, 1);
3319 for (c
= gfc_constructor_first (shape
->value
.constructor
);
3320 c
; c
= gfc_constructor_next (c
))
3321 mpz_mul (size
, size
, c
->expr
->value
.integer
);
3323 test
= mpz_cmp (nelems
, size
) < 0 && mpz_cmp_ui (size
, 0) > 0;
3329 gfc_error ("Without padding, there are not enough elements "
3330 "in the intrinsic RESHAPE source at %L to match "
3331 "the shape", &source
->where
);
3342 gfc_check_same_type_as (gfc_expr
*a
, gfc_expr
*b
)
3344 if (a
->ts
.type
!= BT_DERIVED
&& a
->ts
.type
!= BT_CLASS
)
3346 gfc_error ("'%s' argument of '%s' intrinsic at %L "
3347 "cannot be of type %s",
3348 gfc_current_intrinsic_arg
[0]->name
,
3349 gfc_current_intrinsic
,
3350 &a
->where
, gfc_typename (&a
->ts
));
3354 if (!(gfc_type_is_extensible (a
->ts
.u
.derived
) || UNLIMITED_POLY (a
)))
3356 gfc_error ("'%s' argument of '%s' intrinsic at %L "
3357 "must be of an extensible type",
3358 gfc_current_intrinsic_arg
[0]->name
, gfc_current_intrinsic
,
3363 if (b
->ts
.type
!= BT_DERIVED
&& b
->ts
.type
!= BT_CLASS
)
3365 gfc_error ("'%s' argument of '%s' intrinsic at %L "
3366 "cannot be of type %s",
3367 gfc_current_intrinsic_arg
[0]->name
,
3368 gfc_current_intrinsic
,
3369 &b
->where
, gfc_typename (&b
->ts
));
3373 if (!(gfc_type_is_extensible (b
->ts
.u
.derived
) || UNLIMITED_POLY (b
)))
3375 gfc_error ("'%s' argument of '%s' intrinsic at %L "
3376 "must be of an extensible type",
3377 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
3387 gfc_check_scale (gfc_expr
*x
, gfc_expr
*i
)
3389 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
3392 if (type_check (i
, 1, BT_INTEGER
) == FAILURE
)
3400 gfc_check_scan (gfc_expr
*x
, gfc_expr
*y
, gfc_expr
*z
, gfc_expr
*kind
)
3402 if (type_check (x
, 0, BT_CHARACTER
) == FAILURE
)
3405 if (type_check (y
, 1, BT_CHARACTER
) == FAILURE
)
3408 if (z
!= NULL
&& type_check (z
, 2, BT_LOGICAL
) == FAILURE
)
3411 if (kind_check (kind
, 3, BT_INTEGER
) == FAILURE
)
3413 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "'%s' intrinsic "
3414 "with KIND argument at %L",
3415 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
3418 if (same_type_check (x
, 0, y
, 1) == FAILURE
)
3426 gfc_check_secnds (gfc_expr
*r
)
3428 if (type_check (r
, 0, BT_REAL
) == FAILURE
)
3431 if (kind_value_check (r
, 0, 4) == FAILURE
)
3434 if (scalar_check (r
, 0) == FAILURE
)
3442 gfc_check_selected_char_kind (gfc_expr
*name
)
3444 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
3447 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
3450 if (scalar_check (name
, 0) == FAILURE
)
3458 gfc_check_selected_int_kind (gfc_expr
*r
)
3460 if (type_check (r
, 0, BT_INTEGER
) == FAILURE
)
3463 if (scalar_check (r
, 0) == FAILURE
)
3471 gfc_check_selected_real_kind (gfc_expr
*p
, gfc_expr
*r
, gfc_expr
*radix
)
3473 if (p
== NULL
&& r
== NULL
3474 && gfc_notify_std (GFC_STD_F2008
, "SELECTED_REAL_KIND with"
3475 " neither 'P' nor 'R' argument at %L",
3476 gfc_current_intrinsic_where
) == FAILURE
)
3481 if (type_check (p
, 0, BT_INTEGER
) == FAILURE
)
3484 if (scalar_check (p
, 0) == FAILURE
)
3490 if (type_check (r
, 1, BT_INTEGER
) == FAILURE
)
3493 if (scalar_check (r
, 1) == FAILURE
)
3499 if (type_check (radix
, 1, BT_INTEGER
) == FAILURE
)
3502 if (scalar_check (radix
, 1) == FAILURE
)
3505 if (gfc_notify_std (GFC_STD_F2008
, "'%s' intrinsic with "
3506 "RADIX argument at %L", gfc_current_intrinsic
,
3507 &radix
->where
) == FAILURE
)
3516 gfc_check_set_exponent (gfc_expr
*x
, gfc_expr
*i
)
3518 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
3521 if (type_check (i
, 1, BT_INTEGER
) == FAILURE
)
3529 gfc_check_shape (gfc_expr
*source
, gfc_expr
*kind
)
3533 if (source
->rank
== 0 || source
->expr_type
!= EXPR_VARIABLE
)
3536 ar
= gfc_find_array_ref (source
);
3538 if (ar
->as
&& ar
->as
->type
== AS_ASSUMED_SIZE
&& ar
->type
== AR_FULL
)
3540 gfc_error ("'source' argument of 'shape' intrinsic at %L must not be "
3541 "an assumed size array", &source
->where
);
3545 if (kind_check (kind
, 1, BT_INTEGER
) == FAILURE
)
3547 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "'%s' intrinsic "
3548 "with KIND argument at %L",
3549 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
3557 gfc_check_shift (gfc_expr
*i
, gfc_expr
*shift
)
3559 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
3562 if (type_check (shift
, 0, BT_INTEGER
) == FAILURE
)
3565 if (nonnegative_check ("SHIFT", shift
) == FAILURE
)
3568 if (less_than_bitsize1 ("I", i
, "SHIFT", shift
, true) == FAILURE
)
3576 gfc_check_sign (gfc_expr
*a
, gfc_expr
*b
)
3578 if (int_or_real_check (a
, 0) == FAILURE
)
3581 if (same_type_check (a
, 0, b
, 1) == FAILURE
)
3589 gfc_check_size (gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
3591 if (array_check (array
, 0) == FAILURE
)
3594 if (dim_check (dim
, 1, true) == FAILURE
)
3597 if (dim_rank_check (dim
, array
, 0) == FAILURE
)
3600 if (kind_check (kind
, 2, BT_INTEGER
) == FAILURE
)
3602 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "'%s' intrinsic "
3603 "with KIND argument at %L",
3604 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
3613 gfc_check_sizeof (gfc_expr
*arg
)
3615 if (arg
->ts
.type
== BT_PROCEDURE
)
3617 gfc_error ("'%s' argument of '%s' intrinsic at %L may not be a procedure",
3618 gfc_current_intrinsic_arg
[0]->name
, gfc_current_intrinsic
,
3627 gfc_check_c_sizeof (gfc_expr
*arg
)
3629 if (gfc_verify_c_interop (&arg
->ts
) != SUCCESS
)
3631 gfc_error ("'%s' argument of '%s' intrinsic at %L must be an "
3632 "interoperable data entity",
3633 gfc_current_intrinsic_arg
[0]->name
, gfc_current_intrinsic
,
3642 gfc_check_sleep_sub (gfc_expr
*seconds
)
3644 if (type_check (seconds
, 0, BT_INTEGER
) == FAILURE
)
3647 if (scalar_check (seconds
, 0) == FAILURE
)
3654 gfc_check_sngl (gfc_expr
*a
)
3656 if (type_check (a
, 0, BT_REAL
) == FAILURE
)
3659 if ((a
->ts
.kind
!= gfc_default_double_kind
)
3660 && gfc_notify_std (GFC_STD_GNU
, "non double precision "
3661 "REAL argument to %s intrinsic at %L",
3662 gfc_current_intrinsic
, &a
->where
) == FAILURE
)
3669 gfc_check_spread (gfc_expr
*source
, gfc_expr
*dim
, gfc_expr
*ncopies
)
3671 if (source
->rank
>= GFC_MAX_DIMENSIONS
)
3673 gfc_error ("'%s' argument of '%s' intrinsic at %L must be less "
3674 "than rank %d", gfc_current_intrinsic_arg
[0]->name
,
3675 gfc_current_intrinsic
, &source
->where
, GFC_MAX_DIMENSIONS
);
3683 if (dim_check (dim
, 1, false) == FAILURE
)
3686 /* dim_rank_check() does not apply here. */
3688 && dim
->expr_type
== EXPR_CONSTANT
3689 && (mpz_cmp_ui (dim
->value
.integer
, 1) < 0
3690 || mpz_cmp_ui (dim
->value
.integer
, source
->rank
+ 1) > 0))
3692 gfc_error ("'%s' argument of '%s' intrinsic at %L is not a valid "
3693 "dimension index", gfc_current_intrinsic_arg
[1]->name
,
3694 gfc_current_intrinsic
, &dim
->where
);
3698 if (type_check (ncopies
, 2, BT_INTEGER
) == FAILURE
)
3701 if (scalar_check (ncopies
, 2) == FAILURE
)
3708 /* Functions for checking FGETC, FPUTC, FGET and FPUT (subroutines and
3712 gfc_check_fgetputc_sub (gfc_expr
*unit
, gfc_expr
*c
, gfc_expr
*status
)
3714 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
3717 if (scalar_check (unit
, 0) == FAILURE
)
3720 if (type_check (c
, 1, BT_CHARACTER
) == FAILURE
)
3722 if (kind_value_check (c
, 1, gfc_default_character_kind
) == FAILURE
)
3728 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
3729 || kind_value_check (status
, 2, gfc_default_integer_kind
) == FAILURE
3730 || scalar_check (status
, 2) == FAILURE
)
3738 gfc_check_fgetputc (gfc_expr
*unit
, gfc_expr
*c
)
3740 return gfc_check_fgetputc_sub (unit
, c
, NULL
);
3745 gfc_check_fgetput_sub (gfc_expr
*c
, gfc_expr
*status
)
3747 if (type_check (c
, 0, BT_CHARACTER
) == FAILURE
)
3749 if (kind_value_check (c
, 0, gfc_default_character_kind
) == FAILURE
)
3755 if (type_check (status
, 1, BT_INTEGER
) == FAILURE
3756 || kind_value_check (status
, 1, gfc_default_integer_kind
) == FAILURE
3757 || scalar_check (status
, 1) == FAILURE
)
3765 gfc_check_fgetput (gfc_expr
*c
)
3767 return gfc_check_fgetput_sub (c
, NULL
);
3772 gfc_check_fseek_sub (gfc_expr
*unit
, gfc_expr
*offset
, gfc_expr
*whence
, gfc_expr
*status
)
3774 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
3777 if (scalar_check (unit
, 0) == FAILURE
)
3780 if (type_check (offset
, 1, BT_INTEGER
) == FAILURE
)
3783 if (scalar_check (offset
, 1) == FAILURE
)
3786 if (type_check (whence
, 2, BT_INTEGER
) == FAILURE
)
3789 if (scalar_check (whence
, 2) == FAILURE
)
3795 if (type_check (status
, 3, BT_INTEGER
) == FAILURE
)
3798 if (kind_value_check (status
, 3, 4) == FAILURE
)
3801 if (scalar_check (status
, 3) == FAILURE
)
3810 gfc_check_fstat (gfc_expr
*unit
, gfc_expr
*array
)
3812 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
3815 if (scalar_check (unit
, 0) == FAILURE
)
3818 if (type_check (array
, 1, BT_INTEGER
) == FAILURE
3819 || kind_value_check (unit
, 0, gfc_default_integer_kind
) == FAILURE
)
3822 if (array_check (array
, 1) == FAILURE
)
3830 gfc_check_fstat_sub (gfc_expr
*unit
, gfc_expr
*array
, gfc_expr
*status
)
3832 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
3835 if (scalar_check (unit
, 0) == FAILURE
)
3838 if (type_check (array
, 1, BT_INTEGER
) == FAILURE
3839 || kind_value_check (array
, 1, gfc_default_integer_kind
) == FAILURE
)
3842 if (array_check (array
, 1) == FAILURE
)
3848 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
3849 || kind_value_check (status
, 2, gfc_default_integer_kind
) == FAILURE
)
3852 if (scalar_check (status
, 2) == FAILURE
)
3860 gfc_check_ftell (gfc_expr
*unit
)
3862 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
3865 if (scalar_check (unit
, 0) == FAILURE
)
3873 gfc_check_ftell_sub (gfc_expr
*unit
, gfc_expr
*offset
)
3875 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
3878 if (scalar_check (unit
, 0) == FAILURE
)
3881 if (type_check (offset
, 1, BT_INTEGER
) == FAILURE
)
3884 if (scalar_check (offset
, 1) == FAILURE
)
3892 gfc_check_stat (gfc_expr
*name
, gfc_expr
*array
)
3894 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
3896 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
3899 if (type_check (array
, 1, BT_INTEGER
) == FAILURE
3900 || kind_value_check (array
, 1, gfc_default_integer_kind
) == FAILURE
)
3903 if (array_check (array
, 1) == FAILURE
)
3911 gfc_check_stat_sub (gfc_expr
*name
, gfc_expr
*array
, gfc_expr
*status
)
3913 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
3915 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
3918 if (type_check (array
, 1, BT_INTEGER
) == FAILURE
3919 || kind_value_check (array
, 1, gfc_default_integer_kind
) == FAILURE
)
3922 if (array_check (array
, 1) == FAILURE
)
3928 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
3929 || kind_value_check (array
, 1, gfc_default_integer_kind
) == FAILURE
)
3932 if (scalar_check (status
, 2) == FAILURE
)
3940 gfc_check_image_index (gfc_expr
*coarray
, gfc_expr
*sub
)
3944 if (gfc_option
.coarray
== GFC_FCOARRAY_NONE
)
3946 gfc_fatal_error ("Coarrays disabled at %C, use -fcoarray= to enable");
3950 if (coarray_check (coarray
, 0) == FAILURE
)
3955 gfc_error ("%s argument to IMAGE_INDEX must be a rank one array at %L",
3956 gfc_current_intrinsic_arg
[1]->name
, &sub
->where
);
3960 if (gfc_array_size (sub
, &nelems
) == SUCCESS
)
3962 int corank
= gfc_get_corank (coarray
);
3964 if (mpz_cmp_ui (nelems
, corank
) != 0)
3966 gfc_error ("The number of array elements of the SUB argument to "
3967 "IMAGE_INDEX at %L shall be %d (corank) not %d",
3968 &sub
->where
, corank
, (int) mpz_get_si (nelems
));
3980 gfc_check_this_image (gfc_expr
*coarray
, gfc_expr
*dim
)
3982 if (gfc_option
.coarray
== GFC_FCOARRAY_NONE
)
3984 gfc_fatal_error ("Coarrays disabled at %C, use -fcoarray= to enable");
3988 if (dim
!= NULL
&& coarray
== NULL
)
3990 gfc_error ("DIM argument without ARRAY argument not allowed for THIS_IMAGE "
3991 "intrinsic at %L", &dim
->where
);
3995 if (coarray
== NULL
)
3998 if (coarray_check (coarray
, 0) == FAILURE
)
4003 if (dim_check (dim
, 1, false) == FAILURE
)
4006 if (dim_corank_check (dim
, coarray
) == FAILURE
)
4013 /* Calculate the sizes for transfer, used by gfc_check_transfer and also
4014 by gfc_simplify_transfer. Return FAILURE if we cannot do so. */
4017 gfc_calculate_transfer_sizes (gfc_expr
*source
, gfc_expr
*mold
, gfc_expr
*size
,
4018 size_t *source_size
, size_t *result_size
,
4019 size_t *result_length_p
)
4021 size_t result_elt_size
;
4023 gfc_expr
*mold_element
;
4025 if (source
->expr_type
== EXPR_FUNCTION
)
4028 if (size
&& size
->expr_type
!= EXPR_CONSTANT
)
4031 /* Calculate the size of the source. */
4032 if (source
->expr_type
== EXPR_ARRAY
4033 && gfc_array_size (source
, &tmp
) == FAILURE
)
4036 *source_size
= gfc_target_expr_size (source
);
4037 if (*source_size
== 0)
4040 mold_element
= mold
->expr_type
== EXPR_ARRAY
4041 ? gfc_constructor_first (mold
->value
.constructor
)->expr
4044 /* Determine the size of the element. */
4045 result_elt_size
= gfc_target_expr_size (mold_element
);
4046 if (result_elt_size
== 0)
4049 if (mold
->expr_type
== EXPR_ARRAY
|| mold
->rank
|| size
)
4054 result_length
= (size_t)mpz_get_ui (size
->value
.integer
);
4057 result_length
= *source_size
/ result_elt_size
;
4058 if (result_length
* result_elt_size
< *source_size
)
4062 *result_size
= result_length
* result_elt_size
;
4063 if (result_length_p
)
4064 *result_length_p
= result_length
;
4067 *result_size
= result_elt_size
;
4074 gfc_check_transfer (gfc_expr
*source
, gfc_expr
*mold
, gfc_expr
*size
)
4079 if (mold
->ts
.type
== BT_HOLLERITH
)
4081 gfc_error ("'MOLD' argument of 'TRANSFER' intrinsic at %L must not be %s",
4082 &mold
->where
, gfc_basic_typename (BT_HOLLERITH
));
4088 if (type_check (size
, 2, BT_INTEGER
) == FAILURE
)
4091 if (scalar_check (size
, 2) == FAILURE
)
4094 if (nonoptional_check (size
, 2) == FAILURE
)
4098 if (!gfc_option
.warn_surprising
)
4101 /* If we can't calculate the sizes, we cannot check any more.
4102 Return SUCCESS for that case. */
4104 if (gfc_calculate_transfer_sizes (source
, mold
, size
, &source_size
,
4105 &result_size
, NULL
) == FAILURE
)
4108 if (source_size
< result_size
)
4109 gfc_warning("Intrinsic TRANSFER at %L has partly undefined result: "
4110 "source size %ld < result size %ld", &source
->where
,
4111 (long) source_size
, (long) result_size
);
4118 gfc_check_transpose (gfc_expr
*matrix
)
4120 if (rank_check (matrix
, 0, 2) == FAILURE
)
4128 gfc_check_ubound (gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
4130 if (array_check (array
, 0) == FAILURE
)
4133 if (dim_check (dim
, 1, false) == FAILURE
)
4136 if (dim_rank_check (dim
, array
, 0) == FAILURE
)
4139 if (kind_check (kind
, 2, BT_INTEGER
) == FAILURE
)
4141 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "'%s' intrinsic "
4142 "with KIND argument at %L",
4143 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
4151 gfc_check_ucobound (gfc_expr
*coarray
, gfc_expr
*dim
, gfc_expr
*kind
)
4153 if (gfc_option
.coarray
== GFC_FCOARRAY_NONE
)
4155 gfc_fatal_error ("Coarrays disabled at %C, use -fcoarray= to enable");
4159 if (coarray_check (coarray
, 0) == FAILURE
)
4164 if (dim_check (dim
, 1, false) == FAILURE
)
4167 if (dim_corank_check (dim
, coarray
) == FAILURE
)
4171 if (kind_check (kind
, 2, BT_INTEGER
) == FAILURE
)
4179 gfc_check_unpack (gfc_expr
*vector
, gfc_expr
*mask
, gfc_expr
*field
)
4183 if (rank_check (vector
, 0, 1) == FAILURE
)
4186 if (array_check (mask
, 1) == FAILURE
)
4189 if (type_check (mask
, 1, BT_LOGICAL
) == FAILURE
)
4192 if (same_type_check (vector
, 0, field
, 2) == FAILURE
)
4195 if (mask
->expr_type
== EXPR_ARRAY
4196 && gfc_array_size (vector
, &vector_size
) == SUCCESS
)
4198 int mask_true_count
= 0;
4199 gfc_constructor
*mask_ctor
;
4200 mask_ctor
= gfc_constructor_first (mask
->value
.constructor
);
4203 if (mask_ctor
->expr
->expr_type
!= EXPR_CONSTANT
)
4205 mask_true_count
= 0;
4209 if (mask_ctor
->expr
->value
.logical
)
4212 mask_ctor
= gfc_constructor_next (mask_ctor
);
4215 if (mpz_get_si (vector_size
) < mask_true_count
)
4217 gfc_error ("'%s' argument of '%s' intrinsic at %L must "
4218 "provide at least as many elements as there "
4219 "are .TRUE. values in '%s' (%ld/%d)",
4220 gfc_current_intrinsic_arg
[0]->name
, gfc_current_intrinsic
,
4221 &vector
->where
, gfc_current_intrinsic_arg
[1]->name
,
4222 mpz_get_si (vector_size
), mask_true_count
);
4226 mpz_clear (vector_size
);
4229 if (mask
->rank
!= field
->rank
&& field
->rank
!= 0)
4231 gfc_error ("'%s' argument of '%s' intrinsic at %L must have "
4232 "the same rank as '%s' or be a scalar",
4233 gfc_current_intrinsic_arg
[2]->name
, gfc_current_intrinsic
,
4234 &field
->where
, gfc_current_intrinsic_arg
[1]->name
);
4238 if (mask
->rank
== field
->rank
)
4241 for (i
= 0; i
< field
->rank
; i
++)
4242 if (! identical_dimen_shape (mask
, i
, field
, i
))
4244 gfc_error ("'%s' and '%s' arguments of '%s' intrinsic at %L "
4245 "must have identical shape.",
4246 gfc_current_intrinsic_arg
[2]->name
,
4247 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
4257 gfc_check_verify (gfc_expr
*x
, gfc_expr
*y
, gfc_expr
*z
, gfc_expr
*kind
)
4259 if (type_check (x
, 0, BT_CHARACTER
) == FAILURE
)
4262 if (same_type_check (x
, 0, y
, 1) == FAILURE
)
4265 if (z
!= NULL
&& type_check (z
, 2, BT_LOGICAL
) == FAILURE
)
4268 if (kind_check (kind
, 3, BT_INTEGER
) == FAILURE
)
4270 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "'%s' intrinsic "
4271 "with KIND argument at %L",
4272 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
4280 gfc_check_trim (gfc_expr
*x
)
4282 if (type_check (x
, 0, BT_CHARACTER
) == FAILURE
)
4285 if (scalar_check (x
, 0) == FAILURE
)
4293 gfc_check_ttynam (gfc_expr
*unit
)
4295 if (scalar_check (unit
, 0) == FAILURE
)
4298 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
4305 /* Common check function for the half a dozen intrinsics that have a
4306 single real argument. */
4309 gfc_check_x (gfc_expr
*x
)
4311 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
4318 /************* Check functions for intrinsic subroutines *************/
4321 gfc_check_cpu_time (gfc_expr
*time
)
4323 if (scalar_check (time
, 0) == FAILURE
)
4326 if (type_check (time
, 0, BT_REAL
) == FAILURE
)
4329 if (variable_check (time
, 0, false) == FAILURE
)
4337 gfc_check_date_and_time (gfc_expr
*date
, gfc_expr
*time
,
4338 gfc_expr
*zone
, gfc_expr
*values
)
4342 if (type_check (date
, 0, BT_CHARACTER
) == FAILURE
)
4344 if (kind_value_check (date
, 0, gfc_default_character_kind
) == FAILURE
)
4346 if (scalar_check (date
, 0) == FAILURE
)
4348 if (variable_check (date
, 0, false) == FAILURE
)
4354 if (type_check (time
, 1, BT_CHARACTER
) == FAILURE
)
4356 if (kind_value_check (time
, 1, gfc_default_character_kind
) == FAILURE
)
4358 if (scalar_check (time
, 1) == FAILURE
)
4360 if (variable_check (time
, 1, false) == FAILURE
)
4366 if (type_check (zone
, 2, BT_CHARACTER
) == FAILURE
)
4368 if (kind_value_check (zone
, 2, gfc_default_character_kind
) == FAILURE
)
4370 if (scalar_check (zone
, 2) == FAILURE
)
4372 if (variable_check (zone
, 2, false) == FAILURE
)
4378 if (type_check (values
, 3, BT_INTEGER
) == FAILURE
)
4380 if (array_check (values
, 3) == FAILURE
)
4382 if (rank_check (values
, 3, 1) == FAILURE
)
4384 if (variable_check (values
, 3, false) == FAILURE
)
4393 gfc_check_mvbits (gfc_expr
*from
, gfc_expr
*frompos
, gfc_expr
*len
,
4394 gfc_expr
*to
, gfc_expr
*topos
)
4396 if (type_check (from
, 0, BT_INTEGER
) == FAILURE
)
4399 if (type_check (frompos
, 1, BT_INTEGER
) == FAILURE
)
4402 if (type_check (len
, 2, BT_INTEGER
) == FAILURE
)
4405 if (same_type_check (from
, 0, to
, 3) == FAILURE
)
4408 if (variable_check (to
, 3, false) == FAILURE
)
4411 if (type_check (topos
, 4, BT_INTEGER
) == FAILURE
)
4414 if (nonnegative_check ("frompos", frompos
) == FAILURE
)
4417 if (nonnegative_check ("topos", topos
) == FAILURE
)
4420 if (nonnegative_check ("len", len
) == FAILURE
)
4423 if (less_than_bitsize2 ("from", from
, "frompos", frompos
, "len", len
)
4427 if (less_than_bitsize2 ("to", to
, "topos", topos
, "len", len
) == FAILURE
)
4435 gfc_check_random_number (gfc_expr
*harvest
)
4437 if (type_check (harvest
, 0, BT_REAL
) == FAILURE
)
4440 if (variable_check (harvest
, 0, false) == FAILURE
)
4448 gfc_check_random_seed (gfc_expr
*size
, gfc_expr
*put
, gfc_expr
*get
)
4450 unsigned int nargs
= 0, kiss_size
;
4451 locus
*where
= NULL
;
4452 mpz_t put_size
, get_size
;
4453 bool have_gfc_real_16
; /* Try and mimic HAVE_GFC_REAL_16 in libgfortran. */
4455 have_gfc_real_16
= gfc_validate_kind (BT_REAL
, 16, true) != -1;
4457 /* Keep the number of bytes in sync with kiss_size in
4458 libgfortran/intrinsics/random.c. */
4459 kiss_size
= (have_gfc_real_16
? 48 : 32) / gfc_default_integer_kind
;
4463 if (size
->expr_type
!= EXPR_VARIABLE
4464 || !size
->symtree
->n
.sym
->attr
.optional
)
4467 if (scalar_check (size
, 0) == FAILURE
)
4470 if (type_check (size
, 0, BT_INTEGER
) == FAILURE
)
4473 if (variable_check (size
, 0, false) == FAILURE
)
4476 if (kind_value_check (size
, 0, gfc_default_integer_kind
) == FAILURE
)
4482 if (put
->expr_type
!= EXPR_VARIABLE
4483 || !put
->symtree
->n
.sym
->attr
.optional
)
4486 where
= &put
->where
;
4489 if (array_check (put
, 1) == FAILURE
)
4492 if (rank_check (put
, 1, 1) == FAILURE
)
4495 if (type_check (put
, 1, BT_INTEGER
) == FAILURE
)
4498 if (kind_value_check (put
, 1, gfc_default_integer_kind
) == FAILURE
)
4501 if (gfc_array_size (put
, &put_size
) == SUCCESS
4502 && mpz_get_ui (put_size
) < kiss_size
)
4503 gfc_error ("Size of '%s' argument of '%s' intrinsic at %L "
4504 "too small (%i/%i)",
4505 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
4506 where
, (int) mpz_get_ui (put_size
), kiss_size
);
4511 if (get
->expr_type
!= EXPR_VARIABLE
4512 || !get
->symtree
->n
.sym
->attr
.optional
)
4515 where
= &get
->where
;
4518 if (array_check (get
, 2) == FAILURE
)
4521 if (rank_check (get
, 2, 1) == FAILURE
)
4524 if (type_check (get
, 2, BT_INTEGER
) == FAILURE
)
4527 if (variable_check (get
, 2, false) == FAILURE
)
4530 if (kind_value_check (get
, 2, gfc_default_integer_kind
) == FAILURE
)
4533 if (gfc_array_size (get
, &get_size
) == SUCCESS
4534 && mpz_get_ui (get_size
) < kiss_size
)
4535 gfc_error ("Size of '%s' argument of '%s' intrinsic at %L "
4536 "too small (%i/%i)",
4537 gfc_current_intrinsic_arg
[2]->name
, gfc_current_intrinsic
,
4538 where
, (int) mpz_get_ui (get_size
), kiss_size
);
4541 /* RANDOM_SEED may not have more than one non-optional argument. */
4543 gfc_error ("Too many arguments to %s at %L", gfc_current_intrinsic
, where
);
4550 gfc_check_second_sub (gfc_expr
*time
)
4552 if (scalar_check (time
, 0) == FAILURE
)
4555 if (type_check (time
, 0, BT_REAL
) == FAILURE
)
4558 if (kind_value_check(time
, 0, 4) == FAILURE
)
4565 /* The arguments of SYSTEM_CLOCK are scalar, integer variables. Note,
4566 count, count_rate, and count_max are all optional arguments */
4569 gfc_check_system_clock (gfc_expr
*count
, gfc_expr
*count_rate
,
4570 gfc_expr
*count_max
)
4574 if (scalar_check (count
, 0) == FAILURE
)
4577 if (type_check (count
, 0, BT_INTEGER
) == FAILURE
)
4580 if (variable_check (count
, 0, false) == FAILURE
)
4584 if (count_rate
!= NULL
)
4586 if (scalar_check (count_rate
, 1) == FAILURE
)
4589 if (type_check (count_rate
, 1, BT_INTEGER
) == FAILURE
)
4592 if (variable_check (count_rate
, 1, false) == FAILURE
)
4596 && same_type_check (count
, 0, count_rate
, 1) == FAILURE
)
4601 if (count_max
!= NULL
)
4603 if (scalar_check (count_max
, 2) == FAILURE
)
4606 if (type_check (count_max
, 2, BT_INTEGER
) == FAILURE
)
4609 if (variable_check (count_max
, 2, false) == FAILURE
)
4613 && same_type_check (count
, 0, count_max
, 2) == FAILURE
)
4616 if (count_rate
!= NULL
4617 && same_type_check (count_rate
, 1, count_max
, 2) == FAILURE
)
4626 gfc_check_irand (gfc_expr
*x
)
4631 if (scalar_check (x
, 0) == FAILURE
)
4634 if (type_check (x
, 0, BT_INTEGER
) == FAILURE
)
4637 if (kind_value_check(x
, 0, 4) == FAILURE
)
4645 gfc_check_alarm_sub (gfc_expr
*seconds
, gfc_expr
*handler
, gfc_expr
*status
)
4647 if (scalar_check (seconds
, 0) == FAILURE
)
4649 if (type_check (seconds
, 0, BT_INTEGER
) == FAILURE
)
4652 if (int_or_proc_check (handler
, 1) == FAILURE
)
4654 if (handler
->ts
.type
== BT_INTEGER
&& scalar_check (handler
, 1) == FAILURE
)
4660 if (scalar_check (status
, 2) == FAILURE
)
4662 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
4664 if (kind_value_check (status
, 2, gfc_default_integer_kind
) == FAILURE
)
4672 gfc_check_rand (gfc_expr
*x
)
4677 if (scalar_check (x
, 0) == FAILURE
)
4680 if (type_check (x
, 0, BT_INTEGER
) == FAILURE
)
4683 if (kind_value_check(x
, 0, 4) == FAILURE
)
4691 gfc_check_srand (gfc_expr
*x
)
4693 if (scalar_check (x
, 0) == FAILURE
)
4696 if (type_check (x
, 0, BT_INTEGER
) == FAILURE
)
4699 if (kind_value_check(x
, 0, 4) == FAILURE
)
4707 gfc_check_ctime_sub (gfc_expr
*time
, gfc_expr
*result
)
4709 if (scalar_check (time
, 0) == FAILURE
)
4711 if (type_check (time
, 0, BT_INTEGER
) == FAILURE
)
4714 if (type_check (result
, 1, BT_CHARACTER
) == FAILURE
)
4716 if (kind_value_check (result
, 1, gfc_default_character_kind
) == FAILURE
)
4724 gfc_check_dtime_etime (gfc_expr
*x
)
4726 if (array_check (x
, 0) == FAILURE
)
4729 if (rank_check (x
, 0, 1) == FAILURE
)
4732 if (variable_check (x
, 0, false) == FAILURE
)
4735 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
4738 if (kind_value_check(x
, 0, 4) == FAILURE
)
4746 gfc_check_dtime_etime_sub (gfc_expr
*values
, gfc_expr
*time
)
4748 if (array_check (values
, 0) == FAILURE
)
4751 if (rank_check (values
, 0, 1) == FAILURE
)
4754 if (variable_check (values
, 0, false) == FAILURE
)
4757 if (type_check (values
, 0, BT_REAL
) == FAILURE
)
4760 if (kind_value_check(values
, 0, 4) == FAILURE
)
4763 if (scalar_check (time
, 1) == FAILURE
)
4766 if (type_check (time
, 1, BT_REAL
) == FAILURE
)
4769 if (kind_value_check(time
, 1, 4) == FAILURE
)
4777 gfc_check_fdate_sub (gfc_expr
*date
)
4779 if (type_check (date
, 0, BT_CHARACTER
) == FAILURE
)
4781 if (kind_value_check (date
, 0, gfc_default_character_kind
) == FAILURE
)
4789 gfc_check_gerror (gfc_expr
*msg
)
4791 if (type_check (msg
, 0, BT_CHARACTER
) == FAILURE
)
4793 if (kind_value_check (msg
, 0, gfc_default_character_kind
) == FAILURE
)
4801 gfc_check_getcwd_sub (gfc_expr
*cwd
, gfc_expr
*status
)
4803 if (type_check (cwd
, 0, BT_CHARACTER
) == FAILURE
)
4805 if (kind_value_check (cwd
, 0, gfc_default_character_kind
) == FAILURE
)
4811 if (scalar_check (status
, 1) == FAILURE
)
4814 if (type_check (status
, 1, BT_INTEGER
) == FAILURE
)
4822 gfc_check_getarg (gfc_expr
*pos
, gfc_expr
*value
)
4824 if (type_check (pos
, 0, BT_INTEGER
) == FAILURE
)
4827 if (pos
->ts
.kind
> gfc_default_integer_kind
)
4829 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of a kind "
4830 "not wider than the default kind (%d)",
4831 gfc_current_intrinsic_arg
[0]->name
, gfc_current_intrinsic
,
4832 &pos
->where
, gfc_default_integer_kind
);
4836 if (type_check (value
, 1, BT_CHARACTER
) == FAILURE
)
4838 if (kind_value_check (value
, 1, gfc_default_character_kind
) == FAILURE
)
4846 gfc_check_getlog (gfc_expr
*msg
)
4848 if (type_check (msg
, 0, BT_CHARACTER
) == FAILURE
)
4850 if (kind_value_check (msg
, 0, gfc_default_character_kind
) == FAILURE
)
4858 gfc_check_exit (gfc_expr
*status
)
4863 if (type_check (status
, 0, BT_INTEGER
) == FAILURE
)
4866 if (scalar_check (status
, 0) == FAILURE
)
4874 gfc_check_flush (gfc_expr
*unit
)
4879 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
4882 if (scalar_check (unit
, 0) == FAILURE
)
4890 gfc_check_free (gfc_expr
*i
)
4892 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
4895 if (scalar_check (i
, 0) == FAILURE
)
4903 gfc_check_hostnm (gfc_expr
*name
)
4905 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
4907 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
4915 gfc_check_hostnm_sub (gfc_expr
*name
, gfc_expr
*status
)
4917 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
4919 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
4925 if (scalar_check (status
, 1) == FAILURE
)
4928 if (type_check (status
, 1, BT_INTEGER
) == FAILURE
)
4936 gfc_check_itime_idate (gfc_expr
*values
)
4938 if (array_check (values
, 0) == FAILURE
)
4941 if (rank_check (values
, 0, 1) == FAILURE
)
4944 if (variable_check (values
, 0, false) == FAILURE
)
4947 if (type_check (values
, 0, BT_INTEGER
) == FAILURE
)
4950 if (kind_value_check(values
, 0, gfc_default_integer_kind
) == FAILURE
)
4958 gfc_check_ltime_gmtime (gfc_expr
*time
, gfc_expr
*values
)
4960 if (type_check (time
, 0, BT_INTEGER
) == FAILURE
)
4963 if (kind_value_check(time
, 0, gfc_default_integer_kind
) == FAILURE
)
4966 if (scalar_check (time
, 0) == FAILURE
)
4969 if (array_check (values
, 1) == FAILURE
)
4972 if (rank_check (values
, 1, 1) == FAILURE
)
4975 if (variable_check (values
, 1, false) == FAILURE
)
4978 if (type_check (values
, 1, BT_INTEGER
) == FAILURE
)
4981 if (kind_value_check(values
, 1, gfc_default_integer_kind
) == FAILURE
)
4989 gfc_check_ttynam_sub (gfc_expr
*unit
, gfc_expr
*name
)
4991 if (scalar_check (unit
, 0) == FAILURE
)
4994 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
4997 if (type_check (name
, 1, BT_CHARACTER
) == FAILURE
)
4999 if (kind_value_check (name
, 1, gfc_default_character_kind
) == FAILURE
)
5007 gfc_check_isatty (gfc_expr
*unit
)
5012 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
5015 if (scalar_check (unit
, 0) == FAILURE
)
5023 gfc_check_isnan (gfc_expr
*x
)
5025 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
5033 gfc_check_perror (gfc_expr
*string
)
5035 if (type_check (string
, 0, BT_CHARACTER
) == FAILURE
)
5037 if (kind_value_check (string
, 0, gfc_default_character_kind
) == FAILURE
)
5045 gfc_check_umask (gfc_expr
*mask
)
5047 if (type_check (mask
, 0, BT_INTEGER
) == FAILURE
)
5050 if (scalar_check (mask
, 0) == FAILURE
)
5058 gfc_check_umask_sub (gfc_expr
*mask
, gfc_expr
*old
)
5060 if (type_check (mask
, 0, BT_INTEGER
) == FAILURE
)
5063 if (scalar_check (mask
, 0) == FAILURE
)
5069 if (scalar_check (old
, 1) == FAILURE
)
5072 if (type_check (old
, 1, BT_INTEGER
) == FAILURE
)
5080 gfc_check_unlink (gfc_expr
*name
)
5082 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
5084 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
5092 gfc_check_unlink_sub (gfc_expr
*name
, gfc_expr
*status
)
5094 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
5096 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
5102 if (scalar_check (status
, 1) == FAILURE
)
5105 if (type_check (status
, 1, BT_INTEGER
) == FAILURE
)
5113 gfc_check_signal (gfc_expr
*number
, gfc_expr
*handler
)
5115 if (scalar_check (number
, 0) == FAILURE
)
5117 if (type_check (number
, 0, BT_INTEGER
) == FAILURE
)
5120 if (int_or_proc_check (handler
, 1) == FAILURE
)
5122 if (handler
->ts
.type
== BT_INTEGER
&& scalar_check (handler
, 1) == FAILURE
)
5130 gfc_check_signal_sub (gfc_expr
*number
, gfc_expr
*handler
, gfc_expr
*status
)
5132 if (scalar_check (number
, 0) == FAILURE
)
5134 if (type_check (number
, 0, BT_INTEGER
) == FAILURE
)
5137 if (int_or_proc_check (handler
, 1) == FAILURE
)
5139 if (handler
->ts
.type
== BT_INTEGER
&& scalar_check (handler
, 1) == FAILURE
)
5145 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
5147 if (scalar_check (status
, 2) == FAILURE
)
5155 gfc_check_system_sub (gfc_expr
*cmd
, gfc_expr
*status
)
5157 if (type_check (cmd
, 0, BT_CHARACTER
) == FAILURE
)
5159 if (kind_value_check (cmd
, 0, gfc_default_character_kind
) == FAILURE
)
5162 if (scalar_check (status
, 1) == FAILURE
)
5165 if (type_check (status
, 1, BT_INTEGER
) == FAILURE
)
5168 if (kind_value_check (status
, 1, gfc_default_integer_kind
) == FAILURE
)
5175 /* This is used for the GNU intrinsics AND, OR and XOR. */
5177 gfc_check_and (gfc_expr
*i
, gfc_expr
*j
)
5179 if (i
->ts
.type
!= BT_INTEGER
&& i
->ts
.type
!= BT_LOGICAL
)
5181 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
5182 "or LOGICAL", gfc_current_intrinsic_arg
[0]->name
,
5183 gfc_current_intrinsic
, &i
->where
);
5187 if (j
->ts
.type
!= BT_INTEGER
&& j
->ts
.type
!= BT_LOGICAL
)
5189 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
5190 "or LOGICAL", gfc_current_intrinsic_arg
[1]->name
,
5191 gfc_current_intrinsic
, &j
->where
);
5195 if (i
->ts
.type
!= j
->ts
.type
)
5197 gfc_error ("'%s' and '%s' arguments of '%s' intrinsic at %L must "
5198 "have the same type", gfc_current_intrinsic_arg
[0]->name
,
5199 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
5204 if (scalar_check (i
, 0) == FAILURE
)
5207 if (scalar_check (j
, 1) == FAILURE
)
5215 gfc_check_storage_size (gfc_expr
*a ATTRIBUTE_UNUSED
, gfc_expr
*kind
)
5220 if (type_check (kind
, 1, BT_INTEGER
) == FAILURE
)
5223 if (scalar_check (kind
, 1) == FAILURE
)
5226 if (kind
->expr_type
!= EXPR_CONSTANT
)
5228 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a constant",
5229 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,