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. */
29 #define INCLUDE_MEMORY
32 #include "coretypes.h"
35 #include "stringpool.h"
36 #include "intrinsic.h"
37 #include "constructor.h"
41 /* Given printf-like arguments, return a stable version of the result string.
43 We already have a working, optimized string hashing table in the form of
44 the identifier table. Reusing this table is likely not to be wasted,
45 since if the function name makes it to the gimple output of the frontend,
46 we'll have to create the identifier anyway. */
49 gfc_get_string (const char *format
, ...)
51 /* Provide sufficient space for "_F.caf_token__symbol.symbol_MOD_symbol". */
52 char temp_name
[15 + 2*GFC_MAX_SYMBOL_LEN
+ 5 + GFC_MAX_SYMBOL_LEN
+ 1];
57 /* Handle common case without vsnprintf and temporary buffer. */
58 if (format
[0] == '%' && format
[1] == 's' && format
[2] == '\0')
60 va_start (ap
, format
);
61 str
= va_arg (ap
, const char *);
67 va_start (ap
, format
);
68 ret
= vsnprintf (temp_name
, sizeof (temp_name
), format
, ap
);
70 if (ret
< 1 || ret
>= (int) sizeof (temp_name
)) /* Reject truncation. */
71 gfc_internal_error ("identifier overflow: %d", ret
);
72 temp_name
[sizeof (temp_name
) - 1] = 0;
76 ident
= get_identifier (str
);
77 return IDENTIFIER_POINTER (ident
);
80 /* MERGE and SPREAD need to have source charlen's present for passing
81 to the result expression. */
83 check_charlen_present (gfc_expr
*source
)
85 if (source
->ts
.u
.cl
== NULL
)
86 source
->ts
.u
.cl
= gfc_new_charlen (gfc_current_ns
, NULL
);
88 if (source
->expr_type
== EXPR_CONSTANT
)
90 source
->ts
.u
.cl
->length
91 = gfc_get_int_expr (gfc_charlen_int_kind
, NULL
,
92 source
->value
.character
.length
);
95 else if (source
->expr_type
== EXPR_ARRAY
)
97 gfc_constructor
*c
= gfc_constructor_first (source
->value
.constructor
);
99 source
->ts
.u
.cl
->length
100 = gfc_get_int_expr (gfc_charlen_int_kind
, NULL
,
101 c
->expr
->value
.character
.length
);
102 if (source
->ts
.u
.cl
->length
== NULL
)
103 gfc_internal_error ("check_charlen_present(): length not set");
107 /* Helper function for resolving the "mask" argument. */
110 resolve_mask_arg (gfc_expr
*mask
)
118 /* For the scalar case, coerce the mask to kind=4 unconditionally
119 (because this is the only kind we have a library function
122 if (mask
->ts
.kind
!= 4)
124 ts
.type
= BT_LOGICAL
;
126 gfc_convert_type (mask
, &ts
, 2);
131 /* In the library, we access the mask with a GFC_LOGICAL_1
132 argument. No need to waste memory if we are about to create
133 a temporary array. */
134 if (mask
->expr_type
== EXPR_OP
&& mask
->ts
.kind
!= 1)
136 ts
.type
= BT_LOGICAL
;
138 gfc_convert_type_warn (mask
, &ts
, 2, 0);
145 resolve_bound (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
,
146 const char *name
, bool coarray
)
148 f
->ts
.type
= BT_INTEGER
;
150 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
152 f
->ts
.kind
= gfc_default_integer_kind
;
156 if (array
->rank
!= -1)
158 /* Assume f->rank gives the size of the shape, because there is no
159 other way to determine the size. */
160 if (!f
->shape
|| f
->rank
!= 1)
163 gfc_free_shape (&f
->shape
, f
->rank
);
164 f
->shape
= gfc_get_shape (1);
166 mpz_init_set_ui (f
->shape
[0], coarray
? array
->corank
: array
->rank
);
168 /* Applying bound to a coarray always results in a regular array. */
173 f
->value
.function
.name
= gfc_get_string ("%s", name
);
178 resolve_transformational (const char *name
, gfc_expr
*f
, gfc_expr
*array
,
179 gfc_expr
*dim
, gfc_expr
*mask
,
180 bool use_integer
= false)
194 resolve_mask_arg (mask
);
201 f
->rank
= array
->rank
- 1;
202 f
->shape
= gfc_copy_shape_excluding (array
->shape
, array
->rank
, dim
);
203 gfc_resolve_dim_arg (dim
);
206 /* For those intrinsic like SUM where we use the integer version
207 actually uses unsigned, but we call it as the integer
210 if (use_integer
&& array
->ts
.type
== BT_UNSIGNED
)
213 type
= array
->ts
.type
;
215 f
->value
.function
.name
216 = gfc_get_string (PREFIX ("%s%s_%c%d"), prefix
, name
,
217 gfc_type_letter (type
),
218 gfc_type_abi_kind (&array
->ts
));
222 /********************** Resolution functions **********************/
226 gfc_resolve_abs (gfc_expr
*f
, gfc_expr
*a
)
229 if (f
->ts
.type
== BT_COMPLEX
)
230 f
->ts
.type
= BT_REAL
;
232 f
->value
.function
.name
233 = gfc_get_string ("__abs_%c%d", gfc_type_letter (a
->ts
.type
),
234 gfc_type_abi_kind (&a
->ts
));
239 gfc_resolve_access (gfc_expr
*f
, gfc_expr
*name ATTRIBUTE_UNUSED
,
240 gfc_expr
*mode ATTRIBUTE_UNUSED
)
242 f
->ts
.type
= BT_INTEGER
;
243 f
->ts
.kind
= gfc_c_int_kind
;
244 f
->value
.function
.name
= PREFIX ("access_func");
249 gfc_resolve_adjustl (gfc_expr
*f
, gfc_expr
*string
)
251 f
->ts
.type
= BT_CHARACTER
;
252 f
->ts
.kind
= string
->ts
.kind
;
253 if (string
->ts
.deferred
)
255 else if (string
->ts
.u
.cl
)
256 f
->ts
.u
.cl
= gfc_new_charlen (gfc_current_ns
, string
->ts
.u
.cl
);
258 f
->value
.function
.name
= gfc_get_string ("__adjustl_s%d", f
->ts
.kind
);
263 gfc_resolve_adjustr (gfc_expr
*f
, gfc_expr
*string
)
265 f
->ts
.type
= BT_CHARACTER
;
266 f
->ts
.kind
= string
->ts
.kind
;
267 if (string
->ts
.deferred
)
269 else if (string
->ts
.u
.cl
)
270 f
->ts
.u
.cl
= gfc_new_charlen (gfc_current_ns
, string
->ts
.u
.cl
);
272 f
->value
.function
.name
= gfc_get_string ("__adjustr_s%d", f
->ts
.kind
);
277 gfc_resolve_char_achar (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*kind
,
280 f
->ts
.type
= BT_CHARACTER
;
281 f
->ts
.kind
= (kind
== NULL
)
282 ? gfc_default_character_kind
: mpz_get_si (kind
->value
.integer
);
283 f
->ts
.u
.cl
= gfc_new_charlen (gfc_current_ns
, NULL
);
284 f
->ts
.u
.cl
->length
= gfc_get_int_expr (gfc_charlen_int_kind
, NULL
, 1);
286 f
->value
.function
.name
287 = gfc_get_string ("__%schar_%d_%c%d", is_achar
? "a" : "", f
->ts
.kind
,
288 gfc_type_letter (x
->ts
.type
),
289 gfc_type_abi_kind (&x
->ts
));
294 gfc_resolve_achar (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*kind
)
296 gfc_resolve_char_achar (f
, x
, kind
, true);
301 gfc_resolve_acos (gfc_expr
*f
, gfc_expr
*x
)
304 f
->value
.function
.name
305 = gfc_get_string ("__acos_%c%d", gfc_type_letter (x
->ts
.type
),
306 gfc_type_abi_kind (&x
->ts
));
311 gfc_resolve_acosh (gfc_expr
*f
, gfc_expr
*x
)
314 f
->value
.function
.name
315 = gfc_get_string ("__acosh_%c%d", gfc_type_letter (x
->ts
.type
),
316 gfc_type_abi_kind (&x
->ts
));
321 gfc_resolve_aimag (gfc_expr
*f
, gfc_expr
*x
)
323 f
->ts
.type
= BT_REAL
;
324 f
->ts
.kind
= x
->ts
.kind
;
325 f
->value
.function
.name
326 = gfc_get_string ("__aimag_%c%d", gfc_type_letter (x
->ts
.type
),
327 gfc_type_abi_kind (&x
->ts
));
332 gfc_resolve_and (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
334 f
->ts
.type
= i
->ts
.type
;
335 f
->ts
.kind
= gfc_kind_max (i
, j
);
337 if (i
->ts
.kind
!= j
->ts
.kind
)
339 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
340 gfc_convert_type (j
, &i
->ts
, 2);
342 gfc_convert_type (i
, &j
->ts
, 2);
345 f
->value
.function
.name
346 = gfc_get_string ("__and_%c%d", gfc_type_letter (i
->ts
.type
),
347 gfc_type_abi_kind (&f
->ts
));
352 gfc_resolve_aint (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
357 f
->ts
.type
= a
->ts
.type
;
358 f
->ts
.kind
= (kind
== NULL
) ? a
->ts
.kind
: mpz_get_si (kind
->value
.integer
);
360 if (a
->ts
.kind
!= f
->ts
.kind
)
362 ts
.type
= f
->ts
.type
;
363 ts
.kind
= f
->ts
.kind
;
364 gfc_convert_type (a
, &ts
, 2);
366 /* The resolved name is only used for specific intrinsics where
367 the return kind is the same as the arg kind. */
368 f
->value
.function
.name
369 = gfc_get_string ("__aint_%c%d", gfc_type_letter (a
->ts
.type
),
370 gfc_type_abi_kind (&a
->ts
));
375 gfc_resolve_dint (gfc_expr
*f
, gfc_expr
*a
)
377 gfc_resolve_aint (f
, a
, NULL
);
382 gfc_resolve_all (gfc_expr
*f
, gfc_expr
*mask
, gfc_expr
*dim
)
388 gfc_resolve_dim_arg (dim
);
389 f
->rank
= mask
->rank
- 1;
390 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
393 f
->value
.function
.name
394 = gfc_get_string (PREFIX ("all_%c%d"), gfc_type_letter (mask
->ts
.type
),
395 gfc_type_abi_kind (&mask
->ts
));
400 gfc_resolve_anint (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
405 f
->ts
.type
= a
->ts
.type
;
406 f
->ts
.kind
= (kind
== NULL
) ? a
->ts
.kind
: mpz_get_si (kind
->value
.integer
);
408 if (a
->ts
.kind
!= f
->ts
.kind
)
410 ts
.type
= f
->ts
.type
;
411 ts
.kind
= f
->ts
.kind
;
412 gfc_convert_type (a
, &ts
, 2);
415 /* The resolved name is only used for specific intrinsics where
416 the return kind is the same as the arg kind. */
417 f
->value
.function
.name
418 = gfc_get_string ("__anint_%c%d", gfc_type_letter (a
->ts
.type
),
419 gfc_type_abi_kind (&a
->ts
));
424 gfc_resolve_dnint (gfc_expr
*f
, gfc_expr
*a
)
426 gfc_resolve_anint (f
, a
, NULL
);
431 gfc_resolve_any (gfc_expr
*f
, gfc_expr
*mask
, gfc_expr
*dim
)
437 gfc_resolve_dim_arg (dim
);
438 f
->rank
= mask
->rank
- 1;
439 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
442 f
->value
.function
.name
443 = gfc_get_string (PREFIX ("any_%c%d"), gfc_type_letter (mask
->ts
.type
),
444 gfc_type_abi_kind (&mask
->ts
));
449 gfc_resolve_asin (gfc_expr
*f
, gfc_expr
*x
)
452 f
->value
.function
.name
453 = gfc_get_string ("__asin_%c%d", gfc_type_letter (x
->ts
.type
),
454 gfc_type_abi_kind (&x
->ts
));
458 gfc_resolve_asinh (gfc_expr
*f
, gfc_expr
*x
)
461 f
->value
.function
.name
462 = gfc_get_string ("__asinh_%c%d", gfc_type_letter (x
->ts
.type
),
463 gfc_type_abi_kind (&x
->ts
));
467 gfc_resolve_atan (gfc_expr
*f
, gfc_expr
*x
)
470 f
->value
.function
.name
471 = gfc_get_string ("__atan_%c%d", gfc_type_letter (x
->ts
.type
),
472 gfc_type_abi_kind (&x
->ts
));
476 gfc_resolve_atanh (gfc_expr
*f
, gfc_expr
*x
)
479 f
->value
.function
.name
480 = gfc_get_string ("__atanh_%c%d", gfc_type_letter (x
->ts
.type
),
481 gfc_type_abi_kind (&x
->ts
));
485 gfc_resolve_atan2 (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y ATTRIBUTE_UNUSED
)
488 f
->value
.function
.name
489 = gfc_get_string ("__atan2_%c%d", gfc_type_letter (x
->ts
.type
),
490 gfc_type_abi_kind (&x
->ts
));
494 /* Resolve the BESYN and BESJN intrinsics. */
497 gfc_resolve_besn (gfc_expr
*f
, gfc_expr
*n
, gfc_expr
*x
)
503 if (n
->ts
.kind
!= gfc_c_int_kind
)
505 ts
.type
= BT_INTEGER
;
506 ts
.kind
= gfc_c_int_kind
;
507 gfc_convert_type (n
, &ts
, 2);
509 f
->value
.function
.name
= gfc_get_string ("<intrinsic>");
514 gfc_resolve_bessel_n2 (gfc_expr
*f
, gfc_expr
*n1
, gfc_expr
*n2
, gfc_expr
*x
)
521 if (n1
->expr_type
== EXPR_CONSTANT
&& n2
->expr_type
== EXPR_CONSTANT
)
523 f
->shape
= gfc_get_shape (1);
524 mpz_init (f
->shape
[0]);
525 mpz_sub (f
->shape
[0], n2
->value
.integer
, n1
->value
.integer
);
526 mpz_add_ui (f
->shape
[0], f
->shape
[0], 1);
529 if (n1
->ts
.kind
!= gfc_c_int_kind
)
531 ts
.type
= BT_INTEGER
;
532 ts
.kind
= gfc_c_int_kind
;
533 gfc_convert_type (n1
, &ts
, 2);
536 if (n2
->ts
.kind
!= gfc_c_int_kind
)
538 ts
.type
= BT_INTEGER
;
539 ts
.kind
= gfc_c_int_kind
;
540 gfc_convert_type (n2
, &ts
, 2);
543 if (f
->value
.function
.isym
->id
== GFC_ISYM_JN2
)
544 f
->value
.function
.name
= gfc_get_string (PREFIX ("bessel_jn_r%d"),
545 gfc_type_abi_kind (&f
->ts
));
547 f
->value
.function
.name
= gfc_get_string (PREFIX ("bessel_yn_r%d"),
548 gfc_type_abi_kind (&f
->ts
));
553 gfc_resolve_btest (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos
)
555 f
->ts
.type
= BT_LOGICAL
;
556 f
->ts
.kind
= gfc_default_logical_kind
;
557 f
->value
.function
.name
558 = gfc_get_string ("__btest_%d_%d", i
->ts
.kind
, pos
->ts
.kind
);
563 gfc_resolve_c_loc (gfc_expr
*f
, gfc_expr
*x ATTRIBUTE_UNUSED
)
565 f
->ts
= f
->value
.function
.isym
->ts
;
570 gfc_resolve_c_funloc (gfc_expr
*f
, gfc_expr
*x ATTRIBUTE_UNUSED
)
572 f
->ts
= f
->value
.function
.isym
->ts
;
577 gfc_resolve_ceiling (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
579 f
->ts
.type
= BT_INTEGER
;
580 f
->ts
.kind
= (kind
== NULL
)
581 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
582 f
->value
.function
.name
583 = gfc_get_string ("__ceiling_%d_%c%d", f
->ts
.kind
,
584 gfc_type_letter (a
->ts
.type
),
585 gfc_type_abi_kind (&a
->ts
));
590 gfc_resolve_char (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
592 gfc_resolve_char_achar (f
, a
, kind
, false);
597 gfc_resolve_chdir (gfc_expr
*f
, gfc_expr
*d ATTRIBUTE_UNUSED
)
599 f
->ts
.type
= BT_INTEGER
;
600 f
->ts
.kind
= gfc_default_integer_kind
;
601 f
->value
.function
.name
= gfc_get_string (PREFIX ("chdir_i%d"), f
->ts
.kind
);
606 gfc_resolve_chdir_sub (gfc_code
*c
)
611 if (c
->ext
.actual
->next
->expr
!= NULL
)
612 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
614 kind
= gfc_default_integer_kind
;
616 name
= gfc_get_string (PREFIX ("chdir_i%d_sub"), kind
);
617 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
622 gfc_resolve_chmod (gfc_expr
*f
, gfc_expr
*name ATTRIBUTE_UNUSED
,
623 gfc_expr
*mode ATTRIBUTE_UNUSED
)
625 f
->ts
.type
= BT_INTEGER
;
626 f
->ts
.kind
= gfc_c_int_kind
;
627 f
->value
.function
.name
= PREFIX ("chmod_func");
632 gfc_resolve_chmod_sub (gfc_code
*c
)
637 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
638 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
640 kind
= gfc_default_integer_kind
;
642 name
= gfc_get_string (PREFIX ("chmod_i%d_sub"), kind
);
643 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
648 gfc_resolve_cmplx (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y
, gfc_expr
*kind
)
650 f
->ts
.type
= BT_COMPLEX
;
651 f
->ts
.kind
= (kind
== NULL
)
652 ? gfc_default_real_kind
: mpz_get_si (kind
->value
.integer
);
655 f
->value
.function
.name
656 = gfc_get_string ("__cmplx0_%d_%c%d", f
->ts
.kind
,
657 gfc_type_letter (x
->ts
.type
),
658 gfc_type_abi_kind (&x
->ts
));
660 f
->value
.function
.name
661 = gfc_get_string ("__cmplx1_%d_%c%d_%c%d", f
->ts
.kind
,
662 gfc_type_letter (x
->ts
.type
),
663 gfc_type_abi_kind (&x
->ts
),
664 gfc_type_letter (y
->ts
.type
),
665 gfc_type_abi_kind (&y
->ts
));
670 gfc_resolve_dcmplx (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y
)
672 gfc_resolve_cmplx (f
, x
, y
, gfc_get_int_expr (gfc_default_integer_kind
, NULL
,
673 gfc_default_double_kind
));
678 gfc_resolve_complex (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y
)
682 if (x
->ts
.type
== BT_INTEGER
)
684 if (y
->ts
.type
== BT_INTEGER
)
685 kind
= gfc_default_real_kind
;
691 if (y
->ts
.type
== BT_REAL
)
692 kind
= (x
->ts
.kind
> y
->ts
.kind
) ? x
->ts
.kind
: y
->ts
.kind
;
697 f
->ts
.type
= BT_COMPLEX
;
699 f
->value
.function
.name
700 = gfc_get_string ("__cmplx1_%d_%c%d_%c%d", f
->ts
.kind
,
701 gfc_type_letter (x
->ts
.type
),
702 gfc_type_abi_kind (&x
->ts
),
703 gfc_type_letter (y
->ts
.type
),
704 gfc_type_abi_kind (&y
->ts
));
709 gfc_resolve_conjg (gfc_expr
*f
, gfc_expr
*x
)
712 f
->value
.function
.name
= gfc_get_string ("__conjg_%d", x
->ts
.kind
);
717 gfc_resolve_cos (gfc_expr
*f
, gfc_expr
*x
)
720 f
->value
.function
.name
721 = gfc_get_string ("__cos_%c%d", gfc_type_letter (x
->ts
.type
),
722 gfc_type_abi_kind (&x
->ts
));
727 gfc_resolve_cosh (gfc_expr
*f
, gfc_expr
*x
)
730 f
->value
.function
.name
731 = gfc_get_string ("__cosh_%c%d", gfc_type_letter (x
->ts
.type
),
732 gfc_type_abi_kind (&x
->ts
));
737 gfc_resolve_count (gfc_expr
*f
, gfc_expr
*mask
, gfc_expr
*dim
, gfc_expr
*kind
)
739 f
->ts
.type
= BT_INTEGER
;
741 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
743 f
->ts
.kind
= gfc_default_integer_kind
;
747 f
->rank
= mask
->rank
- 1;
748 gfc_resolve_dim_arg (dim
);
749 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
752 resolve_mask_arg (mask
);
754 f
->value
.function
.name
755 = gfc_get_string (PREFIX ("count_%d_%c"), gfc_type_abi_kind (&f
->ts
),
756 gfc_type_letter (mask
->ts
.type
));
761 gfc_resolve_cshift (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*shift
,
766 if (array
->ts
.type
== BT_CHARACTER
&& array
->ref
)
767 gfc_resolve_substring_charlen (array
);
770 f
->rank
= array
->rank
;
771 f
->corank
= array
->corank
;
772 f
->shape
= gfc_copy_shape (array
->shape
, array
->rank
);
779 /* If dim kind is greater than default integer we need to use the larger. */
780 m
= gfc_default_integer_kind
;
782 m
= m
< dim
->ts
.kind
? dim
->ts
.kind
: m
;
784 /* Convert shift to at least m, so we don't need
785 kind=1 and kind=2 versions of the library functions. */
786 if (shift
->ts
.kind
< m
)
790 ts
.type
= BT_INTEGER
;
792 gfc_convert_type_warn (shift
, &ts
, 2, 0);
797 if (dim
->expr_type
!= EXPR_CONSTANT
&& dim
->symtree
!= NULL
798 && dim
->symtree
->n
.sym
->attr
.optional
)
800 /* Mark this for later setting the type in gfc_conv_missing_dummy. */
801 dim
->representation
.length
= shift
->ts
.kind
;
805 gfc_resolve_dim_arg (dim
);
806 /* Convert dim to shift's kind to reduce variations. */
807 if (dim
->ts
.kind
!= shift
->ts
.kind
)
808 gfc_convert_type_warn (dim
, &shift
->ts
, 2, 0);
812 if (array
->ts
.type
== BT_CHARACTER
)
814 if (array
->ts
.kind
== gfc_default_character_kind
)
815 f
->value
.function
.name
816 = gfc_get_string (PREFIX ("cshift%d_%d_char"), n
, shift
->ts
.kind
);
818 f
->value
.function
.name
819 = gfc_get_string (PREFIX ("cshift%d_%d_char%d"), n
, shift
->ts
.kind
,
823 f
->value
.function
.name
824 = gfc_get_string (PREFIX ("cshift%d_%d"), n
, shift
->ts
.kind
);
829 gfc_resolve_ctime (gfc_expr
*f
, gfc_expr
*time
)
834 f
->ts
.type
= BT_CHARACTER
;
835 f
->ts
.kind
= gfc_default_character_kind
;
837 /* ctime TIME argument is a INTEGER(KIND=8), says the doc */
838 if (time
->ts
.kind
!= 8)
840 ts
.type
= BT_INTEGER
;
844 gfc_convert_type (time
, &ts
, 2);
847 f
->value
.function
.name
= gfc_get_string (PREFIX ("ctime"));
852 gfc_resolve_dble (gfc_expr
*f
, gfc_expr
*a
)
854 f
->ts
.type
= BT_REAL
;
855 f
->ts
.kind
= gfc_default_double_kind
;
856 f
->value
.function
.name
857 = gfc_get_string ("__dble_%c%d", gfc_type_letter (a
->ts
.type
),
858 gfc_type_abi_kind (&a
->ts
));
863 gfc_resolve_dim (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p
)
865 f
->ts
.type
= a
->ts
.type
;
867 f
->ts
.kind
= gfc_kind_max (a
,p
);
869 f
->ts
.kind
= a
->ts
.kind
;
871 if (p
!= NULL
&& a
->ts
.kind
!= p
->ts
.kind
)
873 if (a
->ts
.kind
== gfc_kind_max (a
,p
))
874 gfc_convert_type (p
, &a
->ts
, 2);
876 gfc_convert_type (a
, &p
->ts
, 2);
879 f
->value
.function
.name
880 = gfc_get_string ("__dim_%c%d", gfc_type_letter (f
->ts
.type
),
881 gfc_type_abi_kind (&f
->ts
));
886 gfc_resolve_dot_product (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*b
)
890 temp
.expr_type
= EXPR_OP
;
891 gfc_clear_ts (&temp
.ts
);
892 temp
.value
.op
.op
= INTRINSIC_NONE
;
893 temp
.value
.op
.op1
= a
;
894 temp
.value
.op
.op2
= b
;
895 gfc_type_convert_binary (&temp
, 1);
897 f
->value
.function
.name
898 = gfc_get_string (PREFIX ("dot_product_%c%d"),
899 gfc_type_letter (f
->ts
.type
),
900 gfc_type_abi_kind (&f
->ts
));
905 gfc_resolve_dprod (gfc_expr
*f
, gfc_expr
*a ATTRIBUTE_UNUSED
,
906 gfc_expr
*b ATTRIBUTE_UNUSED
)
908 f
->ts
.kind
= gfc_default_double_kind
;
909 f
->ts
.type
= BT_REAL
;
910 f
->value
.function
.name
= gfc_get_string ("__dprod_r%d",
911 gfc_type_abi_kind (&f
->ts
));
916 gfc_resolve_dshift (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j ATTRIBUTE_UNUSED
,
917 gfc_expr
*shift ATTRIBUTE_UNUSED
)
919 char c
= i
->ts
.type
== BT_INTEGER
? 'i' : 'u';
922 if (f
->value
.function
.isym
->id
== GFC_ISYM_DSHIFTL
)
923 f
->value
.function
.name
= gfc_get_string ("dshiftl_%c%d", c
, f
->ts
.kind
);
924 else if (f
->value
.function
.isym
->id
== GFC_ISYM_DSHIFTR
)
925 f
->value
.function
.name
= gfc_get_string ("dshiftr_%c%d", c
, f
->ts
.kind
);
932 gfc_resolve_eoshift (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*shift
,
933 gfc_expr
*boundary
, gfc_expr
*dim
)
937 if (array
->ts
.type
== BT_CHARACTER
&& array
->ref
)
938 gfc_resolve_substring_charlen (array
);
941 f
->rank
= array
->rank
;
942 f
->corank
= array
->corank
;
943 f
->shape
= gfc_copy_shape (array
->shape
, array
->rank
);
948 if (boundary
&& boundary
->rank
> 0)
951 /* If dim kind is greater than default integer we need to use the larger. */
952 m
= gfc_default_integer_kind
;
954 m
= m
< dim
->ts
.kind
? dim
->ts
.kind
: m
;
956 /* Convert shift to at least m, so we don't need
957 kind=1 and kind=2 versions of the library functions. */
958 if (shift
->ts
.kind
< m
)
962 ts
.type
= BT_INTEGER
;
964 gfc_convert_type_warn (shift
, &ts
, 2, 0);
969 if (dim
->expr_type
!= EXPR_CONSTANT
&& dim
->symtree
!= NULL
970 && dim
->symtree
->n
.sym
->attr
.optional
)
972 /* Mark this for later setting the type in gfc_conv_missing_dummy. */
973 dim
->representation
.length
= shift
->ts
.kind
;
977 gfc_resolve_dim_arg (dim
);
978 /* Convert dim to shift's kind to reduce variations. */
979 if (dim
->ts
.kind
!= shift
->ts
.kind
)
980 gfc_convert_type_warn (dim
, &shift
->ts
, 2, 0);
984 if (array
->ts
.type
== BT_CHARACTER
)
986 if (array
->ts
.kind
== gfc_default_character_kind
)
987 f
->value
.function
.name
988 = gfc_get_string (PREFIX ("eoshift%d_%d_char"), n
, shift
->ts
.kind
);
990 f
->value
.function
.name
991 = gfc_get_string (PREFIX ("eoshift%d_%d_char%d"), n
, shift
->ts
.kind
,
995 f
->value
.function
.name
996 = gfc_get_string (PREFIX ("eoshift%d_%d"), n
, shift
->ts
.kind
);
1001 gfc_resolve_exp (gfc_expr
*f
, gfc_expr
*x
)
1004 f
->value
.function
.name
1005 = gfc_get_string ("__exp_%c%d", gfc_type_letter (x
->ts
.type
),
1006 gfc_type_abi_kind (&x
->ts
));
1011 gfc_resolve_exponent (gfc_expr
*f
, gfc_expr
*x
)
1013 f
->ts
.type
= BT_INTEGER
;
1014 f
->ts
.kind
= gfc_default_integer_kind
;
1015 f
->value
.function
.name
= gfc_get_string ("__exponent_%d", x
->ts
.kind
);
1019 /* Resolve the EXTENDS_TYPE_OF intrinsic function. */
1022 gfc_resolve_extends_type_of (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*mo
)
1027 /* Prevent double resolution. */
1028 if (f
->ts
.type
== BT_LOGICAL
)
1031 /* Replace the first argument with the corresponding vtab. */
1032 if (a
->ts
.type
== BT_CLASS
)
1033 gfc_add_vptr_component (a
);
1034 else if (a
->ts
.type
== BT_DERIVED
)
1038 vtab
= gfc_find_derived_vtab (a
->ts
.u
.derived
);
1039 /* Clear the old expr. */
1040 gfc_free_ref_list (a
->ref
);
1042 memset (a
, '\0', sizeof (gfc_expr
));
1043 /* Construct a new one. */
1044 a
->expr_type
= EXPR_VARIABLE
;
1045 st
= gfc_find_symtree (vtab
->ns
->sym_root
, vtab
->name
);
1051 /* Replace the second argument with the corresponding vtab. */
1052 if (mo
->ts
.type
== BT_CLASS
)
1053 gfc_add_vptr_component (mo
);
1054 else if (mo
->ts
.type
== BT_DERIVED
)
1058 vtab
= gfc_find_derived_vtab (mo
->ts
.u
.derived
);
1059 /* Clear the old expr. */
1061 gfc_free_ref_list (mo
->ref
);
1062 memset (mo
, '\0', sizeof (gfc_expr
));
1063 /* Construct a new one. */
1064 mo
->expr_type
= EXPR_VARIABLE
;
1065 st
= gfc_find_symtree (vtab
->ns
->sym_root
, vtab
->name
);
1071 f
->ts
.type
= BT_LOGICAL
;
1074 f
->value
.function
.isym
->formal
->ts
= a
->ts
;
1075 f
->value
.function
.isym
->formal
->next
->ts
= mo
->ts
;
1077 /* Call library function. */
1078 f
->value
.function
.name
= gfc_get_string (PREFIX ("is_extension_of"));
1083 gfc_resolve_fdate (gfc_expr
*f
)
1085 f
->ts
.type
= BT_CHARACTER
;
1086 f
->ts
.kind
= gfc_default_character_kind
;
1087 f
->value
.function
.name
= gfc_get_string (PREFIX ("fdate"));
1092 gfc_resolve_floor (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
1094 f
->ts
.type
= BT_INTEGER
;
1095 f
->ts
.kind
= (kind
== NULL
)
1096 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
1097 f
->value
.function
.name
1098 = gfc_get_string ("__floor%d_%c%d", f
->ts
.kind
,
1099 gfc_type_letter (a
->ts
.type
),
1100 gfc_type_abi_kind (&a
->ts
));
1105 gfc_resolve_fnum (gfc_expr
*f
, gfc_expr
*n
)
1107 f
->ts
.type
= BT_INTEGER
;
1108 f
->ts
.kind
= gfc_default_integer_kind
;
1109 if (n
->ts
.kind
!= f
->ts
.kind
)
1110 gfc_convert_type (n
, &f
->ts
, 2);
1111 f
->value
.function
.name
= gfc_get_string (PREFIX ("fnum_i%d"), f
->ts
.kind
);
1116 gfc_resolve_fraction (gfc_expr
*f
, gfc_expr
*x
)
1119 f
->value
.function
.name
= gfc_get_string ("__fraction_%d", x
->ts
.kind
);
1123 /* Resolve single-argument g77 math intrinsics, eg BESY0, ERF. */
1126 gfc_resolve_g77_math1 (gfc_expr
*f
, gfc_expr
*x
)
1129 f
->value
.function
.name
= gfc_get_string ("<intrinsic>");
1134 gfc_resolve_gamma (gfc_expr
*f
, gfc_expr
*x
)
1137 f
->value
.function
.name
1138 = gfc_get_string ("__tgamma_%d", x
->ts
.kind
);
1143 gfc_resolve_getcwd (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
1145 f
->ts
.type
= BT_INTEGER
;
1147 f
->value
.function
.name
= gfc_get_string (PREFIX ("getcwd"));
1152 gfc_resolve_getgid (gfc_expr
*f
)
1154 f
->ts
.type
= BT_INTEGER
;
1156 f
->value
.function
.name
= gfc_get_string (PREFIX ("getgid"));
1161 gfc_resolve_getpid (gfc_expr
*f
)
1163 f
->ts
.type
= BT_INTEGER
;
1165 f
->value
.function
.name
= gfc_get_string (PREFIX ("getpid"));
1170 gfc_resolve_getuid (gfc_expr
*f
)
1172 f
->ts
.type
= BT_INTEGER
;
1174 f
->value
.function
.name
= gfc_get_string (PREFIX ("getuid"));
1179 gfc_resolve_hostnm (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
1181 f
->ts
.type
= BT_INTEGER
;
1183 f
->value
.function
.name
= gfc_get_string (PREFIX ("hostnm"));
1188 gfc_resolve_hypot (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y ATTRIBUTE_UNUSED
)
1191 f
->value
.function
.name
= gfc_get_string ("__hypot_r%d",
1192 gfc_type_abi_kind (&x
->ts
));
1197 gfc_resolve_iall (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*mask
)
1199 resolve_transformational ("iall", f
, array
, dim
, mask
, true);
1204 gfc_resolve_iand (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
1206 /* If the kind of i and j are different, then g77 cross-promoted the
1207 kinds to the largest value. The Fortran 95 standard requires the
1210 if (i
->ts
.kind
!= j
->ts
.kind
)
1212 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
1213 gfc_convert_type (j
, &i
->ts
, 2);
1215 gfc_convert_type (i
, &j
->ts
, 2);
1219 const char *name
= i
->ts
.kind
== BT_UNSIGNED
? "__iand_m_%d" : "__iand_%d";
1220 f
->value
.function
.name
= gfc_get_string (name
, i
->ts
.kind
);
1225 gfc_resolve_iany (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*mask
)
1227 resolve_transformational ("iany", f
, array
, dim
, mask
, true);
1232 gfc_resolve_ibclr (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos ATTRIBUTE_UNUSED
)
1235 const char *name
= i
->ts
.kind
== BT_UNSIGNED
? "__ibclr_m_%d" : "__ibclr_%d";
1236 f
->value
.function
.name
= gfc_get_string (name
, i
->ts
.kind
);
1241 gfc_resolve_ibits (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos ATTRIBUTE_UNUSED
,
1242 gfc_expr
*len ATTRIBUTE_UNUSED
)
1245 const char *name
= i
->ts
.kind
== BT_UNSIGNED
? "__ibits_m_%d" : "__ibits_%d";
1246 f
->value
.function
.name
= gfc_get_string (name
, i
->ts
.kind
);
1251 gfc_resolve_ibset (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos ATTRIBUTE_UNUSED
)
1254 const char *name
= i
->ts
.kind
== BT_UNSIGNED
? "__ibset_m_%d" : "__ibset_%d";
1255 f
->value
.function
.name
= gfc_get_string (name
, i
->ts
.kind
);
1260 gfc_resolve_iachar (gfc_expr
*f
, gfc_expr
*c
, gfc_expr
*kind
)
1262 f
->ts
.type
= BT_INTEGER
;
1264 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1266 f
->ts
.kind
= gfc_default_integer_kind
;
1267 f
->value
.function
.name
= gfc_get_string ("__ichar_%d", c
->ts
.kind
);
1272 gfc_resolve_ichar (gfc_expr
*f
, gfc_expr
*c
, gfc_expr
*kind
)
1274 f
->ts
.type
= BT_INTEGER
;
1276 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1278 f
->ts
.kind
= gfc_default_integer_kind
;
1279 f
->value
.function
.name
= gfc_get_string ("__ichar_%d", c
->ts
.kind
);
1284 gfc_resolve_idnint (gfc_expr
*f
, gfc_expr
*a
)
1286 gfc_resolve_nint (f
, a
, NULL
);
1291 gfc_resolve_ierrno (gfc_expr
*f
)
1293 f
->ts
.type
= BT_INTEGER
;
1294 f
->ts
.kind
= gfc_default_integer_kind
;
1295 f
->value
.function
.name
= gfc_get_string (PREFIX ("ierrno_i%d"), f
->ts
.kind
);
1300 gfc_resolve_ieor (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
1302 /* If the kind of i and j are different, then g77 cross-promoted the
1303 kinds to the largest value. The Fortran 95 standard requires the
1306 if (i
->ts
.kind
!= j
->ts
.kind
)
1308 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
1309 gfc_convert_type (j
, &i
->ts
, 2);
1311 gfc_convert_type (i
, &j
->ts
, 2);
1314 const char *name
= i
->ts
.kind
== BT_UNSIGNED
? "__ieor_m_%d" : "__ieor_%d";
1316 f
->value
.function
.name
= gfc_get_string (name
, i
->ts
.kind
);
1321 gfc_resolve_ior (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
1323 /* If the kind of i and j are different, then g77 cross-promoted the
1324 kinds to the largest value. The Fortran 95 standard requires the
1327 if (i
->ts
.kind
!= j
->ts
.kind
)
1329 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
1330 gfc_convert_type (j
, &i
->ts
, 2);
1332 gfc_convert_type (i
, &j
->ts
, 2);
1335 const char *name
= i
->ts
.kind
== BT_UNSIGNED
? "__ior_m_%d" : "__ior_%d";
1337 f
->value
.function
.name
= gfc_get_string (name
, i
->ts
.kind
);
1342 gfc_resolve_index_func (gfc_expr
*f
, gfc_expr
*str
,
1343 gfc_expr
*sub_str ATTRIBUTE_UNUSED
, gfc_expr
*back
,
1349 f
->ts
.type
= BT_INTEGER
;
1351 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1353 f
->ts
.kind
= gfc_default_integer_kind
;
1355 if (back
&& back
->ts
.kind
!= gfc_default_integer_kind
)
1357 ts
.type
= BT_LOGICAL
;
1358 ts
.kind
= gfc_default_integer_kind
;
1359 ts
.u
.derived
= NULL
;
1361 gfc_convert_type (back
, &ts
, 2);
1364 f
->value
.function
.name
1365 = gfc_get_string ("__index_%d_i%d", str
->ts
.kind
, f
->ts
.kind
);
1370 gfc_resolve_int (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
1372 f
->ts
.type
= BT_INTEGER
;
1373 f
->ts
.kind
= (kind
== NULL
)
1374 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
1375 f
->value
.function
.name
1376 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1377 gfc_type_letter (a
->ts
.type
),
1378 gfc_type_abi_kind (&a
->ts
));
1382 gfc_resolve_uint (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
1384 f
->ts
.type
= BT_UNSIGNED
;
1385 f
->ts
.kind
= (kind
== NULL
)
1386 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
1387 f
->value
.function
.name
1388 = gfc_get_string ("__uint_%d_%c%d", f
->ts
.kind
,
1389 gfc_type_letter (a
->ts
.type
),
1390 gfc_type_abi_kind (&a
->ts
));
1395 gfc_resolve_int2 (gfc_expr
*f
, gfc_expr
*a
)
1397 f
->ts
.type
= BT_INTEGER
;
1399 f
->value
.function
.name
1400 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1401 gfc_type_letter (a
->ts
.type
),
1402 gfc_type_abi_kind (&a
->ts
));
1407 gfc_resolve_int8 (gfc_expr
*f
, gfc_expr
*a
)
1409 f
->ts
.type
= BT_INTEGER
;
1411 f
->value
.function
.name
1412 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1413 gfc_type_letter (a
->ts
.type
),
1414 gfc_type_abi_kind (&a
->ts
));
1419 gfc_resolve_long (gfc_expr
*f
, gfc_expr
*a
)
1421 f
->ts
.type
= BT_INTEGER
;
1423 f
->value
.function
.name
1424 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1425 gfc_type_letter (a
->ts
.type
),
1426 gfc_type_abi_kind (&a
->ts
));
1431 gfc_resolve_iparity (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*mask
)
1433 resolve_transformational ("iparity", f
, array
, dim
, mask
, true);
1438 gfc_resolve_isatty (gfc_expr
*f
, gfc_expr
*u
)
1443 f
->ts
.type
= BT_LOGICAL
;
1444 f
->ts
.kind
= gfc_default_integer_kind
;
1445 if (u
->ts
.kind
!= gfc_c_int_kind
)
1447 ts
.type
= BT_INTEGER
;
1448 ts
.kind
= gfc_c_int_kind
;
1449 ts
.u
.derived
= NULL
;
1451 gfc_convert_type (u
, &ts
, 2);
1454 f
->value
.function
.name
= gfc_get_string (PREFIX ("isatty_l%d"), f
->ts
.kind
);
1459 gfc_resolve_is_contiguous (gfc_expr
*f
, gfc_expr
*array ATTRIBUTE_UNUSED
)
1461 f
->ts
.type
= BT_LOGICAL
;
1462 f
->ts
.kind
= gfc_default_logical_kind
;
1463 f
->value
.function
.name
= gfc_get_string ("__is_contiguous");
1468 gfc_resolve_ishft (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
)
1471 f
->value
.function
.name
1472 = gfc_get_string ("__ishft_%d_%d", i
->ts
.kind
, shift
->ts
.kind
);
1477 gfc_resolve_rshift (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
)
1480 f
->value
.function
.name
1481 = gfc_get_string ("__rshift_%d_%d", i
->ts
.kind
, shift
->ts
.kind
);
1486 gfc_resolve_lshift (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
)
1489 f
->value
.function
.name
1490 = gfc_get_string ("__lshift_%d_%d", i
->ts
.kind
, shift
->ts
.kind
);
1495 gfc_resolve_ishftc (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
, gfc_expr
*size
)
1499 s_kind
= (size
== NULL
) ? gfc_default_integer_kind
: size
->ts
.kind
;
1502 f
->value
.function
.name
1503 = gfc_get_string ("__ishftc_%d_%d_%d", i
->ts
.kind
, shift
->ts
.kind
, s_kind
);
1508 gfc_resolve_lbound (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
1510 resolve_bound (f
, array
, dim
, kind
, "__lbound", false);
1515 gfc_resolve_lcobound (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
1517 resolve_bound (f
, array
, dim
, kind
, "__lcobound", true);
1522 gfc_resolve_len (gfc_expr
*f
, gfc_expr
*string
, gfc_expr
*kind
)
1524 f
->ts
.type
= BT_INTEGER
;
1526 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1528 f
->ts
.kind
= gfc_default_integer_kind
;
1529 f
->value
.function
.name
1530 = gfc_get_string ("__len_%d_i%d", string
->ts
.kind
,
1531 gfc_default_integer_kind
);
1536 gfc_resolve_len_trim (gfc_expr
*f
, gfc_expr
*string
, gfc_expr
*kind
)
1538 f
->ts
.type
= BT_INTEGER
;
1540 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1542 f
->ts
.kind
= gfc_default_integer_kind
;
1543 f
->value
.function
.name
= gfc_get_string ("__len_trim%d", string
->ts
.kind
);
1548 gfc_resolve_lgamma (gfc_expr
*f
, gfc_expr
*x
)
1551 f
->value
.function
.name
1552 = gfc_get_string ("__lgamma_%d", x
->ts
.kind
);
1557 gfc_resolve_link (gfc_expr
*f
, gfc_expr
*p1 ATTRIBUTE_UNUSED
,
1558 gfc_expr
*p2 ATTRIBUTE_UNUSED
)
1560 f
->ts
.type
= BT_INTEGER
;
1561 f
->ts
.kind
= gfc_default_integer_kind
;
1562 f
->value
.function
.name
= gfc_get_string (PREFIX ("link_i%d"), f
->ts
.kind
);
1567 gfc_resolve_loc (gfc_expr
*f
, gfc_expr
*x
)
1569 f
->ts
.type
= BT_INTEGER
;
1570 f
->ts
.kind
= gfc_index_integer_kind
;
1571 f
->value
.function
.name
= gfc_get_string ("__loc_%d", x
->ts
.kind
);
1576 gfc_resolve_log (gfc_expr
*f
, gfc_expr
*x
)
1579 f
->value
.function
.name
1580 = gfc_get_string ("__log_%c%d", gfc_type_letter (x
->ts
.type
),
1581 gfc_type_abi_kind (&x
->ts
));
1586 gfc_resolve_log10 (gfc_expr
*f
, gfc_expr
*x
)
1589 f
->value
.function
.name
1590 = gfc_get_string ("__log10_%c%d", gfc_type_letter (x
->ts
.type
),
1591 gfc_type_abi_kind (&x
->ts
));
1596 gfc_resolve_logical (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
1598 f
->ts
.type
= BT_LOGICAL
;
1599 f
->ts
.kind
= (kind
== NULL
)
1600 ? gfc_default_logical_kind
: mpz_get_si (kind
->value
.integer
);
1602 f
->corank
= a
->corank
;
1604 f
->value
.function
.name
1605 = gfc_get_string ("__logical_%d_%c%d", f
->ts
.kind
,
1606 gfc_type_letter (a
->ts
.type
),
1607 gfc_type_abi_kind (&a
->ts
));
1612 gfc_resolve_matmul (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*b
)
1617 if (a
->ts
.type
== BT_LOGICAL
&& b
->ts
.type
== BT_LOGICAL
)
1619 f
->ts
.type
= BT_LOGICAL
;
1620 f
->ts
.kind
= gfc_default_logical_kind
;
1624 temp
.expr_type
= EXPR_OP
;
1625 gfc_clear_ts (&temp
.ts
);
1626 temp
.value
.op
.op
= INTRINSIC_NONE
;
1627 temp
.value
.op
.op1
= a
;
1628 temp
.value
.op
.op2
= b
;
1629 gfc_type_convert_binary (&temp
, 1);
1633 f
->rank
= (a
->rank
== 2 && b
->rank
== 2) ? 2 : 1;
1634 f
->corank
= a
->corank
;
1636 if (a
->rank
== 2 && b
->rank
== 2)
1638 if (a
->shape
&& b
->shape
)
1640 f
->shape
= gfc_get_shape (f
->rank
);
1641 mpz_init_set (f
->shape
[0], a
->shape
[0]);
1642 mpz_init_set (f
->shape
[1], b
->shape
[1]);
1645 else if (a
->rank
== 1)
1649 f
->shape
= gfc_get_shape (f
->rank
);
1650 mpz_init_set (f
->shape
[0], b
->shape
[1]);
1655 /* b->rank == 1 and a->rank == 2 here, all other cases have
1656 been caught in check.cc. */
1659 f
->shape
= gfc_get_shape (f
->rank
);
1660 mpz_init_set (f
->shape
[0], a
->shape
[0]);
1664 /* We use the same library version of matmul for INTEGER and UNSIGNED,
1665 which we call as the INTEGER version. */
1667 if (f
->ts
.type
== BT_UNSIGNED
)
1672 f
->value
.function
.name
1673 = gfc_get_string (PREFIX ("matmul_%c%d"), gfc_type_letter (type
),
1674 gfc_type_abi_kind (&f
->ts
));
1679 gfc_resolve_minmax (const char *name
, gfc_expr
*f
, gfc_actual_arglist
*args
)
1681 gfc_actual_arglist
*a
;
1683 f
->ts
.type
= args
->expr
->ts
.type
;
1684 f
->ts
.kind
= args
->expr
->ts
.kind
;
1685 /* Find the largest type kind. */
1686 for (a
= args
->next
; a
; a
= a
->next
)
1688 if (a
->expr
->ts
.kind
> f
->ts
.kind
)
1689 f
->ts
.kind
= a
->expr
->ts
.kind
;
1692 /* Convert all parameters to the required kind. */
1693 for (a
= args
; a
; a
= a
->next
)
1695 if (a
->expr
->ts
.kind
!= f
->ts
.kind
)
1696 gfc_convert_type (a
->expr
, &f
->ts
, 2);
1699 f
->value
.function
.name
1700 = gfc_get_string (name
, gfc_type_letter (f
->ts
.type
),
1701 gfc_type_abi_kind (&f
->ts
));
1706 gfc_resolve_max (gfc_expr
*f
, gfc_actual_arglist
*args
)
1708 gfc_resolve_minmax ("__max_%c%d", f
, args
);
1711 /* The smallest kind for which a minloc and maxloc implementation exists. */
1713 #define MINMAXLOC_MIN_KIND 4
1716 gfc_resolve_maxloc (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
1717 gfc_expr
*mask
, gfc_expr
*kind
, gfc_expr
*back
)
1724 f
->ts
.type
= BT_INTEGER
;
1726 /* The library versions only exist for kinds 4, 8 and 16. For smaller kinds,
1727 we do a type conversion further down. */
1729 fkind
= mpz_get_si (kind
->value
.integer
);
1731 fkind
= gfc_default_integer_kind
;
1733 if (fkind
< MINMAXLOC_MIN_KIND
)
1734 f
->ts
.kind
= MINMAXLOC_MIN_KIND
;
1741 f
->shape
= gfc_get_shape (1);
1742 mpz_init_set_si (f
->shape
[0], array
->rank
);
1746 f
->rank
= array
->rank
- 1;
1747 gfc_resolve_dim_arg (dim
);
1748 if (array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
1750 idim
= (int) mpz_get_si (dim
->value
.integer
);
1751 f
->shape
= gfc_get_shape (f
->rank
);
1752 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
1754 if (i
== (idim
- 1))
1756 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
1763 if (mask
->rank
== 0)
1768 resolve_mask_arg (mask
);
1775 if (array
->ts
.type
!= BT_CHARACTER
|| f
->rank
!= 0)
1783 f
->value
.function
.name
1784 = gfc_get_string (PREFIX ("%s%d_%d_%c%d"), name
, d_num
, f
->ts
.kind
,
1785 gfc_type_letter (array
->ts
.type
),
1786 gfc_type_abi_kind (&array
->ts
));
1789 fkind
= mpz_get_si (kind
->value
.integer
);
1791 fkind
= gfc_default_integer_kind
;
1793 if (fkind
!= f
->ts
.kind
)
1798 ts
.type
= BT_INTEGER
;
1800 gfc_convert_type_warn (f
, &ts
, 2, 0);
1803 if (back
->ts
.kind
!= gfc_logical_4_kind
)
1807 ts
.type
= BT_LOGICAL
;
1808 ts
.kind
= gfc_logical_4_kind
;
1809 gfc_convert_type_warn (back
, &ts
, 2, 0);
1815 gfc_resolve_findloc (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*value
,
1816 gfc_expr
*dim
, gfc_expr
*mask
, gfc_expr
*kind
,
1825 /* See at the end of the function for why this is necessary. */
1827 if (f
->do_not_resolve_again
)
1830 f
->ts
.type
= BT_INTEGER
;
1832 /* We have a single library version, which uses index_type. */
1835 fkind
= mpz_get_si (kind
->value
.integer
);
1837 fkind
= gfc_default_integer_kind
;
1839 f
->ts
.kind
= gfc_index_integer_kind
;
1841 /* Convert value. If array is not LOGICAL and value is, we already
1842 issued an error earlier. */
1844 if ((array
->ts
.type
!= value
->ts
.type
&& value
->ts
.type
!= BT_LOGICAL
)
1845 || array
->ts
.kind
!= value
->ts
.kind
)
1846 gfc_convert_type_warn (value
, &array
->ts
, 2, 0);
1851 f
->shape
= gfc_get_shape (1);
1852 mpz_init_set_si (f
->shape
[0], array
->rank
);
1856 f
->rank
= array
->rank
- 1;
1857 gfc_resolve_dim_arg (dim
);
1858 if (array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
1860 idim
= (int) mpz_get_si (dim
->value
.integer
);
1861 f
->shape
= gfc_get_shape (f
->rank
);
1862 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
1864 if (i
== (idim
- 1))
1866 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
1873 if (mask
->rank
== 0)
1878 resolve_mask_arg (mask
);
1893 if (back
->ts
.kind
!= gfc_logical_4_kind
)
1897 ts
.type
= BT_LOGICAL
;
1898 ts
.kind
= gfc_logical_4_kind
;
1899 gfc_convert_type_warn (back
, &ts
, 2, 0);
1902 /* Use the INTEGER library function for UNSIGNED. */
1903 if (array
->ts
.type
!= BT_UNSIGNED
)
1904 type
= array
->ts
.type
;
1908 f
->value
.function
.name
1909 = gfc_get_string (PREFIX ("%s%d_%c%d"), name
, d_num
,
1910 gfc_type_letter (type
, true),
1911 gfc_type_abi_kind (&array
->ts
));
1913 /* We only have a single library function, so we need to convert
1914 here. If the function is resolved from within a convert
1915 function generated on a previous round of resolution, endless
1916 recursion could occur. Guard against that here. */
1918 if (f
->ts
.kind
!= fkind
)
1920 f
->do_not_resolve_again
= 1;
1924 ts
.type
= BT_INTEGER
;
1926 gfc_convert_type_warn (f
, &ts
, 2, 0);
1932 gfc_resolve_maxval (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
1942 f
->rank
= array
->rank
- 1;
1943 gfc_resolve_dim_arg (dim
);
1945 if (f
->rank
&& array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
1947 idim
= (int) mpz_get_si (dim
->value
.integer
);
1948 f
->shape
= gfc_get_shape (f
->rank
);
1949 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
1951 if (i
== (idim
- 1))
1953 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
1960 if (mask
->rank
== 0)
1965 resolve_mask_arg (mask
);
1970 if (array
->ts
.type
!= BT_CHARACTER
)
1971 f
->value
.function
.name
1972 = gfc_get_string (PREFIX ("%s_%c%d"), name
,
1973 gfc_type_letter (array
->ts
.type
),
1974 gfc_type_abi_kind (&array
->ts
));
1976 f
->value
.function
.name
1977 = gfc_get_string (PREFIX ("%s%d_%c%d"), name
, f
->rank
!= 0,
1978 gfc_type_letter (array
->ts
.type
),
1979 gfc_type_abi_kind (&array
->ts
));
1984 gfc_resolve_mclock (gfc_expr
*f
)
1986 f
->ts
.type
= BT_INTEGER
;
1988 f
->value
.function
.name
= PREFIX ("mclock");
1993 gfc_resolve_mclock8 (gfc_expr
*f
)
1995 f
->ts
.type
= BT_INTEGER
;
1997 f
->value
.function
.name
= PREFIX ("mclock8");
2002 gfc_resolve_mask (gfc_expr
*f
, gfc_expr
*i ATTRIBUTE_UNUSED
,
2005 f
->ts
.type
= BT_INTEGER
;
2006 f
->ts
.kind
= kind
? mpz_get_si (kind
->value
.integer
)
2007 : gfc_default_integer_kind
;
2009 if (f
->value
.function
.isym
->id
== GFC_ISYM_MASKL
)
2010 f
->value
.function
.name
= gfc_get_string ("__maskl_i%d", f
->ts
.kind
);
2012 f
->value
.function
.name
= gfc_get_string ("__maskr_i%d", f
->ts
.kind
);
2016 gfc_resolve_umasklr (gfc_expr
*f
, gfc_expr
*i ATTRIBUTE_UNUSED
,
2019 f
->ts
.type
= BT_UNSIGNED
;
2020 f
->ts
.kind
= kind
? mpz_get_si (kind
->value
.integer
)
2021 : gfc_default_unsigned_kind
;
2023 if (f
->value
.function
.isym
->id
== GFC_ISYM_UMASKL
)
2024 f
->value
.function
.name
= gfc_get_string ("__maskl_m%d", f
->ts
.kind
);
2026 f
->value
.function
.name
= gfc_get_string ("__maskr_m%d", f
->ts
.kind
);
2031 gfc_resolve_merge (gfc_expr
*f
, gfc_expr
*tsource
,
2032 gfc_expr
*fsource ATTRIBUTE_UNUSED
,
2033 gfc_expr
*mask ATTRIBUTE_UNUSED
)
2035 if (tsource
->ts
.type
== BT_CHARACTER
&& tsource
->ref
)
2036 gfc_resolve_substring_charlen (tsource
);
2038 if (fsource
->ts
.type
== BT_CHARACTER
&& fsource
->ref
)
2039 gfc_resolve_substring_charlen (fsource
);
2041 if (tsource
->ts
.type
== BT_CHARACTER
)
2042 check_charlen_present (tsource
);
2044 f
->ts
= tsource
->ts
;
2045 f
->value
.function
.name
2046 = gfc_get_string ("__merge_%c%d", gfc_type_letter (tsource
->ts
.type
),
2047 gfc_type_abi_kind (&tsource
->ts
));
2052 gfc_resolve_merge_bits (gfc_expr
*f
, gfc_expr
*i
,
2053 gfc_expr
*j ATTRIBUTE_UNUSED
,
2054 gfc_expr
*mask ATTRIBUTE_UNUSED
)
2058 f
->value
.function
.name
2059 = gfc_get_string ("__merge_bits_%c%d", gfc_type_letter (i
->ts
.type
),
2065 gfc_resolve_min (gfc_expr
*f
, gfc_actual_arglist
*args
)
2067 gfc_resolve_minmax ("__min_%c%d", f
, args
);
2072 gfc_resolve_minloc (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
2073 gfc_expr
*mask
, gfc_expr
*kind
, gfc_expr
*back
)
2080 f
->ts
.type
= BT_INTEGER
;
2082 /* The library versions only exist for kinds 4, 8 and 16. For smaller kinds,
2083 we do a type conversion further down. */
2085 fkind
= mpz_get_si (kind
->value
.integer
);
2087 fkind
= gfc_default_integer_kind
;
2089 if (fkind
< MINMAXLOC_MIN_KIND
)
2090 f
->ts
.kind
= MINMAXLOC_MIN_KIND
;
2097 f
->shape
= gfc_get_shape (1);
2098 mpz_init_set_si (f
->shape
[0], array
->rank
);
2102 f
->rank
= array
->rank
- 1;
2103 gfc_resolve_dim_arg (dim
);
2104 if (array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
2106 idim
= (int) mpz_get_si (dim
->value
.integer
);
2107 f
->shape
= gfc_get_shape (f
->rank
);
2108 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
2110 if (i
== (idim
- 1))
2112 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
2119 if (mask
->rank
== 0)
2124 resolve_mask_arg (mask
);
2131 if (array
->ts
.type
!= BT_CHARACTER
|| f
->rank
!= 0)
2139 f
->value
.function
.name
2140 = gfc_get_string (PREFIX ("%s%d_%d_%c%d"), name
, d_num
, f
->ts
.kind
,
2141 gfc_type_letter (array
->ts
.type
),
2142 gfc_type_abi_kind (&array
->ts
));
2144 if (fkind
!= f
->ts
.kind
)
2149 ts
.type
= BT_INTEGER
;
2151 gfc_convert_type_warn (f
, &ts
, 2, 0);
2154 if (back
->ts
.kind
!= gfc_logical_4_kind
)
2158 ts
.type
= BT_LOGICAL
;
2159 ts
.kind
= gfc_logical_4_kind
;
2160 gfc_convert_type_warn (back
, &ts
, 2, 0);
2166 gfc_resolve_minval (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
2176 f
->rank
= array
->rank
- 1;
2177 gfc_resolve_dim_arg (dim
);
2179 if (f
->rank
&& array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
2181 idim
= (int) mpz_get_si (dim
->value
.integer
);
2182 f
->shape
= gfc_get_shape (f
->rank
);
2183 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
2185 if (i
== (idim
- 1))
2187 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
2194 if (mask
->rank
== 0)
2199 resolve_mask_arg (mask
);
2204 if (array
->ts
.type
!= BT_CHARACTER
)
2205 f
->value
.function
.name
2206 = gfc_get_string (PREFIX ("%s_%c%d"), name
,
2207 gfc_type_letter (array
->ts
.type
),
2208 gfc_type_abi_kind (&array
->ts
));
2210 f
->value
.function
.name
2211 = gfc_get_string (PREFIX ("%s%d_%c%d"), name
, f
->rank
!= 0,
2212 gfc_type_letter (array
->ts
.type
),
2213 gfc_type_abi_kind (&array
->ts
));
2218 gfc_resolve_mod (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p
)
2220 f
->ts
.type
= a
->ts
.type
;
2222 f
->ts
.kind
= gfc_kind_max (a
,p
);
2224 f
->ts
.kind
= a
->ts
.kind
;
2226 if (p
!= NULL
&& a
->ts
.kind
!= p
->ts
.kind
)
2228 if (a
->ts
.kind
== gfc_kind_max (a
,p
))
2229 gfc_convert_type (p
, &a
->ts
, 2);
2231 gfc_convert_type (a
, &p
->ts
, 2);
2234 f
->value
.function
.name
2235 = gfc_get_string ("__mod_%c%d", gfc_type_letter (f
->ts
.type
),
2236 gfc_type_abi_kind (&f
->ts
));
2241 gfc_resolve_modulo (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p
)
2243 f
->ts
.type
= a
->ts
.type
;
2245 f
->ts
.kind
= gfc_kind_max (a
,p
);
2247 f
->ts
.kind
= a
->ts
.kind
;
2249 if (p
!= NULL
&& a
->ts
.kind
!= p
->ts
.kind
)
2251 if (a
->ts
.kind
== gfc_kind_max (a
,p
))
2252 gfc_convert_type (p
, &a
->ts
, 2);
2254 gfc_convert_type (a
, &p
->ts
, 2);
2257 f
->value
.function
.name
2258 = gfc_get_string ("__modulo_%c%d", gfc_type_letter (f
->ts
.type
),
2259 gfc_type_abi_kind (&f
->ts
));
2263 gfc_resolve_nearest (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p
)
2265 if (p
->ts
.kind
!= a
->ts
.kind
)
2266 gfc_convert_type (p
, &a
->ts
, 2);
2269 f
->value
.function
.name
2270 = gfc_get_string ("__nearest_%c%d", gfc_type_letter (a
->ts
.type
),
2271 gfc_type_abi_kind (&a
->ts
));
2275 gfc_resolve_nint (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
2277 f
->ts
.type
= BT_INTEGER
;
2278 f
->ts
.kind
= (kind
== NULL
)
2279 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
2280 f
->value
.function
.name
2281 = gfc_get_string ("__nint_%d_%d", f
->ts
.kind
, a
->ts
.kind
);
2286 gfc_resolve_norm2 (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
)
2288 resolve_transformational ("norm2", f
, array
, dim
, NULL
);
2293 gfc_resolve_not (gfc_expr
*f
, gfc_expr
*i
)
2296 const char *name
= i
->ts
.kind
== BT_UNSIGNED
? "__not_u_%d" : "__not_%d";
2297 f
->value
.function
.name
= gfc_get_string (name
, i
->ts
.kind
);
2302 gfc_resolve_or (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
2304 f
->ts
.type
= i
->ts
.type
;
2305 f
->ts
.kind
= gfc_kind_max (i
, j
);
2307 if (i
->ts
.kind
!= j
->ts
.kind
)
2309 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
2310 gfc_convert_type (j
, &i
->ts
, 2);
2312 gfc_convert_type (i
, &j
->ts
, 2);
2315 f
->value
.function
.name
2316 = gfc_get_string ("__or_%c%d", gfc_type_letter (i
->ts
.type
),
2317 gfc_type_abi_kind (&f
->ts
));
2322 gfc_resolve_pack (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*mask
,
2323 gfc_expr
*vector ATTRIBUTE_UNUSED
)
2325 if (array
->ts
.type
== BT_CHARACTER
&& array
->ref
)
2326 gfc_resolve_substring_charlen (array
);
2331 resolve_mask_arg (mask
);
2333 if (mask
->rank
!= 0)
2335 if (array
->ts
.type
== BT_CHARACTER
)
2336 f
->value
.function
.name
2337 = array
->ts
.kind
== 1 ? PREFIX ("pack_char")
2339 (PREFIX ("pack_char%d"),
2342 f
->value
.function
.name
= PREFIX ("pack");
2346 if (array
->ts
.type
== BT_CHARACTER
)
2347 f
->value
.function
.name
2348 = array
->ts
.kind
== 1 ? PREFIX ("pack_s_char")
2350 (PREFIX ("pack_s_char%d"),
2353 f
->value
.function
.name
= PREFIX ("pack_s");
2359 gfc_resolve_parity (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
)
2361 resolve_transformational ("parity", f
, array
, dim
, NULL
);
2366 gfc_resolve_product (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
2369 resolve_transformational ("product", f
, array
, dim
, mask
, true);
2374 gfc_resolve_rank (gfc_expr
*f
, gfc_expr
*array ATTRIBUTE_UNUSED
)
2376 f
->ts
.type
= BT_INTEGER
;
2377 f
->ts
.kind
= gfc_default_integer_kind
;
2378 f
->value
.function
.name
= gfc_get_string ("__rank");
2383 gfc_resolve_real (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
2385 f
->ts
.type
= BT_REAL
;
2388 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2390 f
->ts
.kind
= (a
->ts
.type
== BT_COMPLEX
)
2391 ? a
->ts
.kind
: gfc_default_real_kind
;
2393 f
->value
.function
.name
2394 = gfc_get_string ("__real_%d_%c%d", f
->ts
.kind
,
2395 gfc_type_letter (a
->ts
.type
),
2396 gfc_type_abi_kind (&a
->ts
));
2401 gfc_resolve_realpart (gfc_expr
*f
, gfc_expr
*a
)
2403 f
->ts
.type
= BT_REAL
;
2404 f
->ts
.kind
= a
->ts
.kind
;
2405 f
->value
.function
.name
2406 = gfc_get_string ("__real_%d_%c%d", f
->ts
.kind
,
2407 gfc_type_letter (a
->ts
.type
),
2408 gfc_type_abi_kind (&a
->ts
));
2413 gfc_resolve_rename (gfc_expr
*f
, gfc_expr
*p1 ATTRIBUTE_UNUSED
,
2414 gfc_expr
*p2 ATTRIBUTE_UNUSED
)
2416 f
->ts
.type
= BT_INTEGER
;
2417 f
->ts
.kind
= gfc_default_integer_kind
;
2418 f
->value
.function
.name
= gfc_get_string (PREFIX ("rename_i%d"), f
->ts
.kind
);
2423 gfc_resolve_repeat (gfc_expr
*f
, gfc_expr
*string
,
2427 f
->ts
.type
= BT_CHARACTER
;
2428 f
->ts
.kind
= string
->ts
.kind
;
2429 f
->value
.function
.name
= gfc_get_string ("__repeat_%d", string
->ts
.kind
);
2431 /* If possible, generate a character length. */
2432 if (f
->ts
.u
.cl
== NULL
)
2433 f
->ts
.u
.cl
= gfc_new_charlen (gfc_current_ns
, NULL
);
2436 if (string
->expr_type
== EXPR_CONSTANT
)
2438 tmp
= gfc_get_int_expr (gfc_charlen_int_kind
, NULL
,
2439 string
->value
.character
.length
);
2441 else if (string
->ts
.u
.cl
&& string
->ts
.u
.cl
->length
)
2443 tmp
= gfc_copy_expr (string
->ts
.u
.cl
->length
);
2448 /* Force-convert to gfc_charlen_int_kind before gfc_multiply. */
2449 gfc_expr
*e
= gfc_copy_expr (ncopies
);
2450 gfc_typespec ts
= tmp
->ts
;
2451 ts
.kind
= gfc_charlen_int_kind
;
2452 gfc_convert_type_warn (e
, &ts
, 2, 0);
2453 gfc_convert_type_warn (tmp
, &ts
, 2, 0);
2454 f
->ts
.u
.cl
->length
= gfc_multiply (tmp
, e
);
2460 gfc_resolve_reshape (gfc_expr
*f
, gfc_expr
*source
, gfc_expr
*shape
,
2461 gfc_expr
*pad ATTRIBUTE_UNUSED
,
2462 gfc_expr
*order ATTRIBUTE_UNUSED
)
2468 if (source
->ts
.type
== BT_CHARACTER
&& source
->ref
)
2469 gfc_resolve_substring_charlen (source
);
2473 gfc_array_size (shape
, &rank
);
2474 f
->rank
= mpz_get_si (rank
);
2476 switch (source
->ts
.type
)
2483 kind
= source
->ts
.kind
;
2497 if (source
->ts
.type
== BT_COMPLEX
|| source
->ts
.type
== BT_REAL
)
2498 f
->value
.function
.name
2499 = gfc_get_string (PREFIX ("reshape_%c%d"),
2500 gfc_type_letter (source
->ts
.type
),
2501 gfc_type_abi_kind (&source
->ts
));
2502 else if (source
->ts
.type
== BT_CHARACTER
)
2503 f
->value
.function
.name
= gfc_get_string (PREFIX ("reshape_char%d"),
2506 f
->value
.function
.name
2507 = gfc_get_string (PREFIX ("reshape_%d"), source
->ts
.kind
);
2511 f
->value
.function
.name
= (source
->ts
.type
== BT_CHARACTER
2512 ? PREFIX ("reshape_char") : PREFIX ("reshape"));
2516 if (shape
->expr_type
== EXPR_ARRAY
&& gfc_is_constant_array_expr (shape
))
2519 f
->shape
= gfc_get_shape (f
->rank
);
2520 c
= gfc_constructor_first (shape
->value
.constructor
);
2521 for (i
= 0; i
< f
->rank
; i
++)
2523 mpz_init_set (f
->shape
[i
], c
->expr
->value
.integer
);
2524 c
= gfc_constructor_next (c
);
2528 /* Force-convert both SHAPE and ORDER to index_kind so that we don't need
2529 so many runtime variations. */
2530 if (shape
->ts
.kind
!= gfc_index_integer_kind
)
2532 gfc_typespec ts
= shape
->ts
;
2533 ts
.kind
= gfc_index_integer_kind
;
2534 gfc_convert_type_warn (shape
, &ts
, 2, 0);
2536 if (order
&& order
->ts
.kind
!= gfc_index_integer_kind
)
2537 gfc_convert_type_warn (order
, &shape
->ts
, 2, 0);
2542 gfc_resolve_rrspacing (gfc_expr
*f
, gfc_expr
*x
)
2545 f
->value
.function
.name
= gfc_get_string ("__rrspacing_%d", x
->ts
.kind
);
2549 gfc_resolve_fe_runtime_error (gfc_code
*c
)
2552 gfc_actual_arglist
*a
;
2554 name
= gfc_get_string (PREFIX ("runtime_error"));
2556 for (a
= c
->ext
.actual
->next
; a
; a
= a
->next
)
2559 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2560 /* We set the backend_decl here because runtime_error is a
2561 variadic function and we would use the wrong calling
2562 convention otherwise. */
2563 c
->resolved_sym
->backend_decl
= gfor_fndecl_runtime_error
;
2567 gfc_resolve_scale (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*i ATTRIBUTE_UNUSED
)
2570 f
->value
.function
.name
= gfc_get_string ("__scale_%d", x
->ts
.kind
);
2575 gfc_resolve_scan (gfc_expr
*f
, gfc_expr
*string
,
2576 gfc_expr
*set ATTRIBUTE_UNUSED
,
2577 gfc_expr
*back ATTRIBUTE_UNUSED
, gfc_expr
*kind
)
2579 f
->ts
.type
= BT_INTEGER
;
2581 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2583 f
->ts
.kind
= gfc_default_integer_kind
;
2584 f
->value
.function
.name
= gfc_get_string ("__scan_%d", string
->ts
.kind
);
2589 gfc_resolve_secnds (gfc_expr
*t1
, gfc_expr
*t0
)
2592 t1
->value
.function
.name
= gfc_get_string (PREFIX ("secnds"));
2597 gfc_resolve_set_exponent (gfc_expr
*f
, gfc_expr
*x
,
2598 gfc_expr
*i ATTRIBUTE_UNUSED
)
2601 f
->value
.function
.name
= gfc_get_string ("__set_exponent_%d", x
->ts
.kind
);
2606 gfc_resolve_shape (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*kind
)
2608 f
->ts
.type
= BT_INTEGER
;
2611 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2613 f
->ts
.kind
= gfc_default_integer_kind
;
2616 if (array
->rank
!= -1)
2618 f
->shape
= gfc_get_shape (1);
2619 mpz_init_set_ui (f
->shape
[0], array
->rank
);
2622 f
->value
.function
.name
= gfc_get_string (PREFIX ("shape_%d"), f
->ts
.kind
);
2627 gfc_resolve_shift (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift ATTRIBUTE_UNUSED
)
2630 if (f
->value
.function
.isym
->id
== GFC_ISYM_SHIFTA
)
2631 f
->value
.function
.name
= gfc_get_string ("shifta_i%d", f
->ts
.kind
);
2632 else if (f
->value
.function
.isym
->id
== GFC_ISYM_SHIFTL
)
2633 f
->value
.function
.name
= gfc_get_string ("shiftl_i%d", f
->ts
.kind
);
2634 else if (f
->value
.function
.isym
->id
== GFC_ISYM_SHIFTR
)
2635 f
->value
.function
.name
= gfc_get_string ("shiftr_i%d", f
->ts
.kind
);
2642 gfc_resolve_sign (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*b ATTRIBUTE_UNUSED
)
2645 f
->value
.function
.name
2646 = gfc_get_string ("__sign_%c%d", gfc_type_letter (a
->ts
.type
),
2647 gfc_type_abi_kind (&a
->ts
));
2652 gfc_resolve_signal (gfc_expr
*f
, gfc_expr
*number
, gfc_expr
*handler
)
2654 f
->ts
.type
= BT_INTEGER
;
2655 f
->ts
.kind
= gfc_c_int_kind
;
2657 /* handler can be either BT_INTEGER or BT_PROCEDURE */
2658 if (handler
->ts
.type
== BT_INTEGER
)
2660 if (handler
->ts
.kind
!= gfc_c_int_kind
)
2661 gfc_convert_type (handler
, &f
->ts
, 2);
2662 f
->value
.function
.name
= gfc_get_string (PREFIX ("signal_func_int"));
2665 f
->value
.function
.name
= gfc_get_string (PREFIX ("signal_func"));
2667 if (number
->ts
.kind
!= gfc_c_int_kind
)
2668 gfc_convert_type (number
, &f
->ts
, 2);
2673 gfc_resolve_sin (gfc_expr
*f
, gfc_expr
*x
)
2676 f
->value
.function
.name
2677 = gfc_get_string ("__sin_%c%d", gfc_type_letter (x
->ts
.type
),
2678 gfc_type_abi_kind (&x
->ts
));
2683 gfc_resolve_sinh (gfc_expr
*f
, gfc_expr
*x
)
2686 f
->value
.function
.name
2687 = gfc_get_string ("__sinh_%c%d", gfc_type_letter (x
->ts
.type
),
2688 gfc_type_abi_kind (&x
->ts
));
2693 gfc_resolve_size (gfc_expr
*f
, gfc_expr
*array ATTRIBUTE_UNUSED
,
2694 gfc_expr
*dim ATTRIBUTE_UNUSED
, gfc_expr
*kind
)
2696 f
->ts
.type
= BT_INTEGER
;
2698 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2700 f
->ts
.kind
= gfc_default_integer_kind
;
2705 gfc_resolve_stride (gfc_expr
*f
, gfc_expr
*array ATTRIBUTE_UNUSED
,
2706 gfc_expr
*dim ATTRIBUTE_UNUSED
)
2708 f
->ts
.type
= BT_INTEGER
;
2709 f
->ts
.kind
= gfc_index_integer_kind
;
2714 gfc_resolve_spacing (gfc_expr
*f
, gfc_expr
*x
)
2717 f
->value
.function
.name
= gfc_get_string ("__spacing_%d", x
->ts
.kind
);
2722 gfc_resolve_spread (gfc_expr
*f
, gfc_expr
*source
, gfc_expr
*dim
,
2725 if (source
->ts
.type
== BT_CHARACTER
&& source
->ref
)
2726 gfc_resolve_substring_charlen (source
);
2728 if (source
->ts
.type
== BT_CHARACTER
)
2729 check_charlen_present (source
);
2732 f
->rank
= source
->rank
+ 1;
2733 if (source
->rank
== 0)
2735 if (source
->ts
.type
== BT_CHARACTER
)
2736 f
->value
.function
.name
2737 = source
->ts
.kind
== 1 ? PREFIX ("spread_char_scalar")
2739 (PREFIX ("spread_char%d_scalar"),
2742 f
->value
.function
.name
= PREFIX ("spread_scalar");
2746 if (source
->ts
.type
== BT_CHARACTER
)
2747 f
->value
.function
.name
2748 = source
->ts
.kind
== 1 ? PREFIX ("spread_char")
2750 (PREFIX ("spread_char%d"),
2753 f
->value
.function
.name
= PREFIX ("spread");
2756 if (dim
&& gfc_is_constant_expr (dim
)
2757 && ncopies
&& gfc_is_constant_expr (ncopies
) && source
->shape
[0])
2760 idim
= mpz_get_ui (dim
->value
.integer
);
2761 f
->shape
= gfc_get_shape (f
->rank
);
2762 for (i
= 0; i
< (idim
- 1); i
++)
2763 mpz_init_set (f
->shape
[i
], source
->shape
[i
]);
2765 mpz_init_set (f
->shape
[idim
- 1], ncopies
->value
.integer
);
2767 for (i
= idim
; i
< f
->rank
; i
++)
2768 mpz_init_set (f
->shape
[i
], source
->shape
[i
-1]);
2772 gfc_resolve_dim_arg (dim
);
2773 gfc_resolve_index (ncopies
, 1);
2778 gfc_resolve_sqrt (gfc_expr
*f
, gfc_expr
*x
)
2781 f
->value
.function
.name
2782 = gfc_get_string ("__sqrt_%c%d", gfc_type_letter (x
->ts
.type
),
2783 gfc_type_abi_kind (&x
->ts
));
2787 /* Resolve the g77 compatibility function STAT AND FSTAT. */
2790 gfc_resolve_stat (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
,
2791 gfc_expr
*a ATTRIBUTE_UNUSED
)
2793 f
->ts
.type
= BT_INTEGER
;
2794 f
->ts
.kind
= gfc_default_integer_kind
;
2795 f
->value
.function
.name
= gfc_get_string (PREFIX ("stat_i%d"), f
->ts
.kind
);
2800 gfc_resolve_lstat (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
,
2801 gfc_expr
*a ATTRIBUTE_UNUSED
)
2803 f
->ts
.type
= BT_INTEGER
;
2804 f
->ts
.kind
= gfc_default_integer_kind
;
2805 f
->value
.function
.name
= gfc_get_string (PREFIX ("lstat_i%d"), f
->ts
.kind
);
2810 gfc_resolve_fstat (gfc_expr
*f
, gfc_expr
*n
, gfc_expr
*a ATTRIBUTE_UNUSED
)
2812 f
->ts
.type
= BT_INTEGER
;
2813 f
->ts
.kind
= gfc_default_integer_kind
;
2814 if (n
->ts
.kind
!= f
->ts
.kind
)
2815 gfc_convert_type (n
, &f
->ts
, 2);
2817 f
->value
.function
.name
= gfc_get_string (PREFIX ("fstat_i%d"), f
->ts
.kind
);
2822 gfc_resolve_fgetc (gfc_expr
*f
, gfc_expr
*u
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2827 f
->ts
.type
= BT_INTEGER
;
2828 f
->ts
.kind
= gfc_c_int_kind
;
2829 if (u
->ts
.kind
!= gfc_c_int_kind
)
2831 ts
.type
= BT_INTEGER
;
2832 ts
.kind
= gfc_c_int_kind
;
2833 ts
.u
.derived
= NULL
;
2835 gfc_convert_type (u
, &ts
, 2);
2838 f
->value
.function
.name
= gfc_get_string (PREFIX ("fgetc"));
2843 gfc_resolve_fget (gfc_expr
*f
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2845 f
->ts
.type
= BT_INTEGER
;
2846 f
->ts
.kind
= gfc_c_int_kind
;
2847 f
->value
.function
.name
= gfc_get_string (PREFIX ("fget"));
2852 gfc_resolve_fputc (gfc_expr
*f
, gfc_expr
*u
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2857 f
->ts
.type
= BT_INTEGER
;
2858 f
->ts
.kind
= gfc_c_int_kind
;
2859 if (u
->ts
.kind
!= gfc_c_int_kind
)
2861 ts
.type
= BT_INTEGER
;
2862 ts
.kind
= gfc_c_int_kind
;
2863 ts
.u
.derived
= NULL
;
2865 gfc_convert_type (u
, &ts
, 2);
2868 f
->value
.function
.name
= gfc_get_string (PREFIX ("fputc"));
2873 gfc_resolve_fput (gfc_expr
*f
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2875 f
->ts
.type
= BT_INTEGER
;
2876 f
->ts
.kind
= gfc_c_int_kind
;
2877 f
->value
.function
.name
= gfc_get_string (PREFIX ("fput"));
2882 gfc_resolve_ftell (gfc_expr
*f
, gfc_expr
*u
)
2887 f
->ts
.type
= BT_INTEGER
;
2888 f
->ts
.kind
= gfc_intio_kind
;
2889 if (u
->ts
.kind
!= gfc_c_int_kind
)
2891 ts
.type
= BT_INTEGER
;
2892 ts
.kind
= gfc_c_int_kind
;
2893 ts
.u
.derived
= NULL
;
2895 gfc_convert_type (u
, &ts
, 2);
2898 f
->value
.function
.name
= gfc_get_string (PREFIX ("ftell"));
2903 gfc_resolve_storage_size (gfc_expr
*f
, gfc_expr
*a ATTRIBUTE_UNUSED
,
2906 f
->ts
.type
= BT_INTEGER
;
2908 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2910 f
->ts
.kind
= gfc_default_integer_kind
;
2915 gfc_resolve_sum (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*mask
)
2917 resolve_transformational ("sum", f
, array
, dim
, mask
, true);
2922 gfc_resolve_symlnk (gfc_expr
*f
, gfc_expr
*p1 ATTRIBUTE_UNUSED
,
2923 gfc_expr
*p2 ATTRIBUTE_UNUSED
)
2925 f
->ts
.type
= BT_INTEGER
;
2926 f
->ts
.kind
= gfc_default_integer_kind
;
2927 f
->value
.function
.name
= gfc_get_string (PREFIX ("symlnk_i%d"), f
->ts
.kind
);
2931 /* Resolve the g77 compatibility function SYSTEM. */
2934 gfc_resolve_system (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
2936 f
->ts
.type
= BT_INTEGER
;
2938 f
->value
.function
.name
= gfc_get_string (PREFIX ("system"));
2943 gfc_resolve_tan (gfc_expr
*f
, gfc_expr
*x
)
2946 f
->value
.function
.name
2947 = gfc_get_string ("__tan_%c%d", gfc_type_letter (x
->ts
.type
),
2948 gfc_type_abi_kind (&x
->ts
));
2953 gfc_resolve_tanh (gfc_expr
*f
, gfc_expr
*x
)
2956 f
->value
.function
.name
2957 = gfc_get_string ("__tanh_%c%d", gfc_type_letter (x
->ts
.type
),
2958 gfc_type_abi_kind (&x
->ts
));
2962 /* Resolve failed_images (team, kind). */
2965 gfc_resolve_failed_images (gfc_expr
*f
, gfc_expr
*team ATTRIBUTE_UNUSED
,
2968 static char failed_images
[] = "_gfortran_caf_failed_images";
2970 f
->ts
.type
= BT_INTEGER
;
2972 f
->ts
.kind
= gfc_default_integer_kind
;
2974 gfc_extract_int (kind
, &f
->ts
.kind
);
2975 f
->value
.function
.name
= failed_images
;
2979 /* Resolve image_status (image, team). */
2982 gfc_resolve_image_status (gfc_expr
*f
, gfc_expr
*image ATTRIBUTE_UNUSED
,
2983 gfc_expr
*team ATTRIBUTE_UNUSED
)
2985 static char image_status
[] = "_gfortran_caf_image_status";
2986 f
->ts
.type
= BT_INTEGER
;
2987 f
->ts
.kind
= gfc_default_integer_kind
;
2988 f
->value
.function
.name
= image_status
;
2992 /* Resolve get_team (). */
2995 gfc_resolve_get_team (gfc_expr
*f
, gfc_expr
*level ATTRIBUTE_UNUSED
)
2997 static char get_team
[] = "_gfortran_caf_get_team";
2999 f
->ts
.type
= BT_INTEGER
;
3000 f
->ts
.kind
= gfc_default_integer_kind
;
3001 f
->value
.function
.name
= get_team
;
3005 /* Resolve image_index (...). */
3008 gfc_resolve_image_index (gfc_expr
*f
, gfc_expr
*array ATTRIBUTE_UNUSED
,
3009 gfc_expr
*sub ATTRIBUTE_UNUSED
)
3011 static char image_index
[] = "__image_index";
3012 f
->ts
.type
= BT_INTEGER
;
3013 f
->ts
.kind
= gfc_default_integer_kind
;
3014 f
->value
.function
.name
= image_index
;
3018 /* Resolve stopped_images (team, kind). */
3021 gfc_resolve_stopped_images (gfc_expr
*f
, gfc_expr
*team ATTRIBUTE_UNUSED
,
3024 static char stopped_images
[] = "_gfortran_caf_stopped_images";
3026 f
->ts
.type
= BT_INTEGER
;
3028 f
->ts
.kind
= gfc_default_integer_kind
;
3030 gfc_extract_int (kind
, &f
->ts
.kind
);
3031 f
->value
.function
.name
= stopped_images
;
3035 /* Resolve team_number (team). */
3038 gfc_resolve_team_number (gfc_expr
*f
, gfc_expr
*team ATTRIBUTE_UNUSED
)
3040 static char team_number
[] = "_gfortran_caf_team_number";
3042 f
->ts
.type
= BT_INTEGER
;
3043 f
->ts
.kind
= gfc_default_integer_kind
;
3044 f
->value
.function
.name
= team_number
;
3049 gfc_resolve_this_image (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
3050 gfc_expr
*distance ATTRIBUTE_UNUSED
)
3052 static char this_image
[] = "__this_image";
3053 if (array
&& gfc_is_coarray (array
))
3054 resolve_bound (f
, array
, dim
, NULL
, "__this_image", true);
3057 f
->ts
.type
= BT_INTEGER
;
3058 f
->ts
.kind
= gfc_default_integer_kind
;
3059 f
->value
.function
.name
= this_image
;
3065 gfc_resolve_time (gfc_expr
*f
)
3067 f
->ts
.type
= BT_INTEGER
;
3069 f
->value
.function
.name
= gfc_get_string (PREFIX ("time_func"));
3074 gfc_resolve_time8 (gfc_expr
*f
)
3076 f
->ts
.type
= BT_INTEGER
;
3078 f
->value
.function
.name
= gfc_get_string (PREFIX ("time8_func"));
3083 gfc_resolve_transfer (gfc_expr
*f
, gfc_expr
*source ATTRIBUTE_UNUSED
,
3084 gfc_expr
*mold
, gfc_expr
*size
)
3086 /* TODO: Make this do something meaningful. */
3087 static char transfer0
[] = "__transfer0", transfer1
[] = "__transfer1";
3089 if (mold
->ts
.type
== BT_CHARACTER
3090 && !mold
->ts
.u
.cl
->length
3091 && gfc_is_constant_expr (mold
))
3094 if (mold
->expr_type
== EXPR_CONSTANT
)
3096 len
= mold
->value
.character
.length
;
3097 mold
->ts
.u
.cl
->length
= gfc_get_int_expr (gfc_charlen_int_kind
,
3102 gfc_constructor
*c
= gfc_constructor_first (mold
->value
.constructor
);
3103 len
= c
->expr
->value
.character
.length
;
3104 mold
->ts
.u
.cl
->length
= gfc_get_int_expr (gfc_charlen_int_kind
,
3109 if (UNLIMITED_POLY (mold
))
3110 gfc_error ("TODO: unlimited polymorphic MOLD in TRANSFER intrinsic at %L",
3115 if (size
== NULL
&& mold
->rank
== 0)
3118 f
->value
.function
.name
= transfer0
;
3123 f
->value
.function
.name
= transfer1
;
3124 if (size
&& gfc_is_constant_expr (size
))
3126 f
->shape
= gfc_get_shape (1);
3127 mpz_init_set (f
->shape
[0], size
->value
.integer
);
3134 gfc_resolve_transpose (gfc_expr
*f
, gfc_expr
*matrix
)
3137 if (matrix
->ts
.type
== BT_CHARACTER
&& matrix
->ref
)
3138 gfc_resolve_substring_charlen (matrix
);
3144 f
->shape
= gfc_get_shape (2);
3145 mpz_init_set (f
->shape
[0], matrix
->shape
[1]);
3146 mpz_init_set (f
->shape
[1], matrix
->shape
[0]);
3149 switch (matrix
->ts
.kind
)
3155 switch (matrix
->ts
.type
)
3159 f
->value
.function
.name
3160 = gfc_get_string (PREFIX ("transpose_%c%d"),
3161 gfc_type_letter (matrix
->ts
.type
),
3162 gfc_type_abi_kind (&matrix
->ts
));
3167 /* Use the integer routines for real and logical cases. This
3168 assumes they all have the same alignment requirements. */
3169 f
->value
.function
.name
3170 = gfc_get_string (PREFIX ("transpose_i%d"), matrix
->ts
.kind
);
3174 if (matrix
->ts
.type
== BT_CHARACTER
&& matrix
->ts
.kind
== 4)
3175 f
->value
.function
.name
= PREFIX ("transpose_char4");
3177 f
->value
.function
.name
= PREFIX ("transpose");
3183 f
->value
.function
.name
= (matrix
->ts
.type
== BT_CHARACTER
3184 ? PREFIX ("transpose_char")
3185 : PREFIX ("transpose"));
3192 gfc_resolve_trim (gfc_expr
*f
, gfc_expr
*string
)
3194 f
->ts
.type
= BT_CHARACTER
;
3195 f
->ts
.kind
= string
->ts
.kind
;
3196 f
->value
.function
.name
= gfc_get_string ("__trim_%d", string
->ts
.kind
);
3200 /* Resolve the degree trigonometric functions. This amounts to setting
3201 the function return type-spec from its argument and building a
3202 library function names of the form _gfortran_sind_r4. */
3205 gfc_resolve_trigd (gfc_expr
*f
, gfc_expr
*x
)
3208 f
->value
.function
.name
3209 = gfc_get_string (PREFIX ("%s_%c%d"), f
->value
.function
.isym
->name
,
3210 gfc_type_letter (x
->ts
.type
),
3211 gfc_type_abi_kind (&x
->ts
));
3216 gfc_resolve_trigd2 (gfc_expr
*f
, gfc_expr
*y
, gfc_expr
*x
)
3219 f
->value
.function
.name
3220 = gfc_get_string (PREFIX ("%s_%d"), f
->value
.function
.isym
->name
,
3226 gfc_resolve_ubound (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
3228 resolve_bound (f
, array
, dim
, kind
, "__ubound", false);
3233 gfc_resolve_ucobound (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
3235 resolve_bound (f
, array
, dim
, kind
, "__ucobound", true);
3239 /* Resolve the g77 compatibility function UMASK. */
3242 gfc_resolve_umask (gfc_expr
*f
, gfc_expr
*n
)
3244 f
->ts
.type
= BT_INTEGER
;
3245 f
->ts
.kind
= n
->ts
.kind
;
3246 f
->value
.function
.name
= gfc_get_string (PREFIX ("umask_i%d"), n
->ts
.kind
);
3250 /* Resolve the g77 compatibility function UNLINK. */
3253 gfc_resolve_unlink (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
3255 f
->ts
.type
= BT_INTEGER
;
3257 f
->value
.function
.name
= gfc_get_string (PREFIX ("unlink"));
3262 gfc_resolve_ttynam (gfc_expr
*f
, gfc_expr
*unit
)
3267 f
->ts
.type
= BT_CHARACTER
;
3268 f
->ts
.kind
= gfc_default_character_kind
;
3270 if (unit
->ts
.kind
!= gfc_c_int_kind
)
3272 ts
.type
= BT_INTEGER
;
3273 ts
.kind
= gfc_c_int_kind
;
3274 ts
.u
.derived
= NULL
;
3276 gfc_convert_type (unit
, &ts
, 2);
3279 f
->value
.function
.name
= gfc_get_string (PREFIX ("ttynam"));
3284 gfc_resolve_unpack (gfc_expr
*f
, gfc_expr
*vector
, gfc_expr
*mask
,
3285 gfc_expr
*field ATTRIBUTE_UNUSED
)
3287 if (vector
->ts
.type
== BT_CHARACTER
&& vector
->ref
)
3288 gfc_resolve_substring_charlen (vector
);
3291 f
->rank
= mask
->rank
;
3292 resolve_mask_arg (mask
);
3294 if (vector
->ts
.type
== BT_CHARACTER
)
3296 if (vector
->ts
.kind
== 1)
3297 f
->value
.function
.name
3298 = gfc_get_string (PREFIX ("unpack%d_char"), field
->rank
> 0 ? 1 : 0);
3300 f
->value
.function
.name
3301 = gfc_get_string (PREFIX ("unpack%d_char%d"),
3302 field
->rank
> 0 ? 1 : 0, vector
->ts
.kind
);
3305 f
->value
.function
.name
3306 = gfc_get_string (PREFIX ("unpack%d"), field
->rank
> 0 ? 1 : 0);
3311 gfc_resolve_verify (gfc_expr
*f
, gfc_expr
*string
,
3312 gfc_expr
*set ATTRIBUTE_UNUSED
,
3313 gfc_expr
*back ATTRIBUTE_UNUSED
, gfc_expr
*kind
)
3315 f
->ts
.type
= BT_INTEGER
;
3317 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
3319 f
->ts
.kind
= gfc_default_integer_kind
;
3320 f
->value
.function
.name
= gfc_get_string ("__verify_%d", string
->ts
.kind
);
3325 gfc_resolve_xor (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
3327 f
->ts
.type
= i
->ts
.type
;
3328 f
->ts
.kind
= gfc_kind_max (i
, j
);
3330 if (i
->ts
.kind
!= j
->ts
.kind
)
3332 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
3333 gfc_convert_type (j
, &i
->ts
, 2);
3335 gfc_convert_type (i
, &j
->ts
, 2);
3338 f
->value
.function
.name
3339 = gfc_get_string ("__xor_%c%d", gfc_type_letter (i
->ts
.type
),
3340 gfc_type_abi_kind (&f
->ts
));
3344 /* Intrinsic subroutine resolution. */
3347 gfc_resolve_alarm_sub (gfc_code
*c
)
3350 gfc_expr
*seconds
, *handler
;
3354 seconds
= c
->ext
.actual
->expr
;
3355 handler
= c
->ext
.actual
->next
->expr
;
3356 ts
.type
= BT_INTEGER
;
3357 ts
.kind
= gfc_c_int_kind
;
3359 /* handler can be either BT_INTEGER or BT_PROCEDURE.
3360 In all cases, the status argument is of default integer kind
3361 (enforced in check.cc) so that the function suffix is fixed. */
3362 if (handler
->ts
.type
== BT_INTEGER
)
3364 if (handler
->ts
.kind
!= gfc_c_int_kind
)
3365 gfc_convert_type (handler
, &ts
, 2);
3366 name
= gfc_get_string (PREFIX ("alarm_sub_int_i%d"),
3367 gfc_default_integer_kind
);
3370 name
= gfc_get_string (PREFIX ("alarm_sub_i%d"),
3371 gfc_default_integer_kind
);
3373 if (seconds
->ts
.kind
!= gfc_c_int_kind
)
3374 gfc_convert_type (seconds
, &ts
, 2);
3376 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3380 gfc_resolve_cpu_time (gfc_code
*c
)
3383 name
= gfc_get_string (PREFIX ("cpu_time_%d"), c
->ext
.actual
->expr
->ts
.kind
);
3384 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3388 /* Create a formal arglist based on an actual one and set the INTENTs given. */
3390 static gfc_formal_arglist
*
3391 create_formal_for_intents (gfc_actual_arglist
* actual
, const sym_intent
* ints
)
3393 gfc_formal_arglist
* head
;
3394 gfc_formal_arglist
* tail
;
3400 head
= tail
= gfc_get_formal_arglist ();
3401 for (i
= 0; actual
; actual
= actual
->next
, tail
= tail
->next
, ++i
)
3405 sym
= gfc_new_symbol ("dummyarg", NULL
);
3406 sym
->ts
= actual
->expr
->ts
;
3408 sym
->attr
.intent
= ints
[i
];
3412 tail
->next
= gfc_get_formal_arglist ();
3420 gfc_resolve_atomic_def (gfc_code
*c
)
3422 const char *name
= "atomic_define";
3423 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3428 gfc_resolve_atomic_ref (gfc_code
*c
)
3430 const char *name
= "atomic_ref";
3431 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3435 gfc_resolve_event_query (gfc_code
*c
)
3437 const char *name
= "event_query";
3438 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3442 gfc_resolve_mvbits (gfc_code
*c
)
3444 static const sym_intent INTENTS
[] = {INTENT_IN
, INTENT_IN
, INTENT_IN
,
3445 INTENT_INOUT
, INTENT_IN
};
3448 /* TO and FROM are guaranteed to have the same kind parameter. */
3449 name
= gfc_get_string (PREFIX ("mvbits_i%d"),
3450 c
->ext
.actual
->expr
->ts
.kind
);
3451 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3452 /* Mark as elemental subroutine as this does not happen automatically. */
3453 c
->resolved_sym
->attr
.elemental
= 1;
3455 /* Create a dummy formal arglist so the INTENTs are known later for purpose
3456 of creating temporaries. */
3457 c
->resolved_sym
->formal
= create_formal_for_intents (c
->ext
.actual
, INTENTS
);
3461 /* Set up the call to RANDOM_INIT. */
3464 gfc_resolve_random_init (gfc_code
*c
)
3467 name
= gfc_get_string (PREFIX ("random_init"));
3468 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3473 gfc_resolve_random_number (gfc_code
*c
)
3479 kind
= gfc_type_abi_kind (&c
->ext
.actual
->expr
->ts
);
3480 type
= gfc_type_letter (c
->ext
.actual
->expr
->ts
.type
);
3481 if (c
->ext
.actual
->expr
->rank
== 0)
3482 name
= gfc_get_string (PREFIX ("random_%c%d"), type
, kind
);
3484 name
= gfc_get_string (PREFIX ("arandom_%c%d"), type
, kind
);
3486 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3491 gfc_resolve_random_seed (gfc_code
*c
)
3495 name
= gfc_get_string (PREFIX ("random_seed_i%d"), gfc_default_integer_kind
);
3496 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3501 gfc_resolve_rename_sub (gfc_code
*c
)
3506 /* Find the type of status. If not present use default integer kind. */
3507 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
3508 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
3510 kind
= gfc_default_integer_kind
;
3512 name
= gfc_get_string (PREFIX ("rename_i%d_sub"), kind
);
3513 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3518 gfc_resolve_link_sub (gfc_code
*c
)
3523 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
3524 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
3526 kind
= gfc_default_integer_kind
;
3528 name
= gfc_get_string (PREFIX ("link_i%d_sub"), kind
);
3529 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3534 gfc_resolve_symlnk_sub (gfc_code
*c
)
3539 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
3540 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
3542 kind
= gfc_default_integer_kind
;
3544 name
= gfc_get_string (PREFIX ("symlnk_i%d_sub"), kind
);
3545 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3549 /* G77 compatibility subroutines dtime() and etime(). */
3552 gfc_resolve_dtime_sub (gfc_code
*c
)
3555 name
= gfc_get_string (PREFIX ("dtime_sub"));
3556 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3560 gfc_resolve_etime_sub (gfc_code
*c
)
3563 name
= gfc_get_string (PREFIX ("etime_sub"));
3564 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3568 /* G77 compatibility subroutines itime(), idate(), ltime() and gmtime(). */
3571 gfc_resolve_itime (gfc_code
*c
)
3574 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("itime_i%d"),
3575 gfc_default_integer_kind
));
3579 gfc_resolve_idate (gfc_code
*c
)
3582 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("idate_i%d"),
3583 gfc_default_integer_kind
));
3587 gfc_resolve_ltime (gfc_code
*c
)
3590 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("ltime_i%d"),
3591 gfc_default_integer_kind
));
3595 gfc_resolve_gmtime (gfc_code
*c
)
3598 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("gmtime_i%d"),
3599 gfc_default_integer_kind
));
3603 /* G77 compatibility subroutine second(). */
3606 gfc_resolve_second_sub (gfc_code
*c
)
3609 name
= gfc_get_string (PREFIX ("second_sub"));
3610 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3615 gfc_resolve_sleep_sub (gfc_code
*c
)
3620 if (c
->ext
.actual
->expr
!= NULL
)
3621 kind
= c
->ext
.actual
->expr
->ts
.kind
;
3623 kind
= gfc_default_integer_kind
;
3625 name
= gfc_get_string (PREFIX ("sleep_i%d_sub"), kind
);
3626 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3630 /* G77 compatibility function srand(). */
3633 gfc_resolve_srand (gfc_code
*c
)
3636 name
= gfc_get_string (PREFIX ("srand"));
3637 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3641 /* Resolve the getarg intrinsic subroutine. */
3644 gfc_resolve_getarg (gfc_code
*c
)
3648 if (c
->ext
.actual
->expr
->ts
.kind
!= gfc_default_integer_kind
)
3653 ts
.type
= BT_INTEGER
;
3654 ts
.kind
= gfc_default_integer_kind
;
3656 gfc_convert_type (c
->ext
.actual
->expr
, &ts
, 2);
3659 name
= gfc_get_string (PREFIX ("getarg_i%d"), gfc_default_integer_kind
);
3660 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3664 /* Resolve the getcwd intrinsic subroutine. */
3667 gfc_resolve_getcwd_sub (gfc_code
*c
)
3672 if (c
->ext
.actual
->next
->expr
!= NULL
)
3673 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
3675 kind
= gfc_default_integer_kind
;
3677 name
= gfc_get_string (PREFIX ("getcwd_i%d_sub"), kind
);
3678 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3682 /* Resolve the get_command intrinsic subroutine. */
3685 gfc_resolve_get_command (gfc_code
*c
)
3689 kind
= gfc_default_integer_kind
;
3690 name
= gfc_get_string (PREFIX ("get_command_i%d"), kind
);
3691 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3695 /* Resolve the get_command_argument intrinsic subroutine. */
3698 gfc_resolve_get_command_argument (gfc_code
*c
)
3702 kind
= gfc_default_integer_kind
;
3703 name
= gfc_get_string (PREFIX ("get_command_argument_i%d"), kind
);
3704 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3708 /* Resolve the get_environment_variable intrinsic subroutine. */
3711 gfc_resolve_get_environment_variable (gfc_code
*code
)
3715 kind
= gfc_default_integer_kind
;
3716 name
= gfc_get_string (PREFIX ("get_environment_variable_i%d"), kind
);
3717 code
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3722 gfc_resolve_signal_sub (gfc_code
*c
)
3725 gfc_expr
*number
, *handler
, *status
;
3729 number
= c
->ext
.actual
->expr
;
3730 handler
= c
->ext
.actual
->next
->expr
;
3731 status
= c
->ext
.actual
->next
->next
->expr
;
3732 ts
.type
= BT_INTEGER
;
3733 ts
.kind
= gfc_c_int_kind
;
3735 /* handler can be either BT_INTEGER or BT_PROCEDURE */
3736 if (handler
->ts
.type
== BT_INTEGER
)
3738 if (handler
->ts
.kind
!= gfc_c_int_kind
)
3739 gfc_convert_type (handler
, &ts
, 2);
3740 name
= gfc_get_string (PREFIX ("signal_sub_int"));
3743 name
= gfc_get_string (PREFIX ("signal_sub"));
3745 if (number
->ts
.kind
!= gfc_c_int_kind
)
3746 gfc_convert_type (number
, &ts
, 2);
3747 if (status
!= NULL
&& status
->ts
.kind
!= gfc_c_int_kind
)
3748 gfc_convert_type (status
, &ts
, 2);
3750 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3754 /* Resolve the SYSTEM intrinsic subroutine. */
3757 gfc_resolve_system_sub (gfc_code
*c
)
3760 name
= gfc_get_string (PREFIX ("system_sub"));
3761 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3765 /* Determine if the arguments to SYSTEM_CLOCK are INTEGER(4) or INTEGER(8) */
3768 gfc_resolve_system_clock (gfc_code
*c
)
3772 gfc_expr
*count
= c
->ext
.actual
->expr
;
3773 gfc_expr
*count_max
= c
->ext
.actual
->next
->next
->expr
;
3775 /* The INTEGER(8) version has higher precision, it is used if both COUNT
3776 and COUNT_MAX can hold 64-bit values, or are absent. */
3777 if ((!count
|| count
->ts
.kind
>= 8)
3778 && (!count_max
|| count_max
->ts
.kind
>= 8))
3781 kind
= gfc_default_integer_kind
;
3783 name
= gfc_get_string (PREFIX ("system_clock_%d"), kind
);
3784 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3788 /* Resolve the EXECUTE_COMMAND_LINE intrinsic subroutine. */
3790 gfc_resolve_execute_command_line (gfc_code
*c
)
3793 name
= gfc_get_string (PREFIX ("execute_command_line_i%d"),
3794 gfc_default_integer_kind
);
3795 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3799 /* Resolve the EXIT intrinsic subroutine. */
3802 gfc_resolve_exit (gfc_code
*c
)
3809 /* The STATUS argument has to be of default kind. If it is not,
3811 ts
.type
= BT_INTEGER
;
3812 ts
.kind
= gfc_default_integer_kind
;
3813 n
= c
->ext
.actual
->expr
;
3814 if (n
!= NULL
&& n
->ts
.kind
!= ts
.kind
)
3815 gfc_convert_type (n
, &ts
, 2);
3817 name
= gfc_get_string (PREFIX ("exit_i%d"), ts
.kind
);
3818 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3822 /* Resolve the FLUSH intrinsic subroutine. */
3825 gfc_resolve_flush (gfc_code
*c
)
3832 ts
.type
= BT_INTEGER
;
3833 ts
.kind
= gfc_default_integer_kind
;
3834 n
= c
->ext
.actual
->expr
;
3835 if (n
!= NULL
&& n
->ts
.kind
!= ts
.kind
)
3836 gfc_convert_type (n
, &ts
, 2);
3838 name
= gfc_get_string (PREFIX ("flush_i%d"), ts
.kind
);
3839 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3844 gfc_resolve_ctime_sub (gfc_code
*c
)
3849 /* ctime TIME argument is a INTEGER(KIND=8), says the doc */
3850 if (c
->ext
.actual
->expr
->ts
.kind
!= 8)
3852 ts
.type
= BT_INTEGER
;
3854 ts
.u
.derived
= NULL
;
3856 gfc_convert_type (c
->ext
.actual
->expr
, &ts
, 2);
3859 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("ctime_sub"));
3864 gfc_resolve_fdate_sub (gfc_code
*c
)
3866 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("fdate_sub"));
3871 gfc_resolve_gerror (gfc_code
*c
)
3873 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("gerror"));
3878 gfc_resolve_getlog (gfc_code
*c
)
3880 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("getlog"));
3885 gfc_resolve_hostnm_sub (gfc_code
*c
)
3890 if (c
->ext
.actual
->next
->expr
!= NULL
)
3891 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
3893 kind
= gfc_default_integer_kind
;
3895 name
= gfc_get_string (PREFIX ("hostnm_i%d_sub"), kind
);
3896 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3901 gfc_resolve_perror (gfc_code
*c
)
3903 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("perror_sub"));
3906 /* Resolve the STAT and FSTAT intrinsic subroutines. */
3909 gfc_resolve_stat_sub (gfc_code
*c
)
3912 name
= gfc_get_string (PREFIX ("stat_i%d_sub"), gfc_default_integer_kind
);
3913 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3918 gfc_resolve_lstat_sub (gfc_code
*c
)
3921 name
= gfc_get_string (PREFIX ("lstat_i%d_sub"), gfc_default_integer_kind
);
3922 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3927 gfc_resolve_fstat_sub (gfc_code
*c
)
3933 u
= c
->ext
.actual
->expr
;
3934 ts
= &c
->ext
.actual
->next
->expr
->ts
;
3935 if (u
->ts
.kind
!= ts
->kind
)
3936 gfc_convert_type (u
, ts
, 2);
3937 name
= gfc_get_string (PREFIX ("fstat_i%d_sub"), ts
->kind
);
3938 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3943 gfc_resolve_fgetc_sub (gfc_code
*c
)
3950 u
= c
->ext
.actual
->expr
;
3951 st
= c
->ext
.actual
->next
->next
->expr
;
3953 if (u
->ts
.kind
!= gfc_c_int_kind
)
3955 ts
.type
= BT_INTEGER
;
3956 ts
.kind
= gfc_c_int_kind
;
3957 ts
.u
.derived
= NULL
;
3959 gfc_convert_type (u
, &ts
, 2);
3963 name
= gfc_get_string (PREFIX ("fgetc_i%d_sub"), st
->ts
.kind
);
3965 name
= gfc_get_string (PREFIX ("fgetc_i%d_sub"), gfc_default_integer_kind
);
3967 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3972 gfc_resolve_fget_sub (gfc_code
*c
)
3977 st
= c
->ext
.actual
->next
->expr
;
3979 name
= gfc_get_string (PREFIX ("fget_i%d_sub"), st
->ts
.kind
);
3981 name
= gfc_get_string (PREFIX ("fget_i%d_sub"), gfc_default_integer_kind
);
3983 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3988 gfc_resolve_fputc_sub (gfc_code
*c
)
3995 u
= c
->ext
.actual
->expr
;
3996 st
= c
->ext
.actual
->next
->next
->expr
;
3998 if (u
->ts
.kind
!= gfc_c_int_kind
)
4000 ts
.type
= BT_INTEGER
;
4001 ts
.kind
= gfc_c_int_kind
;
4002 ts
.u
.derived
= NULL
;
4004 gfc_convert_type (u
, &ts
, 2);
4008 name
= gfc_get_string (PREFIX ("fputc_i%d_sub"), st
->ts
.kind
);
4010 name
= gfc_get_string (PREFIX ("fputc_i%d_sub"), gfc_default_integer_kind
);
4012 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
4017 gfc_resolve_fput_sub (gfc_code
*c
)
4022 st
= c
->ext
.actual
->next
->expr
;
4024 name
= gfc_get_string (PREFIX ("fput_i%d_sub"), st
->ts
.kind
);
4026 name
= gfc_get_string (PREFIX ("fput_i%d_sub"), gfc_default_integer_kind
);
4028 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
4033 gfc_resolve_fseek_sub (gfc_code
*c
)
4041 unit
= c
->ext
.actual
->expr
;
4042 offset
= c
->ext
.actual
->next
->expr
;
4043 whence
= c
->ext
.actual
->next
->next
->expr
;
4045 if (unit
->ts
.kind
!= gfc_c_int_kind
)
4047 ts
.type
= BT_INTEGER
;
4048 ts
.kind
= gfc_c_int_kind
;
4049 ts
.u
.derived
= NULL
;
4051 gfc_convert_type (unit
, &ts
, 2);
4054 if (offset
->ts
.kind
!= gfc_intio_kind
)
4056 ts
.type
= BT_INTEGER
;
4057 ts
.kind
= gfc_intio_kind
;
4058 ts
.u
.derived
= NULL
;
4060 gfc_convert_type (offset
, &ts
, 2);
4063 if (whence
->ts
.kind
!= gfc_c_int_kind
)
4065 ts
.type
= BT_INTEGER
;
4066 ts
.kind
= gfc_c_int_kind
;
4067 ts
.u
.derived
= NULL
;
4069 gfc_convert_type (whence
, &ts
, 2);
4072 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("fseek_sub"));
4076 gfc_resolve_ftell_sub (gfc_code
*c
)
4084 unit
= c
->ext
.actual
->expr
;
4085 offset
= c
->ext
.actual
->next
->expr
;
4087 if (unit
->ts
.kind
!= gfc_c_int_kind
)
4089 ts
.type
= BT_INTEGER
;
4090 ts
.kind
= gfc_c_int_kind
;
4091 ts
.u
.derived
= NULL
;
4093 gfc_convert_type (unit
, &ts
, 2);
4096 name
= gfc_get_string (PREFIX ("ftell_i%d_sub"), offset
->ts
.kind
);
4097 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
4102 gfc_resolve_ttynam_sub (gfc_code
*c
)
4107 if (c
->ext
.actual
->expr
->ts
.kind
!= gfc_c_int_kind
)
4109 ts
.type
= BT_INTEGER
;
4110 ts
.kind
= gfc_c_int_kind
;
4111 ts
.u
.derived
= NULL
;
4113 gfc_convert_type (c
->ext
.actual
->expr
, &ts
, 2);
4116 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("ttynam_sub"));
4120 /* Resolve the UMASK intrinsic subroutine. */
4123 gfc_resolve_umask_sub (gfc_code
*c
)
4128 if (c
->ext
.actual
->next
->expr
!= NULL
)
4129 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
4131 kind
= gfc_default_integer_kind
;
4133 name
= gfc_get_string (PREFIX ("umask_i%d_sub"), kind
);
4134 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
4137 /* Resolve the UNLINK intrinsic subroutine. */
4140 gfc_resolve_unlink_sub (gfc_code
*c
)
4145 if (c
->ext
.actual
->next
->expr
!= NULL
)
4146 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
4148 kind
= gfc_default_integer_kind
;
4150 name
= gfc_get_string (PREFIX ("unlink_i%d_sub"), kind
);
4151 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);