1 /* Intrinsic function resolution.
2 Copyright (C) 2000-2024 Free Software Foundation, Inc.
3 Contributed by Andy Vaught & Katherine Holcomb
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
22 /* Assign name and types to intrinsic procedures. For functions, the
23 first argument to a resolution function is an expression pointer to
24 the original function node and the rest are pointers to the
25 arguments of the function call. For subroutines, a pointer to the
26 code node is passed. The result type and library subroutine name
27 are generally set according to the function arguments. */
31 #include "coretypes.h"
34 #include "stringpool.h"
35 #include "intrinsic.h"
36 #include "constructor.h"
40 /* Given printf-like arguments, return a stable version of the result string.
42 We already have a working, optimized string hashing table in the form of
43 the identifier table. Reusing this table is likely not to be wasted,
44 since if the function name makes it to the gimple output of the frontend,
45 we'll have to create the identifier anyway. */
48 gfc_get_string (const char *format
, ...)
50 /* Provide sufficient space for "_F.caf_token__symbol.symbol_MOD_symbol". */
51 char temp_name
[15 + 2*GFC_MAX_SYMBOL_LEN
+ 5 + GFC_MAX_SYMBOL_LEN
+ 1];
56 /* Handle common case without vsnprintf and temporary buffer. */
57 if (format
[0] == '%' && format
[1] == 's' && format
[2] == '\0')
59 va_start (ap
, format
);
60 str
= va_arg (ap
, const char *);
66 va_start (ap
, format
);
67 ret
= vsnprintf (temp_name
, sizeof (temp_name
), format
, ap
);
69 if (ret
< 1 || ret
>= (int) sizeof (temp_name
)) /* Reject truncation. */
70 gfc_internal_error ("identifier overflow: %d", ret
);
71 temp_name
[sizeof (temp_name
) - 1] = 0;
75 ident
= get_identifier (str
);
76 return IDENTIFIER_POINTER (ident
);
79 /* MERGE and SPREAD need to have source charlen's present for passing
80 to the result expression. */
82 check_charlen_present (gfc_expr
*source
)
84 if (source
->ts
.u
.cl
== NULL
)
85 source
->ts
.u
.cl
= gfc_new_charlen (gfc_current_ns
, NULL
);
87 if (source
->expr_type
== EXPR_CONSTANT
)
89 source
->ts
.u
.cl
->length
90 = gfc_get_int_expr (gfc_charlen_int_kind
, NULL
,
91 source
->value
.character
.length
);
94 else if (source
->expr_type
== EXPR_ARRAY
)
96 gfc_constructor
*c
= gfc_constructor_first (source
->value
.constructor
);
98 source
->ts
.u
.cl
->length
99 = gfc_get_int_expr (gfc_charlen_int_kind
, NULL
,
100 c
->expr
->value
.character
.length
);
101 if (source
->ts
.u
.cl
->length
== NULL
)
102 gfc_internal_error ("check_charlen_present(): length not set");
106 /* Helper function for resolving the "mask" argument. */
109 resolve_mask_arg (gfc_expr
*mask
)
117 /* For the scalar case, coerce the mask to kind=4 unconditionally
118 (because this is the only kind we have a library function
121 if (mask
->ts
.kind
!= 4)
123 ts
.type
= BT_LOGICAL
;
125 gfc_convert_type (mask
, &ts
, 2);
130 /* In the library, we access the mask with a GFC_LOGICAL_1
131 argument. No need to waste memory if we are about to create
132 a temporary array. */
133 if (mask
->expr_type
== EXPR_OP
&& mask
->ts
.kind
!= 1)
135 ts
.type
= BT_LOGICAL
;
137 gfc_convert_type_warn (mask
, &ts
, 2, 0);
144 resolve_bound (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
,
145 const char *name
, bool coarray
)
147 f
->ts
.type
= BT_INTEGER
;
149 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
151 f
->ts
.kind
= gfc_default_integer_kind
;
155 if (array
->rank
!= -1)
157 /* Assume f->rank gives the size of the shape, because there is no
158 other way to determine the size. */
159 if (!f
->shape
|| f
->rank
!= 1)
162 gfc_free_shape (&f
->shape
, f
->rank
);
163 f
->shape
= gfc_get_shape (1);
165 mpz_init_set_ui (f
->shape
[0], coarray
? array
->corank
: array
->rank
);
167 /* Applying bound to a coarray always results in a regular array. */
172 f
->value
.function
.name
= gfc_get_string ("%s", name
);
177 resolve_transformational (const char *name
, gfc_expr
*f
, gfc_expr
*array
,
178 gfc_expr
*dim
, gfc_expr
*mask
,
179 bool use_integer
= false)
193 resolve_mask_arg (mask
);
200 f
->rank
= array
->rank
- 1;
201 f
->shape
= gfc_copy_shape_excluding (array
->shape
, array
->rank
, dim
);
202 gfc_resolve_dim_arg (dim
);
205 /* For those intrinsic like SUM where we use the integer version
206 actually uses unsigned, but we call it as the integer
209 if (use_integer
&& array
->ts
.type
== BT_UNSIGNED
)
212 type
= array
->ts
.type
;
214 f
->value
.function
.name
215 = gfc_get_string (PREFIX ("%s%s_%c%d"), prefix
, name
,
216 gfc_type_letter (type
),
217 gfc_type_abi_kind (&array
->ts
));
221 /********************** Resolution functions **********************/
225 gfc_resolve_abs (gfc_expr
*f
, gfc_expr
*a
)
228 if (f
->ts
.type
== BT_COMPLEX
)
229 f
->ts
.type
= BT_REAL
;
231 f
->value
.function
.name
232 = gfc_get_string ("__abs_%c%d", gfc_type_letter (a
->ts
.type
),
233 gfc_type_abi_kind (&a
->ts
));
238 gfc_resolve_access (gfc_expr
*f
, gfc_expr
*name ATTRIBUTE_UNUSED
,
239 gfc_expr
*mode ATTRIBUTE_UNUSED
)
241 f
->ts
.type
= BT_INTEGER
;
242 f
->ts
.kind
= gfc_c_int_kind
;
243 f
->value
.function
.name
= PREFIX ("access_func");
248 gfc_resolve_adjustl (gfc_expr
*f
, gfc_expr
*string
)
250 f
->ts
.type
= BT_CHARACTER
;
251 f
->ts
.kind
= string
->ts
.kind
;
252 if (string
->ts
.deferred
)
254 else if (string
->ts
.u
.cl
)
255 f
->ts
.u
.cl
= gfc_new_charlen (gfc_current_ns
, string
->ts
.u
.cl
);
257 f
->value
.function
.name
= gfc_get_string ("__adjustl_s%d", f
->ts
.kind
);
262 gfc_resolve_adjustr (gfc_expr
*f
, gfc_expr
*string
)
264 f
->ts
.type
= BT_CHARACTER
;
265 f
->ts
.kind
= string
->ts
.kind
;
266 if (string
->ts
.deferred
)
268 else if (string
->ts
.u
.cl
)
269 f
->ts
.u
.cl
= gfc_new_charlen (gfc_current_ns
, string
->ts
.u
.cl
);
271 f
->value
.function
.name
= gfc_get_string ("__adjustr_s%d", f
->ts
.kind
);
276 gfc_resolve_char_achar (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*kind
,
279 f
->ts
.type
= BT_CHARACTER
;
280 f
->ts
.kind
= (kind
== NULL
)
281 ? gfc_default_character_kind
: mpz_get_si (kind
->value
.integer
);
282 f
->ts
.u
.cl
= gfc_new_charlen (gfc_current_ns
, NULL
);
283 f
->ts
.u
.cl
->length
= gfc_get_int_expr (gfc_charlen_int_kind
, NULL
, 1);
285 f
->value
.function
.name
286 = gfc_get_string ("__%schar_%d_%c%d", is_achar
? "a" : "", f
->ts
.kind
,
287 gfc_type_letter (x
->ts
.type
),
288 gfc_type_abi_kind (&x
->ts
));
293 gfc_resolve_achar (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*kind
)
295 gfc_resolve_char_achar (f
, x
, kind
, true);
300 gfc_resolve_acos (gfc_expr
*f
, gfc_expr
*x
)
303 f
->value
.function
.name
304 = gfc_get_string ("__acos_%c%d", gfc_type_letter (x
->ts
.type
),
305 gfc_type_abi_kind (&x
->ts
));
310 gfc_resolve_acosh (gfc_expr
*f
, gfc_expr
*x
)
313 f
->value
.function
.name
314 = gfc_get_string ("__acosh_%c%d", gfc_type_letter (x
->ts
.type
),
315 gfc_type_abi_kind (&x
->ts
));
320 gfc_resolve_aimag (gfc_expr
*f
, gfc_expr
*x
)
322 f
->ts
.type
= BT_REAL
;
323 f
->ts
.kind
= x
->ts
.kind
;
324 f
->value
.function
.name
325 = gfc_get_string ("__aimag_%c%d", gfc_type_letter (x
->ts
.type
),
326 gfc_type_abi_kind (&x
->ts
));
331 gfc_resolve_and (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
333 f
->ts
.type
= i
->ts
.type
;
334 f
->ts
.kind
= gfc_kind_max (i
, j
);
336 if (i
->ts
.kind
!= j
->ts
.kind
)
338 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
339 gfc_convert_type (j
, &i
->ts
, 2);
341 gfc_convert_type (i
, &j
->ts
, 2);
344 f
->value
.function
.name
345 = gfc_get_string ("__and_%c%d", gfc_type_letter (i
->ts
.type
),
346 gfc_type_abi_kind (&f
->ts
));
351 gfc_resolve_aint (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
356 f
->ts
.type
= a
->ts
.type
;
357 f
->ts
.kind
= (kind
== NULL
) ? a
->ts
.kind
: mpz_get_si (kind
->value
.integer
);
359 if (a
->ts
.kind
!= f
->ts
.kind
)
361 ts
.type
= f
->ts
.type
;
362 ts
.kind
= f
->ts
.kind
;
363 gfc_convert_type (a
, &ts
, 2);
365 /* The resolved name is only used for specific intrinsics where
366 the return kind is the same as the arg kind. */
367 f
->value
.function
.name
368 = gfc_get_string ("__aint_%c%d", gfc_type_letter (a
->ts
.type
),
369 gfc_type_abi_kind (&a
->ts
));
374 gfc_resolve_dint (gfc_expr
*f
, gfc_expr
*a
)
376 gfc_resolve_aint (f
, a
, NULL
);
381 gfc_resolve_all (gfc_expr
*f
, gfc_expr
*mask
, gfc_expr
*dim
)
387 gfc_resolve_dim_arg (dim
);
388 f
->rank
= mask
->rank
- 1;
389 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
392 f
->value
.function
.name
393 = gfc_get_string (PREFIX ("all_%c%d"), gfc_type_letter (mask
->ts
.type
),
394 gfc_type_abi_kind (&mask
->ts
));
399 gfc_resolve_anint (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
404 f
->ts
.type
= a
->ts
.type
;
405 f
->ts
.kind
= (kind
== NULL
) ? a
->ts
.kind
: mpz_get_si (kind
->value
.integer
);
407 if (a
->ts
.kind
!= f
->ts
.kind
)
409 ts
.type
= f
->ts
.type
;
410 ts
.kind
= f
->ts
.kind
;
411 gfc_convert_type (a
, &ts
, 2);
414 /* The resolved name is only used for specific intrinsics where
415 the return kind is the same as the arg kind. */
416 f
->value
.function
.name
417 = gfc_get_string ("__anint_%c%d", gfc_type_letter (a
->ts
.type
),
418 gfc_type_abi_kind (&a
->ts
));
423 gfc_resolve_dnint (gfc_expr
*f
, gfc_expr
*a
)
425 gfc_resolve_anint (f
, a
, NULL
);
430 gfc_resolve_any (gfc_expr
*f
, gfc_expr
*mask
, gfc_expr
*dim
)
436 gfc_resolve_dim_arg (dim
);
437 f
->rank
= mask
->rank
- 1;
438 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
441 f
->value
.function
.name
442 = gfc_get_string (PREFIX ("any_%c%d"), gfc_type_letter (mask
->ts
.type
),
443 gfc_type_abi_kind (&mask
->ts
));
448 gfc_resolve_asin (gfc_expr
*f
, gfc_expr
*x
)
451 f
->value
.function
.name
452 = gfc_get_string ("__asin_%c%d", gfc_type_letter (x
->ts
.type
),
453 gfc_type_abi_kind (&x
->ts
));
457 gfc_resolve_asinh (gfc_expr
*f
, gfc_expr
*x
)
460 f
->value
.function
.name
461 = gfc_get_string ("__asinh_%c%d", gfc_type_letter (x
->ts
.type
),
462 gfc_type_abi_kind (&x
->ts
));
466 gfc_resolve_atan (gfc_expr
*f
, gfc_expr
*x
)
469 f
->value
.function
.name
470 = gfc_get_string ("__atan_%c%d", gfc_type_letter (x
->ts
.type
),
471 gfc_type_abi_kind (&x
->ts
));
475 gfc_resolve_atanh (gfc_expr
*f
, gfc_expr
*x
)
478 f
->value
.function
.name
479 = gfc_get_string ("__atanh_%c%d", gfc_type_letter (x
->ts
.type
),
480 gfc_type_abi_kind (&x
->ts
));
484 gfc_resolve_atan2 (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y ATTRIBUTE_UNUSED
)
487 f
->value
.function
.name
488 = gfc_get_string ("__atan2_%c%d", gfc_type_letter (x
->ts
.type
),
489 gfc_type_abi_kind (&x
->ts
));
493 /* Resolve the BESYN and BESJN intrinsics. */
496 gfc_resolve_besn (gfc_expr
*f
, gfc_expr
*n
, gfc_expr
*x
)
502 if (n
->ts
.kind
!= gfc_c_int_kind
)
504 ts
.type
= BT_INTEGER
;
505 ts
.kind
= gfc_c_int_kind
;
506 gfc_convert_type (n
, &ts
, 2);
508 f
->value
.function
.name
= gfc_get_string ("<intrinsic>");
513 gfc_resolve_bessel_n2 (gfc_expr
*f
, gfc_expr
*n1
, gfc_expr
*n2
, gfc_expr
*x
)
520 if (n1
->expr_type
== EXPR_CONSTANT
&& n2
->expr_type
== EXPR_CONSTANT
)
522 f
->shape
= gfc_get_shape (1);
523 mpz_init (f
->shape
[0]);
524 mpz_sub (f
->shape
[0], n2
->value
.integer
, n1
->value
.integer
);
525 mpz_add_ui (f
->shape
[0], f
->shape
[0], 1);
528 if (n1
->ts
.kind
!= gfc_c_int_kind
)
530 ts
.type
= BT_INTEGER
;
531 ts
.kind
= gfc_c_int_kind
;
532 gfc_convert_type (n1
, &ts
, 2);
535 if (n2
->ts
.kind
!= gfc_c_int_kind
)
537 ts
.type
= BT_INTEGER
;
538 ts
.kind
= gfc_c_int_kind
;
539 gfc_convert_type (n2
, &ts
, 2);
542 if (f
->value
.function
.isym
->id
== GFC_ISYM_JN2
)
543 f
->value
.function
.name
= gfc_get_string (PREFIX ("bessel_jn_r%d"),
544 gfc_type_abi_kind (&f
->ts
));
546 f
->value
.function
.name
= gfc_get_string (PREFIX ("bessel_yn_r%d"),
547 gfc_type_abi_kind (&f
->ts
));
552 gfc_resolve_btest (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos
)
554 f
->ts
.type
= BT_LOGICAL
;
555 f
->ts
.kind
= gfc_default_logical_kind
;
556 f
->value
.function
.name
557 = gfc_get_string ("__btest_%d_%d", i
->ts
.kind
, pos
->ts
.kind
);
562 gfc_resolve_c_loc (gfc_expr
*f
, gfc_expr
*x ATTRIBUTE_UNUSED
)
564 f
->ts
= f
->value
.function
.isym
->ts
;
569 gfc_resolve_c_funloc (gfc_expr
*f
, gfc_expr
*x ATTRIBUTE_UNUSED
)
571 f
->ts
= f
->value
.function
.isym
->ts
;
576 gfc_resolve_ceiling (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
578 f
->ts
.type
= BT_INTEGER
;
579 f
->ts
.kind
= (kind
== NULL
)
580 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
581 f
->value
.function
.name
582 = gfc_get_string ("__ceiling_%d_%c%d", f
->ts
.kind
,
583 gfc_type_letter (a
->ts
.type
),
584 gfc_type_abi_kind (&a
->ts
));
589 gfc_resolve_char (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
591 gfc_resolve_char_achar (f
, a
, kind
, false);
596 gfc_resolve_chdir (gfc_expr
*f
, gfc_expr
*d ATTRIBUTE_UNUSED
)
598 f
->ts
.type
= BT_INTEGER
;
599 f
->ts
.kind
= gfc_default_integer_kind
;
600 f
->value
.function
.name
= gfc_get_string (PREFIX ("chdir_i%d"), f
->ts
.kind
);
605 gfc_resolve_chdir_sub (gfc_code
*c
)
610 if (c
->ext
.actual
->next
->expr
!= NULL
)
611 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
613 kind
= gfc_default_integer_kind
;
615 name
= gfc_get_string (PREFIX ("chdir_i%d_sub"), kind
);
616 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
621 gfc_resolve_chmod (gfc_expr
*f
, gfc_expr
*name ATTRIBUTE_UNUSED
,
622 gfc_expr
*mode ATTRIBUTE_UNUSED
)
624 f
->ts
.type
= BT_INTEGER
;
625 f
->ts
.kind
= gfc_c_int_kind
;
626 f
->value
.function
.name
= PREFIX ("chmod_func");
631 gfc_resolve_chmod_sub (gfc_code
*c
)
636 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
637 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
639 kind
= gfc_default_integer_kind
;
641 name
= gfc_get_string (PREFIX ("chmod_i%d_sub"), kind
);
642 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
647 gfc_resolve_cmplx (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y
, gfc_expr
*kind
)
649 f
->ts
.type
= BT_COMPLEX
;
650 f
->ts
.kind
= (kind
== NULL
)
651 ? gfc_default_real_kind
: mpz_get_si (kind
->value
.integer
);
654 f
->value
.function
.name
655 = gfc_get_string ("__cmplx0_%d_%c%d", f
->ts
.kind
,
656 gfc_type_letter (x
->ts
.type
),
657 gfc_type_abi_kind (&x
->ts
));
659 f
->value
.function
.name
660 = gfc_get_string ("__cmplx1_%d_%c%d_%c%d", f
->ts
.kind
,
661 gfc_type_letter (x
->ts
.type
),
662 gfc_type_abi_kind (&x
->ts
),
663 gfc_type_letter (y
->ts
.type
),
664 gfc_type_abi_kind (&y
->ts
));
669 gfc_resolve_dcmplx (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y
)
671 gfc_resolve_cmplx (f
, x
, y
, gfc_get_int_expr (gfc_default_integer_kind
, NULL
,
672 gfc_default_double_kind
));
677 gfc_resolve_complex (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y
)
681 if (x
->ts
.type
== BT_INTEGER
)
683 if (y
->ts
.type
== BT_INTEGER
)
684 kind
= gfc_default_real_kind
;
690 if (y
->ts
.type
== BT_REAL
)
691 kind
= (x
->ts
.kind
> y
->ts
.kind
) ? x
->ts
.kind
: y
->ts
.kind
;
696 f
->ts
.type
= BT_COMPLEX
;
698 f
->value
.function
.name
699 = gfc_get_string ("__cmplx1_%d_%c%d_%c%d", f
->ts
.kind
,
700 gfc_type_letter (x
->ts
.type
),
701 gfc_type_abi_kind (&x
->ts
),
702 gfc_type_letter (y
->ts
.type
),
703 gfc_type_abi_kind (&y
->ts
));
708 gfc_resolve_conjg (gfc_expr
*f
, gfc_expr
*x
)
711 f
->value
.function
.name
= gfc_get_string ("__conjg_%d", x
->ts
.kind
);
716 gfc_resolve_cos (gfc_expr
*f
, gfc_expr
*x
)
719 f
->value
.function
.name
720 = gfc_get_string ("__cos_%c%d", gfc_type_letter (x
->ts
.type
),
721 gfc_type_abi_kind (&x
->ts
));
726 gfc_resolve_cosh (gfc_expr
*f
, gfc_expr
*x
)
729 f
->value
.function
.name
730 = gfc_get_string ("__cosh_%c%d", gfc_type_letter (x
->ts
.type
),
731 gfc_type_abi_kind (&x
->ts
));
736 gfc_resolve_count (gfc_expr
*f
, gfc_expr
*mask
, gfc_expr
*dim
, gfc_expr
*kind
)
738 f
->ts
.type
= BT_INTEGER
;
740 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
742 f
->ts
.kind
= gfc_default_integer_kind
;
746 f
->rank
= mask
->rank
- 1;
747 gfc_resolve_dim_arg (dim
);
748 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
751 resolve_mask_arg (mask
);
753 f
->value
.function
.name
754 = gfc_get_string (PREFIX ("count_%d_%c"), gfc_type_abi_kind (&f
->ts
),
755 gfc_type_letter (mask
->ts
.type
));
760 gfc_resolve_cshift (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*shift
,
765 if (array
->ts
.type
== BT_CHARACTER
&& array
->ref
)
766 gfc_resolve_substring_charlen (array
);
769 f
->rank
= array
->rank
;
770 f
->corank
= array
->corank
;
771 f
->shape
= gfc_copy_shape (array
->shape
, array
->rank
);
778 /* If dim kind is greater than default integer we need to use the larger. */
779 m
= gfc_default_integer_kind
;
781 m
= m
< dim
->ts
.kind
? dim
->ts
.kind
: m
;
783 /* Convert shift to at least m, so we don't need
784 kind=1 and kind=2 versions of the library functions. */
785 if (shift
->ts
.kind
< m
)
789 ts
.type
= BT_INTEGER
;
791 gfc_convert_type_warn (shift
, &ts
, 2, 0);
796 if (dim
->expr_type
!= EXPR_CONSTANT
&& dim
->symtree
!= NULL
797 && dim
->symtree
->n
.sym
->attr
.optional
)
799 /* Mark this for later setting the type in gfc_conv_missing_dummy. */
800 dim
->representation
.length
= shift
->ts
.kind
;
804 gfc_resolve_dim_arg (dim
);
805 /* Convert dim to shift's kind to reduce variations. */
806 if (dim
->ts
.kind
!= shift
->ts
.kind
)
807 gfc_convert_type_warn (dim
, &shift
->ts
, 2, 0);
811 if (array
->ts
.type
== BT_CHARACTER
)
813 if (array
->ts
.kind
== gfc_default_character_kind
)
814 f
->value
.function
.name
815 = gfc_get_string (PREFIX ("cshift%d_%d_char"), n
, shift
->ts
.kind
);
817 f
->value
.function
.name
818 = gfc_get_string (PREFIX ("cshift%d_%d_char%d"), n
, shift
->ts
.kind
,
822 f
->value
.function
.name
823 = gfc_get_string (PREFIX ("cshift%d_%d"), n
, shift
->ts
.kind
);
828 gfc_resolve_ctime (gfc_expr
*f
, gfc_expr
*time
)
833 f
->ts
.type
= BT_CHARACTER
;
834 f
->ts
.kind
= gfc_default_character_kind
;
836 /* ctime TIME argument is a INTEGER(KIND=8), says the doc */
837 if (time
->ts
.kind
!= 8)
839 ts
.type
= BT_INTEGER
;
843 gfc_convert_type (time
, &ts
, 2);
846 f
->value
.function
.name
= gfc_get_string (PREFIX ("ctime"));
851 gfc_resolve_dble (gfc_expr
*f
, gfc_expr
*a
)
853 f
->ts
.type
= BT_REAL
;
854 f
->ts
.kind
= gfc_default_double_kind
;
855 f
->value
.function
.name
856 = gfc_get_string ("__dble_%c%d", gfc_type_letter (a
->ts
.type
),
857 gfc_type_abi_kind (&a
->ts
));
862 gfc_resolve_dim (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p
)
864 f
->ts
.type
= a
->ts
.type
;
866 f
->ts
.kind
= gfc_kind_max (a
,p
);
868 f
->ts
.kind
= a
->ts
.kind
;
870 if (p
!= NULL
&& a
->ts
.kind
!= p
->ts
.kind
)
872 if (a
->ts
.kind
== gfc_kind_max (a
,p
))
873 gfc_convert_type (p
, &a
->ts
, 2);
875 gfc_convert_type (a
, &p
->ts
, 2);
878 f
->value
.function
.name
879 = gfc_get_string ("__dim_%c%d", gfc_type_letter (f
->ts
.type
),
880 gfc_type_abi_kind (&f
->ts
));
885 gfc_resolve_dot_product (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*b
)
889 temp
.expr_type
= EXPR_OP
;
890 gfc_clear_ts (&temp
.ts
);
891 temp
.value
.op
.op
= INTRINSIC_NONE
;
892 temp
.value
.op
.op1
= a
;
893 temp
.value
.op
.op2
= b
;
894 gfc_type_convert_binary (&temp
, 1);
896 f
->value
.function
.name
897 = gfc_get_string (PREFIX ("dot_product_%c%d"),
898 gfc_type_letter (f
->ts
.type
),
899 gfc_type_abi_kind (&f
->ts
));
904 gfc_resolve_dprod (gfc_expr
*f
, gfc_expr
*a ATTRIBUTE_UNUSED
,
905 gfc_expr
*b ATTRIBUTE_UNUSED
)
907 f
->ts
.kind
= gfc_default_double_kind
;
908 f
->ts
.type
= BT_REAL
;
909 f
->value
.function
.name
= gfc_get_string ("__dprod_r%d",
910 gfc_type_abi_kind (&f
->ts
));
915 gfc_resolve_dshift (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j ATTRIBUTE_UNUSED
,
916 gfc_expr
*shift ATTRIBUTE_UNUSED
)
918 char c
= i
->ts
.type
== BT_INTEGER
? 'i' : 'u';
921 if (f
->value
.function
.isym
->id
== GFC_ISYM_DSHIFTL
)
922 f
->value
.function
.name
= gfc_get_string ("dshiftl_%c%d", c
, f
->ts
.kind
);
923 else if (f
->value
.function
.isym
->id
== GFC_ISYM_DSHIFTR
)
924 f
->value
.function
.name
= gfc_get_string ("dshiftr_%c%d", c
, f
->ts
.kind
);
931 gfc_resolve_eoshift (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*shift
,
932 gfc_expr
*boundary
, gfc_expr
*dim
)
936 if (array
->ts
.type
== BT_CHARACTER
&& array
->ref
)
937 gfc_resolve_substring_charlen (array
);
940 f
->rank
= array
->rank
;
941 f
->corank
= array
->corank
;
942 f
->shape
= gfc_copy_shape (array
->shape
, array
->rank
);
947 if (boundary
&& boundary
->rank
> 0)
950 /* If dim kind is greater than default integer we need to use the larger. */
951 m
= gfc_default_integer_kind
;
953 m
= m
< dim
->ts
.kind
? dim
->ts
.kind
: m
;
955 /* Convert shift to at least m, so we don't need
956 kind=1 and kind=2 versions of the library functions. */
957 if (shift
->ts
.kind
< m
)
961 ts
.type
= BT_INTEGER
;
963 gfc_convert_type_warn (shift
, &ts
, 2, 0);
968 if (dim
->expr_type
!= EXPR_CONSTANT
&& dim
->symtree
!= NULL
969 && dim
->symtree
->n
.sym
->attr
.optional
)
971 /* Mark this for later setting the type in gfc_conv_missing_dummy. */
972 dim
->representation
.length
= shift
->ts
.kind
;
976 gfc_resolve_dim_arg (dim
);
977 /* Convert dim to shift's kind to reduce variations. */
978 if (dim
->ts
.kind
!= shift
->ts
.kind
)
979 gfc_convert_type_warn (dim
, &shift
->ts
, 2, 0);
983 if (array
->ts
.type
== BT_CHARACTER
)
985 if (array
->ts
.kind
== gfc_default_character_kind
)
986 f
->value
.function
.name
987 = gfc_get_string (PREFIX ("eoshift%d_%d_char"), n
, shift
->ts
.kind
);
989 f
->value
.function
.name
990 = gfc_get_string (PREFIX ("eoshift%d_%d_char%d"), n
, shift
->ts
.kind
,
994 f
->value
.function
.name
995 = gfc_get_string (PREFIX ("eoshift%d_%d"), n
, shift
->ts
.kind
);
1000 gfc_resolve_exp (gfc_expr
*f
, gfc_expr
*x
)
1003 f
->value
.function
.name
1004 = gfc_get_string ("__exp_%c%d", gfc_type_letter (x
->ts
.type
),
1005 gfc_type_abi_kind (&x
->ts
));
1010 gfc_resolve_exponent (gfc_expr
*f
, gfc_expr
*x
)
1012 f
->ts
.type
= BT_INTEGER
;
1013 f
->ts
.kind
= gfc_default_integer_kind
;
1014 f
->value
.function
.name
= gfc_get_string ("__exponent_%d", x
->ts
.kind
);
1018 /* Resolve the EXTENDS_TYPE_OF intrinsic function. */
1021 gfc_resolve_extends_type_of (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*mo
)
1026 /* Prevent double resolution. */
1027 if (f
->ts
.type
== BT_LOGICAL
)
1030 /* Replace the first argument with the corresponding vtab. */
1031 if (a
->ts
.type
== BT_CLASS
)
1032 gfc_add_vptr_component (a
);
1033 else if (a
->ts
.type
== BT_DERIVED
)
1037 vtab
= gfc_find_derived_vtab (a
->ts
.u
.derived
);
1038 /* Clear the old expr. */
1039 gfc_free_ref_list (a
->ref
);
1041 memset (a
, '\0', sizeof (gfc_expr
));
1042 /* Construct a new one. */
1043 a
->expr_type
= EXPR_VARIABLE
;
1044 st
= gfc_find_symtree (vtab
->ns
->sym_root
, vtab
->name
);
1050 /* Replace the second argument with the corresponding vtab. */
1051 if (mo
->ts
.type
== BT_CLASS
)
1052 gfc_add_vptr_component (mo
);
1053 else if (mo
->ts
.type
== BT_DERIVED
)
1057 vtab
= gfc_find_derived_vtab (mo
->ts
.u
.derived
);
1058 /* Clear the old expr. */
1060 gfc_free_ref_list (mo
->ref
);
1061 memset (mo
, '\0', sizeof (gfc_expr
));
1062 /* Construct a new one. */
1063 mo
->expr_type
= EXPR_VARIABLE
;
1064 st
= gfc_find_symtree (vtab
->ns
->sym_root
, vtab
->name
);
1070 f
->ts
.type
= BT_LOGICAL
;
1073 f
->value
.function
.isym
->formal
->ts
= a
->ts
;
1074 f
->value
.function
.isym
->formal
->next
->ts
= mo
->ts
;
1076 /* Call library function. */
1077 f
->value
.function
.name
= gfc_get_string (PREFIX ("is_extension_of"));
1082 gfc_resolve_fdate (gfc_expr
*f
)
1084 f
->ts
.type
= BT_CHARACTER
;
1085 f
->ts
.kind
= gfc_default_character_kind
;
1086 f
->value
.function
.name
= gfc_get_string (PREFIX ("fdate"));
1091 gfc_resolve_floor (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
1093 f
->ts
.type
= BT_INTEGER
;
1094 f
->ts
.kind
= (kind
== NULL
)
1095 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
1096 f
->value
.function
.name
1097 = gfc_get_string ("__floor%d_%c%d", f
->ts
.kind
,
1098 gfc_type_letter (a
->ts
.type
),
1099 gfc_type_abi_kind (&a
->ts
));
1104 gfc_resolve_fnum (gfc_expr
*f
, gfc_expr
*n
)
1106 f
->ts
.type
= BT_INTEGER
;
1107 f
->ts
.kind
= gfc_default_integer_kind
;
1108 if (n
->ts
.kind
!= f
->ts
.kind
)
1109 gfc_convert_type (n
, &f
->ts
, 2);
1110 f
->value
.function
.name
= gfc_get_string (PREFIX ("fnum_i%d"), f
->ts
.kind
);
1115 gfc_resolve_fraction (gfc_expr
*f
, gfc_expr
*x
)
1118 f
->value
.function
.name
= gfc_get_string ("__fraction_%d", x
->ts
.kind
);
1122 /* Resolve single-argument g77 math intrinsics, eg BESY0, ERF. */
1125 gfc_resolve_g77_math1 (gfc_expr
*f
, gfc_expr
*x
)
1128 f
->value
.function
.name
= gfc_get_string ("<intrinsic>");
1133 gfc_resolve_gamma (gfc_expr
*f
, gfc_expr
*x
)
1136 f
->value
.function
.name
1137 = gfc_get_string ("__tgamma_%d", x
->ts
.kind
);
1142 gfc_resolve_getcwd (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
1144 f
->ts
.type
= BT_INTEGER
;
1146 f
->value
.function
.name
= gfc_get_string (PREFIX ("getcwd"));
1151 gfc_resolve_getgid (gfc_expr
*f
)
1153 f
->ts
.type
= BT_INTEGER
;
1155 f
->value
.function
.name
= gfc_get_string (PREFIX ("getgid"));
1160 gfc_resolve_getpid (gfc_expr
*f
)
1162 f
->ts
.type
= BT_INTEGER
;
1164 f
->value
.function
.name
= gfc_get_string (PREFIX ("getpid"));
1169 gfc_resolve_getuid (gfc_expr
*f
)
1171 f
->ts
.type
= BT_INTEGER
;
1173 f
->value
.function
.name
= gfc_get_string (PREFIX ("getuid"));
1178 gfc_resolve_hostnm (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
1180 f
->ts
.type
= BT_INTEGER
;
1182 f
->value
.function
.name
= gfc_get_string (PREFIX ("hostnm"));
1187 gfc_resolve_hypot (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y ATTRIBUTE_UNUSED
)
1190 f
->value
.function
.name
= gfc_get_string ("__hypot_r%d",
1191 gfc_type_abi_kind (&x
->ts
));
1196 gfc_resolve_iall (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*mask
)
1198 resolve_transformational ("iall", f
, array
, dim
, mask
, true);
1203 gfc_resolve_iand (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
1205 /* If the kind of i and j are different, then g77 cross-promoted the
1206 kinds to the largest value. The Fortran 95 standard requires the
1209 if (i
->ts
.kind
!= j
->ts
.kind
)
1211 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
1212 gfc_convert_type (j
, &i
->ts
, 2);
1214 gfc_convert_type (i
, &j
->ts
, 2);
1218 const char *name
= i
->ts
.kind
== BT_UNSIGNED
? "__iand_m_%d" : "__iand_%d";
1219 f
->value
.function
.name
= gfc_get_string (name
, i
->ts
.kind
);
1224 gfc_resolve_iany (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*mask
)
1226 resolve_transformational ("iany", f
, array
, dim
, mask
, true);
1231 gfc_resolve_ibclr (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos ATTRIBUTE_UNUSED
)
1234 const char *name
= i
->ts
.kind
== BT_UNSIGNED
? "__ibclr_m_%d" : "__ibclr_%d";
1235 f
->value
.function
.name
= gfc_get_string (name
, i
->ts
.kind
);
1240 gfc_resolve_ibits (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos ATTRIBUTE_UNUSED
,
1241 gfc_expr
*len ATTRIBUTE_UNUSED
)
1244 const char *name
= i
->ts
.kind
== BT_UNSIGNED
? "__ibits_m_%d" : "__ibits_%d";
1245 f
->value
.function
.name
= gfc_get_string (name
, i
->ts
.kind
);
1250 gfc_resolve_ibset (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos ATTRIBUTE_UNUSED
)
1253 const char *name
= i
->ts
.kind
== BT_UNSIGNED
? "__ibset_m_%d" : "__ibset_%d";
1254 f
->value
.function
.name
= gfc_get_string (name
, i
->ts
.kind
);
1259 gfc_resolve_iachar (gfc_expr
*f
, gfc_expr
*c
, gfc_expr
*kind
)
1261 f
->ts
.type
= BT_INTEGER
;
1263 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1265 f
->ts
.kind
= gfc_default_integer_kind
;
1266 f
->value
.function
.name
= gfc_get_string ("__ichar_%d", c
->ts
.kind
);
1271 gfc_resolve_ichar (gfc_expr
*f
, gfc_expr
*c
, gfc_expr
*kind
)
1273 f
->ts
.type
= BT_INTEGER
;
1275 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1277 f
->ts
.kind
= gfc_default_integer_kind
;
1278 f
->value
.function
.name
= gfc_get_string ("__ichar_%d", c
->ts
.kind
);
1283 gfc_resolve_idnint (gfc_expr
*f
, gfc_expr
*a
)
1285 gfc_resolve_nint (f
, a
, NULL
);
1290 gfc_resolve_ierrno (gfc_expr
*f
)
1292 f
->ts
.type
= BT_INTEGER
;
1293 f
->ts
.kind
= gfc_default_integer_kind
;
1294 f
->value
.function
.name
= gfc_get_string (PREFIX ("ierrno_i%d"), f
->ts
.kind
);
1299 gfc_resolve_ieor (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
1301 /* If the kind of i and j are different, then g77 cross-promoted the
1302 kinds to the largest value. The Fortran 95 standard requires the
1305 if (i
->ts
.kind
!= j
->ts
.kind
)
1307 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
1308 gfc_convert_type (j
, &i
->ts
, 2);
1310 gfc_convert_type (i
, &j
->ts
, 2);
1313 const char *name
= i
->ts
.kind
== BT_UNSIGNED
? "__ieor_m_%d" : "__ieor_%d";
1315 f
->value
.function
.name
= gfc_get_string (name
, i
->ts
.kind
);
1320 gfc_resolve_ior (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
1322 /* If the kind of i and j are different, then g77 cross-promoted the
1323 kinds to the largest value. The Fortran 95 standard requires the
1326 if (i
->ts
.kind
!= j
->ts
.kind
)
1328 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
1329 gfc_convert_type (j
, &i
->ts
, 2);
1331 gfc_convert_type (i
, &j
->ts
, 2);
1334 const char *name
= i
->ts
.kind
== BT_UNSIGNED
? "__ior_m_%d" : "__ior_%d";
1336 f
->value
.function
.name
= gfc_get_string (name
, i
->ts
.kind
);
1341 gfc_resolve_index_func (gfc_expr
*f
, gfc_expr
*str
,
1342 gfc_expr
*sub_str ATTRIBUTE_UNUSED
, gfc_expr
*back
,
1348 f
->ts
.type
= BT_INTEGER
;
1350 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1352 f
->ts
.kind
= gfc_default_integer_kind
;
1354 if (back
&& back
->ts
.kind
!= gfc_default_integer_kind
)
1356 ts
.type
= BT_LOGICAL
;
1357 ts
.kind
= gfc_default_integer_kind
;
1358 ts
.u
.derived
= NULL
;
1360 gfc_convert_type (back
, &ts
, 2);
1363 f
->value
.function
.name
1364 = gfc_get_string ("__index_%d_i%d", str
->ts
.kind
, f
->ts
.kind
);
1369 gfc_resolve_int (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
1371 f
->ts
.type
= BT_INTEGER
;
1372 f
->ts
.kind
= (kind
== NULL
)
1373 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
1374 f
->value
.function
.name
1375 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1376 gfc_type_letter (a
->ts
.type
),
1377 gfc_type_abi_kind (&a
->ts
));
1381 gfc_resolve_uint (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
1383 f
->ts
.type
= BT_UNSIGNED
;
1384 f
->ts
.kind
= (kind
== NULL
)
1385 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
1386 f
->value
.function
.name
1387 = gfc_get_string ("__uint_%d_%c%d", f
->ts
.kind
,
1388 gfc_type_letter (a
->ts
.type
),
1389 gfc_type_abi_kind (&a
->ts
));
1394 gfc_resolve_int2 (gfc_expr
*f
, gfc_expr
*a
)
1396 f
->ts
.type
= BT_INTEGER
;
1398 f
->value
.function
.name
1399 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1400 gfc_type_letter (a
->ts
.type
),
1401 gfc_type_abi_kind (&a
->ts
));
1406 gfc_resolve_int8 (gfc_expr
*f
, gfc_expr
*a
)
1408 f
->ts
.type
= BT_INTEGER
;
1410 f
->value
.function
.name
1411 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1412 gfc_type_letter (a
->ts
.type
),
1413 gfc_type_abi_kind (&a
->ts
));
1418 gfc_resolve_long (gfc_expr
*f
, gfc_expr
*a
)
1420 f
->ts
.type
= BT_INTEGER
;
1422 f
->value
.function
.name
1423 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1424 gfc_type_letter (a
->ts
.type
),
1425 gfc_type_abi_kind (&a
->ts
));
1430 gfc_resolve_iparity (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*mask
)
1432 resolve_transformational ("iparity", f
, array
, dim
, mask
, true);
1437 gfc_resolve_isatty (gfc_expr
*f
, gfc_expr
*u
)
1442 f
->ts
.type
= BT_LOGICAL
;
1443 f
->ts
.kind
= gfc_default_integer_kind
;
1444 if (u
->ts
.kind
!= gfc_c_int_kind
)
1446 ts
.type
= BT_INTEGER
;
1447 ts
.kind
= gfc_c_int_kind
;
1448 ts
.u
.derived
= NULL
;
1450 gfc_convert_type (u
, &ts
, 2);
1453 f
->value
.function
.name
= gfc_get_string (PREFIX ("isatty_l%d"), f
->ts
.kind
);
1458 gfc_resolve_is_contiguous (gfc_expr
*f
, gfc_expr
*array ATTRIBUTE_UNUSED
)
1460 f
->ts
.type
= BT_LOGICAL
;
1461 f
->ts
.kind
= gfc_default_logical_kind
;
1462 f
->value
.function
.name
= gfc_get_string ("__is_contiguous");
1467 gfc_resolve_ishft (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
)
1470 f
->value
.function
.name
1471 = gfc_get_string ("__ishft_%d_%d", i
->ts
.kind
, shift
->ts
.kind
);
1476 gfc_resolve_rshift (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
)
1479 f
->value
.function
.name
1480 = gfc_get_string ("__rshift_%d_%d", i
->ts
.kind
, shift
->ts
.kind
);
1485 gfc_resolve_lshift (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
)
1488 f
->value
.function
.name
1489 = gfc_get_string ("__lshift_%d_%d", i
->ts
.kind
, shift
->ts
.kind
);
1494 gfc_resolve_ishftc (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
, gfc_expr
*size
)
1498 s_kind
= (size
== NULL
) ? gfc_default_integer_kind
: size
->ts
.kind
;
1501 f
->value
.function
.name
1502 = gfc_get_string ("__ishftc_%d_%d_%d", i
->ts
.kind
, shift
->ts
.kind
, s_kind
);
1507 gfc_resolve_lbound (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
1509 resolve_bound (f
, array
, dim
, kind
, "__lbound", false);
1514 gfc_resolve_lcobound (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
1516 resolve_bound (f
, array
, dim
, kind
, "__lcobound", true);
1521 gfc_resolve_len (gfc_expr
*f
, gfc_expr
*string
, gfc_expr
*kind
)
1523 f
->ts
.type
= BT_INTEGER
;
1525 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1527 f
->ts
.kind
= gfc_default_integer_kind
;
1528 f
->value
.function
.name
1529 = gfc_get_string ("__len_%d_i%d", string
->ts
.kind
,
1530 gfc_default_integer_kind
);
1535 gfc_resolve_len_trim (gfc_expr
*f
, gfc_expr
*string
, gfc_expr
*kind
)
1537 f
->ts
.type
= BT_INTEGER
;
1539 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1541 f
->ts
.kind
= gfc_default_integer_kind
;
1542 f
->value
.function
.name
= gfc_get_string ("__len_trim%d", string
->ts
.kind
);
1547 gfc_resolve_lgamma (gfc_expr
*f
, gfc_expr
*x
)
1550 f
->value
.function
.name
1551 = gfc_get_string ("__lgamma_%d", x
->ts
.kind
);
1556 gfc_resolve_link (gfc_expr
*f
, gfc_expr
*p1 ATTRIBUTE_UNUSED
,
1557 gfc_expr
*p2 ATTRIBUTE_UNUSED
)
1559 f
->ts
.type
= BT_INTEGER
;
1560 f
->ts
.kind
= gfc_default_integer_kind
;
1561 f
->value
.function
.name
= gfc_get_string (PREFIX ("link_i%d"), f
->ts
.kind
);
1566 gfc_resolve_loc (gfc_expr
*f
, gfc_expr
*x
)
1568 f
->ts
.type
= BT_INTEGER
;
1569 f
->ts
.kind
= gfc_index_integer_kind
;
1570 f
->value
.function
.name
= gfc_get_string ("__loc_%d", x
->ts
.kind
);
1575 gfc_resolve_log (gfc_expr
*f
, gfc_expr
*x
)
1578 f
->value
.function
.name
1579 = gfc_get_string ("__log_%c%d", gfc_type_letter (x
->ts
.type
),
1580 gfc_type_abi_kind (&x
->ts
));
1585 gfc_resolve_log10 (gfc_expr
*f
, gfc_expr
*x
)
1588 f
->value
.function
.name
1589 = gfc_get_string ("__log10_%c%d", gfc_type_letter (x
->ts
.type
),
1590 gfc_type_abi_kind (&x
->ts
));
1595 gfc_resolve_logical (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
1597 f
->ts
.type
= BT_LOGICAL
;
1598 f
->ts
.kind
= (kind
== NULL
)
1599 ? gfc_default_logical_kind
: mpz_get_si (kind
->value
.integer
);
1601 f
->corank
= a
->corank
;
1603 f
->value
.function
.name
1604 = gfc_get_string ("__logical_%d_%c%d", f
->ts
.kind
,
1605 gfc_type_letter (a
->ts
.type
),
1606 gfc_type_abi_kind (&a
->ts
));
1611 gfc_resolve_matmul (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*b
)
1616 if (a
->ts
.type
== BT_LOGICAL
&& b
->ts
.type
== BT_LOGICAL
)
1618 f
->ts
.type
= BT_LOGICAL
;
1619 f
->ts
.kind
= gfc_default_logical_kind
;
1623 temp
.expr_type
= EXPR_OP
;
1624 gfc_clear_ts (&temp
.ts
);
1625 temp
.value
.op
.op
= INTRINSIC_NONE
;
1626 temp
.value
.op
.op1
= a
;
1627 temp
.value
.op
.op2
= b
;
1628 gfc_type_convert_binary (&temp
, 1);
1632 f
->rank
= (a
->rank
== 2 && b
->rank
== 2) ? 2 : 1;
1633 f
->corank
= a
->corank
;
1635 if (a
->rank
== 2 && b
->rank
== 2)
1637 if (a
->shape
&& b
->shape
)
1639 f
->shape
= gfc_get_shape (f
->rank
);
1640 mpz_init_set (f
->shape
[0], a
->shape
[0]);
1641 mpz_init_set (f
->shape
[1], b
->shape
[1]);
1644 else if (a
->rank
== 1)
1648 f
->shape
= gfc_get_shape (f
->rank
);
1649 mpz_init_set (f
->shape
[0], b
->shape
[1]);
1654 /* b->rank == 1 and a->rank == 2 here, all other cases have
1655 been caught in check.cc. */
1658 f
->shape
= gfc_get_shape (f
->rank
);
1659 mpz_init_set (f
->shape
[0], a
->shape
[0]);
1663 /* We use the same library version of matmul for INTEGER and UNSIGNED,
1664 which we call as the INTEGER version. */
1666 if (f
->ts
.type
== BT_UNSIGNED
)
1671 f
->value
.function
.name
1672 = gfc_get_string (PREFIX ("matmul_%c%d"), gfc_type_letter (type
),
1673 gfc_type_abi_kind (&f
->ts
));
1678 gfc_resolve_minmax (const char *name
, gfc_expr
*f
, gfc_actual_arglist
*args
)
1680 gfc_actual_arglist
*a
;
1682 f
->ts
.type
= args
->expr
->ts
.type
;
1683 f
->ts
.kind
= args
->expr
->ts
.kind
;
1684 /* Find the largest type kind. */
1685 for (a
= args
->next
; a
; a
= a
->next
)
1687 if (a
->expr
->ts
.kind
> f
->ts
.kind
)
1688 f
->ts
.kind
= a
->expr
->ts
.kind
;
1691 /* Convert all parameters to the required kind. */
1692 for (a
= args
; a
; a
= a
->next
)
1694 if (a
->expr
->ts
.kind
!= f
->ts
.kind
)
1695 gfc_convert_type (a
->expr
, &f
->ts
, 2);
1698 f
->value
.function
.name
1699 = gfc_get_string (name
, gfc_type_letter (f
->ts
.type
),
1700 gfc_type_abi_kind (&f
->ts
));
1705 gfc_resolve_max (gfc_expr
*f
, gfc_actual_arglist
*args
)
1707 gfc_resolve_minmax ("__max_%c%d", f
, args
);
1710 /* The smallest kind for which a minloc and maxloc implementation exists. */
1712 #define MINMAXLOC_MIN_KIND 4
1715 gfc_resolve_maxloc (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
1716 gfc_expr
*mask
, gfc_expr
*kind
, gfc_expr
*back
)
1723 f
->ts
.type
= BT_INTEGER
;
1725 /* The library versions only exist for kinds 4, 8 and 16. For smaller kinds,
1726 we do a type conversion further down. */
1728 fkind
= mpz_get_si (kind
->value
.integer
);
1730 fkind
= gfc_default_integer_kind
;
1732 if (fkind
< MINMAXLOC_MIN_KIND
)
1733 f
->ts
.kind
= MINMAXLOC_MIN_KIND
;
1740 f
->shape
= gfc_get_shape (1);
1741 mpz_init_set_si (f
->shape
[0], array
->rank
);
1745 f
->rank
= array
->rank
- 1;
1746 gfc_resolve_dim_arg (dim
);
1747 if (array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
1749 idim
= (int) mpz_get_si (dim
->value
.integer
);
1750 f
->shape
= gfc_get_shape (f
->rank
);
1751 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
1753 if (i
== (idim
- 1))
1755 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
1762 if (mask
->rank
== 0)
1767 resolve_mask_arg (mask
);
1774 if (array
->ts
.type
!= BT_CHARACTER
|| f
->rank
!= 0)
1782 f
->value
.function
.name
1783 = gfc_get_string (PREFIX ("%s%d_%d_%c%d"), name
, d_num
, f
->ts
.kind
,
1784 gfc_type_letter (array
->ts
.type
),
1785 gfc_type_abi_kind (&array
->ts
));
1788 fkind
= mpz_get_si (kind
->value
.integer
);
1790 fkind
= gfc_default_integer_kind
;
1792 if (fkind
!= f
->ts
.kind
)
1797 ts
.type
= BT_INTEGER
;
1799 gfc_convert_type_warn (f
, &ts
, 2, 0);
1802 if (back
->ts
.kind
!= gfc_logical_4_kind
)
1806 ts
.type
= BT_LOGICAL
;
1807 ts
.kind
= gfc_logical_4_kind
;
1808 gfc_convert_type_warn (back
, &ts
, 2, 0);
1814 gfc_resolve_findloc (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*value
,
1815 gfc_expr
*dim
, gfc_expr
*mask
, gfc_expr
*kind
,
1824 /* See at the end of the function for why this is necessary. */
1826 if (f
->do_not_resolve_again
)
1829 f
->ts
.type
= BT_INTEGER
;
1831 /* We have a single library version, which uses index_type. */
1834 fkind
= mpz_get_si (kind
->value
.integer
);
1836 fkind
= gfc_default_integer_kind
;
1838 f
->ts
.kind
= gfc_index_integer_kind
;
1840 /* Convert value. If array is not LOGICAL and value is, we already
1841 issued an error earlier. */
1843 if ((array
->ts
.type
!= value
->ts
.type
&& value
->ts
.type
!= BT_LOGICAL
)
1844 || array
->ts
.kind
!= value
->ts
.kind
)
1845 gfc_convert_type_warn (value
, &array
->ts
, 2, 0);
1850 f
->shape
= gfc_get_shape (1);
1851 mpz_init_set_si (f
->shape
[0], array
->rank
);
1855 f
->rank
= array
->rank
- 1;
1856 gfc_resolve_dim_arg (dim
);
1857 if (array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
1859 idim
= (int) mpz_get_si (dim
->value
.integer
);
1860 f
->shape
= gfc_get_shape (f
->rank
);
1861 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
1863 if (i
== (idim
- 1))
1865 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
1872 if (mask
->rank
== 0)
1877 resolve_mask_arg (mask
);
1892 if (back
->ts
.kind
!= gfc_logical_4_kind
)
1896 ts
.type
= BT_LOGICAL
;
1897 ts
.kind
= gfc_logical_4_kind
;
1898 gfc_convert_type_warn (back
, &ts
, 2, 0);
1901 /* Use the INTEGER library function for UNSIGNED. */
1902 if (array
->ts
.type
!= BT_UNSIGNED
)
1903 type
= array
->ts
.type
;
1907 f
->value
.function
.name
1908 = gfc_get_string (PREFIX ("%s%d_%c%d"), name
, d_num
,
1909 gfc_type_letter (type
, true),
1910 gfc_type_abi_kind (&array
->ts
));
1912 /* We only have a single library function, so we need to convert
1913 here. If the function is resolved from within a convert
1914 function generated on a previous round of resolution, endless
1915 recursion could occur. Guard against that here. */
1917 if (f
->ts
.kind
!= fkind
)
1919 f
->do_not_resolve_again
= 1;
1923 ts
.type
= BT_INTEGER
;
1925 gfc_convert_type_warn (f
, &ts
, 2, 0);
1931 gfc_resolve_maxval (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
1941 f
->rank
= array
->rank
- 1;
1942 gfc_resolve_dim_arg (dim
);
1944 if (f
->rank
&& array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
1946 idim
= (int) mpz_get_si (dim
->value
.integer
);
1947 f
->shape
= gfc_get_shape (f
->rank
);
1948 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
1950 if (i
== (idim
- 1))
1952 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
1959 if (mask
->rank
== 0)
1964 resolve_mask_arg (mask
);
1969 if (array
->ts
.type
!= BT_CHARACTER
)
1970 f
->value
.function
.name
1971 = gfc_get_string (PREFIX ("%s_%c%d"), name
,
1972 gfc_type_letter (array
->ts
.type
),
1973 gfc_type_abi_kind (&array
->ts
));
1975 f
->value
.function
.name
1976 = gfc_get_string (PREFIX ("%s%d_%c%d"), name
, f
->rank
!= 0,
1977 gfc_type_letter (array
->ts
.type
),
1978 gfc_type_abi_kind (&array
->ts
));
1983 gfc_resolve_mclock (gfc_expr
*f
)
1985 f
->ts
.type
= BT_INTEGER
;
1987 f
->value
.function
.name
= PREFIX ("mclock");
1992 gfc_resolve_mclock8 (gfc_expr
*f
)
1994 f
->ts
.type
= BT_INTEGER
;
1996 f
->value
.function
.name
= PREFIX ("mclock8");
2001 gfc_resolve_mask (gfc_expr
*f
, gfc_expr
*i ATTRIBUTE_UNUSED
,
2004 f
->ts
.type
= BT_INTEGER
;
2005 f
->ts
.kind
= kind
? mpz_get_si (kind
->value
.integer
)
2006 : gfc_default_integer_kind
;
2008 if (f
->value
.function
.isym
->id
== GFC_ISYM_MASKL
)
2009 f
->value
.function
.name
= gfc_get_string ("__maskl_i%d", f
->ts
.kind
);
2011 f
->value
.function
.name
= gfc_get_string ("__maskr_i%d", f
->ts
.kind
);
2016 gfc_resolve_merge (gfc_expr
*f
, gfc_expr
*tsource
,
2017 gfc_expr
*fsource ATTRIBUTE_UNUSED
,
2018 gfc_expr
*mask ATTRIBUTE_UNUSED
)
2020 if (tsource
->ts
.type
== BT_CHARACTER
&& tsource
->ref
)
2021 gfc_resolve_substring_charlen (tsource
);
2023 if (fsource
->ts
.type
== BT_CHARACTER
&& fsource
->ref
)
2024 gfc_resolve_substring_charlen (fsource
);
2026 if (tsource
->ts
.type
== BT_CHARACTER
)
2027 check_charlen_present (tsource
);
2029 f
->ts
= tsource
->ts
;
2030 f
->value
.function
.name
2031 = gfc_get_string ("__merge_%c%d", gfc_type_letter (tsource
->ts
.type
),
2032 gfc_type_abi_kind (&tsource
->ts
));
2037 gfc_resolve_merge_bits (gfc_expr
*f
, gfc_expr
*i
,
2038 gfc_expr
*j ATTRIBUTE_UNUSED
,
2039 gfc_expr
*mask ATTRIBUTE_UNUSED
)
2043 f
->value
.function
.name
2044 = gfc_get_string ("__merge_bits_%c%d", gfc_type_letter (i
->ts
.type
),
2050 gfc_resolve_min (gfc_expr
*f
, gfc_actual_arglist
*args
)
2052 gfc_resolve_minmax ("__min_%c%d", f
, args
);
2057 gfc_resolve_minloc (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
2058 gfc_expr
*mask
, gfc_expr
*kind
, gfc_expr
*back
)
2065 f
->ts
.type
= BT_INTEGER
;
2067 /* The library versions only exist for kinds 4, 8 and 16. For smaller kinds,
2068 we do a type conversion further down. */
2070 fkind
= mpz_get_si (kind
->value
.integer
);
2072 fkind
= gfc_default_integer_kind
;
2074 if (fkind
< MINMAXLOC_MIN_KIND
)
2075 f
->ts
.kind
= MINMAXLOC_MIN_KIND
;
2082 f
->shape
= gfc_get_shape (1);
2083 mpz_init_set_si (f
->shape
[0], array
->rank
);
2087 f
->rank
= array
->rank
- 1;
2088 gfc_resolve_dim_arg (dim
);
2089 if (array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
2091 idim
= (int) mpz_get_si (dim
->value
.integer
);
2092 f
->shape
= gfc_get_shape (f
->rank
);
2093 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
2095 if (i
== (idim
- 1))
2097 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
2104 if (mask
->rank
== 0)
2109 resolve_mask_arg (mask
);
2116 if (array
->ts
.type
!= BT_CHARACTER
|| f
->rank
!= 0)
2124 f
->value
.function
.name
2125 = gfc_get_string (PREFIX ("%s%d_%d_%c%d"), name
, d_num
, f
->ts
.kind
,
2126 gfc_type_letter (array
->ts
.type
),
2127 gfc_type_abi_kind (&array
->ts
));
2129 if (fkind
!= f
->ts
.kind
)
2134 ts
.type
= BT_INTEGER
;
2136 gfc_convert_type_warn (f
, &ts
, 2, 0);
2139 if (back
->ts
.kind
!= gfc_logical_4_kind
)
2143 ts
.type
= BT_LOGICAL
;
2144 ts
.kind
= gfc_logical_4_kind
;
2145 gfc_convert_type_warn (back
, &ts
, 2, 0);
2151 gfc_resolve_minval (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
2161 f
->rank
= array
->rank
- 1;
2162 gfc_resolve_dim_arg (dim
);
2164 if (f
->rank
&& array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
2166 idim
= (int) mpz_get_si (dim
->value
.integer
);
2167 f
->shape
= gfc_get_shape (f
->rank
);
2168 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
2170 if (i
== (idim
- 1))
2172 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
2179 if (mask
->rank
== 0)
2184 resolve_mask_arg (mask
);
2189 if (array
->ts
.type
!= BT_CHARACTER
)
2190 f
->value
.function
.name
2191 = gfc_get_string (PREFIX ("%s_%c%d"), name
,
2192 gfc_type_letter (array
->ts
.type
),
2193 gfc_type_abi_kind (&array
->ts
));
2195 f
->value
.function
.name
2196 = gfc_get_string (PREFIX ("%s%d_%c%d"), name
, f
->rank
!= 0,
2197 gfc_type_letter (array
->ts
.type
),
2198 gfc_type_abi_kind (&array
->ts
));
2203 gfc_resolve_mod (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p
)
2205 f
->ts
.type
= a
->ts
.type
;
2207 f
->ts
.kind
= gfc_kind_max (a
,p
);
2209 f
->ts
.kind
= a
->ts
.kind
;
2211 if (p
!= NULL
&& a
->ts
.kind
!= p
->ts
.kind
)
2213 if (a
->ts
.kind
== gfc_kind_max (a
,p
))
2214 gfc_convert_type (p
, &a
->ts
, 2);
2216 gfc_convert_type (a
, &p
->ts
, 2);
2219 f
->value
.function
.name
2220 = gfc_get_string ("__mod_%c%d", gfc_type_letter (f
->ts
.type
),
2221 gfc_type_abi_kind (&f
->ts
));
2226 gfc_resolve_modulo (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p
)
2228 f
->ts
.type
= a
->ts
.type
;
2230 f
->ts
.kind
= gfc_kind_max (a
,p
);
2232 f
->ts
.kind
= a
->ts
.kind
;
2234 if (p
!= NULL
&& a
->ts
.kind
!= p
->ts
.kind
)
2236 if (a
->ts
.kind
== gfc_kind_max (a
,p
))
2237 gfc_convert_type (p
, &a
->ts
, 2);
2239 gfc_convert_type (a
, &p
->ts
, 2);
2242 f
->value
.function
.name
2243 = gfc_get_string ("__modulo_%c%d", gfc_type_letter (f
->ts
.type
),
2244 gfc_type_abi_kind (&f
->ts
));
2248 gfc_resolve_nearest (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p
)
2250 if (p
->ts
.kind
!= a
->ts
.kind
)
2251 gfc_convert_type (p
, &a
->ts
, 2);
2254 f
->value
.function
.name
2255 = gfc_get_string ("__nearest_%c%d", gfc_type_letter (a
->ts
.type
),
2256 gfc_type_abi_kind (&a
->ts
));
2260 gfc_resolve_nint (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
2262 f
->ts
.type
= BT_INTEGER
;
2263 f
->ts
.kind
= (kind
== NULL
)
2264 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
2265 f
->value
.function
.name
2266 = gfc_get_string ("__nint_%d_%d", f
->ts
.kind
, a
->ts
.kind
);
2271 gfc_resolve_norm2 (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
)
2273 resolve_transformational ("norm2", f
, array
, dim
, NULL
);
2278 gfc_resolve_not (gfc_expr
*f
, gfc_expr
*i
)
2281 const char *name
= i
->ts
.kind
== BT_UNSIGNED
? "__not_u_%d" : "__not_%d";
2282 f
->value
.function
.name
= gfc_get_string (name
, i
->ts
.kind
);
2287 gfc_resolve_or (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
2289 f
->ts
.type
= i
->ts
.type
;
2290 f
->ts
.kind
= gfc_kind_max (i
, j
);
2292 if (i
->ts
.kind
!= j
->ts
.kind
)
2294 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
2295 gfc_convert_type (j
, &i
->ts
, 2);
2297 gfc_convert_type (i
, &j
->ts
, 2);
2300 f
->value
.function
.name
2301 = gfc_get_string ("__or_%c%d", gfc_type_letter (i
->ts
.type
),
2302 gfc_type_abi_kind (&f
->ts
));
2307 gfc_resolve_pack (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*mask
,
2308 gfc_expr
*vector ATTRIBUTE_UNUSED
)
2310 if (array
->ts
.type
== BT_CHARACTER
&& array
->ref
)
2311 gfc_resolve_substring_charlen (array
);
2316 resolve_mask_arg (mask
);
2318 if (mask
->rank
!= 0)
2320 if (array
->ts
.type
== BT_CHARACTER
)
2321 f
->value
.function
.name
2322 = array
->ts
.kind
== 1 ? PREFIX ("pack_char")
2324 (PREFIX ("pack_char%d"),
2327 f
->value
.function
.name
= PREFIX ("pack");
2331 if (array
->ts
.type
== BT_CHARACTER
)
2332 f
->value
.function
.name
2333 = array
->ts
.kind
== 1 ? PREFIX ("pack_s_char")
2335 (PREFIX ("pack_s_char%d"),
2338 f
->value
.function
.name
= PREFIX ("pack_s");
2344 gfc_resolve_parity (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
)
2346 resolve_transformational ("parity", f
, array
, dim
, NULL
);
2351 gfc_resolve_product (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
2354 resolve_transformational ("product", f
, array
, dim
, mask
, true);
2359 gfc_resolve_rank (gfc_expr
*f
, gfc_expr
*array ATTRIBUTE_UNUSED
)
2361 f
->ts
.type
= BT_INTEGER
;
2362 f
->ts
.kind
= gfc_default_integer_kind
;
2363 f
->value
.function
.name
= gfc_get_string ("__rank");
2368 gfc_resolve_real (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
2370 f
->ts
.type
= BT_REAL
;
2373 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2375 f
->ts
.kind
= (a
->ts
.type
== BT_COMPLEX
)
2376 ? a
->ts
.kind
: gfc_default_real_kind
;
2378 f
->value
.function
.name
2379 = gfc_get_string ("__real_%d_%c%d", f
->ts
.kind
,
2380 gfc_type_letter (a
->ts
.type
),
2381 gfc_type_abi_kind (&a
->ts
));
2386 gfc_resolve_realpart (gfc_expr
*f
, gfc_expr
*a
)
2388 f
->ts
.type
= BT_REAL
;
2389 f
->ts
.kind
= a
->ts
.kind
;
2390 f
->value
.function
.name
2391 = gfc_get_string ("__real_%d_%c%d", f
->ts
.kind
,
2392 gfc_type_letter (a
->ts
.type
),
2393 gfc_type_abi_kind (&a
->ts
));
2398 gfc_resolve_rename (gfc_expr
*f
, gfc_expr
*p1 ATTRIBUTE_UNUSED
,
2399 gfc_expr
*p2 ATTRIBUTE_UNUSED
)
2401 f
->ts
.type
= BT_INTEGER
;
2402 f
->ts
.kind
= gfc_default_integer_kind
;
2403 f
->value
.function
.name
= gfc_get_string (PREFIX ("rename_i%d"), f
->ts
.kind
);
2408 gfc_resolve_repeat (gfc_expr
*f
, gfc_expr
*string
,
2412 f
->ts
.type
= BT_CHARACTER
;
2413 f
->ts
.kind
= string
->ts
.kind
;
2414 f
->value
.function
.name
= gfc_get_string ("__repeat_%d", string
->ts
.kind
);
2416 /* If possible, generate a character length. */
2417 if (f
->ts
.u
.cl
== NULL
)
2418 f
->ts
.u
.cl
= gfc_new_charlen (gfc_current_ns
, NULL
);
2421 if (string
->expr_type
== EXPR_CONSTANT
)
2423 tmp
= gfc_get_int_expr (gfc_charlen_int_kind
, NULL
,
2424 string
->value
.character
.length
);
2426 else if (string
->ts
.u
.cl
&& string
->ts
.u
.cl
->length
)
2428 tmp
= gfc_copy_expr (string
->ts
.u
.cl
->length
);
2433 /* Force-convert to gfc_charlen_int_kind before gfc_multiply. */
2434 gfc_expr
*e
= gfc_copy_expr (ncopies
);
2435 gfc_typespec ts
= tmp
->ts
;
2436 ts
.kind
= gfc_charlen_int_kind
;
2437 gfc_convert_type_warn (e
, &ts
, 2, 0);
2438 gfc_convert_type_warn (tmp
, &ts
, 2, 0);
2439 f
->ts
.u
.cl
->length
= gfc_multiply (tmp
, e
);
2445 gfc_resolve_reshape (gfc_expr
*f
, gfc_expr
*source
, gfc_expr
*shape
,
2446 gfc_expr
*pad ATTRIBUTE_UNUSED
,
2447 gfc_expr
*order ATTRIBUTE_UNUSED
)
2453 if (source
->ts
.type
== BT_CHARACTER
&& source
->ref
)
2454 gfc_resolve_substring_charlen (source
);
2458 gfc_array_size (shape
, &rank
);
2459 f
->rank
= mpz_get_si (rank
);
2461 switch (source
->ts
.type
)
2468 kind
= source
->ts
.kind
;
2482 if (source
->ts
.type
== BT_COMPLEX
|| source
->ts
.type
== BT_REAL
)
2483 f
->value
.function
.name
2484 = gfc_get_string (PREFIX ("reshape_%c%d"),
2485 gfc_type_letter (source
->ts
.type
),
2486 gfc_type_abi_kind (&source
->ts
));
2487 else if (source
->ts
.type
== BT_CHARACTER
)
2488 f
->value
.function
.name
= gfc_get_string (PREFIX ("reshape_char%d"),
2491 f
->value
.function
.name
2492 = gfc_get_string (PREFIX ("reshape_%d"), source
->ts
.kind
);
2496 f
->value
.function
.name
= (source
->ts
.type
== BT_CHARACTER
2497 ? PREFIX ("reshape_char") : PREFIX ("reshape"));
2501 if (shape
->expr_type
== EXPR_ARRAY
&& gfc_is_constant_array_expr (shape
))
2504 f
->shape
= gfc_get_shape (f
->rank
);
2505 c
= gfc_constructor_first (shape
->value
.constructor
);
2506 for (i
= 0; i
< f
->rank
; i
++)
2508 mpz_init_set (f
->shape
[i
], c
->expr
->value
.integer
);
2509 c
= gfc_constructor_next (c
);
2513 /* Force-convert both SHAPE and ORDER to index_kind so that we don't need
2514 so many runtime variations. */
2515 if (shape
->ts
.kind
!= gfc_index_integer_kind
)
2517 gfc_typespec ts
= shape
->ts
;
2518 ts
.kind
= gfc_index_integer_kind
;
2519 gfc_convert_type_warn (shape
, &ts
, 2, 0);
2521 if (order
&& order
->ts
.kind
!= gfc_index_integer_kind
)
2522 gfc_convert_type_warn (order
, &shape
->ts
, 2, 0);
2527 gfc_resolve_rrspacing (gfc_expr
*f
, gfc_expr
*x
)
2530 f
->value
.function
.name
= gfc_get_string ("__rrspacing_%d", x
->ts
.kind
);
2534 gfc_resolve_fe_runtime_error (gfc_code
*c
)
2537 gfc_actual_arglist
*a
;
2539 name
= gfc_get_string (PREFIX ("runtime_error"));
2541 for (a
= c
->ext
.actual
->next
; a
; a
= a
->next
)
2544 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2545 /* We set the backend_decl here because runtime_error is a
2546 variadic function and we would use the wrong calling
2547 convention otherwise. */
2548 c
->resolved_sym
->backend_decl
= gfor_fndecl_runtime_error
;
2552 gfc_resolve_scale (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*i ATTRIBUTE_UNUSED
)
2555 f
->value
.function
.name
= gfc_get_string ("__scale_%d", x
->ts
.kind
);
2560 gfc_resolve_scan (gfc_expr
*f
, gfc_expr
*string
,
2561 gfc_expr
*set ATTRIBUTE_UNUSED
,
2562 gfc_expr
*back ATTRIBUTE_UNUSED
, gfc_expr
*kind
)
2564 f
->ts
.type
= BT_INTEGER
;
2566 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2568 f
->ts
.kind
= gfc_default_integer_kind
;
2569 f
->value
.function
.name
= gfc_get_string ("__scan_%d", string
->ts
.kind
);
2574 gfc_resolve_secnds (gfc_expr
*t1
, gfc_expr
*t0
)
2577 t1
->value
.function
.name
= gfc_get_string (PREFIX ("secnds"));
2582 gfc_resolve_set_exponent (gfc_expr
*f
, gfc_expr
*x
,
2583 gfc_expr
*i ATTRIBUTE_UNUSED
)
2586 f
->value
.function
.name
= gfc_get_string ("__set_exponent_%d", x
->ts
.kind
);
2591 gfc_resolve_shape (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*kind
)
2593 f
->ts
.type
= BT_INTEGER
;
2596 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2598 f
->ts
.kind
= gfc_default_integer_kind
;
2601 if (array
->rank
!= -1)
2603 f
->shape
= gfc_get_shape (1);
2604 mpz_init_set_ui (f
->shape
[0], array
->rank
);
2607 f
->value
.function
.name
= gfc_get_string (PREFIX ("shape_%d"), f
->ts
.kind
);
2612 gfc_resolve_shift (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift ATTRIBUTE_UNUSED
)
2615 if (f
->value
.function
.isym
->id
== GFC_ISYM_SHIFTA
)
2616 f
->value
.function
.name
= gfc_get_string ("shifta_i%d", f
->ts
.kind
);
2617 else if (f
->value
.function
.isym
->id
== GFC_ISYM_SHIFTL
)
2618 f
->value
.function
.name
= gfc_get_string ("shiftl_i%d", f
->ts
.kind
);
2619 else if (f
->value
.function
.isym
->id
== GFC_ISYM_SHIFTR
)
2620 f
->value
.function
.name
= gfc_get_string ("shiftr_i%d", f
->ts
.kind
);
2627 gfc_resolve_sign (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*b ATTRIBUTE_UNUSED
)
2630 f
->value
.function
.name
2631 = gfc_get_string ("__sign_%c%d", gfc_type_letter (a
->ts
.type
),
2632 gfc_type_abi_kind (&a
->ts
));
2637 gfc_resolve_signal (gfc_expr
*f
, gfc_expr
*number
, gfc_expr
*handler
)
2639 f
->ts
.type
= BT_INTEGER
;
2640 f
->ts
.kind
= gfc_c_int_kind
;
2642 /* handler can be either BT_INTEGER or BT_PROCEDURE */
2643 if (handler
->ts
.type
== BT_INTEGER
)
2645 if (handler
->ts
.kind
!= gfc_c_int_kind
)
2646 gfc_convert_type (handler
, &f
->ts
, 2);
2647 f
->value
.function
.name
= gfc_get_string (PREFIX ("signal_func_int"));
2650 f
->value
.function
.name
= gfc_get_string (PREFIX ("signal_func"));
2652 if (number
->ts
.kind
!= gfc_c_int_kind
)
2653 gfc_convert_type (number
, &f
->ts
, 2);
2658 gfc_resolve_sin (gfc_expr
*f
, gfc_expr
*x
)
2661 f
->value
.function
.name
2662 = gfc_get_string ("__sin_%c%d", gfc_type_letter (x
->ts
.type
),
2663 gfc_type_abi_kind (&x
->ts
));
2668 gfc_resolve_sinh (gfc_expr
*f
, gfc_expr
*x
)
2671 f
->value
.function
.name
2672 = gfc_get_string ("__sinh_%c%d", gfc_type_letter (x
->ts
.type
),
2673 gfc_type_abi_kind (&x
->ts
));
2678 gfc_resolve_size (gfc_expr
*f
, gfc_expr
*array ATTRIBUTE_UNUSED
,
2679 gfc_expr
*dim ATTRIBUTE_UNUSED
, gfc_expr
*kind
)
2681 f
->ts
.type
= BT_INTEGER
;
2683 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2685 f
->ts
.kind
= gfc_default_integer_kind
;
2690 gfc_resolve_stride (gfc_expr
*f
, gfc_expr
*array ATTRIBUTE_UNUSED
,
2691 gfc_expr
*dim ATTRIBUTE_UNUSED
)
2693 f
->ts
.type
= BT_INTEGER
;
2694 f
->ts
.kind
= gfc_index_integer_kind
;
2699 gfc_resolve_spacing (gfc_expr
*f
, gfc_expr
*x
)
2702 f
->value
.function
.name
= gfc_get_string ("__spacing_%d", x
->ts
.kind
);
2707 gfc_resolve_spread (gfc_expr
*f
, gfc_expr
*source
, gfc_expr
*dim
,
2710 if (source
->ts
.type
== BT_CHARACTER
&& source
->ref
)
2711 gfc_resolve_substring_charlen (source
);
2713 if (source
->ts
.type
== BT_CHARACTER
)
2714 check_charlen_present (source
);
2717 f
->rank
= source
->rank
+ 1;
2718 if (source
->rank
== 0)
2720 if (source
->ts
.type
== BT_CHARACTER
)
2721 f
->value
.function
.name
2722 = source
->ts
.kind
== 1 ? PREFIX ("spread_char_scalar")
2724 (PREFIX ("spread_char%d_scalar"),
2727 f
->value
.function
.name
= PREFIX ("spread_scalar");
2731 if (source
->ts
.type
== BT_CHARACTER
)
2732 f
->value
.function
.name
2733 = source
->ts
.kind
== 1 ? PREFIX ("spread_char")
2735 (PREFIX ("spread_char%d"),
2738 f
->value
.function
.name
= PREFIX ("spread");
2741 if (dim
&& gfc_is_constant_expr (dim
)
2742 && ncopies
&& gfc_is_constant_expr (ncopies
) && source
->shape
[0])
2745 idim
= mpz_get_ui (dim
->value
.integer
);
2746 f
->shape
= gfc_get_shape (f
->rank
);
2747 for (i
= 0; i
< (idim
- 1); i
++)
2748 mpz_init_set (f
->shape
[i
], source
->shape
[i
]);
2750 mpz_init_set (f
->shape
[idim
- 1], ncopies
->value
.integer
);
2752 for (i
= idim
; i
< f
->rank
; i
++)
2753 mpz_init_set (f
->shape
[i
], source
->shape
[i
-1]);
2757 gfc_resolve_dim_arg (dim
);
2758 gfc_resolve_index (ncopies
, 1);
2763 gfc_resolve_sqrt (gfc_expr
*f
, gfc_expr
*x
)
2766 f
->value
.function
.name
2767 = gfc_get_string ("__sqrt_%c%d", gfc_type_letter (x
->ts
.type
),
2768 gfc_type_abi_kind (&x
->ts
));
2772 /* Resolve the g77 compatibility function STAT AND FSTAT. */
2775 gfc_resolve_stat (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
,
2776 gfc_expr
*a ATTRIBUTE_UNUSED
)
2778 f
->ts
.type
= BT_INTEGER
;
2779 f
->ts
.kind
= gfc_default_integer_kind
;
2780 f
->value
.function
.name
= gfc_get_string (PREFIX ("stat_i%d"), f
->ts
.kind
);
2785 gfc_resolve_lstat (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
,
2786 gfc_expr
*a ATTRIBUTE_UNUSED
)
2788 f
->ts
.type
= BT_INTEGER
;
2789 f
->ts
.kind
= gfc_default_integer_kind
;
2790 f
->value
.function
.name
= gfc_get_string (PREFIX ("lstat_i%d"), f
->ts
.kind
);
2795 gfc_resolve_fstat (gfc_expr
*f
, gfc_expr
*n
, gfc_expr
*a ATTRIBUTE_UNUSED
)
2797 f
->ts
.type
= BT_INTEGER
;
2798 f
->ts
.kind
= gfc_default_integer_kind
;
2799 if (n
->ts
.kind
!= f
->ts
.kind
)
2800 gfc_convert_type (n
, &f
->ts
, 2);
2802 f
->value
.function
.name
= gfc_get_string (PREFIX ("fstat_i%d"), f
->ts
.kind
);
2807 gfc_resolve_fgetc (gfc_expr
*f
, gfc_expr
*u
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2812 f
->ts
.type
= BT_INTEGER
;
2813 f
->ts
.kind
= gfc_c_int_kind
;
2814 if (u
->ts
.kind
!= gfc_c_int_kind
)
2816 ts
.type
= BT_INTEGER
;
2817 ts
.kind
= gfc_c_int_kind
;
2818 ts
.u
.derived
= NULL
;
2820 gfc_convert_type (u
, &ts
, 2);
2823 f
->value
.function
.name
= gfc_get_string (PREFIX ("fgetc"));
2828 gfc_resolve_fget (gfc_expr
*f
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2830 f
->ts
.type
= BT_INTEGER
;
2831 f
->ts
.kind
= gfc_c_int_kind
;
2832 f
->value
.function
.name
= gfc_get_string (PREFIX ("fget"));
2837 gfc_resolve_fputc (gfc_expr
*f
, gfc_expr
*u
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2842 f
->ts
.type
= BT_INTEGER
;
2843 f
->ts
.kind
= gfc_c_int_kind
;
2844 if (u
->ts
.kind
!= gfc_c_int_kind
)
2846 ts
.type
= BT_INTEGER
;
2847 ts
.kind
= gfc_c_int_kind
;
2848 ts
.u
.derived
= NULL
;
2850 gfc_convert_type (u
, &ts
, 2);
2853 f
->value
.function
.name
= gfc_get_string (PREFIX ("fputc"));
2858 gfc_resolve_fput (gfc_expr
*f
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2860 f
->ts
.type
= BT_INTEGER
;
2861 f
->ts
.kind
= gfc_c_int_kind
;
2862 f
->value
.function
.name
= gfc_get_string (PREFIX ("fput"));
2867 gfc_resolve_ftell (gfc_expr
*f
, gfc_expr
*u
)
2872 f
->ts
.type
= BT_INTEGER
;
2873 f
->ts
.kind
= gfc_intio_kind
;
2874 if (u
->ts
.kind
!= gfc_c_int_kind
)
2876 ts
.type
= BT_INTEGER
;
2877 ts
.kind
= gfc_c_int_kind
;
2878 ts
.u
.derived
= NULL
;
2880 gfc_convert_type (u
, &ts
, 2);
2883 f
->value
.function
.name
= gfc_get_string (PREFIX ("ftell"));
2888 gfc_resolve_storage_size (gfc_expr
*f
, gfc_expr
*a ATTRIBUTE_UNUSED
,
2891 f
->ts
.type
= BT_INTEGER
;
2893 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2895 f
->ts
.kind
= gfc_default_integer_kind
;
2900 gfc_resolve_sum (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*mask
)
2902 resolve_transformational ("sum", f
, array
, dim
, mask
, true);
2907 gfc_resolve_symlnk (gfc_expr
*f
, gfc_expr
*p1 ATTRIBUTE_UNUSED
,
2908 gfc_expr
*p2 ATTRIBUTE_UNUSED
)
2910 f
->ts
.type
= BT_INTEGER
;
2911 f
->ts
.kind
= gfc_default_integer_kind
;
2912 f
->value
.function
.name
= gfc_get_string (PREFIX ("symlnk_i%d"), f
->ts
.kind
);
2916 /* Resolve the g77 compatibility function SYSTEM. */
2919 gfc_resolve_system (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
2921 f
->ts
.type
= BT_INTEGER
;
2923 f
->value
.function
.name
= gfc_get_string (PREFIX ("system"));
2928 gfc_resolve_tan (gfc_expr
*f
, gfc_expr
*x
)
2931 f
->value
.function
.name
2932 = gfc_get_string ("__tan_%c%d", gfc_type_letter (x
->ts
.type
),
2933 gfc_type_abi_kind (&x
->ts
));
2938 gfc_resolve_tanh (gfc_expr
*f
, gfc_expr
*x
)
2941 f
->value
.function
.name
2942 = gfc_get_string ("__tanh_%c%d", gfc_type_letter (x
->ts
.type
),
2943 gfc_type_abi_kind (&x
->ts
));
2947 /* Resolve failed_images (team, kind). */
2950 gfc_resolve_failed_images (gfc_expr
*f
, gfc_expr
*team ATTRIBUTE_UNUSED
,
2953 static char failed_images
[] = "_gfortran_caf_failed_images";
2955 f
->ts
.type
= BT_INTEGER
;
2957 f
->ts
.kind
= gfc_default_integer_kind
;
2959 gfc_extract_int (kind
, &f
->ts
.kind
);
2960 f
->value
.function
.name
= failed_images
;
2964 /* Resolve image_status (image, team). */
2967 gfc_resolve_image_status (gfc_expr
*f
, gfc_expr
*image ATTRIBUTE_UNUSED
,
2968 gfc_expr
*team ATTRIBUTE_UNUSED
)
2970 static char image_status
[] = "_gfortran_caf_image_status";
2971 f
->ts
.type
= BT_INTEGER
;
2972 f
->ts
.kind
= gfc_default_integer_kind
;
2973 f
->value
.function
.name
= image_status
;
2977 /* Resolve get_team (). */
2980 gfc_resolve_get_team (gfc_expr
*f
, gfc_expr
*level ATTRIBUTE_UNUSED
)
2982 static char get_team
[] = "_gfortran_caf_get_team";
2984 f
->ts
.type
= BT_INTEGER
;
2985 f
->ts
.kind
= gfc_default_integer_kind
;
2986 f
->value
.function
.name
= get_team
;
2990 /* Resolve image_index (...). */
2993 gfc_resolve_image_index (gfc_expr
*f
, gfc_expr
*array ATTRIBUTE_UNUSED
,
2994 gfc_expr
*sub ATTRIBUTE_UNUSED
)
2996 static char image_index
[] = "__image_index";
2997 f
->ts
.type
= BT_INTEGER
;
2998 f
->ts
.kind
= gfc_default_integer_kind
;
2999 f
->value
.function
.name
= image_index
;
3003 /* Resolve stopped_images (team, kind). */
3006 gfc_resolve_stopped_images (gfc_expr
*f
, gfc_expr
*team ATTRIBUTE_UNUSED
,
3009 static char stopped_images
[] = "_gfortran_caf_stopped_images";
3011 f
->ts
.type
= BT_INTEGER
;
3013 f
->ts
.kind
= gfc_default_integer_kind
;
3015 gfc_extract_int (kind
, &f
->ts
.kind
);
3016 f
->value
.function
.name
= stopped_images
;
3020 /* Resolve team_number (team). */
3023 gfc_resolve_team_number (gfc_expr
*f
, gfc_expr
*team ATTRIBUTE_UNUSED
)
3025 static char team_number
[] = "_gfortran_caf_team_number";
3027 f
->ts
.type
= BT_INTEGER
;
3028 f
->ts
.kind
= gfc_default_integer_kind
;
3029 f
->value
.function
.name
= team_number
;
3034 gfc_resolve_this_image (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
3035 gfc_expr
*distance ATTRIBUTE_UNUSED
)
3037 static char this_image
[] = "__this_image";
3038 if (array
&& gfc_is_coarray (array
))
3039 resolve_bound (f
, array
, dim
, NULL
, "__this_image", true);
3042 f
->ts
.type
= BT_INTEGER
;
3043 f
->ts
.kind
= gfc_default_integer_kind
;
3044 f
->value
.function
.name
= this_image
;
3050 gfc_resolve_time (gfc_expr
*f
)
3052 f
->ts
.type
= BT_INTEGER
;
3054 f
->value
.function
.name
= gfc_get_string (PREFIX ("time_func"));
3059 gfc_resolve_time8 (gfc_expr
*f
)
3061 f
->ts
.type
= BT_INTEGER
;
3063 f
->value
.function
.name
= gfc_get_string (PREFIX ("time8_func"));
3068 gfc_resolve_transfer (gfc_expr
*f
, gfc_expr
*source ATTRIBUTE_UNUSED
,
3069 gfc_expr
*mold
, gfc_expr
*size
)
3071 /* TODO: Make this do something meaningful. */
3072 static char transfer0
[] = "__transfer0", transfer1
[] = "__transfer1";
3074 if (mold
->ts
.type
== BT_CHARACTER
3075 && !mold
->ts
.u
.cl
->length
3076 && gfc_is_constant_expr (mold
))
3079 if (mold
->expr_type
== EXPR_CONSTANT
)
3081 len
= mold
->value
.character
.length
;
3082 mold
->ts
.u
.cl
->length
= gfc_get_int_expr (gfc_charlen_int_kind
,
3087 gfc_constructor
*c
= gfc_constructor_first (mold
->value
.constructor
);
3088 len
= c
->expr
->value
.character
.length
;
3089 mold
->ts
.u
.cl
->length
= gfc_get_int_expr (gfc_charlen_int_kind
,
3094 if (UNLIMITED_POLY (mold
))
3095 gfc_error ("TODO: unlimited polymorphic MOLD in TRANSFER intrinsic at %L",
3100 if (size
== NULL
&& mold
->rank
== 0)
3103 f
->value
.function
.name
= transfer0
;
3108 f
->value
.function
.name
= transfer1
;
3109 if (size
&& gfc_is_constant_expr (size
))
3111 f
->shape
= gfc_get_shape (1);
3112 mpz_init_set (f
->shape
[0], size
->value
.integer
);
3119 gfc_resolve_transpose (gfc_expr
*f
, gfc_expr
*matrix
)
3122 if (matrix
->ts
.type
== BT_CHARACTER
&& matrix
->ref
)
3123 gfc_resolve_substring_charlen (matrix
);
3129 f
->shape
= gfc_get_shape (2);
3130 mpz_init_set (f
->shape
[0], matrix
->shape
[1]);
3131 mpz_init_set (f
->shape
[1], matrix
->shape
[0]);
3134 switch (matrix
->ts
.kind
)
3140 switch (matrix
->ts
.type
)
3144 f
->value
.function
.name
3145 = gfc_get_string (PREFIX ("transpose_%c%d"),
3146 gfc_type_letter (matrix
->ts
.type
),
3147 gfc_type_abi_kind (&matrix
->ts
));
3152 /* Use the integer routines for real and logical cases. This
3153 assumes they all have the same alignment requirements. */
3154 f
->value
.function
.name
3155 = gfc_get_string (PREFIX ("transpose_i%d"), matrix
->ts
.kind
);
3159 if (matrix
->ts
.type
== BT_CHARACTER
&& matrix
->ts
.kind
== 4)
3160 f
->value
.function
.name
= PREFIX ("transpose_char4");
3162 f
->value
.function
.name
= PREFIX ("transpose");
3168 f
->value
.function
.name
= (matrix
->ts
.type
== BT_CHARACTER
3169 ? PREFIX ("transpose_char")
3170 : PREFIX ("transpose"));
3177 gfc_resolve_trim (gfc_expr
*f
, gfc_expr
*string
)
3179 f
->ts
.type
= BT_CHARACTER
;
3180 f
->ts
.kind
= string
->ts
.kind
;
3181 f
->value
.function
.name
= gfc_get_string ("__trim_%d", string
->ts
.kind
);
3185 /* Resolve the degree trigonometric functions. This amounts to setting
3186 the function return type-spec from its argument and building a
3187 library function names of the form _gfortran_sind_r4. */
3190 gfc_resolve_trigd (gfc_expr
*f
, gfc_expr
*x
)
3193 f
->value
.function
.name
3194 = gfc_get_string (PREFIX ("%s_%c%d"), f
->value
.function
.isym
->name
,
3195 gfc_type_letter (x
->ts
.type
),
3196 gfc_type_abi_kind (&x
->ts
));
3201 gfc_resolve_trigd2 (gfc_expr
*f
, gfc_expr
*y
, gfc_expr
*x
)
3204 f
->value
.function
.name
3205 = gfc_get_string (PREFIX ("%s_%d"), f
->value
.function
.isym
->name
,
3211 gfc_resolve_ubound (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
3213 resolve_bound (f
, array
, dim
, kind
, "__ubound", false);
3218 gfc_resolve_ucobound (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
3220 resolve_bound (f
, array
, dim
, kind
, "__ucobound", true);
3224 /* Resolve the g77 compatibility function UMASK. */
3227 gfc_resolve_umask (gfc_expr
*f
, gfc_expr
*n
)
3229 f
->ts
.type
= BT_INTEGER
;
3230 f
->ts
.kind
= n
->ts
.kind
;
3231 f
->value
.function
.name
= gfc_get_string (PREFIX ("umask_i%d"), n
->ts
.kind
);
3235 /* Resolve the g77 compatibility function UNLINK. */
3238 gfc_resolve_unlink (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
3240 f
->ts
.type
= BT_INTEGER
;
3242 f
->value
.function
.name
= gfc_get_string (PREFIX ("unlink"));
3247 gfc_resolve_ttynam (gfc_expr
*f
, gfc_expr
*unit
)
3252 f
->ts
.type
= BT_CHARACTER
;
3253 f
->ts
.kind
= gfc_default_character_kind
;
3255 if (unit
->ts
.kind
!= gfc_c_int_kind
)
3257 ts
.type
= BT_INTEGER
;
3258 ts
.kind
= gfc_c_int_kind
;
3259 ts
.u
.derived
= NULL
;
3261 gfc_convert_type (unit
, &ts
, 2);
3264 f
->value
.function
.name
= gfc_get_string (PREFIX ("ttynam"));
3269 gfc_resolve_unpack (gfc_expr
*f
, gfc_expr
*vector
, gfc_expr
*mask
,
3270 gfc_expr
*field ATTRIBUTE_UNUSED
)
3272 if (vector
->ts
.type
== BT_CHARACTER
&& vector
->ref
)
3273 gfc_resolve_substring_charlen (vector
);
3276 f
->rank
= mask
->rank
;
3277 resolve_mask_arg (mask
);
3279 if (vector
->ts
.type
== BT_CHARACTER
)
3281 if (vector
->ts
.kind
== 1)
3282 f
->value
.function
.name
3283 = gfc_get_string (PREFIX ("unpack%d_char"), field
->rank
> 0 ? 1 : 0);
3285 f
->value
.function
.name
3286 = gfc_get_string (PREFIX ("unpack%d_char%d"),
3287 field
->rank
> 0 ? 1 : 0, vector
->ts
.kind
);
3290 f
->value
.function
.name
3291 = gfc_get_string (PREFIX ("unpack%d"), field
->rank
> 0 ? 1 : 0);
3296 gfc_resolve_verify (gfc_expr
*f
, gfc_expr
*string
,
3297 gfc_expr
*set ATTRIBUTE_UNUSED
,
3298 gfc_expr
*back ATTRIBUTE_UNUSED
, gfc_expr
*kind
)
3300 f
->ts
.type
= BT_INTEGER
;
3302 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
3304 f
->ts
.kind
= gfc_default_integer_kind
;
3305 f
->value
.function
.name
= gfc_get_string ("__verify_%d", string
->ts
.kind
);
3310 gfc_resolve_xor (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
3312 f
->ts
.type
= i
->ts
.type
;
3313 f
->ts
.kind
= gfc_kind_max (i
, j
);
3315 if (i
->ts
.kind
!= j
->ts
.kind
)
3317 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
3318 gfc_convert_type (j
, &i
->ts
, 2);
3320 gfc_convert_type (i
, &j
->ts
, 2);
3323 f
->value
.function
.name
3324 = gfc_get_string ("__xor_%c%d", gfc_type_letter (i
->ts
.type
),
3325 gfc_type_abi_kind (&f
->ts
));
3329 /* Intrinsic subroutine resolution. */
3332 gfc_resolve_alarm_sub (gfc_code
*c
)
3335 gfc_expr
*seconds
, *handler
;
3339 seconds
= c
->ext
.actual
->expr
;
3340 handler
= c
->ext
.actual
->next
->expr
;
3341 ts
.type
= BT_INTEGER
;
3342 ts
.kind
= gfc_c_int_kind
;
3344 /* handler can be either BT_INTEGER or BT_PROCEDURE.
3345 In all cases, the status argument is of default integer kind
3346 (enforced in check.cc) so that the function suffix is fixed. */
3347 if (handler
->ts
.type
== BT_INTEGER
)
3349 if (handler
->ts
.kind
!= gfc_c_int_kind
)
3350 gfc_convert_type (handler
, &ts
, 2);
3351 name
= gfc_get_string (PREFIX ("alarm_sub_int_i%d"),
3352 gfc_default_integer_kind
);
3355 name
= gfc_get_string (PREFIX ("alarm_sub_i%d"),
3356 gfc_default_integer_kind
);
3358 if (seconds
->ts
.kind
!= gfc_c_int_kind
)
3359 gfc_convert_type (seconds
, &ts
, 2);
3361 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3365 gfc_resolve_cpu_time (gfc_code
*c
)
3368 name
= gfc_get_string (PREFIX ("cpu_time_%d"), c
->ext
.actual
->expr
->ts
.kind
);
3369 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3373 /* Create a formal arglist based on an actual one and set the INTENTs given. */
3375 static gfc_formal_arglist
*
3376 create_formal_for_intents (gfc_actual_arglist
* actual
, const sym_intent
* ints
)
3378 gfc_formal_arglist
* head
;
3379 gfc_formal_arglist
* tail
;
3385 head
= tail
= gfc_get_formal_arglist ();
3386 for (i
= 0; actual
; actual
= actual
->next
, tail
= tail
->next
, ++i
)
3390 sym
= gfc_new_symbol ("dummyarg", NULL
);
3391 sym
->ts
= actual
->expr
->ts
;
3393 sym
->attr
.intent
= ints
[i
];
3397 tail
->next
= gfc_get_formal_arglist ();
3405 gfc_resolve_atomic_def (gfc_code
*c
)
3407 const char *name
= "atomic_define";
3408 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3413 gfc_resolve_atomic_ref (gfc_code
*c
)
3415 const char *name
= "atomic_ref";
3416 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3420 gfc_resolve_event_query (gfc_code
*c
)
3422 const char *name
= "event_query";
3423 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3427 gfc_resolve_mvbits (gfc_code
*c
)
3429 static const sym_intent INTENTS
[] = {INTENT_IN
, INTENT_IN
, INTENT_IN
,
3430 INTENT_INOUT
, INTENT_IN
};
3433 /* TO and FROM are guaranteed to have the same kind parameter. */
3434 name
= gfc_get_string (PREFIX ("mvbits_i%d"),
3435 c
->ext
.actual
->expr
->ts
.kind
);
3436 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3437 /* Mark as elemental subroutine as this does not happen automatically. */
3438 c
->resolved_sym
->attr
.elemental
= 1;
3440 /* Create a dummy formal arglist so the INTENTs are known later for purpose
3441 of creating temporaries. */
3442 c
->resolved_sym
->formal
= create_formal_for_intents (c
->ext
.actual
, INTENTS
);
3446 /* Set up the call to RANDOM_INIT. */
3449 gfc_resolve_random_init (gfc_code
*c
)
3452 name
= gfc_get_string (PREFIX ("random_init"));
3453 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3458 gfc_resolve_random_number (gfc_code
*c
)
3464 kind
= gfc_type_abi_kind (&c
->ext
.actual
->expr
->ts
);
3465 type
= gfc_type_letter (c
->ext
.actual
->expr
->ts
.type
);
3466 if (c
->ext
.actual
->expr
->rank
== 0)
3467 name
= gfc_get_string (PREFIX ("random_%c%d"), type
, kind
);
3469 name
= gfc_get_string (PREFIX ("arandom_%c%d"), type
, kind
);
3471 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3476 gfc_resolve_random_seed (gfc_code
*c
)
3480 name
= gfc_get_string (PREFIX ("random_seed_i%d"), gfc_default_integer_kind
);
3481 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3486 gfc_resolve_rename_sub (gfc_code
*c
)
3491 /* Find the type of status. If not present use default integer kind. */
3492 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
3493 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
3495 kind
= gfc_default_integer_kind
;
3497 name
= gfc_get_string (PREFIX ("rename_i%d_sub"), kind
);
3498 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3503 gfc_resolve_link_sub (gfc_code
*c
)
3508 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
3509 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
3511 kind
= gfc_default_integer_kind
;
3513 name
= gfc_get_string (PREFIX ("link_i%d_sub"), kind
);
3514 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3519 gfc_resolve_symlnk_sub (gfc_code
*c
)
3524 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
3525 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
3527 kind
= gfc_default_integer_kind
;
3529 name
= gfc_get_string (PREFIX ("symlnk_i%d_sub"), kind
);
3530 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3534 /* G77 compatibility subroutines dtime() and etime(). */
3537 gfc_resolve_dtime_sub (gfc_code
*c
)
3540 name
= gfc_get_string (PREFIX ("dtime_sub"));
3541 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3545 gfc_resolve_etime_sub (gfc_code
*c
)
3548 name
= gfc_get_string (PREFIX ("etime_sub"));
3549 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3553 /* G77 compatibility subroutines itime(), idate(), ltime() and gmtime(). */
3556 gfc_resolve_itime (gfc_code
*c
)
3559 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("itime_i%d"),
3560 gfc_default_integer_kind
));
3564 gfc_resolve_idate (gfc_code
*c
)
3567 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("idate_i%d"),
3568 gfc_default_integer_kind
));
3572 gfc_resolve_ltime (gfc_code
*c
)
3575 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("ltime_i%d"),
3576 gfc_default_integer_kind
));
3580 gfc_resolve_gmtime (gfc_code
*c
)
3583 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("gmtime_i%d"),
3584 gfc_default_integer_kind
));
3588 /* G77 compatibility subroutine second(). */
3591 gfc_resolve_second_sub (gfc_code
*c
)
3594 name
= gfc_get_string (PREFIX ("second_sub"));
3595 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3600 gfc_resolve_sleep_sub (gfc_code
*c
)
3605 if (c
->ext
.actual
->expr
!= NULL
)
3606 kind
= c
->ext
.actual
->expr
->ts
.kind
;
3608 kind
= gfc_default_integer_kind
;
3610 name
= gfc_get_string (PREFIX ("sleep_i%d_sub"), kind
);
3611 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3615 /* G77 compatibility function srand(). */
3618 gfc_resolve_srand (gfc_code
*c
)
3621 name
= gfc_get_string (PREFIX ("srand"));
3622 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3626 /* Resolve the getarg intrinsic subroutine. */
3629 gfc_resolve_getarg (gfc_code
*c
)
3633 if (c
->ext
.actual
->expr
->ts
.kind
!= gfc_default_integer_kind
)
3638 ts
.type
= BT_INTEGER
;
3639 ts
.kind
= gfc_default_integer_kind
;
3641 gfc_convert_type (c
->ext
.actual
->expr
, &ts
, 2);
3644 name
= gfc_get_string (PREFIX ("getarg_i%d"), gfc_default_integer_kind
);
3645 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3649 /* Resolve the getcwd intrinsic subroutine. */
3652 gfc_resolve_getcwd_sub (gfc_code
*c
)
3657 if (c
->ext
.actual
->next
->expr
!= NULL
)
3658 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
3660 kind
= gfc_default_integer_kind
;
3662 name
= gfc_get_string (PREFIX ("getcwd_i%d_sub"), kind
);
3663 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3667 /* Resolve the get_command intrinsic subroutine. */
3670 gfc_resolve_get_command (gfc_code
*c
)
3674 kind
= gfc_default_integer_kind
;
3675 name
= gfc_get_string (PREFIX ("get_command_i%d"), kind
);
3676 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3680 /* Resolve the get_command_argument intrinsic subroutine. */
3683 gfc_resolve_get_command_argument (gfc_code
*c
)
3687 kind
= gfc_default_integer_kind
;
3688 name
= gfc_get_string (PREFIX ("get_command_argument_i%d"), kind
);
3689 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3693 /* Resolve the get_environment_variable intrinsic subroutine. */
3696 gfc_resolve_get_environment_variable (gfc_code
*code
)
3700 kind
= gfc_default_integer_kind
;
3701 name
= gfc_get_string (PREFIX ("get_environment_variable_i%d"), kind
);
3702 code
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3707 gfc_resolve_signal_sub (gfc_code
*c
)
3710 gfc_expr
*number
, *handler
, *status
;
3714 number
= c
->ext
.actual
->expr
;
3715 handler
= c
->ext
.actual
->next
->expr
;
3716 status
= c
->ext
.actual
->next
->next
->expr
;
3717 ts
.type
= BT_INTEGER
;
3718 ts
.kind
= gfc_c_int_kind
;
3720 /* handler can be either BT_INTEGER or BT_PROCEDURE */
3721 if (handler
->ts
.type
== BT_INTEGER
)
3723 if (handler
->ts
.kind
!= gfc_c_int_kind
)
3724 gfc_convert_type (handler
, &ts
, 2);
3725 name
= gfc_get_string (PREFIX ("signal_sub_int"));
3728 name
= gfc_get_string (PREFIX ("signal_sub"));
3730 if (number
->ts
.kind
!= gfc_c_int_kind
)
3731 gfc_convert_type (number
, &ts
, 2);
3732 if (status
!= NULL
&& status
->ts
.kind
!= gfc_c_int_kind
)
3733 gfc_convert_type (status
, &ts
, 2);
3735 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3739 /* Resolve the SYSTEM intrinsic subroutine. */
3742 gfc_resolve_system_sub (gfc_code
*c
)
3745 name
= gfc_get_string (PREFIX ("system_sub"));
3746 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3750 /* Determine if the arguments to SYSTEM_CLOCK are INTEGER(4) or INTEGER(8) */
3753 gfc_resolve_system_clock (gfc_code
*c
)
3757 gfc_expr
*count
= c
->ext
.actual
->expr
;
3758 gfc_expr
*count_max
= c
->ext
.actual
->next
->next
->expr
;
3760 /* The INTEGER(8) version has higher precision, it is used if both COUNT
3761 and COUNT_MAX can hold 64-bit values, or are absent. */
3762 if ((!count
|| count
->ts
.kind
>= 8)
3763 && (!count_max
|| count_max
->ts
.kind
>= 8))
3766 kind
= gfc_default_integer_kind
;
3768 name
= gfc_get_string (PREFIX ("system_clock_%d"), kind
);
3769 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3773 /* Resolve the EXECUTE_COMMAND_LINE intrinsic subroutine. */
3775 gfc_resolve_execute_command_line (gfc_code
*c
)
3778 name
= gfc_get_string (PREFIX ("execute_command_line_i%d"),
3779 gfc_default_integer_kind
);
3780 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3784 /* Resolve the EXIT intrinsic subroutine. */
3787 gfc_resolve_exit (gfc_code
*c
)
3794 /* The STATUS argument has to be of default kind. If it is not,
3796 ts
.type
= BT_INTEGER
;
3797 ts
.kind
= gfc_default_integer_kind
;
3798 n
= c
->ext
.actual
->expr
;
3799 if (n
!= NULL
&& n
->ts
.kind
!= ts
.kind
)
3800 gfc_convert_type (n
, &ts
, 2);
3802 name
= gfc_get_string (PREFIX ("exit_i%d"), ts
.kind
);
3803 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3807 /* Resolve the FLUSH intrinsic subroutine. */
3810 gfc_resolve_flush (gfc_code
*c
)
3817 ts
.type
= BT_INTEGER
;
3818 ts
.kind
= gfc_default_integer_kind
;
3819 n
= c
->ext
.actual
->expr
;
3820 if (n
!= NULL
&& n
->ts
.kind
!= ts
.kind
)
3821 gfc_convert_type (n
, &ts
, 2);
3823 name
= gfc_get_string (PREFIX ("flush_i%d"), ts
.kind
);
3824 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3829 gfc_resolve_ctime_sub (gfc_code
*c
)
3834 /* ctime TIME argument is a INTEGER(KIND=8), says the doc */
3835 if (c
->ext
.actual
->expr
->ts
.kind
!= 8)
3837 ts
.type
= BT_INTEGER
;
3839 ts
.u
.derived
= NULL
;
3841 gfc_convert_type (c
->ext
.actual
->expr
, &ts
, 2);
3844 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("ctime_sub"));
3849 gfc_resolve_fdate_sub (gfc_code
*c
)
3851 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("fdate_sub"));
3856 gfc_resolve_gerror (gfc_code
*c
)
3858 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("gerror"));
3863 gfc_resolve_getlog (gfc_code
*c
)
3865 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("getlog"));
3870 gfc_resolve_hostnm_sub (gfc_code
*c
)
3875 if (c
->ext
.actual
->next
->expr
!= NULL
)
3876 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
3878 kind
= gfc_default_integer_kind
;
3880 name
= gfc_get_string (PREFIX ("hostnm_i%d_sub"), kind
);
3881 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3886 gfc_resolve_perror (gfc_code
*c
)
3888 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("perror_sub"));
3891 /* Resolve the STAT and FSTAT intrinsic subroutines. */
3894 gfc_resolve_stat_sub (gfc_code
*c
)
3897 name
= gfc_get_string (PREFIX ("stat_i%d_sub"), gfc_default_integer_kind
);
3898 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3903 gfc_resolve_lstat_sub (gfc_code
*c
)
3906 name
= gfc_get_string (PREFIX ("lstat_i%d_sub"), gfc_default_integer_kind
);
3907 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3912 gfc_resolve_fstat_sub (gfc_code
*c
)
3918 u
= c
->ext
.actual
->expr
;
3919 ts
= &c
->ext
.actual
->next
->expr
->ts
;
3920 if (u
->ts
.kind
!= ts
->kind
)
3921 gfc_convert_type (u
, ts
, 2);
3922 name
= gfc_get_string (PREFIX ("fstat_i%d_sub"), ts
->kind
);
3923 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3928 gfc_resolve_fgetc_sub (gfc_code
*c
)
3935 u
= c
->ext
.actual
->expr
;
3936 st
= c
->ext
.actual
->next
->next
->expr
;
3938 if (u
->ts
.kind
!= gfc_c_int_kind
)
3940 ts
.type
= BT_INTEGER
;
3941 ts
.kind
= gfc_c_int_kind
;
3942 ts
.u
.derived
= NULL
;
3944 gfc_convert_type (u
, &ts
, 2);
3948 name
= gfc_get_string (PREFIX ("fgetc_i%d_sub"), st
->ts
.kind
);
3950 name
= gfc_get_string (PREFIX ("fgetc_i%d_sub"), gfc_default_integer_kind
);
3952 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3957 gfc_resolve_fget_sub (gfc_code
*c
)
3962 st
= c
->ext
.actual
->next
->expr
;
3964 name
= gfc_get_string (PREFIX ("fget_i%d_sub"), st
->ts
.kind
);
3966 name
= gfc_get_string (PREFIX ("fget_i%d_sub"), gfc_default_integer_kind
);
3968 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3973 gfc_resolve_fputc_sub (gfc_code
*c
)
3980 u
= c
->ext
.actual
->expr
;
3981 st
= c
->ext
.actual
->next
->next
->expr
;
3983 if (u
->ts
.kind
!= gfc_c_int_kind
)
3985 ts
.type
= BT_INTEGER
;
3986 ts
.kind
= gfc_c_int_kind
;
3987 ts
.u
.derived
= NULL
;
3989 gfc_convert_type (u
, &ts
, 2);
3993 name
= gfc_get_string (PREFIX ("fputc_i%d_sub"), st
->ts
.kind
);
3995 name
= gfc_get_string (PREFIX ("fputc_i%d_sub"), gfc_default_integer_kind
);
3997 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
4002 gfc_resolve_fput_sub (gfc_code
*c
)
4007 st
= c
->ext
.actual
->next
->expr
;
4009 name
= gfc_get_string (PREFIX ("fput_i%d_sub"), st
->ts
.kind
);
4011 name
= gfc_get_string (PREFIX ("fput_i%d_sub"), gfc_default_integer_kind
);
4013 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
4018 gfc_resolve_fseek_sub (gfc_code
*c
)
4026 unit
= c
->ext
.actual
->expr
;
4027 offset
= c
->ext
.actual
->next
->expr
;
4028 whence
= c
->ext
.actual
->next
->next
->expr
;
4030 if (unit
->ts
.kind
!= gfc_c_int_kind
)
4032 ts
.type
= BT_INTEGER
;
4033 ts
.kind
= gfc_c_int_kind
;
4034 ts
.u
.derived
= NULL
;
4036 gfc_convert_type (unit
, &ts
, 2);
4039 if (offset
->ts
.kind
!= gfc_intio_kind
)
4041 ts
.type
= BT_INTEGER
;
4042 ts
.kind
= gfc_intio_kind
;
4043 ts
.u
.derived
= NULL
;
4045 gfc_convert_type (offset
, &ts
, 2);
4048 if (whence
->ts
.kind
!= gfc_c_int_kind
)
4050 ts
.type
= BT_INTEGER
;
4051 ts
.kind
= gfc_c_int_kind
;
4052 ts
.u
.derived
= NULL
;
4054 gfc_convert_type (whence
, &ts
, 2);
4057 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("fseek_sub"));
4061 gfc_resolve_ftell_sub (gfc_code
*c
)
4069 unit
= c
->ext
.actual
->expr
;
4070 offset
= c
->ext
.actual
->next
->expr
;
4072 if (unit
->ts
.kind
!= gfc_c_int_kind
)
4074 ts
.type
= BT_INTEGER
;
4075 ts
.kind
= gfc_c_int_kind
;
4076 ts
.u
.derived
= NULL
;
4078 gfc_convert_type (unit
, &ts
, 2);
4081 name
= gfc_get_string (PREFIX ("ftell_i%d_sub"), offset
->ts
.kind
);
4082 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
4087 gfc_resolve_ttynam_sub (gfc_code
*c
)
4092 if (c
->ext
.actual
->expr
->ts
.kind
!= gfc_c_int_kind
)
4094 ts
.type
= BT_INTEGER
;
4095 ts
.kind
= gfc_c_int_kind
;
4096 ts
.u
.derived
= NULL
;
4098 gfc_convert_type (c
->ext
.actual
->expr
, &ts
, 2);
4101 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("ttynam_sub"));
4105 /* Resolve the UMASK intrinsic subroutine. */
4108 gfc_resolve_umask_sub (gfc_code
*c
)
4113 if (c
->ext
.actual
->next
->expr
!= NULL
)
4114 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
4116 kind
= gfc_default_integer_kind
;
4118 name
= gfc_get_string (PREFIX ("umask_i%d_sub"), kind
);
4119 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
4122 /* Resolve the UNLINK intrinsic subroutine. */
4125 gfc_resolve_unlink_sub (gfc_code
*c
)
4130 if (c
->ext
.actual
->next
->expr
!= NULL
)
4131 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
4133 kind
= gfc_default_integer_kind
;
4135 name
= gfc_get_string (PREFIX ("unlink_i%d_sub"), kind
);
4136 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);