2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
3 Free Software Foundation, Inc.
4 Contributed by Andy Vaught & Katherine Holcomb
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
23 /* These functions check to see if an argument list is compatible with
24 a particular intrinsic function or subroutine. Presence of
25 required arguments has already been established, the argument list
26 has been sorted into the right order and has NULL arguments in the
27 correct places for missing optional arguments. */
33 #include "intrinsic.h"
34 #include "constructor.h"
35 #include "target-memory.h"
38 /* Make sure an expression is a scalar. */
41 scalar_check (gfc_expr
*e
, int n
)
46 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a scalar",
47 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
,
54 /* Check the type of an expression. */
57 type_check (gfc_expr
*e
, int n
, bt type
)
59 if (e
->ts
.type
== type
)
62 gfc_error ("'%s' argument of '%s' intrinsic at %L must be %s",
63 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
,
64 &e
->where
, gfc_basic_typename (type
));
70 /* Check that the expression is a numeric type. */
73 numeric_check (gfc_expr
*e
, int n
)
75 if (gfc_numeric_ts (&e
->ts
))
78 /* If the expression has not got a type, check if its namespace can
79 offer a default type. */
80 if ((e
->expr_type
== EXPR_VARIABLE
|| e
->expr_type
== EXPR_VARIABLE
)
81 && e
->symtree
->n
.sym
->ts
.type
== BT_UNKNOWN
82 && gfc_set_default_type (e
->symtree
->n
.sym
, 0,
83 e
->symtree
->n
.sym
->ns
) == SUCCESS
84 && gfc_numeric_ts (&e
->symtree
->n
.sym
->ts
))
86 e
->ts
= e
->symtree
->n
.sym
->ts
;
90 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a numeric type",
91 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
,
98 /* Check that an expression is integer or real. */
101 int_or_real_check (gfc_expr
*e
, int n
)
103 if (e
->ts
.type
!= BT_INTEGER
&& e
->ts
.type
!= BT_REAL
)
105 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
106 "or REAL", gfc_current_intrinsic_arg
[n
]->name
,
107 gfc_current_intrinsic
, &e
->where
);
115 /* Check that an expression is real or complex. */
118 real_or_complex_check (gfc_expr
*e
, int n
)
120 if (e
->ts
.type
!= BT_REAL
&& e
->ts
.type
!= BT_COMPLEX
)
122 gfc_error ("'%s' argument of '%s' intrinsic at %L must be REAL "
123 "or COMPLEX", gfc_current_intrinsic_arg
[n
]->name
,
124 gfc_current_intrinsic
, &e
->where
);
132 /* Check that an expression is INTEGER or PROCEDURE. */
135 int_or_proc_check (gfc_expr
*e
, int n
)
137 if (e
->ts
.type
!= BT_INTEGER
&& e
->ts
.type
!= BT_PROCEDURE
)
139 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
140 "or PROCEDURE", gfc_current_intrinsic_arg
[n
]->name
,
141 gfc_current_intrinsic
, &e
->where
);
149 /* Check that the expression is an optional constant integer
150 and that it specifies a valid kind for that type. */
153 kind_check (gfc_expr
*k
, int n
, bt type
)
160 if (type_check (k
, n
, BT_INTEGER
) == FAILURE
)
163 if (scalar_check (k
, n
) == FAILURE
)
166 if (k
->expr_type
!= EXPR_CONSTANT
)
168 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a constant",
169 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
,
174 if (gfc_extract_int (k
, &kind
) != NULL
175 || gfc_validate_kind (type
, kind
, true) < 0)
177 gfc_error ("Invalid kind for %s at %L", gfc_basic_typename (type
),
186 /* Make sure the expression is a double precision real. */
189 double_check (gfc_expr
*d
, int n
)
191 if (type_check (d
, n
, BT_REAL
) == FAILURE
)
194 if (d
->ts
.kind
!= gfc_default_double_kind
)
196 gfc_error ("'%s' argument of '%s' intrinsic at %L must be double "
197 "precision", gfc_current_intrinsic_arg
[n
]->name
,
198 gfc_current_intrinsic
, &d
->where
);
207 coarray_check (gfc_expr
*e
, int n
)
209 if (!gfc_is_coarray (e
))
211 gfc_error ("Expected coarray variable as '%s' argument to the %s "
212 "intrinsic at %L", gfc_current_intrinsic_arg
[n
]->name
,
213 gfc_current_intrinsic
, &e
->where
);
221 /* Make sure the expression is a logical array. */
224 logical_array_check (gfc_expr
*array
, int n
)
226 if (array
->ts
.type
!= BT_LOGICAL
|| array
->rank
== 0)
228 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a logical "
229 "array", gfc_current_intrinsic_arg
[n
]->name
,
230 gfc_current_intrinsic
, &array
->where
);
238 /* Make sure an expression is an array. */
241 array_check (gfc_expr
*e
, int n
)
246 gfc_error ("'%s' argument of '%s' intrinsic at %L must be an array",
247 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
,
254 /* If expr is a constant, then check to ensure that it is greater than
258 nonnegative_check (const char *arg
, gfc_expr
*expr
)
262 if (expr
->expr_type
== EXPR_CONSTANT
)
264 gfc_extract_int (expr
, &i
);
267 gfc_error ("'%s' at %L must be nonnegative", arg
, &expr
->where
);
276 /* If expr2 is constant, then check that the value is less than
277 (less than or equal to, if 'or_equal' is true) bit_size(expr1). */
280 less_than_bitsize1 (const char *arg1
, gfc_expr
*expr1
, const char *arg2
,
281 gfc_expr
*expr2
, bool or_equal
)
285 if (expr2
->expr_type
== EXPR_CONSTANT
)
287 gfc_extract_int (expr2
, &i2
);
288 i3
= gfc_validate_kind (BT_INTEGER
, expr1
->ts
.kind
, false);
290 /* For ISHFT[C], check that |shift| <= bit_size(i). */
296 if (i2
> gfc_integer_kinds
[i3
].bit_size
)
298 gfc_error ("The absolute value of SHIFT at %L must be less "
299 "than or equal to BIT_SIZE('%s')",
300 &expr2
->where
, arg1
);
307 if (i2
> gfc_integer_kinds
[i3
].bit_size
)
309 gfc_error ("'%s' at %L must be less than "
310 "or equal to BIT_SIZE('%s')",
311 arg2
, &expr2
->where
, arg1
);
317 if (i2
>= gfc_integer_kinds
[i3
].bit_size
)
319 gfc_error ("'%s' at %L must be less than BIT_SIZE('%s')",
320 arg2
, &expr2
->where
, arg1
);
330 /* If expr is constant, then check that the value is less than or equal
331 to the bit_size of the kind k. */
334 less_than_bitsizekind (const char *arg
, gfc_expr
*expr
, int k
)
338 if (expr
->expr_type
!= EXPR_CONSTANT
)
341 i
= gfc_validate_kind (BT_INTEGER
, k
, false);
342 gfc_extract_int (expr
, &val
);
344 if (val
> gfc_integer_kinds
[i
].bit_size
)
346 gfc_error ("'%s' at %L must be less than or equal to the BIT_SIZE of "
347 "INTEGER(KIND=%d)", arg
, &expr
->where
, k
);
355 /* If expr2 and expr3 are constants, then check that the value is less than
356 or equal to bit_size(expr1). */
359 less_than_bitsize2 (const char *arg1
, gfc_expr
*expr1
, const char *arg2
,
360 gfc_expr
*expr2
, const char *arg3
, gfc_expr
*expr3
)
364 if (expr2
->expr_type
== EXPR_CONSTANT
&& expr3
->expr_type
== EXPR_CONSTANT
)
366 gfc_extract_int (expr2
, &i2
);
367 gfc_extract_int (expr3
, &i3
);
369 i3
= gfc_validate_kind (BT_INTEGER
, expr1
->ts
.kind
, false);
370 if (i2
> gfc_integer_kinds
[i3
].bit_size
)
372 gfc_error ("'%s + %s' at %L must be less than or equal "
374 arg2
, arg3
, &expr2
->where
, arg1
);
382 /* Make sure two expressions have the same type. */
385 same_type_check (gfc_expr
*e
, int n
, gfc_expr
*f
, int m
)
387 if (gfc_compare_types (&e
->ts
, &f
->ts
))
390 gfc_error ("'%s' argument of '%s' intrinsic at %L must be the same type "
391 "and kind as '%s'", gfc_current_intrinsic_arg
[m
]->name
,
392 gfc_current_intrinsic
, &f
->where
,
393 gfc_current_intrinsic_arg
[n
]->name
);
399 /* Make sure that an expression has a certain (nonzero) rank. */
402 rank_check (gfc_expr
*e
, int n
, int rank
)
407 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of rank %d",
408 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
,
415 /* Make sure a variable expression is not an optional dummy argument. */
418 nonoptional_check (gfc_expr
*e
, int n
)
420 if (e
->expr_type
== EXPR_VARIABLE
&& e
->symtree
->n
.sym
->attr
.optional
)
422 gfc_error ("'%s' argument of '%s' intrinsic at %L must not be OPTIONAL",
423 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
,
427 /* TODO: Recursive check on nonoptional variables? */
433 /* Check for ALLOCATABLE attribute. */
436 allocatable_check (gfc_expr
*e
, int n
)
438 symbol_attribute attr
;
440 attr
= gfc_variable_attr (e
, NULL
);
441 if (!attr
.allocatable
)
443 gfc_error ("'%s' argument of '%s' intrinsic at %L must be ALLOCATABLE",
444 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
,
453 /* Check that an expression has a particular kind. */
456 kind_value_check (gfc_expr
*e
, int n
, int k
)
461 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of kind %d",
462 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
,
469 /* Make sure an expression is a variable. */
472 variable_check (gfc_expr
*e
, int n
, bool allow_proc
)
474 if (e
->expr_type
== EXPR_VARIABLE
475 && e
->symtree
->n
.sym
->attr
.intent
== INTENT_IN
476 && (gfc_current_intrinsic_arg
[n
]->intent
== INTENT_OUT
477 || gfc_current_intrinsic_arg
[n
]->intent
== INTENT_INOUT
))
479 gfc_error ("'%s' argument of '%s' intrinsic at %L cannot be INTENT(IN)",
480 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
,
485 if (e
->expr_type
== EXPR_VARIABLE
486 && e
->symtree
->n
.sym
->attr
.flavor
!= FL_PARAMETER
488 || !e
->symtree
->n
.sym
->attr
.function
489 || (e
->symtree
->n
.sym
== e
->symtree
->n
.sym
->result
490 && (e
->symtree
->n
.sym
== gfc_current_ns
->proc_name
491 || (gfc_current_ns
->parent
493 == gfc_current_ns
->parent
->proc_name
)))))
496 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a variable",
497 gfc_current_intrinsic_arg
[n
]->name
, gfc_current_intrinsic
, &e
->where
);
503 /* Check the common DIM parameter for correctness. */
506 dim_check (gfc_expr
*dim
, int n
, bool optional
)
511 if (type_check (dim
, n
, BT_INTEGER
) == FAILURE
)
514 if (scalar_check (dim
, n
) == FAILURE
)
517 if (!optional
&& nonoptional_check (dim
, n
) == FAILURE
)
524 /* If a coarray DIM parameter is a constant, make sure that it is greater than
525 zero and less than or equal to the corank of the given array. */
528 dim_corank_check (gfc_expr
*dim
, gfc_expr
*array
)
532 gcc_assert (array
->expr_type
== EXPR_VARIABLE
);
534 if (dim
->expr_type
!= EXPR_CONSTANT
)
537 corank
= gfc_get_corank (array
);
539 if (mpz_cmp_ui (dim
->value
.integer
, 1) < 0
540 || mpz_cmp_ui (dim
->value
.integer
, corank
) > 0)
542 gfc_error ("'dim' argument of '%s' intrinsic at %L is not a valid "
543 "codimension index", gfc_current_intrinsic
, &dim
->where
);
552 /* If a DIM parameter is a constant, make sure that it is greater than
553 zero and less than or equal to the rank of the given array. If
554 allow_assumed is zero then dim must be less than the rank of the array
555 for assumed size arrays. */
558 dim_rank_check (gfc_expr
*dim
, gfc_expr
*array
, int allow_assumed
)
566 if (dim
->expr_type
!= EXPR_CONSTANT
)
569 if (array
->expr_type
== EXPR_FUNCTION
&& array
->value
.function
.isym
570 && array
->value
.function
.isym
->id
== GFC_ISYM_SPREAD
)
571 rank
= array
->rank
+ 1;
575 if (array
->expr_type
== EXPR_VARIABLE
)
577 ar
= gfc_find_array_ref (array
);
578 if (ar
->as
->type
== AS_ASSUMED_SIZE
580 && ar
->type
!= AR_ELEMENT
581 && ar
->type
!= AR_SECTION
)
585 if (mpz_cmp_ui (dim
->value
.integer
, 1) < 0
586 || mpz_cmp_ui (dim
->value
.integer
, rank
) > 0)
588 gfc_error ("'dim' argument of '%s' intrinsic at %L is not a valid "
589 "dimension index", gfc_current_intrinsic
, &dim
->where
);
598 /* Compare the size of a along dimension ai with the size of b along
599 dimension bi, returning 0 if they are known not to be identical,
600 and 1 if they are identical, or if this cannot be determined. */
603 identical_dimen_shape (gfc_expr
*a
, int ai
, gfc_expr
*b
, int bi
)
605 mpz_t a_size
, b_size
;
608 gcc_assert (a
->rank
> ai
);
609 gcc_assert (b
->rank
> bi
);
613 if (gfc_array_dimen_size (a
, ai
, &a_size
) == SUCCESS
)
615 if (gfc_array_dimen_size (b
, bi
, &b_size
) == SUCCESS
)
617 if (mpz_cmp (a_size
, b_size
) != 0)
627 /* Calculate the length of a character variable, including substrings.
628 Strip away parentheses if necessary. Return -1 if no length could
632 gfc_var_strlen (const gfc_expr
*a
)
636 while (a
->expr_type
== EXPR_OP
&& a
->value
.op
.op
== INTRINSIC_PARENTHESES
)
639 for (ra
= a
->ref
; ra
!= NULL
&& ra
->type
!= REF_SUBSTRING
; ra
= ra
->next
)
646 if (ra
->u
.ss
.start
->expr_type
== EXPR_CONSTANT
647 && ra
->u
.ss
.end
->expr_type
== EXPR_CONSTANT
)
649 start_a
= mpz_get_si (ra
->u
.ss
.start
->value
.integer
);
650 end_a
= mpz_get_si (ra
->u
.ss
.end
->value
.integer
);
651 return end_a
- start_a
+ 1;
653 else if (gfc_dep_compare_expr (ra
->u
.ss
.start
, ra
->u
.ss
.end
) == 0)
659 if (a
->ts
.u
.cl
&& a
->ts
.u
.cl
->length
660 && a
->ts
.u
.cl
->length
->expr_type
== EXPR_CONSTANT
)
661 return mpz_get_si (a
->ts
.u
.cl
->length
->value
.integer
);
662 else if (a
->expr_type
== EXPR_CONSTANT
663 && (a
->ts
.u
.cl
== NULL
|| a
->ts
.u
.cl
->length
== NULL
))
664 return a
->value
.character
.length
;
670 /* Check whether two character expressions have the same length;
671 returns SUCCESS if they have or if the length cannot be determined,
672 otherwise return FAILURE and raise a gfc_error. */
675 gfc_check_same_strlen (const gfc_expr
*a
, const gfc_expr
*b
, const char *name
)
679 len_a
= gfc_var_strlen(a
);
680 len_b
= gfc_var_strlen(b
);
682 if (len_a
== -1 || len_b
== -1 || len_a
== len_b
)
686 gfc_error ("Unequal character lengths (%ld/%ld) in %s at %L",
687 len_a
, len_b
, name
, &a
->where
);
693 /***** Check functions *****/
695 /* Check subroutine suitable for intrinsics taking a real argument and
696 a kind argument for the result. */
699 check_a_kind (gfc_expr
*a
, gfc_expr
*kind
, bt type
)
701 if (type_check (a
, 0, BT_REAL
) == FAILURE
)
703 if (kind_check (kind
, 1, type
) == FAILURE
)
710 /* Check subroutine suitable for ceiling, floor and nint. */
713 gfc_check_a_ikind (gfc_expr
*a
, gfc_expr
*kind
)
715 return check_a_kind (a
, kind
, BT_INTEGER
);
719 /* Check subroutine suitable for aint, anint. */
722 gfc_check_a_xkind (gfc_expr
*a
, gfc_expr
*kind
)
724 return check_a_kind (a
, kind
, BT_REAL
);
729 gfc_check_abs (gfc_expr
*a
)
731 if (numeric_check (a
, 0) == FAILURE
)
739 gfc_check_achar (gfc_expr
*a
, gfc_expr
*kind
)
741 if (type_check (a
, 0, BT_INTEGER
) == FAILURE
)
743 if (kind_check (kind
, 1, BT_CHARACTER
) == FAILURE
)
751 gfc_check_access_func (gfc_expr
*name
, gfc_expr
*mode
)
753 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
754 || scalar_check (name
, 0) == FAILURE
)
756 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
759 if (type_check (mode
, 1, BT_CHARACTER
) == FAILURE
760 || scalar_check (mode
, 1) == FAILURE
)
762 if (kind_value_check (mode
, 1, gfc_default_character_kind
) == FAILURE
)
770 gfc_check_all_any (gfc_expr
*mask
, gfc_expr
*dim
)
772 if (logical_array_check (mask
, 0) == FAILURE
)
775 if (dim_check (dim
, 1, false) == FAILURE
)
778 if (dim_rank_check (dim
, mask
, 0) == FAILURE
)
786 gfc_check_allocated (gfc_expr
*array
)
788 if (variable_check (array
, 0, false) == FAILURE
)
790 if (allocatable_check (array
, 0) == FAILURE
)
797 /* Common check function where the first argument must be real or
798 integer and the second argument must be the same as the first. */
801 gfc_check_a_p (gfc_expr
*a
, gfc_expr
*p
)
803 if (int_or_real_check (a
, 0) == FAILURE
)
806 if (a
->ts
.type
!= p
->ts
.type
)
808 gfc_error ("'%s' and '%s' arguments of '%s' intrinsic at %L must "
809 "have the same type", gfc_current_intrinsic_arg
[0]->name
,
810 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
815 if (a
->ts
.kind
!= p
->ts
.kind
)
817 if (gfc_notify_std (GFC_STD_GNU
, "Extension: Different type kinds at %L",
818 &p
->where
) == FAILURE
)
827 gfc_check_x_yd (gfc_expr
*x
, gfc_expr
*y
)
829 if (double_check (x
, 0) == FAILURE
|| double_check (y
, 1) == FAILURE
)
837 gfc_check_associated (gfc_expr
*pointer
, gfc_expr
*target
)
839 symbol_attribute attr1
, attr2
;
844 where
= &pointer
->where
;
846 if (pointer
->expr_type
== EXPR_VARIABLE
|| pointer
->expr_type
== EXPR_FUNCTION
)
847 attr1
= gfc_expr_attr (pointer
);
848 else if (pointer
->expr_type
== EXPR_NULL
)
851 gcc_assert (0); /* Pointer must be a variable or a function. */
853 if (!attr1
.pointer
&& !attr1
.proc_pointer
)
855 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a POINTER",
856 gfc_current_intrinsic_arg
[0]->name
, gfc_current_intrinsic
,
862 if (attr1
.pointer
&& gfc_is_coindexed (pointer
))
864 gfc_error ("'%s' argument of '%s' intrinsic at %L shall not be "
865 "conindexed", gfc_current_intrinsic_arg
[0]->name
,
866 gfc_current_intrinsic
, &pointer
->where
);
870 /* Target argument is optional. */
874 where
= &target
->where
;
875 if (target
->expr_type
== EXPR_NULL
)
878 if (target
->expr_type
== EXPR_VARIABLE
|| target
->expr_type
== EXPR_FUNCTION
)
879 attr2
= gfc_expr_attr (target
);
882 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a pointer "
883 "or target VARIABLE or FUNCTION",
884 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
889 if (attr1
.pointer
&& !attr2
.pointer
&& !attr2
.target
)
891 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a POINTER "
892 "or a TARGET", gfc_current_intrinsic_arg
[1]->name
,
893 gfc_current_intrinsic
, &target
->where
);
898 if (attr1
.pointer
&& gfc_is_coindexed (target
))
900 gfc_error ("'%s' argument of '%s' intrinsic at %L shall not be "
901 "conindexed", gfc_current_intrinsic_arg
[1]->name
,
902 gfc_current_intrinsic
, &target
->where
);
907 if (same_type_check (pointer
, 0, target
, 1) == FAILURE
)
909 if (rank_check (target
, 0, pointer
->rank
) == FAILURE
)
911 if (target
->rank
> 0)
913 for (i
= 0; i
< target
->rank
; i
++)
914 if (target
->ref
->u
.ar
.dimen_type
[i
] == DIMEN_VECTOR
)
916 gfc_error ("Array section with a vector subscript at %L shall not "
917 "be the target of a pointer",
927 gfc_error ("NULL pointer at %L is not permitted as actual argument "
928 "of '%s' intrinsic function", where
, gfc_current_intrinsic
);
935 gfc_check_atan_2 (gfc_expr
*y
, gfc_expr
*x
)
937 /* gfc_notify_std would be a wast of time as the return value
938 is seemingly used only for the generic resolution. The error
939 will be: Too many arguments. */
940 if ((gfc_option
.allow_std
& GFC_STD_F2008
) == 0)
943 return gfc_check_atan2 (y
, x
);
948 gfc_check_atan2 (gfc_expr
*y
, gfc_expr
*x
)
950 if (type_check (y
, 0, BT_REAL
) == FAILURE
)
952 if (same_type_check (y
, 0, x
, 1) == FAILURE
)
960 gfc_check_atomic (gfc_expr
*atom
, gfc_expr
*value
)
962 if (!(atom
->ts
.type
== BT_INTEGER
&& atom
->ts
.kind
== gfc_atomic_int_kind
)
963 && !(atom
->ts
.type
== BT_LOGICAL
964 && atom
->ts
.kind
== gfc_atomic_logical_kind
))
966 gfc_error ("ATOM argument at %L to intrinsic function %s shall be an "
967 "integer of ATOMIC_INT_KIND or a logical of "
968 "ATOMIC_LOGICAL_KIND", &atom
->where
, gfc_current_intrinsic
);
972 if (!gfc_expr_attr (atom
).codimension
)
974 gfc_error ("ATOM argument at %L of the %s intrinsic function shall be a "
975 "coarray or coindexed", &atom
->where
, gfc_current_intrinsic
);
979 if (atom
->ts
.type
!= value
->ts
.type
)
981 gfc_error ("ATOM and VALUE argument of the %s intrinsic function shall "
982 "have the same type at %L", gfc_current_intrinsic
,
992 gfc_check_atomic_def (gfc_expr
*atom
, gfc_expr
*value
)
994 if (scalar_check (atom
, 0) == FAILURE
|| scalar_check (value
, 1) == FAILURE
)
997 if (gfc_check_vardef_context (atom
, false, false, NULL
) == FAILURE
)
999 gfc_error ("ATOM argument of the %s intrinsic function at %L shall be "
1000 "definable", gfc_current_intrinsic
, &atom
->where
);
1004 return gfc_check_atomic (atom
, value
);
1009 gfc_check_atomic_ref (gfc_expr
*value
, gfc_expr
*atom
)
1011 if (scalar_check (value
, 0) == FAILURE
|| scalar_check (atom
, 1) == FAILURE
)
1014 if (gfc_check_vardef_context (value
, false, false, NULL
) == FAILURE
)
1016 gfc_error ("VALUE argument of the %s intrinsic function at %L shall be "
1017 "definable", gfc_current_intrinsic
, &value
->where
);
1021 return gfc_check_atomic (atom
, value
);
1025 /* BESJN and BESYN functions. */
1028 gfc_check_besn (gfc_expr
*n
, gfc_expr
*x
)
1030 if (type_check (n
, 0, BT_INTEGER
) == FAILURE
)
1032 if (n
->expr_type
== EXPR_CONSTANT
)
1035 gfc_extract_int (n
, &i
);
1036 if (i
< 0 && gfc_notify_std (GFC_STD_GNU
, "Extension: Negative argument "
1037 "N at %L", &n
->where
) == FAILURE
)
1041 if (type_check (x
, 1, BT_REAL
) == FAILURE
)
1048 /* Transformational version of the Bessel JN and YN functions. */
1051 gfc_check_bessel_n2 (gfc_expr
*n1
, gfc_expr
*n2
, gfc_expr
*x
)
1053 if (type_check (n1
, 0, BT_INTEGER
) == FAILURE
)
1055 if (scalar_check (n1
, 0) == FAILURE
)
1057 if (nonnegative_check("N1", n1
) == FAILURE
)
1060 if (type_check (n2
, 1, BT_INTEGER
) == FAILURE
)
1062 if (scalar_check (n2
, 1) == FAILURE
)
1064 if (nonnegative_check("N2", n2
) == FAILURE
)
1067 if (type_check (x
, 2, BT_REAL
) == FAILURE
)
1069 if (scalar_check (x
, 2) == FAILURE
)
1077 gfc_check_bge_bgt_ble_blt (gfc_expr
*i
, gfc_expr
*j
)
1079 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1082 if (type_check (j
, 1, BT_INTEGER
) == FAILURE
)
1090 gfc_check_bitfcn (gfc_expr
*i
, gfc_expr
*pos
)
1092 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1095 if (type_check (pos
, 1, BT_INTEGER
) == FAILURE
)
1098 if (nonnegative_check ("pos", pos
) == FAILURE
)
1101 if (less_than_bitsize1 ("i", i
, "pos", pos
, false) == FAILURE
)
1109 gfc_check_char (gfc_expr
*i
, gfc_expr
*kind
)
1111 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1113 if (kind_check (kind
, 1, BT_CHARACTER
) == FAILURE
)
1121 gfc_check_chdir (gfc_expr
*dir
)
1123 if (type_check (dir
, 0, BT_CHARACTER
) == FAILURE
)
1125 if (kind_value_check (dir
, 0, gfc_default_character_kind
) == FAILURE
)
1133 gfc_check_chdir_sub (gfc_expr
*dir
, gfc_expr
*status
)
1135 if (type_check (dir
, 0, BT_CHARACTER
) == FAILURE
)
1137 if (kind_value_check (dir
, 0, gfc_default_character_kind
) == FAILURE
)
1143 if (type_check (status
, 1, BT_INTEGER
) == FAILURE
)
1145 if (scalar_check (status
, 1) == FAILURE
)
1153 gfc_check_chmod (gfc_expr
*name
, gfc_expr
*mode
)
1155 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
1157 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
1160 if (type_check (mode
, 1, BT_CHARACTER
) == FAILURE
)
1162 if (kind_value_check (mode
, 1, gfc_default_character_kind
) == FAILURE
)
1170 gfc_check_chmod_sub (gfc_expr
*name
, gfc_expr
*mode
, gfc_expr
*status
)
1172 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
1174 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
1177 if (type_check (mode
, 1, BT_CHARACTER
) == FAILURE
)
1179 if (kind_value_check (mode
, 1, gfc_default_character_kind
) == FAILURE
)
1185 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
1188 if (scalar_check (status
, 2) == FAILURE
)
1196 gfc_check_cmplx (gfc_expr
*x
, gfc_expr
*y
, gfc_expr
*kind
)
1198 if (numeric_check (x
, 0) == FAILURE
)
1203 if (numeric_check (y
, 1) == FAILURE
)
1206 if (x
->ts
.type
== BT_COMPLEX
)
1208 gfc_error ("'%s' argument of '%s' intrinsic at %L must not be "
1209 "present if 'x' is COMPLEX",
1210 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
1215 if (y
->ts
.type
== BT_COMPLEX
)
1217 gfc_error ("'%s' argument of '%s' intrinsic at %L must have a type "
1218 "of either REAL or INTEGER",
1219 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
1226 if (kind_check (kind
, 2, BT_COMPLEX
) == FAILURE
)
1234 gfc_check_complex (gfc_expr
*x
, gfc_expr
*y
)
1236 if (int_or_real_check (x
, 0) == FAILURE
)
1238 if (scalar_check (x
, 0) == FAILURE
)
1241 if (int_or_real_check (y
, 1) == FAILURE
)
1243 if (scalar_check (y
, 1) == FAILURE
)
1251 gfc_check_count (gfc_expr
*mask
, gfc_expr
*dim
, gfc_expr
*kind
)
1253 if (logical_array_check (mask
, 0) == FAILURE
)
1255 if (dim_check (dim
, 1, false) == FAILURE
)
1257 if (dim_rank_check (dim
, mask
, 0) == FAILURE
)
1259 if (kind_check (kind
, 2, BT_INTEGER
) == FAILURE
)
1261 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "Fortran 2003: '%s' intrinsic "
1262 "with KIND argument at %L",
1263 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
1271 gfc_check_cshift (gfc_expr
*array
, gfc_expr
*shift
, gfc_expr
*dim
)
1273 if (array_check (array
, 0) == FAILURE
)
1276 if (type_check (shift
, 1, BT_INTEGER
) == FAILURE
)
1279 if (dim_check (dim
, 2, true) == FAILURE
)
1282 if (dim_rank_check (dim
, array
, false) == FAILURE
)
1285 if (array
->rank
== 1 || shift
->rank
== 0)
1287 if (scalar_check (shift
, 1) == FAILURE
)
1290 else if (shift
->rank
== array
->rank
- 1)
1295 else if (dim
->expr_type
== EXPR_CONSTANT
)
1296 gfc_extract_int (dim
, &d
);
1303 for (i
= 0, j
= 0; i
< array
->rank
; i
++)
1306 if (!identical_dimen_shape (array
, i
, shift
, j
))
1308 gfc_error ("'%s' argument of '%s' intrinsic at %L has "
1309 "invalid shape in dimension %d (%ld/%ld)",
1310 gfc_current_intrinsic_arg
[1]->name
,
1311 gfc_current_intrinsic
, &shift
->where
, i
+ 1,
1312 mpz_get_si (array
->shape
[i
]),
1313 mpz_get_si (shift
->shape
[j
]));
1323 gfc_error ("'%s' argument of intrinsic '%s' at %L of must have rank "
1324 "%d or be a scalar", gfc_current_intrinsic_arg
[1]->name
,
1325 gfc_current_intrinsic
, &shift
->where
, array
->rank
- 1);
1334 gfc_check_ctime (gfc_expr
*time
)
1336 if (scalar_check (time
, 0) == FAILURE
)
1339 if (type_check (time
, 0, BT_INTEGER
) == FAILURE
)
1346 gfc_try
gfc_check_datan2 (gfc_expr
*y
, gfc_expr
*x
)
1348 if (double_check (y
, 0) == FAILURE
|| double_check (x
, 1) == FAILURE
)
1355 gfc_check_dcmplx (gfc_expr
*x
, gfc_expr
*y
)
1357 if (numeric_check (x
, 0) == FAILURE
)
1362 if (numeric_check (y
, 1) == FAILURE
)
1365 if (x
->ts
.type
== BT_COMPLEX
)
1367 gfc_error ("'%s' argument of '%s' intrinsic at %L must not be "
1368 "present if 'x' is COMPLEX",
1369 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
1374 if (y
->ts
.type
== BT_COMPLEX
)
1376 gfc_error ("'%s' argument of '%s' intrinsic at %L must have a type "
1377 "of either REAL or INTEGER",
1378 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
1389 gfc_check_dble (gfc_expr
*x
)
1391 if (numeric_check (x
, 0) == FAILURE
)
1399 gfc_check_digits (gfc_expr
*x
)
1401 if (int_or_real_check (x
, 0) == FAILURE
)
1409 gfc_check_dot_product (gfc_expr
*vector_a
, gfc_expr
*vector_b
)
1411 switch (vector_a
->ts
.type
)
1414 if (type_check (vector_b
, 1, BT_LOGICAL
) == FAILURE
)
1421 if (numeric_check (vector_b
, 1) == FAILURE
)
1426 gfc_error ("'%s' argument of '%s' intrinsic at %L must be numeric "
1427 "or LOGICAL", gfc_current_intrinsic_arg
[0]->name
,
1428 gfc_current_intrinsic
, &vector_a
->where
);
1432 if (rank_check (vector_a
, 0, 1) == FAILURE
)
1435 if (rank_check (vector_b
, 1, 1) == FAILURE
)
1438 if (! identical_dimen_shape (vector_a
, 0, vector_b
, 0))
1440 gfc_error ("Different shape for arguments '%s' and '%s' at %L for "
1441 "intrinsic 'dot_product'", gfc_current_intrinsic_arg
[0]->name
,
1442 gfc_current_intrinsic_arg
[1]->name
, &vector_a
->where
);
1451 gfc_check_dprod (gfc_expr
*x
, gfc_expr
*y
)
1453 if (type_check (x
, 0, BT_REAL
) == FAILURE
1454 || type_check (y
, 1, BT_REAL
) == FAILURE
)
1457 if (x
->ts
.kind
!= gfc_default_real_kind
)
1459 gfc_error ("'%s' argument of '%s' intrinsic at %L must be default "
1460 "real", gfc_current_intrinsic_arg
[0]->name
,
1461 gfc_current_intrinsic
, &x
->where
);
1465 if (y
->ts
.kind
!= gfc_default_real_kind
)
1467 gfc_error ("'%s' argument of '%s' intrinsic at %L must be default "
1468 "real", gfc_current_intrinsic_arg
[1]->name
,
1469 gfc_current_intrinsic
, &y
->where
);
1478 gfc_check_dshift (gfc_expr
*i
, gfc_expr
*j
, gfc_expr
*shift
)
1480 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1483 if (type_check (j
, 1, BT_INTEGER
) == FAILURE
)
1486 if (same_type_check (i
, 0, j
, 1) == FAILURE
)
1489 if (type_check (shift
, 2, BT_INTEGER
) == FAILURE
)
1492 if (nonnegative_check ("SHIFT", shift
) == FAILURE
)
1495 if (less_than_bitsize1 ("I", i
, "SHIFT", shift
, true) == FAILURE
)
1503 gfc_check_eoshift (gfc_expr
*array
, gfc_expr
*shift
, gfc_expr
*boundary
,
1506 if (array_check (array
, 0) == FAILURE
)
1509 if (type_check (shift
, 1, BT_INTEGER
) == FAILURE
)
1512 if (dim_check (dim
, 3, true) == FAILURE
)
1515 if (dim_rank_check (dim
, array
, false) == FAILURE
)
1518 if (array
->rank
== 1 || shift
->rank
== 0)
1520 if (scalar_check (shift
, 1) == FAILURE
)
1523 else if (shift
->rank
== array
->rank
- 1)
1528 else if (dim
->expr_type
== EXPR_CONSTANT
)
1529 gfc_extract_int (dim
, &d
);
1536 for (i
= 0, j
= 0; i
< array
->rank
; i
++)
1539 if (!identical_dimen_shape (array
, i
, shift
, j
))
1541 gfc_error ("'%s' argument of '%s' intrinsic at %L has "
1542 "invalid shape in dimension %d (%ld/%ld)",
1543 gfc_current_intrinsic_arg
[1]->name
,
1544 gfc_current_intrinsic
, &shift
->where
, i
+ 1,
1545 mpz_get_si (array
->shape
[i
]),
1546 mpz_get_si (shift
->shape
[j
]));
1556 gfc_error ("'%s' argument of intrinsic '%s' at %L of must have rank "
1557 "%d or be a scalar", gfc_current_intrinsic_arg
[1]->name
,
1558 gfc_current_intrinsic
, &shift
->where
, array
->rank
- 1);
1562 if (boundary
!= NULL
)
1564 if (same_type_check (array
, 0, boundary
, 2) == FAILURE
)
1567 if (array
->rank
== 1 || boundary
->rank
== 0)
1569 if (scalar_check (boundary
, 2) == FAILURE
)
1572 else if (boundary
->rank
== array
->rank
- 1)
1574 if (gfc_check_conformance (shift
, boundary
,
1575 "arguments '%s' and '%s' for "
1577 gfc_current_intrinsic_arg
[1]->name
,
1578 gfc_current_intrinsic_arg
[2]->name
,
1579 gfc_current_intrinsic
) == FAILURE
)
1584 gfc_error ("'%s' argument of intrinsic '%s' at %L of must have "
1585 "rank %d or be a scalar",
1586 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
1587 &shift
->where
, array
->rank
- 1);
1596 gfc_check_float (gfc_expr
*a
)
1598 if (type_check (a
, 0, BT_INTEGER
) == FAILURE
)
1601 if ((a
->ts
.kind
!= gfc_default_integer_kind
)
1602 && gfc_notify_std (GFC_STD_GNU
, "GNU extension: non-default INTEGER "
1603 "kind argument to %s intrinsic at %L",
1604 gfc_current_intrinsic
, &a
->where
) == FAILURE
)
1610 /* A single complex argument. */
1613 gfc_check_fn_c (gfc_expr
*a
)
1615 if (type_check (a
, 0, BT_COMPLEX
) == FAILURE
)
1621 /* A single real argument. */
1624 gfc_check_fn_r (gfc_expr
*a
)
1626 if (type_check (a
, 0, BT_REAL
) == FAILURE
)
1632 /* A single double argument. */
1635 gfc_check_fn_d (gfc_expr
*a
)
1637 if (double_check (a
, 0) == FAILURE
)
1643 /* A single real or complex argument. */
1646 gfc_check_fn_rc (gfc_expr
*a
)
1648 if (real_or_complex_check (a
, 0) == FAILURE
)
1656 gfc_check_fn_rc2008 (gfc_expr
*a
)
1658 if (real_or_complex_check (a
, 0) == FAILURE
)
1661 if (a
->ts
.type
== BT_COMPLEX
1662 && gfc_notify_std (GFC_STD_F2008
, "Fortran 2008: COMPLEX argument '%s' "
1663 "argument of '%s' intrinsic at %L",
1664 gfc_current_intrinsic_arg
[0]->name
,
1665 gfc_current_intrinsic
, &a
->where
) == FAILURE
)
1673 gfc_check_fnum (gfc_expr
*unit
)
1675 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
1678 if (scalar_check (unit
, 0) == FAILURE
)
1686 gfc_check_huge (gfc_expr
*x
)
1688 if (int_or_real_check (x
, 0) == FAILURE
)
1696 gfc_check_hypot (gfc_expr
*x
, gfc_expr
*y
)
1698 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
1700 if (same_type_check (x
, 0, y
, 1) == FAILURE
)
1707 /* Check that the single argument is an integer. */
1710 gfc_check_i (gfc_expr
*i
)
1712 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1720 gfc_check_iand (gfc_expr
*i
, gfc_expr
*j
)
1722 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1725 if (type_check (j
, 1, BT_INTEGER
) == FAILURE
)
1728 if (i
->ts
.kind
!= j
->ts
.kind
)
1730 if (gfc_notify_std (GFC_STD_GNU
, "Extension: Different type kinds at %L",
1731 &i
->where
) == FAILURE
)
1740 gfc_check_ibits (gfc_expr
*i
, gfc_expr
*pos
, gfc_expr
*len
)
1742 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1745 if (type_check (pos
, 1, BT_INTEGER
) == FAILURE
)
1748 if (type_check (len
, 2, BT_INTEGER
) == FAILURE
)
1751 if (nonnegative_check ("pos", pos
) == FAILURE
)
1754 if (nonnegative_check ("len", len
) == FAILURE
)
1757 if (less_than_bitsize2 ("i", i
, "pos", pos
, "len", len
) == FAILURE
)
1765 gfc_check_ichar_iachar (gfc_expr
*c
, gfc_expr
*kind
)
1769 if (type_check (c
, 0, BT_CHARACTER
) == FAILURE
)
1772 if (kind_check (kind
, 1, BT_INTEGER
) == FAILURE
)
1775 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "Fortran 2003: '%s' intrinsic "
1776 "with KIND argument at %L",
1777 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
1780 if (c
->expr_type
== EXPR_VARIABLE
|| c
->expr_type
== EXPR_SUBSTRING
)
1786 /* Substring references don't have the charlength set. */
1788 while (ref
&& ref
->type
!= REF_SUBSTRING
)
1791 gcc_assert (ref
== NULL
|| ref
->type
== REF_SUBSTRING
);
1795 /* Check that the argument is length one. Non-constant lengths
1796 can't be checked here, so assume they are ok. */
1797 if (c
->ts
.u
.cl
&& c
->ts
.u
.cl
->length
)
1799 /* If we already have a length for this expression then use it. */
1800 if (c
->ts
.u
.cl
->length
->expr_type
!= EXPR_CONSTANT
)
1802 i
= mpz_get_si (c
->ts
.u
.cl
->length
->value
.integer
);
1809 start
= ref
->u
.ss
.start
;
1810 end
= ref
->u
.ss
.end
;
1813 if (end
== NULL
|| end
->expr_type
!= EXPR_CONSTANT
1814 || start
->expr_type
!= EXPR_CONSTANT
)
1817 i
= mpz_get_si (end
->value
.integer
) + 1
1818 - mpz_get_si (start
->value
.integer
);
1826 gfc_error ("Argument of %s at %L must be of length one",
1827 gfc_current_intrinsic
, &c
->where
);
1836 gfc_check_idnint (gfc_expr
*a
)
1838 if (double_check (a
, 0) == FAILURE
)
1846 gfc_check_ieor (gfc_expr
*i
, gfc_expr
*j
)
1848 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1851 if (type_check (j
, 1, BT_INTEGER
) == FAILURE
)
1854 if (i
->ts
.kind
!= j
->ts
.kind
)
1856 if (gfc_notify_std (GFC_STD_GNU
, "Extension: Different type kinds at %L",
1857 &i
->where
) == FAILURE
)
1866 gfc_check_index (gfc_expr
*string
, gfc_expr
*substring
, gfc_expr
*back
,
1869 if (type_check (string
, 0, BT_CHARACTER
) == FAILURE
1870 || type_check (substring
, 1, BT_CHARACTER
) == FAILURE
)
1873 if (back
!= NULL
&& type_check (back
, 2, BT_LOGICAL
) == FAILURE
)
1876 if (kind_check (kind
, 3, BT_INTEGER
) == FAILURE
)
1878 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "Fortran 2003: '%s' intrinsic "
1879 "with KIND argument at %L",
1880 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
1883 if (string
->ts
.kind
!= substring
->ts
.kind
)
1885 gfc_error ("'%s' argument of '%s' intrinsic at %L must be the same "
1886 "kind as '%s'", gfc_current_intrinsic_arg
[1]->name
,
1887 gfc_current_intrinsic
, &substring
->where
,
1888 gfc_current_intrinsic_arg
[0]->name
);
1897 gfc_check_int (gfc_expr
*x
, gfc_expr
*kind
)
1899 if (numeric_check (x
, 0) == FAILURE
)
1902 if (kind_check (kind
, 1, BT_INTEGER
) == FAILURE
)
1910 gfc_check_intconv (gfc_expr
*x
)
1912 if (numeric_check (x
, 0) == FAILURE
)
1920 gfc_check_ior (gfc_expr
*i
, gfc_expr
*j
)
1922 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
1925 if (type_check (j
, 1, BT_INTEGER
) == FAILURE
)
1928 if (i
->ts
.kind
!= j
->ts
.kind
)
1930 if (gfc_notify_std (GFC_STD_GNU
, "Extension: Different type kinds at %L",
1931 &i
->where
) == FAILURE
)
1940 gfc_check_ishft (gfc_expr
*i
, gfc_expr
*shift
)
1942 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
1943 || type_check (shift
, 1, BT_INTEGER
) == FAILURE
)
1946 if (less_than_bitsize1 ("I", i
, NULL
, shift
, true) == FAILURE
)
1954 gfc_check_ishftc (gfc_expr
*i
, gfc_expr
*shift
, gfc_expr
*size
)
1956 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
1957 || type_check (shift
, 1, BT_INTEGER
) == FAILURE
)
1964 if (type_check (size
, 2, BT_INTEGER
) == FAILURE
)
1967 if (less_than_bitsize1 ("I", i
, "SIZE", size
, true) == FAILURE
)
1970 gfc_extract_int (size
, &i3
);
1973 gfc_error ("SIZE at %L must be positive", &size
->where
);
1977 gfc_extract_int (shift
, &i2
);
1983 gfc_error ("The absolute value of SHIFT at %L must be less than "
1984 "or equal to SIZE at %L", &shift
->where
, &size
->where
);
1988 else if (less_than_bitsize1 ("I", i
, NULL
, shift
, true) == FAILURE
)
1996 gfc_check_kill (gfc_expr
*pid
, gfc_expr
*sig
)
1998 if (type_check (pid
, 0, BT_INTEGER
) == FAILURE
)
2001 if (type_check (sig
, 1, BT_INTEGER
) == FAILURE
)
2009 gfc_check_kill_sub (gfc_expr
*pid
, gfc_expr
*sig
, gfc_expr
*status
)
2011 if (type_check (pid
, 0, BT_INTEGER
) == FAILURE
)
2014 if (scalar_check (pid
, 0) == FAILURE
)
2017 if (type_check (sig
, 1, BT_INTEGER
) == FAILURE
)
2020 if (scalar_check (sig
, 1) == FAILURE
)
2026 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
2029 if (scalar_check (status
, 2) == FAILURE
)
2037 gfc_check_kind (gfc_expr
*x
)
2039 if (x
->ts
.type
== BT_DERIVED
)
2041 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a "
2042 "non-derived type", gfc_current_intrinsic_arg
[0]->name
,
2043 gfc_current_intrinsic
, &x
->where
);
2052 gfc_check_lbound (gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
2054 if (array_check (array
, 0) == FAILURE
)
2057 if (dim_check (dim
, 1, false) == FAILURE
)
2060 if (dim_rank_check (dim
, array
, 1) == FAILURE
)
2063 if (kind_check (kind
, 2, BT_INTEGER
) == FAILURE
)
2065 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "Fortran 2003: '%s' intrinsic "
2066 "with KIND argument at %L",
2067 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
2075 gfc_check_lcobound (gfc_expr
*coarray
, gfc_expr
*dim
, gfc_expr
*kind
)
2077 if (gfc_option
.coarray
== GFC_FCOARRAY_NONE
)
2079 gfc_fatal_error ("Coarrays disabled at %C, use -fcoarray= to enable");
2083 if (coarray_check (coarray
, 0) == FAILURE
)
2088 if (dim_check (dim
, 1, false) == FAILURE
)
2091 if (dim_corank_check (dim
, coarray
) == FAILURE
)
2095 if (kind_check (kind
, 2, BT_INTEGER
) == FAILURE
)
2103 gfc_check_len_lentrim (gfc_expr
*s
, gfc_expr
*kind
)
2105 if (type_check (s
, 0, BT_CHARACTER
) == FAILURE
)
2108 if (kind_check (kind
, 1, BT_INTEGER
) == FAILURE
)
2110 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "Fortran 2003: '%s' intrinsic "
2111 "with KIND argument at %L",
2112 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
2120 gfc_check_lge_lgt_lle_llt (gfc_expr
*a
, gfc_expr
*b
)
2122 if (type_check (a
, 0, BT_CHARACTER
) == FAILURE
)
2124 if (kind_value_check (a
, 0, gfc_default_character_kind
) == FAILURE
)
2127 if (type_check (b
, 1, BT_CHARACTER
) == FAILURE
)
2129 if (kind_value_check (b
, 1, gfc_default_character_kind
) == FAILURE
)
2137 gfc_check_link (gfc_expr
*path1
, gfc_expr
*path2
)
2139 if (type_check (path1
, 0, BT_CHARACTER
) == FAILURE
)
2141 if (kind_value_check (path1
, 0, gfc_default_character_kind
) == FAILURE
)
2144 if (type_check (path2
, 1, BT_CHARACTER
) == FAILURE
)
2146 if (kind_value_check (path2
, 1, gfc_default_character_kind
) == FAILURE
)
2154 gfc_check_link_sub (gfc_expr
*path1
, gfc_expr
*path2
, gfc_expr
*status
)
2156 if (type_check (path1
, 0, BT_CHARACTER
) == FAILURE
)
2158 if (kind_value_check (path1
, 0, gfc_default_character_kind
) == FAILURE
)
2161 if (type_check (path2
, 1, BT_CHARACTER
) == FAILURE
)
2163 if (kind_value_check (path2
, 0, gfc_default_character_kind
) == FAILURE
)
2169 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
2172 if (scalar_check (status
, 2) == FAILURE
)
2180 gfc_check_loc (gfc_expr
*expr
)
2182 return variable_check (expr
, 0, true);
2187 gfc_check_symlnk (gfc_expr
*path1
, gfc_expr
*path2
)
2189 if (type_check (path1
, 0, BT_CHARACTER
) == FAILURE
)
2191 if (kind_value_check (path1
, 0, gfc_default_character_kind
) == FAILURE
)
2194 if (type_check (path2
, 1, BT_CHARACTER
) == FAILURE
)
2196 if (kind_value_check (path2
, 1, gfc_default_character_kind
) == FAILURE
)
2204 gfc_check_symlnk_sub (gfc_expr
*path1
, gfc_expr
*path2
, gfc_expr
*status
)
2206 if (type_check (path1
, 0, BT_CHARACTER
) == FAILURE
)
2208 if (kind_value_check (path1
, 0, gfc_default_character_kind
) == FAILURE
)
2211 if (type_check (path2
, 1, BT_CHARACTER
) == FAILURE
)
2213 if (kind_value_check (path2
, 1, gfc_default_character_kind
) == FAILURE
)
2219 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
2222 if (scalar_check (status
, 2) == FAILURE
)
2230 gfc_check_logical (gfc_expr
*a
, gfc_expr
*kind
)
2232 if (type_check (a
, 0, BT_LOGICAL
) == FAILURE
)
2234 if (kind_check (kind
, 1, BT_LOGICAL
) == FAILURE
)
2241 /* Min/max family. */
2244 min_max_args (gfc_actual_arglist
*arg
)
2246 if (arg
== NULL
|| arg
->next
== NULL
)
2248 gfc_error ("Intrinsic '%s' at %L must have at least two arguments",
2249 gfc_current_intrinsic
, gfc_current_intrinsic_where
);
2258 check_rest (bt type
, int kind
, gfc_actual_arglist
*arglist
)
2260 gfc_actual_arglist
*arg
, *tmp
;
2265 if (min_max_args (arglist
) == FAILURE
)
2268 for (arg
= arglist
, n
=1; arg
; arg
= arg
->next
, n
++)
2271 if (x
->ts
.type
!= type
|| x
->ts
.kind
!= kind
)
2273 if (x
->ts
.type
== type
)
2275 if (gfc_notify_std (GFC_STD_GNU
, "Extension: Different type "
2276 "kinds at %L", &x
->where
) == FAILURE
)
2281 gfc_error ("'a%d' argument of '%s' intrinsic at %L must be "
2282 "%s(%d)", n
, gfc_current_intrinsic
, &x
->where
,
2283 gfc_basic_typename (type
), kind
);
2288 for (tmp
= arglist
, m
=1; tmp
!= arg
; tmp
= tmp
->next
, m
++)
2289 if (gfc_check_conformance (tmp
->expr
, x
,
2290 "arguments 'a%d' and 'a%d' for "
2291 "intrinsic '%s'", m
, n
,
2292 gfc_current_intrinsic
) == FAILURE
)
2301 gfc_check_min_max (gfc_actual_arglist
*arg
)
2305 if (min_max_args (arg
) == FAILURE
)
2310 if (x
->ts
.type
== BT_CHARACTER
)
2312 if (gfc_notify_std (GFC_STD_F2003
, "Fortran 2003: '%s' intrinsic "
2313 "with CHARACTER argument at %L",
2314 gfc_current_intrinsic
, &x
->where
) == FAILURE
)
2317 else if (x
->ts
.type
!= BT_INTEGER
&& x
->ts
.type
!= BT_REAL
)
2319 gfc_error ("'a1' argument of '%s' intrinsic at %L must be INTEGER, "
2320 "REAL or CHARACTER", gfc_current_intrinsic
, &x
->where
);
2324 return check_rest (x
->ts
.type
, x
->ts
.kind
, arg
);
2329 gfc_check_min_max_integer (gfc_actual_arglist
*arg
)
2331 return check_rest (BT_INTEGER
, gfc_default_integer_kind
, arg
);
2336 gfc_check_min_max_real (gfc_actual_arglist
*arg
)
2338 return check_rest (BT_REAL
, gfc_default_real_kind
, arg
);
2343 gfc_check_min_max_double (gfc_actual_arglist
*arg
)
2345 return check_rest (BT_REAL
, gfc_default_double_kind
, arg
);
2349 /* End of min/max family. */
2352 gfc_check_malloc (gfc_expr
*size
)
2354 if (type_check (size
, 0, BT_INTEGER
) == FAILURE
)
2357 if (scalar_check (size
, 0) == FAILURE
)
2365 gfc_check_matmul (gfc_expr
*matrix_a
, gfc_expr
*matrix_b
)
2367 if ((matrix_a
->ts
.type
!= BT_LOGICAL
) && !gfc_numeric_ts (&matrix_a
->ts
))
2369 gfc_error ("'%s' argument of '%s' intrinsic at %L must be numeric "
2370 "or LOGICAL", gfc_current_intrinsic_arg
[0]->name
,
2371 gfc_current_intrinsic
, &matrix_a
->where
);
2375 if ((matrix_b
->ts
.type
!= BT_LOGICAL
) && !gfc_numeric_ts (&matrix_b
->ts
))
2377 gfc_error ("'%s' argument of '%s' intrinsic at %L must be numeric "
2378 "or LOGICAL", gfc_current_intrinsic_arg
[1]->name
,
2379 gfc_current_intrinsic
, &matrix_b
->where
);
2383 if ((matrix_a
->ts
.type
== BT_LOGICAL
&& gfc_numeric_ts (&matrix_b
->ts
))
2384 || (gfc_numeric_ts (&matrix_a
->ts
) && matrix_b
->ts
.type
== BT_LOGICAL
))
2386 gfc_error ("Argument types of '%s' intrinsic at %L must match (%s/%s)",
2387 gfc_current_intrinsic
, &matrix_a
->where
,
2388 gfc_typename(&matrix_a
->ts
), gfc_typename(&matrix_b
->ts
));
2392 switch (matrix_a
->rank
)
2395 if (rank_check (matrix_b
, 1, 2) == FAILURE
)
2397 /* Check for case matrix_a has shape(m), matrix_b has shape (m, k). */
2398 if (!identical_dimen_shape (matrix_a
, 0, matrix_b
, 0))
2400 gfc_error ("Different shape on dimension 1 for arguments '%s' "
2401 "and '%s' at %L for intrinsic matmul",
2402 gfc_current_intrinsic_arg
[0]->name
,
2403 gfc_current_intrinsic_arg
[1]->name
, &matrix_a
->where
);
2409 if (matrix_b
->rank
!= 2)
2411 if (rank_check (matrix_b
, 1, 1) == FAILURE
)
2414 /* matrix_b has rank 1 or 2 here. Common check for the cases
2415 - matrix_a has shape (n,m) and matrix_b has shape (m, k)
2416 - matrix_a has shape (n,m) and matrix_b has shape (m). */
2417 if (!identical_dimen_shape (matrix_a
, 1, matrix_b
, 0))
2419 gfc_error ("Different shape on dimension 2 for argument '%s' and "
2420 "dimension 1 for argument '%s' at %L for intrinsic "
2421 "matmul", gfc_current_intrinsic_arg
[0]->name
,
2422 gfc_current_intrinsic_arg
[1]->name
, &matrix_a
->where
);
2428 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of rank "
2429 "1 or 2", gfc_current_intrinsic_arg
[0]->name
,
2430 gfc_current_intrinsic
, &matrix_a
->where
);
2438 /* Whoever came up with this interface was probably on something.
2439 The possibilities for the occupation of the second and third
2446 NULL MASK minloc(array, mask=m)
2449 I.e. in the case of minloc(array,mask), mask will be in the second
2450 position of the argument list and we'll have to fix that up. */
2453 gfc_check_minloc_maxloc (gfc_actual_arglist
*ap
)
2455 gfc_expr
*a
, *m
, *d
;
2458 if (int_or_real_check (a
, 0) == FAILURE
|| array_check (a
, 0) == FAILURE
)
2462 m
= ap
->next
->next
->expr
;
2464 if (m
== NULL
&& d
!= NULL
&& d
->ts
.type
== BT_LOGICAL
2465 && ap
->next
->name
== NULL
)
2469 ap
->next
->expr
= NULL
;
2470 ap
->next
->next
->expr
= m
;
2473 if (dim_check (d
, 1, false) == FAILURE
)
2476 if (dim_rank_check (d
, a
, 0) == FAILURE
)
2479 if (m
!= NULL
&& type_check (m
, 2, BT_LOGICAL
) == FAILURE
)
2483 && gfc_check_conformance (a
, m
,
2484 "arguments '%s' and '%s' for intrinsic %s",
2485 gfc_current_intrinsic_arg
[0]->name
,
2486 gfc_current_intrinsic_arg
[2]->name
,
2487 gfc_current_intrinsic
) == FAILURE
)
2494 /* Similar to minloc/maxloc, the argument list might need to be
2495 reordered for the MINVAL, MAXVAL, PRODUCT, and SUM intrinsics. The
2496 difference is that MINLOC/MAXLOC take an additional KIND argument.
2497 The possibilities are:
2503 NULL MASK minval(array, mask=m)
2506 I.e. in the case of minval(array,mask), mask will be in the second
2507 position of the argument list and we'll have to fix that up. */
2510 check_reduction (gfc_actual_arglist
*ap
)
2512 gfc_expr
*a
, *m
, *d
;
2516 m
= ap
->next
->next
->expr
;
2518 if (m
== NULL
&& d
!= NULL
&& d
->ts
.type
== BT_LOGICAL
2519 && ap
->next
->name
== NULL
)
2523 ap
->next
->expr
= NULL
;
2524 ap
->next
->next
->expr
= m
;
2527 if (dim_check (d
, 1, false) == FAILURE
)
2530 if (dim_rank_check (d
, a
, 0) == FAILURE
)
2533 if (m
!= NULL
&& type_check (m
, 2, BT_LOGICAL
) == FAILURE
)
2537 && gfc_check_conformance (a
, m
,
2538 "arguments '%s' and '%s' for intrinsic %s",
2539 gfc_current_intrinsic_arg
[0]->name
,
2540 gfc_current_intrinsic_arg
[2]->name
,
2541 gfc_current_intrinsic
) == FAILURE
)
2549 gfc_check_minval_maxval (gfc_actual_arglist
*ap
)
2551 if (int_or_real_check (ap
->expr
, 0) == FAILURE
2552 || array_check (ap
->expr
, 0) == FAILURE
)
2555 return check_reduction (ap
);
2560 gfc_check_product_sum (gfc_actual_arglist
*ap
)
2562 if (numeric_check (ap
->expr
, 0) == FAILURE
2563 || array_check (ap
->expr
, 0) == FAILURE
)
2566 return check_reduction (ap
);
2570 /* For IANY, IALL and IPARITY. */
2573 gfc_check_mask (gfc_expr
*i
, gfc_expr
*kind
)
2577 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
2580 if (nonnegative_check ("I", i
) == FAILURE
)
2583 if (kind_check (kind
, 1, BT_INTEGER
) == FAILURE
)
2587 gfc_extract_int (kind
, &k
);
2589 k
= gfc_default_integer_kind
;
2591 if (less_than_bitsizekind ("I", i
, k
) == FAILURE
)
2599 gfc_check_transf_bit_intrins (gfc_actual_arglist
*ap
)
2601 if (ap
->expr
->ts
.type
!= BT_INTEGER
)
2603 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER",
2604 gfc_current_intrinsic_arg
[0]->name
,
2605 gfc_current_intrinsic
, &ap
->expr
->where
);
2609 if (array_check (ap
->expr
, 0) == FAILURE
)
2612 return check_reduction (ap
);
2617 gfc_check_merge (gfc_expr
*tsource
, gfc_expr
*fsource
, gfc_expr
*mask
)
2619 if (same_type_check (tsource
, 0, fsource
, 1) == FAILURE
)
2622 if (type_check (mask
, 2, BT_LOGICAL
) == FAILURE
)
2625 if (tsource
->ts
.type
== BT_CHARACTER
)
2626 return gfc_check_same_strlen (tsource
, fsource
, "MERGE intrinsic");
2633 gfc_check_merge_bits (gfc_expr
*i
, gfc_expr
*j
, gfc_expr
*mask
)
2635 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
2638 if (type_check (j
, 1, BT_INTEGER
) == FAILURE
)
2641 if (type_check (mask
, 2, BT_INTEGER
) == FAILURE
)
2644 if (same_type_check (i
, 0, j
, 1) == FAILURE
)
2647 if (same_type_check (i
, 0, mask
, 2) == FAILURE
)
2655 gfc_check_move_alloc (gfc_expr
*from
, gfc_expr
*to
)
2657 if (variable_check (from
, 0, false) == FAILURE
)
2659 if (allocatable_check (from
, 0) == FAILURE
)
2662 if (variable_check (to
, 1, false) == FAILURE
)
2664 if (allocatable_check (to
, 1) == FAILURE
)
2667 if (same_type_check (to
, 1, from
, 0) == FAILURE
)
2670 if (to
->rank
!= from
->rank
)
2672 gfc_error ("the '%s' and '%s' arguments of '%s' intrinsic at %L must "
2673 "have the same rank %d/%d", gfc_current_intrinsic_arg
[0]->name
,
2674 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
2675 &to
->where
, from
->rank
, to
->rank
);
2679 if (to
->ts
.kind
!= from
->ts
.kind
)
2681 gfc_error ("the '%s' and '%s' arguments of '%s' intrinsic at %L must "
2682 "be of the same kind %d/%d",
2683 gfc_current_intrinsic_arg
[0]->name
,
2684 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
2685 &to
->where
, from
->ts
.kind
, to
->ts
.kind
);
2689 /* CLASS arguments: Make sure the vtab is present. */
2690 if (to
->ts
.type
== BT_CLASS
)
2691 gfc_find_derived_vtab (from
->ts
.u
.derived
);
2698 gfc_check_nearest (gfc_expr
*x
, gfc_expr
*s
)
2700 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
2703 if (type_check (s
, 1, BT_REAL
) == FAILURE
)
2711 gfc_check_new_line (gfc_expr
*a
)
2713 if (type_check (a
, 0, BT_CHARACTER
) == FAILURE
)
2721 gfc_check_norm2 (gfc_expr
*array
, gfc_expr
*dim
)
2723 if (type_check (array
, 0, BT_REAL
) == FAILURE
)
2726 if (array_check (array
, 0) == FAILURE
)
2729 if (dim_rank_check (dim
, array
, false) == FAILURE
)
2736 gfc_check_null (gfc_expr
*mold
)
2738 symbol_attribute attr
;
2743 if (variable_check (mold
, 0, true) == FAILURE
)
2746 attr
= gfc_variable_attr (mold
, NULL
);
2748 if (!attr
.pointer
&& !attr
.proc_pointer
&& !attr
.allocatable
)
2750 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a POINTER, "
2751 "ALLOCATABLE or procedure pointer",
2752 gfc_current_intrinsic_arg
[0]->name
,
2753 gfc_current_intrinsic
, &mold
->where
);
2757 if (attr
.allocatable
2758 && gfc_notify_std (GFC_STD_F2003
, "Fortran 2003: NULL intrinsic with "
2759 "allocatable MOLD at %L", &mold
->where
) == FAILURE
)
2763 if (gfc_is_coindexed (mold
))
2765 gfc_error ("'%s' argument of '%s' intrinsic at %L shall not be "
2766 "conindexed", gfc_current_intrinsic_arg
[0]->name
,
2767 gfc_current_intrinsic
, &mold
->where
);
2776 gfc_check_pack (gfc_expr
*array
, gfc_expr
*mask
, gfc_expr
*vector
)
2778 if (array_check (array
, 0) == FAILURE
)
2781 if (type_check (mask
, 1, BT_LOGICAL
) == FAILURE
)
2784 if (gfc_check_conformance (array
, mask
,
2785 "arguments '%s' and '%s' for intrinsic '%s'",
2786 gfc_current_intrinsic_arg
[0]->name
,
2787 gfc_current_intrinsic_arg
[1]->name
,
2788 gfc_current_intrinsic
) == FAILURE
)
2793 mpz_t array_size
, vector_size
;
2794 bool have_array_size
, have_vector_size
;
2796 if (same_type_check (array
, 0, vector
, 2) == FAILURE
)
2799 if (rank_check (vector
, 2, 1) == FAILURE
)
2802 /* VECTOR requires at least as many elements as MASK
2803 has .TRUE. values. */
2804 have_array_size
= gfc_array_size (array
, &array_size
) == SUCCESS
;
2805 have_vector_size
= gfc_array_size (vector
, &vector_size
) == SUCCESS
;
2807 if (have_vector_size
2808 && (mask
->expr_type
== EXPR_ARRAY
2809 || (mask
->expr_type
== EXPR_CONSTANT
2810 && have_array_size
)))
2812 int mask_true_values
= 0;
2814 if (mask
->expr_type
== EXPR_ARRAY
)
2816 gfc_constructor
*mask_ctor
;
2817 mask_ctor
= gfc_constructor_first (mask
->value
.constructor
);
2820 if (mask_ctor
->expr
->expr_type
!= EXPR_CONSTANT
)
2822 mask_true_values
= 0;
2826 if (mask_ctor
->expr
->value
.logical
)
2829 mask_ctor
= gfc_constructor_next (mask_ctor
);
2832 else if (mask
->expr_type
== EXPR_CONSTANT
&& mask
->value
.logical
)
2833 mask_true_values
= mpz_get_si (array_size
);
2835 if (mpz_get_si (vector_size
) < mask_true_values
)
2837 gfc_error ("'%s' argument of '%s' intrinsic at %L must "
2838 "provide at least as many elements as there "
2839 "are .TRUE. values in '%s' (%ld/%d)",
2840 gfc_current_intrinsic_arg
[2]->name
,
2841 gfc_current_intrinsic
, &vector
->where
,
2842 gfc_current_intrinsic_arg
[1]->name
,
2843 mpz_get_si (vector_size
), mask_true_values
);
2848 if (have_array_size
)
2849 mpz_clear (array_size
);
2850 if (have_vector_size
)
2851 mpz_clear (vector_size
);
2859 gfc_check_parity (gfc_expr
*mask
, gfc_expr
*dim
)
2861 if (type_check (mask
, 0, BT_LOGICAL
) == FAILURE
)
2864 if (array_check (mask
, 0) == FAILURE
)
2867 if (dim_rank_check (dim
, mask
, false) == FAILURE
)
2875 gfc_check_precision (gfc_expr
*x
)
2877 if (real_or_complex_check (x
, 0) == FAILURE
)
2885 gfc_check_present (gfc_expr
*a
)
2889 if (variable_check (a
, 0, true) == FAILURE
)
2892 sym
= a
->symtree
->n
.sym
;
2893 if (!sym
->attr
.dummy
)
2895 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of a "
2896 "dummy variable", gfc_current_intrinsic_arg
[0]->name
,
2897 gfc_current_intrinsic
, &a
->where
);
2901 if (!sym
->attr
.optional
)
2903 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of "
2904 "an OPTIONAL dummy variable",
2905 gfc_current_intrinsic_arg
[0]->name
, gfc_current_intrinsic
,
2910 /* 13.14.82 PRESENT(A)
2912 Argument. A shall be the name of an optional dummy argument that is
2913 accessible in the subprogram in which the PRESENT function reference
2917 && !(a
->ref
->next
== NULL
&& a
->ref
->type
== REF_ARRAY
2918 && (a
->ref
->u
.ar
.type
== AR_FULL
2919 || (a
->ref
->u
.ar
.type
== AR_ELEMENT
2920 && a
->ref
->u
.ar
.as
->rank
== 0))))
2922 gfc_error ("'%s' argument of '%s' intrinsic at %L must not be a "
2923 "subobject of '%s'", gfc_current_intrinsic_arg
[0]->name
,
2924 gfc_current_intrinsic
, &a
->where
, sym
->name
);
2933 gfc_check_radix (gfc_expr
*x
)
2935 if (int_or_real_check (x
, 0) == FAILURE
)
2943 gfc_check_range (gfc_expr
*x
)
2945 if (numeric_check (x
, 0) == FAILURE
)
2953 gfc_check_rank (gfc_expr
*a ATTRIBUTE_UNUSED
)
2955 /* Any data object is allowed; a "data object" is a "constant (4.1.3),
2956 variable (6), or subobject of a constant (2.4.3.2.3)" (F2008, 1.3.45). */
2958 bool is_variable
= true;
2960 /* Functions returning pointers are regarded as variable, cf. F2008, R602. */
2961 if (a
->expr_type
== EXPR_FUNCTION
)
2962 is_variable
= a
->value
.function
.esym
2963 ? a
->value
.function
.esym
->result
->attr
.pointer
2964 : a
->symtree
->n
.sym
->result
->attr
.pointer
;
2966 if (a
->expr_type
== EXPR_OP
|| a
->expr_type
== EXPR_NULL
2967 || a
->expr_type
== EXPR_COMPCALL
|| a
->expr_type
== EXPR_PPC
2970 gfc_error ("The argument of the RANK intrinsic at %L must be a data "
2971 "object", &a
->where
);
2979 /* real, float, sngl. */
2981 gfc_check_real (gfc_expr
*a
, gfc_expr
*kind
)
2983 if (numeric_check (a
, 0) == FAILURE
)
2986 if (kind_check (kind
, 1, BT_REAL
) == FAILURE
)
2994 gfc_check_rename (gfc_expr
*path1
, gfc_expr
*path2
)
2996 if (type_check (path1
, 0, BT_CHARACTER
) == FAILURE
)
2998 if (kind_value_check (path1
, 0, gfc_default_character_kind
) == FAILURE
)
3001 if (type_check (path2
, 1, BT_CHARACTER
) == FAILURE
)
3003 if (kind_value_check (path2
, 1, gfc_default_character_kind
) == FAILURE
)
3011 gfc_check_rename_sub (gfc_expr
*path1
, gfc_expr
*path2
, gfc_expr
*status
)
3013 if (type_check (path1
, 0, BT_CHARACTER
) == FAILURE
)
3015 if (kind_value_check (path1
, 0, gfc_default_character_kind
) == FAILURE
)
3018 if (type_check (path2
, 1, BT_CHARACTER
) == FAILURE
)
3020 if (kind_value_check (path2
, 1, gfc_default_character_kind
) == FAILURE
)
3026 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
3029 if (scalar_check (status
, 2) == FAILURE
)
3037 gfc_check_repeat (gfc_expr
*x
, gfc_expr
*y
)
3039 if (type_check (x
, 0, BT_CHARACTER
) == FAILURE
)
3042 if (scalar_check (x
, 0) == FAILURE
)
3045 if (type_check (y
, 0, BT_INTEGER
) == FAILURE
)
3048 if (scalar_check (y
, 1) == FAILURE
)
3056 gfc_check_reshape (gfc_expr
*source
, gfc_expr
*shape
,
3057 gfc_expr
*pad
, gfc_expr
*order
)
3063 if (array_check (source
, 0) == FAILURE
)
3066 if (rank_check (shape
, 1, 1) == FAILURE
)
3069 if (type_check (shape
, 1, BT_INTEGER
) == FAILURE
)
3072 if (gfc_array_size (shape
, &size
) != SUCCESS
)
3074 gfc_error ("'shape' argument of 'reshape' intrinsic at %L must be an "
3075 "array of constant size", &shape
->where
);
3079 shape_size
= mpz_get_ui (size
);
3082 if (shape_size
<= 0)
3084 gfc_error ("'%s' argument of '%s' intrinsic at %L is empty",
3085 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
3089 else if (shape_size
> GFC_MAX_DIMENSIONS
)
3091 gfc_error ("'shape' argument of 'reshape' intrinsic at %L has more "
3092 "than %d elements", &shape
->where
, GFC_MAX_DIMENSIONS
);
3095 else if (shape
->expr_type
== EXPR_ARRAY
)
3099 for (i
= 0; i
< shape_size
; ++i
)
3101 e
= gfc_constructor_lookup_expr (shape
->value
.constructor
, i
);
3102 if (e
->expr_type
!= EXPR_CONSTANT
)
3105 gfc_extract_int (e
, &extent
);
3108 gfc_error ("'%s' argument of '%s' intrinsic at %L has "
3109 "negative element (%d)",
3110 gfc_current_intrinsic_arg
[1]->name
,
3111 gfc_current_intrinsic
, &e
->where
, extent
);
3119 if (same_type_check (source
, 0, pad
, 2) == FAILURE
)
3122 if (array_check (pad
, 2) == FAILURE
)
3128 if (array_check (order
, 3) == FAILURE
)
3131 if (type_check (order
, 3, BT_INTEGER
) == FAILURE
)
3134 if (order
->expr_type
== EXPR_ARRAY
)
3136 int i
, order_size
, dim
, perm
[GFC_MAX_DIMENSIONS
];
3139 for (i
= 0; i
< GFC_MAX_DIMENSIONS
; ++i
)
3142 gfc_array_size (order
, &size
);
3143 order_size
= mpz_get_ui (size
);
3146 if (order_size
!= shape_size
)
3148 gfc_error ("'%s' argument of '%s' intrinsic at %L "
3149 "has wrong number of elements (%d/%d)",
3150 gfc_current_intrinsic_arg
[3]->name
,
3151 gfc_current_intrinsic
, &order
->where
,
3152 order_size
, shape_size
);
3156 for (i
= 1; i
<= order_size
; ++i
)
3158 e
= gfc_constructor_lookup_expr (order
->value
.constructor
, i
-1);
3159 if (e
->expr_type
!= EXPR_CONSTANT
)
3162 gfc_extract_int (e
, &dim
);
3164 if (dim
< 1 || dim
> order_size
)
3166 gfc_error ("'%s' argument of '%s' intrinsic at %L "
3167 "has out-of-range dimension (%d)",
3168 gfc_current_intrinsic_arg
[3]->name
,
3169 gfc_current_intrinsic
, &e
->where
, dim
);
3173 if (perm
[dim
-1] != 0)
3175 gfc_error ("'%s' argument of '%s' intrinsic at %L has "
3176 "invalid permutation of dimensions (dimension "
3178 gfc_current_intrinsic_arg
[3]->name
,
3179 gfc_current_intrinsic
, &e
->where
, dim
);
3188 if (pad
== NULL
&& shape
->expr_type
== EXPR_ARRAY
3189 && gfc_is_constant_expr (shape
)
3190 && !(source
->expr_type
== EXPR_VARIABLE
&& source
->symtree
->n
.sym
->as
3191 && source
->symtree
->n
.sym
->as
->type
== AS_ASSUMED_SIZE
))
3193 /* Check the match in size between source and destination. */
3194 if (gfc_array_size (source
, &nelems
) == SUCCESS
)
3200 mpz_init_set_ui (size
, 1);
3201 for (c
= gfc_constructor_first (shape
->value
.constructor
);
3202 c
; c
= gfc_constructor_next (c
))
3203 mpz_mul (size
, size
, c
->expr
->value
.integer
);
3205 test
= mpz_cmp (nelems
, size
) < 0 && mpz_cmp_ui (size
, 0) > 0;
3211 gfc_error ("Without padding, there are not enough elements "
3212 "in the intrinsic RESHAPE source at %L to match "
3213 "the shape", &source
->where
);
3224 gfc_check_same_type_as (gfc_expr
*a
, gfc_expr
*b
)
3227 if (a
->ts
.type
!= BT_DERIVED
&& a
->ts
.type
!= BT_CLASS
)
3229 gfc_error ("'%s' argument of '%s' intrinsic at %L "
3230 "must be of a derived type",
3231 gfc_current_intrinsic_arg
[0]->name
, gfc_current_intrinsic
,
3236 if (!gfc_type_is_extensible (a
->ts
.u
.derived
))
3238 gfc_error ("'%s' argument of '%s' intrinsic at %L "
3239 "must be of an extensible type",
3240 gfc_current_intrinsic_arg
[0]->name
, gfc_current_intrinsic
,
3245 if (b
->ts
.type
!= BT_DERIVED
&& b
->ts
.type
!= BT_CLASS
)
3247 gfc_error ("'%s' argument of '%s' intrinsic at %L "
3248 "must be of a derived type",
3249 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
3254 if (!gfc_type_is_extensible (b
->ts
.u
.derived
))
3256 gfc_error ("'%s' argument of '%s' intrinsic at %L "
3257 "must be of an extensible type",
3258 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
3268 gfc_check_scale (gfc_expr
*x
, gfc_expr
*i
)
3270 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
3273 if (type_check (i
, 1, BT_INTEGER
) == FAILURE
)
3281 gfc_check_scan (gfc_expr
*x
, gfc_expr
*y
, gfc_expr
*z
, gfc_expr
*kind
)
3283 if (type_check (x
, 0, BT_CHARACTER
) == FAILURE
)
3286 if (type_check (y
, 1, BT_CHARACTER
) == FAILURE
)
3289 if (z
!= NULL
&& type_check (z
, 2, BT_LOGICAL
) == FAILURE
)
3292 if (kind_check (kind
, 3, BT_INTEGER
) == FAILURE
)
3294 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "Fortran 2003: '%s' intrinsic "
3295 "with KIND argument at %L",
3296 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
3299 if (same_type_check (x
, 0, y
, 1) == FAILURE
)
3307 gfc_check_secnds (gfc_expr
*r
)
3309 if (type_check (r
, 0, BT_REAL
) == FAILURE
)
3312 if (kind_value_check (r
, 0, 4) == FAILURE
)
3315 if (scalar_check (r
, 0) == FAILURE
)
3323 gfc_check_selected_char_kind (gfc_expr
*name
)
3325 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
3328 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
3331 if (scalar_check (name
, 0) == FAILURE
)
3339 gfc_check_selected_int_kind (gfc_expr
*r
)
3341 if (type_check (r
, 0, BT_INTEGER
) == FAILURE
)
3344 if (scalar_check (r
, 0) == FAILURE
)
3352 gfc_check_selected_real_kind (gfc_expr
*p
, gfc_expr
*r
, gfc_expr
*radix
)
3354 if (p
== NULL
&& r
== NULL
3355 && gfc_notify_std (GFC_STD_F2008
, "Fortran 2008: SELECTED_REAL_KIND with"
3356 " neither 'P' nor 'R' argument at %L",
3357 gfc_current_intrinsic_where
) == FAILURE
)
3362 if (type_check (p
, 0, BT_INTEGER
) == FAILURE
)
3365 if (scalar_check (p
, 0) == FAILURE
)
3371 if (type_check (r
, 1, BT_INTEGER
) == FAILURE
)
3374 if (scalar_check (r
, 1) == FAILURE
)
3380 if (type_check (radix
, 1, BT_INTEGER
) == FAILURE
)
3383 if (scalar_check (radix
, 1) == FAILURE
)
3386 if (gfc_notify_std (GFC_STD_F2008
, "Fortran 2008: '%s' intrinsic with "
3387 "RADIX argument at %L", gfc_current_intrinsic
,
3388 &radix
->where
) == FAILURE
)
3397 gfc_check_set_exponent (gfc_expr
*x
, gfc_expr
*i
)
3399 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
3402 if (type_check (i
, 1, BT_INTEGER
) == FAILURE
)
3410 gfc_check_shape (gfc_expr
*source
, gfc_expr
*kind
)
3414 if (source
->rank
== 0 || source
->expr_type
!= EXPR_VARIABLE
)
3417 ar
= gfc_find_array_ref (source
);
3419 if (ar
->as
&& ar
->as
->type
== AS_ASSUMED_SIZE
&& ar
->type
== AR_FULL
)
3421 gfc_error ("'source' argument of 'shape' intrinsic at %L must not be "
3422 "an assumed size array", &source
->where
);
3426 if (kind_check (kind
, 1, BT_INTEGER
) == FAILURE
)
3428 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "Fortran 2003: '%s' intrinsic "
3429 "with KIND argument at %L",
3430 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
3438 gfc_check_shift (gfc_expr
*i
, gfc_expr
*shift
)
3440 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
3443 if (type_check (shift
, 0, BT_INTEGER
) == FAILURE
)
3446 if (nonnegative_check ("SHIFT", shift
) == FAILURE
)
3449 if (less_than_bitsize1 ("I", i
, "SHIFT", shift
, true) == FAILURE
)
3457 gfc_check_sign (gfc_expr
*a
, gfc_expr
*b
)
3459 if (int_or_real_check (a
, 0) == FAILURE
)
3462 if (same_type_check (a
, 0, b
, 1) == FAILURE
)
3470 gfc_check_size (gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
3472 if (array_check (array
, 0) == FAILURE
)
3475 if (dim_check (dim
, 1, true) == FAILURE
)
3478 if (dim_rank_check (dim
, array
, 0) == FAILURE
)
3481 if (kind_check (kind
, 2, BT_INTEGER
) == FAILURE
)
3483 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "Fortran 2003: '%s' intrinsic "
3484 "with KIND argument at %L",
3485 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
3494 gfc_check_sizeof (gfc_expr
*arg
)
3496 if (arg
->ts
.type
== BT_PROCEDURE
)
3498 gfc_error ("'%s' argument of '%s' intrinsic at %L may not be a procedure",
3499 gfc_current_intrinsic_arg
[0]->name
, gfc_current_intrinsic
,
3508 gfc_check_c_sizeof (gfc_expr
*arg
)
3510 if (gfc_verify_c_interop (&arg
->ts
) != SUCCESS
)
3512 gfc_error ("'%s' argument of '%s' intrinsic at %L must be an "
3513 "interoperable data entity",
3514 gfc_current_intrinsic_arg
[0]->name
, gfc_current_intrinsic
,
3523 gfc_check_sleep_sub (gfc_expr
*seconds
)
3525 if (type_check (seconds
, 0, BT_INTEGER
) == FAILURE
)
3528 if (scalar_check (seconds
, 0) == FAILURE
)
3535 gfc_check_sngl (gfc_expr
*a
)
3537 if (type_check (a
, 0, BT_REAL
) == FAILURE
)
3540 if ((a
->ts
.kind
!= gfc_default_double_kind
)
3541 && gfc_notify_std (GFC_STD_GNU
, "GNU extension: non double precision "
3542 "REAL argument to %s intrinsic at %L",
3543 gfc_current_intrinsic
, &a
->where
) == FAILURE
)
3550 gfc_check_spread (gfc_expr
*source
, gfc_expr
*dim
, gfc_expr
*ncopies
)
3552 if (source
->rank
>= GFC_MAX_DIMENSIONS
)
3554 gfc_error ("'%s' argument of '%s' intrinsic at %L must be less "
3555 "than rank %d", gfc_current_intrinsic_arg
[0]->name
,
3556 gfc_current_intrinsic
, &source
->where
, GFC_MAX_DIMENSIONS
);
3564 if (dim_check (dim
, 1, false) == FAILURE
)
3567 /* dim_rank_check() does not apply here. */
3569 && dim
->expr_type
== EXPR_CONSTANT
3570 && (mpz_cmp_ui (dim
->value
.integer
, 1) < 0
3571 || mpz_cmp_ui (dim
->value
.integer
, source
->rank
+ 1) > 0))
3573 gfc_error ("'%s' argument of '%s' intrinsic at %L is not a valid "
3574 "dimension index", gfc_current_intrinsic_arg
[1]->name
,
3575 gfc_current_intrinsic
, &dim
->where
);
3579 if (type_check (ncopies
, 2, BT_INTEGER
) == FAILURE
)
3582 if (scalar_check (ncopies
, 2) == FAILURE
)
3589 /* Functions for checking FGETC, FPUTC, FGET and FPUT (subroutines and
3593 gfc_check_fgetputc_sub (gfc_expr
*unit
, gfc_expr
*c
, gfc_expr
*status
)
3595 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
3598 if (scalar_check (unit
, 0) == FAILURE
)
3601 if (type_check (c
, 1, BT_CHARACTER
) == FAILURE
)
3603 if (kind_value_check (c
, 1, gfc_default_character_kind
) == FAILURE
)
3609 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
3610 || kind_value_check (status
, 2, gfc_default_integer_kind
) == FAILURE
3611 || scalar_check (status
, 2) == FAILURE
)
3619 gfc_check_fgetputc (gfc_expr
*unit
, gfc_expr
*c
)
3621 return gfc_check_fgetputc_sub (unit
, c
, NULL
);
3626 gfc_check_fgetput_sub (gfc_expr
*c
, gfc_expr
*status
)
3628 if (type_check (c
, 0, BT_CHARACTER
) == FAILURE
)
3630 if (kind_value_check (c
, 0, gfc_default_character_kind
) == FAILURE
)
3636 if (type_check (status
, 1, BT_INTEGER
) == FAILURE
3637 || kind_value_check (status
, 1, gfc_default_integer_kind
) == FAILURE
3638 || scalar_check (status
, 1) == FAILURE
)
3646 gfc_check_fgetput (gfc_expr
*c
)
3648 return gfc_check_fgetput_sub (c
, NULL
);
3653 gfc_check_fseek_sub (gfc_expr
*unit
, gfc_expr
*offset
, gfc_expr
*whence
, gfc_expr
*status
)
3655 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
3658 if (scalar_check (unit
, 0) == FAILURE
)
3661 if (type_check (offset
, 1, BT_INTEGER
) == FAILURE
)
3664 if (scalar_check (offset
, 1) == FAILURE
)
3667 if (type_check (whence
, 2, BT_INTEGER
) == FAILURE
)
3670 if (scalar_check (whence
, 2) == FAILURE
)
3676 if (type_check (status
, 3, BT_INTEGER
) == FAILURE
)
3679 if (kind_value_check (status
, 3, 4) == FAILURE
)
3682 if (scalar_check (status
, 3) == FAILURE
)
3691 gfc_check_fstat (gfc_expr
*unit
, gfc_expr
*array
)
3693 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
3696 if (scalar_check (unit
, 0) == FAILURE
)
3699 if (type_check (array
, 1, BT_INTEGER
) == FAILURE
3700 || kind_value_check (unit
, 0, gfc_default_integer_kind
) == FAILURE
)
3703 if (array_check (array
, 1) == FAILURE
)
3711 gfc_check_fstat_sub (gfc_expr
*unit
, gfc_expr
*array
, gfc_expr
*status
)
3713 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
3716 if (scalar_check (unit
, 0) == FAILURE
)
3719 if (type_check (array
, 1, BT_INTEGER
) == FAILURE
3720 || kind_value_check (array
, 1, gfc_default_integer_kind
) == FAILURE
)
3723 if (array_check (array
, 1) == FAILURE
)
3729 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
3730 || kind_value_check (status
, 2, gfc_default_integer_kind
) == FAILURE
)
3733 if (scalar_check (status
, 2) == FAILURE
)
3741 gfc_check_ftell (gfc_expr
*unit
)
3743 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
3746 if (scalar_check (unit
, 0) == FAILURE
)
3754 gfc_check_ftell_sub (gfc_expr
*unit
, gfc_expr
*offset
)
3756 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
3759 if (scalar_check (unit
, 0) == FAILURE
)
3762 if (type_check (offset
, 1, BT_INTEGER
) == FAILURE
)
3765 if (scalar_check (offset
, 1) == FAILURE
)
3773 gfc_check_stat (gfc_expr
*name
, gfc_expr
*array
)
3775 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
3777 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
3780 if (type_check (array
, 1, BT_INTEGER
) == FAILURE
3781 || kind_value_check (array
, 1, gfc_default_integer_kind
) == FAILURE
)
3784 if (array_check (array
, 1) == FAILURE
)
3792 gfc_check_stat_sub (gfc_expr
*name
, gfc_expr
*array
, gfc_expr
*status
)
3794 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
3796 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
3799 if (type_check (array
, 1, BT_INTEGER
) == FAILURE
3800 || kind_value_check (array
, 1, gfc_default_integer_kind
) == FAILURE
)
3803 if (array_check (array
, 1) == FAILURE
)
3809 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
3810 || kind_value_check (array
, 1, gfc_default_integer_kind
) == FAILURE
)
3813 if (scalar_check (status
, 2) == FAILURE
)
3821 gfc_check_image_index (gfc_expr
*coarray
, gfc_expr
*sub
)
3825 if (gfc_option
.coarray
== GFC_FCOARRAY_NONE
)
3827 gfc_fatal_error ("Coarrays disabled at %C, use -fcoarray= to enable");
3831 if (coarray_check (coarray
, 0) == FAILURE
)
3836 gfc_error ("%s argument to IMAGE_INDEX must be a rank one array at %L",
3837 gfc_current_intrinsic_arg
[1]->name
, &sub
->where
);
3841 if (gfc_array_size (sub
, &nelems
) == SUCCESS
)
3843 int corank
= gfc_get_corank (coarray
);
3845 if (mpz_cmp_ui (nelems
, corank
) != 0)
3847 gfc_error ("The number of array elements of the SUB argument to "
3848 "IMAGE_INDEX at %L shall be %d (corank) not %d",
3849 &sub
->where
, corank
, (int) mpz_get_si (nelems
));
3861 gfc_check_this_image (gfc_expr
*coarray
, gfc_expr
*dim
)
3863 if (gfc_option
.coarray
== GFC_FCOARRAY_NONE
)
3865 gfc_fatal_error ("Coarrays disabled at %C, use -fcoarray= to enable");
3869 if (dim
!= NULL
&& coarray
== NULL
)
3871 gfc_error ("DIM argument without ARRAY argument not allowed for THIS_IMAGE "
3872 "intrinsic at %L", &dim
->where
);
3876 if (coarray
== NULL
)
3879 if (coarray_check (coarray
, 0) == FAILURE
)
3884 if (dim_check (dim
, 1, false) == FAILURE
)
3887 if (dim_corank_check (dim
, coarray
) == FAILURE
)
3894 /* Calculate the sizes for transfer, used by gfc_check_transfer and also
3895 by gfc_simplify_transfer. Return FAILURE if we cannot do so. */
3898 gfc_calculate_transfer_sizes (gfc_expr
*source
, gfc_expr
*mold
, gfc_expr
*size
,
3899 size_t *source_size
, size_t *result_size
,
3900 size_t *result_length_p
)
3903 size_t result_elt_size
;
3905 gfc_expr
*mold_element
;
3907 if (source
->expr_type
== EXPR_FUNCTION
)
3910 /* Calculate the size of the source. */
3911 if (source
->expr_type
== EXPR_ARRAY
3912 && gfc_array_size (source
, &tmp
) == FAILURE
)
3915 *source_size
= gfc_target_expr_size (source
);
3917 mold_element
= mold
->expr_type
== EXPR_ARRAY
3918 ? gfc_constructor_first (mold
->value
.constructor
)->expr
3921 /* Determine the size of the element. */
3922 result_elt_size
= gfc_target_expr_size (mold_element
);
3923 if (result_elt_size
== 0)
3926 if (mold
->expr_type
== EXPR_ARRAY
|| mold
->rank
|| size
)
3931 result_length
= (size_t)mpz_get_ui (size
->value
.integer
);
3934 result_length
= *source_size
/ result_elt_size
;
3935 if (result_length
* result_elt_size
< *source_size
)
3939 *result_size
= result_length
* result_elt_size
;
3940 if (result_length_p
)
3941 *result_length_p
= result_length
;
3944 *result_size
= result_elt_size
;
3951 gfc_check_transfer (gfc_expr
*source
, gfc_expr
*mold
, gfc_expr
*size
)
3956 if (mold
->ts
.type
== BT_HOLLERITH
)
3958 gfc_error ("'MOLD' argument of 'TRANSFER' intrinsic at %L must not be %s",
3959 &mold
->where
, gfc_basic_typename (BT_HOLLERITH
));
3965 if (type_check (size
, 2, BT_INTEGER
) == FAILURE
)
3968 if (scalar_check (size
, 2) == FAILURE
)
3971 if (nonoptional_check (size
, 2) == FAILURE
)
3975 if (!gfc_option
.warn_surprising
)
3978 /* If we can't calculate the sizes, we cannot check any more.
3979 Return SUCCESS for that case. */
3981 if (gfc_calculate_transfer_sizes (source
, mold
, size
, &source_size
,
3982 &result_size
, NULL
) == FAILURE
)
3985 if (source_size
< result_size
)
3986 gfc_warning("Intrinsic TRANSFER at %L has partly undefined result: "
3987 "source size %ld < result size %ld", &source
->where
,
3988 (long) source_size
, (long) result_size
);
3995 gfc_check_transpose (gfc_expr
*matrix
)
3997 if (rank_check (matrix
, 0, 2) == FAILURE
)
4005 gfc_check_ubound (gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
4007 if (array_check (array
, 0) == FAILURE
)
4010 if (dim_check (dim
, 1, false) == FAILURE
)
4013 if (dim_rank_check (dim
, array
, 0) == FAILURE
)
4016 if (kind_check (kind
, 2, BT_INTEGER
) == FAILURE
)
4018 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "Fortran 2003: '%s' intrinsic "
4019 "with KIND argument at %L",
4020 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
4028 gfc_check_ucobound (gfc_expr
*coarray
, gfc_expr
*dim
, gfc_expr
*kind
)
4030 if (gfc_option
.coarray
== GFC_FCOARRAY_NONE
)
4032 gfc_fatal_error ("Coarrays disabled at %C, use -fcoarray= to enable");
4036 if (coarray_check (coarray
, 0) == FAILURE
)
4041 if (dim_check (dim
, 1, false) == FAILURE
)
4044 if (dim_corank_check (dim
, coarray
) == FAILURE
)
4048 if (kind_check (kind
, 2, BT_INTEGER
) == FAILURE
)
4056 gfc_check_unpack (gfc_expr
*vector
, gfc_expr
*mask
, gfc_expr
*field
)
4060 if (rank_check (vector
, 0, 1) == FAILURE
)
4063 if (array_check (mask
, 1) == FAILURE
)
4066 if (type_check (mask
, 1, BT_LOGICAL
) == FAILURE
)
4069 if (same_type_check (vector
, 0, field
, 2) == FAILURE
)
4072 if (mask
->expr_type
== EXPR_ARRAY
4073 && gfc_array_size (vector
, &vector_size
) == SUCCESS
)
4075 int mask_true_count
= 0;
4076 gfc_constructor
*mask_ctor
;
4077 mask_ctor
= gfc_constructor_first (mask
->value
.constructor
);
4080 if (mask_ctor
->expr
->expr_type
!= EXPR_CONSTANT
)
4082 mask_true_count
= 0;
4086 if (mask_ctor
->expr
->value
.logical
)
4089 mask_ctor
= gfc_constructor_next (mask_ctor
);
4092 if (mpz_get_si (vector_size
) < mask_true_count
)
4094 gfc_error ("'%s' argument of '%s' intrinsic at %L must "
4095 "provide at least as many elements as there "
4096 "are .TRUE. values in '%s' (%ld/%d)",
4097 gfc_current_intrinsic_arg
[0]->name
, gfc_current_intrinsic
,
4098 &vector
->where
, gfc_current_intrinsic_arg
[1]->name
,
4099 mpz_get_si (vector_size
), mask_true_count
);
4103 mpz_clear (vector_size
);
4106 if (mask
->rank
!= field
->rank
&& field
->rank
!= 0)
4108 gfc_error ("'%s' argument of '%s' intrinsic at %L must have "
4109 "the same rank as '%s' or be a scalar",
4110 gfc_current_intrinsic_arg
[2]->name
, gfc_current_intrinsic
,
4111 &field
->where
, gfc_current_intrinsic_arg
[1]->name
);
4115 if (mask
->rank
== field
->rank
)
4118 for (i
= 0; i
< field
->rank
; i
++)
4119 if (! identical_dimen_shape (mask
, i
, field
, i
))
4121 gfc_error ("'%s' and '%s' arguments of '%s' intrinsic at %L "
4122 "must have identical shape.",
4123 gfc_current_intrinsic_arg
[2]->name
,
4124 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
4134 gfc_check_verify (gfc_expr
*x
, gfc_expr
*y
, gfc_expr
*z
, gfc_expr
*kind
)
4136 if (type_check (x
, 0, BT_CHARACTER
) == FAILURE
)
4139 if (same_type_check (x
, 0, y
, 1) == FAILURE
)
4142 if (z
!= NULL
&& type_check (z
, 2, BT_LOGICAL
) == FAILURE
)
4145 if (kind_check (kind
, 3, BT_INTEGER
) == FAILURE
)
4147 if (kind
&& gfc_notify_std (GFC_STD_F2003
, "Fortran 2003: '%s' intrinsic "
4148 "with KIND argument at %L",
4149 gfc_current_intrinsic
, &kind
->where
) == FAILURE
)
4157 gfc_check_trim (gfc_expr
*x
)
4159 if (type_check (x
, 0, BT_CHARACTER
) == FAILURE
)
4162 if (scalar_check (x
, 0) == FAILURE
)
4170 gfc_check_ttynam (gfc_expr
*unit
)
4172 if (scalar_check (unit
, 0) == FAILURE
)
4175 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
4182 /* Common check function for the half a dozen intrinsics that have a
4183 single real argument. */
4186 gfc_check_x (gfc_expr
*x
)
4188 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
4195 /************* Check functions for intrinsic subroutines *************/
4198 gfc_check_cpu_time (gfc_expr
*time
)
4200 if (scalar_check (time
, 0) == FAILURE
)
4203 if (type_check (time
, 0, BT_REAL
) == FAILURE
)
4206 if (variable_check (time
, 0, false) == FAILURE
)
4214 gfc_check_date_and_time (gfc_expr
*date
, gfc_expr
*time
,
4215 gfc_expr
*zone
, gfc_expr
*values
)
4219 if (type_check (date
, 0, BT_CHARACTER
) == FAILURE
)
4221 if (kind_value_check (date
, 0, gfc_default_character_kind
) == FAILURE
)
4223 if (scalar_check (date
, 0) == FAILURE
)
4225 if (variable_check (date
, 0, false) == FAILURE
)
4231 if (type_check (time
, 1, BT_CHARACTER
) == FAILURE
)
4233 if (kind_value_check (time
, 1, gfc_default_character_kind
) == FAILURE
)
4235 if (scalar_check (time
, 1) == FAILURE
)
4237 if (variable_check (time
, 1, false) == FAILURE
)
4243 if (type_check (zone
, 2, BT_CHARACTER
) == FAILURE
)
4245 if (kind_value_check (zone
, 2, gfc_default_character_kind
) == FAILURE
)
4247 if (scalar_check (zone
, 2) == FAILURE
)
4249 if (variable_check (zone
, 2, false) == FAILURE
)
4255 if (type_check (values
, 3, BT_INTEGER
) == FAILURE
)
4257 if (array_check (values
, 3) == FAILURE
)
4259 if (rank_check (values
, 3, 1) == FAILURE
)
4261 if (variable_check (values
, 3, false) == FAILURE
)
4270 gfc_check_mvbits (gfc_expr
*from
, gfc_expr
*frompos
, gfc_expr
*len
,
4271 gfc_expr
*to
, gfc_expr
*topos
)
4273 if (type_check (from
, 0, BT_INTEGER
) == FAILURE
)
4276 if (type_check (frompos
, 1, BT_INTEGER
) == FAILURE
)
4279 if (type_check (len
, 2, BT_INTEGER
) == FAILURE
)
4282 if (same_type_check (from
, 0, to
, 3) == FAILURE
)
4285 if (variable_check (to
, 3, false) == FAILURE
)
4288 if (type_check (topos
, 4, BT_INTEGER
) == FAILURE
)
4291 if (nonnegative_check ("frompos", frompos
) == FAILURE
)
4294 if (nonnegative_check ("topos", topos
) == FAILURE
)
4297 if (nonnegative_check ("len", len
) == FAILURE
)
4300 if (less_than_bitsize2 ("from", from
, "frompos", frompos
, "len", len
)
4304 if (less_than_bitsize2 ("to", to
, "topos", topos
, "len", len
) == FAILURE
)
4312 gfc_check_random_number (gfc_expr
*harvest
)
4314 if (type_check (harvest
, 0, BT_REAL
) == FAILURE
)
4317 if (variable_check (harvest
, 0, false) == FAILURE
)
4325 gfc_check_random_seed (gfc_expr
*size
, gfc_expr
*put
, gfc_expr
*get
)
4327 unsigned int nargs
= 0, kiss_size
;
4328 locus
*where
= NULL
;
4329 mpz_t put_size
, get_size
;
4330 bool have_gfc_real_16
; /* Try and mimic HAVE_GFC_REAL_16 in libgfortran. */
4332 have_gfc_real_16
= gfc_validate_kind (BT_REAL
, 16, true) != -1;
4334 /* Keep the number of bytes in sync with kiss_size in
4335 libgfortran/intrinsics/random.c. */
4336 kiss_size
= (have_gfc_real_16
? 48 : 32) / gfc_default_integer_kind
;
4340 if (size
->expr_type
!= EXPR_VARIABLE
4341 || !size
->symtree
->n
.sym
->attr
.optional
)
4344 if (scalar_check (size
, 0) == FAILURE
)
4347 if (type_check (size
, 0, BT_INTEGER
) == FAILURE
)
4350 if (variable_check (size
, 0, false) == FAILURE
)
4353 if (kind_value_check (size
, 0, gfc_default_integer_kind
) == FAILURE
)
4359 if (put
->expr_type
!= EXPR_VARIABLE
4360 || !put
->symtree
->n
.sym
->attr
.optional
)
4363 where
= &put
->where
;
4366 if (array_check (put
, 1) == FAILURE
)
4369 if (rank_check (put
, 1, 1) == FAILURE
)
4372 if (type_check (put
, 1, BT_INTEGER
) == FAILURE
)
4375 if (kind_value_check (put
, 1, gfc_default_integer_kind
) == FAILURE
)
4378 if (gfc_array_size (put
, &put_size
) == SUCCESS
4379 && mpz_get_ui (put_size
) < kiss_size
)
4380 gfc_error ("Size of '%s' argument of '%s' intrinsic at %L "
4381 "too small (%i/%i)",
4382 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
4383 where
, (int) mpz_get_ui (put_size
), kiss_size
);
4388 if (get
->expr_type
!= EXPR_VARIABLE
4389 || !get
->symtree
->n
.sym
->attr
.optional
)
4392 where
= &get
->where
;
4395 if (array_check (get
, 2) == FAILURE
)
4398 if (rank_check (get
, 2, 1) == FAILURE
)
4401 if (type_check (get
, 2, BT_INTEGER
) == FAILURE
)
4404 if (variable_check (get
, 2, false) == FAILURE
)
4407 if (kind_value_check (get
, 2, gfc_default_integer_kind
) == FAILURE
)
4410 if (gfc_array_size (get
, &get_size
) == SUCCESS
4411 && mpz_get_ui (get_size
) < kiss_size
)
4412 gfc_error ("Size of '%s' argument of '%s' intrinsic at %L "
4413 "too small (%i/%i)",
4414 gfc_current_intrinsic_arg
[2]->name
, gfc_current_intrinsic
,
4415 where
, (int) mpz_get_ui (get_size
), kiss_size
);
4418 /* RANDOM_SEED may not have more than one non-optional argument. */
4420 gfc_error ("Too many arguments to %s at %L", gfc_current_intrinsic
, where
);
4427 gfc_check_second_sub (gfc_expr
*time
)
4429 if (scalar_check (time
, 0) == FAILURE
)
4432 if (type_check (time
, 0, BT_REAL
) == FAILURE
)
4435 if (kind_value_check(time
, 0, 4) == FAILURE
)
4442 /* The arguments of SYSTEM_CLOCK are scalar, integer variables. Note,
4443 count, count_rate, and count_max are all optional arguments */
4446 gfc_check_system_clock (gfc_expr
*count
, gfc_expr
*count_rate
,
4447 gfc_expr
*count_max
)
4451 if (scalar_check (count
, 0) == FAILURE
)
4454 if (type_check (count
, 0, BT_INTEGER
) == FAILURE
)
4457 if (variable_check (count
, 0, false) == FAILURE
)
4461 if (count_rate
!= NULL
)
4463 if (scalar_check (count_rate
, 1) == FAILURE
)
4466 if (type_check (count_rate
, 1, BT_INTEGER
) == FAILURE
)
4469 if (variable_check (count_rate
, 1, false) == FAILURE
)
4473 && same_type_check (count
, 0, count_rate
, 1) == FAILURE
)
4478 if (count_max
!= NULL
)
4480 if (scalar_check (count_max
, 2) == FAILURE
)
4483 if (type_check (count_max
, 2, BT_INTEGER
) == FAILURE
)
4486 if (variable_check (count_max
, 2, false) == FAILURE
)
4490 && same_type_check (count
, 0, count_max
, 2) == FAILURE
)
4493 if (count_rate
!= NULL
4494 && same_type_check (count_rate
, 1, count_max
, 2) == FAILURE
)
4503 gfc_check_irand (gfc_expr
*x
)
4508 if (scalar_check (x
, 0) == FAILURE
)
4511 if (type_check (x
, 0, BT_INTEGER
) == FAILURE
)
4514 if (kind_value_check(x
, 0, 4) == FAILURE
)
4522 gfc_check_alarm_sub (gfc_expr
*seconds
, gfc_expr
*handler
, gfc_expr
*status
)
4524 if (scalar_check (seconds
, 0) == FAILURE
)
4526 if (type_check (seconds
, 0, BT_INTEGER
) == FAILURE
)
4529 if (int_or_proc_check (handler
, 1) == FAILURE
)
4531 if (handler
->ts
.type
== BT_INTEGER
&& scalar_check (handler
, 1) == FAILURE
)
4537 if (scalar_check (status
, 2) == FAILURE
)
4539 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
4541 if (kind_value_check (status
, 2, gfc_default_integer_kind
) == FAILURE
)
4549 gfc_check_rand (gfc_expr
*x
)
4554 if (scalar_check (x
, 0) == FAILURE
)
4557 if (type_check (x
, 0, BT_INTEGER
) == FAILURE
)
4560 if (kind_value_check(x
, 0, 4) == FAILURE
)
4568 gfc_check_srand (gfc_expr
*x
)
4570 if (scalar_check (x
, 0) == FAILURE
)
4573 if (type_check (x
, 0, BT_INTEGER
) == FAILURE
)
4576 if (kind_value_check(x
, 0, 4) == FAILURE
)
4584 gfc_check_ctime_sub (gfc_expr
*time
, gfc_expr
*result
)
4586 if (scalar_check (time
, 0) == FAILURE
)
4588 if (type_check (time
, 0, BT_INTEGER
) == FAILURE
)
4591 if (type_check (result
, 1, BT_CHARACTER
) == FAILURE
)
4593 if (kind_value_check (result
, 1, gfc_default_character_kind
) == FAILURE
)
4601 gfc_check_dtime_etime (gfc_expr
*x
)
4603 if (array_check (x
, 0) == FAILURE
)
4606 if (rank_check (x
, 0, 1) == FAILURE
)
4609 if (variable_check (x
, 0, false) == FAILURE
)
4612 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
4615 if (kind_value_check(x
, 0, 4) == FAILURE
)
4623 gfc_check_dtime_etime_sub (gfc_expr
*values
, gfc_expr
*time
)
4625 if (array_check (values
, 0) == FAILURE
)
4628 if (rank_check (values
, 0, 1) == FAILURE
)
4631 if (variable_check (values
, 0, false) == FAILURE
)
4634 if (type_check (values
, 0, BT_REAL
) == FAILURE
)
4637 if (kind_value_check(values
, 0, 4) == FAILURE
)
4640 if (scalar_check (time
, 1) == FAILURE
)
4643 if (type_check (time
, 1, BT_REAL
) == FAILURE
)
4646 if (kind_value_check(time
, 1, 4) == FAILURE
)
4654 gfc_check_fdate_sub (gfc_expr
*date
)
4656 if (type_check (date
, 0, BT_CHARACTER
) == FAILURE
)
4658 if (kind_value_check (date
, 0, gfc_default_character_kind
) == FAILURE
)
4666 gfc_check_gerror (gfc_expr
*msg
)
4668 if (type_check (msg
, 0, BT_CHARACTER
) == FAILURE
)
4670 if (kind_value_check (msg
, 0, gfc_default_character_kind
) == FAILURE
)
4678 gfc_check_getcwd_sub (gfc_expr
*cwd
, gfc_expr
*status
)
4680 if (type_check (cwd
, 0, BT_CHARACTER
) == FAILURE
)
4682 if (kind_value_check (cwd
, 0, gfc_default_character_kind
) == FAILURE
)
4688 if (scalar_check (status
, 1) == FAILURE
)
4691 if (type_check (status
, 1, BT_INTEGER
) == FAILURE
)
4699 gfc_check_getarg (gfc_expr
*pos
, gfc_expr
*value
)
4701 if (type_check (pos
, 0, BT_INTEGER
) == FAILURE
)
4704 if (pos
->ts
.kind
> gfc_default_integer_kind
)
4706 gfc_error ("'%s' argument of '%s' intrinsic at %L must be of a kind "
4707 "not wider than the default kind (%d)",
4708 gfc_current_intrinsic_arg
[0]->name
, gfc_current_intrinsic
,
4709 &pos
->where
, gfc_default_integer_kind
);
4713 if (type_check (value
, 1, BT_CHARACTER
) == FAILURE
)
4715 if (kind_value_check (value
, 1, gfc_default_character_kind
) == FAILURE
)
4723 gfc_check_getlog (gfc_expr
*msg
)
4725 if (type_check (msg
, 0, BT_CHARACTER
) == FAILURE
)
4727 if (kind_value_check (msg
, 0, gfc_default_character_kind
) == FAILURE
)
4735 gfc_check_exit (gfc_expr
*status
)
4740 if (type_check (status
, 0, BT_INTEGER
) == FAILURE
)
4743 if (scalar_check (status
, 0) == FAILURE
)
4751 gfc_check_flush (gfc_expr
*unit
)
4756 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
4759 if (scalar_check (unit
, 0) == FAILURE
)
4767 gfc_check_free (gfc_expr
*i
)
4769 if (type_check (i
, 0, BT_INTEGER
) == FAILURE
)
4772 if (scalar_check (i
, 0) == FAILURE
)
4780 gfc_check_hostnm (gfc_expr
*name
)
4782 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
4784 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
4792 gfc_check_hostnm_sub (gfc_expr
*name
, gfc_expr
*status
)
4794 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
4796 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
4802 if (scalar_check (status
, 1) == FAILURE
)
4805 if (type_check (status
, 1, BT_INTEGER
) == FAILURE
)
4813 gfc_check_itime_idate (gfc_expr
*values
)
4815 if (array_check (values
, 0) == FAILURE
)
4818 if (rank_check (values
, 0, 1) == FAILURE
)
4821 if (variable_check (values
, 0, false) == FAILURE
)
4824 if (type_check (values
, 0, BT_INTEGER
) == FAILURE
)
4827 if (kind_value_check(values
, 0, gfc_default_integer_kind
) == FAILURE
)
4835 gfc_check_ltime_gmtime (gfc_expr
*time
, gfc_expr
*values
)
4837 if (type_check (time
, 0, BT_INTEGER
) == FAILURE
)
4840 if (kind_value_check(time
, 0, gfc_default_integer_kind
) == FAILURE
)
4843 if (scalar_check (time
, 0) == FAILURE
)
4846 if (array_check (values
, 1) == FAILURE
)
4849 if (rank_check (values
, 1, 1) == FAILURE
)
4852 if (variable_check (values
, 1, false) == FAILURE
)
4855 if (type_check (values
, 1, BT_INTEGER
) == FAILURE
)
4858 if (kind_value_check(values
, 1, gfc_default_integer_kind
) == FAILURE
)
4866 gfc_check_ttynam_sub (gfc_expr
*unit
, gfc_expr
*name
)
4868 if (scalar_check (unit
, 0) == FAILURE
)
4871 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
4874 if (type_check (name
, 1, BT_CHARACTER
) == FAILURE
)
4876 if (kind_value_check (name
, 1, gfc_default_character_kind
) == FAILURE
)
4884 gfc_check_isatty (gfc_expr
*unit
)
4889 if (type_check (unit
, 0, BT_INTEGER
) == FAILURE
)
4892 if (scalar_check (unit
, 0) == FAILURE
)
4900 gfc_check_isnan (gfc_expr
*x
)
4902 if (type_check (x
, 0, BT_REAL
) == FAILURE
)
4910 gfc_check_perror (gfc_expr
*string
)
4912 if (type_check (string
, 0, BT_CHARACTER
) == FAILURE
)
4914 if (kind_value_check (string
, 0, gfc_default_character_kind
) == FAILURE
)
4922 gfc_check_umask (gfc_expr
*mask
)
4924 if (type_check (mask
, 0, BT_INTEGER
) == FAILURE
)
4927 if (scalar_check (mask
, 0) == FAILURE
)
4935 gfc_check_umask_sub (gfc_expr
*mask
, gfc_expr
*old
)
4937 if (type_check (mask
, 0, BT_INTEGER
) == FAILURE
)
4940 if (scalar_check (mask
, 0) == FAILURE
)
4946 if (scalar_check (old
, 1) == FAILURE
)
4949 if (type_check (old
, 1, BT_INTEGER
) == FAILURE
)
4957 gfc_check_unlink (gfc_expr
*name
)
4959 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
4961 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
4969 gfc_check_unlink_sub (gfc_expr
*name
, gfc_expr
*status
)
4971 if (type_check (name
, 0, BT_CHARACTER
) == FAILURE
)
4973 if (kind_value_check (name
, 0, gfc_default_character_kind
) == FAILURE
)
4979 if (scalar_check (status
, 1) == FAILURE
)
4982 if (type_check (status
, 1, BT_INTEGER
) == FAILURE
)
4990 gfc_check_signal (gfc_expr
*number
, gfc_expr
*handler
)
4992 if (scalar_check (number
, 0) == FAILURE
)
4994 if (type_check (number
, 0, BT_INTEGER
) == FAILURE
)
4997 if (int_or_proc_check (handler
, 1) == FAILURE
)
4999 if (handler
->ts
.type
== BT_INTEGER
&& scalar_check (handler
, 1) == FAILURE
)
5007 gfc_check_signal_sub (gfc_expr
*number
, gfc_expr
*handler
, gfc_expr
*status
)
5009 if (scalar_check (number
, 0) == FAILURE
)
5011 if (type_check (number
, 0, BT_INTEGER
) == FAILURE
)
5014 if (int_or_proc_check (handler
, 1) == FAILURE
)
5016 if (handler
->ts
.type
== BT_INTEGER
&& scalar_check (handler
, 1) == FAILURE
)
5022 if (type_check (status
, 2, BT_INTEGER
) == FAILURE
)
5024 if (scalar_check (status
, 2) == FAILURE
)
5032 gfc_check_system_sub (gfc_expr
*cmd
, gfc_expr
*status
)
5034 if (type_check (cmd
, 0, BT_CHARACTER
) == FAILURE
)
5036 if (kind_value_check (cmd
, 0, gfc_default_character_kind
) == FAILURE
)
5039 if (scalar_check (status
, 1) == FAILURE
)
5042 if (type_check (status
, 1, BT_INTEGER
) == FAILURE
)
5045 if (kind_value_check (status
, 1, gfc_default_integer_kind
) == FAILURE
)
5052 /* This is used for the GNU intrinsics AND, OR and XOR. */
5054 gfc_check_and (gfc_expr
*i
, gfc_expr
*j
)
5056 if (i
->ts
.type
!= BT_INTEGER
&& i
->ts
.type
!= BT_LOGICAL
)
5058 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
5059 "or LOGICAL", gfc_current_intrinsic_arg
[0]->name
,
5060 gfc_current_intrinsic
, &i
->where
);
5064 if (j
->ts
.type
!= BT_INTEGER
&& j
->ts
.type
!= BT_LOGICAL
)
5066 gfc_error ("'%s' argument of '%s' intrinsic at %L must be INTEGER "
5067 "or LOGICAL", gfc_current_intrinsic_arg
[1]->name
,
5068 gfc_current_intrinsic
, &j
->where
);
5072 if (i
->ts
.type
!= j
->ts
.type
)
5074 gfc_error ("'%s' and '%s' arguments of '%s' intrinsic at %L must "
5075 "have the same type", gfc_current_intrinsic_arg
[0]->name
,
5076 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,
5081 if (scalar_check (i
, 0) == FAILURE
)
5084 if (scalar_check (j
, 1) == FAILURE
)
5092 gfc_check_storage_size (gfc_expr
*a ATTRIBUTE_UNUSED
, gfc_expr
*kind
)
5097 if (type_check (kind
, 1, BT_INTEGER
) == FAILURE
)
5100 if (scalar_check (kind
, 1) == FAILURE
)
5103 if (kind
->expr_type
!= EXPR_CONSTANT
)
5105 gfc_error ("'%s' argument of '%s' intrinsic at %L must be a constant",
5106 gfc_current_intrinsic_arg
[1]->name
, gfc_current_intrinsic
,