1 /* Intrinsic function resolution.
2 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
3 Free Software Foundation, Inc.
4 Contributed by Andy Vaught & Katherine Holcomb
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
23 /* Assign name and types to intrinsic procedures. For functions, the
24 first argument to a resolution function is an expression pointer to
25 the original function node and the rest are pointers to the
26 arguments of the function call. For subroutines, a pointer to the
27 code node is passed. The result type and library subroutine name
28 are generally set according to the function arguments. */
32 #include "coretypes.h"
35 #include "intrinsic.h"
37 /* Given printf-like arguments, return a stable version of the result string.
39 We already have a working, optimized string hashing table in the form of
40 the identifier table. Reusing this table is likely not to be wasted,
41 since if the function name makes it to the gimple output of the frontend,
42 we'll have to create the identifier anyway. */
45 gfc_get_string (const char *format
, ...)
51 va_start (ap
, format
);
52 vsnprintf (temp_name
, sizeof (temp_name
), format
, ap
);
54 temp_name
[sizeof (temp_name
) - 1] = 0;
56 ident
= get_identifier (temp_name
);
57 return IDENTIFIER_POINTER (ident
);
60 /* MERGE and SPREAD need to have source charlen's present for passing
61 to the result expression. */
63 check_charlen_present (gfc_expr
*source
)
65 if (source
->ts
.cl
== NULL
)
67 source
->ts
.cl
= gfc_get_charlen ();
68 source
->ts
.cl
->next
= gfc_current_ns
->cl_list
;
69 gfc_current_ns
->cl_list
= source
->ts
.cl
;
72 if (source
->expr_type
== EXPR_CONSTANT
)
74 source
->ts
.cl
->length
= gfc_int_expr (source
->value
.character
.length
);
77 else if (source
->expr_type
== EXPR_ARRAY
)
79 source
->ts
.cl
->length
=
80 gfc_int_expr (source
->value
.constructor
->expr
->value
.character
.length
);
85 /* Helper function for resolving the "mask" argument. */
88 resolve_mask_arg (gfc_expr
*mask
)
95 /* For the scalar case, coerce the mask to kind=4 unconditionally
96 (because this is the only kind we have a library function
99 if (mask
->ts
.kind
!= 4)
101 ts
.type
= BT_LOGICAL
;
103 gfc_convert_type (mask
, &ts
, 2);
108 /* In the library, we access the mask with a GFC_LOGICAL_1
109 argument. No need to waste memory if we are about to create
110 a temporary array. */
111 if (mask
->expr_type
== EXPR_OP
)
113 ts
.type
= BT_LOGICAL
;
115 gfc_convert_type (mask
, &ts
, 2);
120 /********************** Resolution functions **********************/
124 gfc_resolve_abs (gfc_expr
*f
, gfc_expr
*a
)
127 if (f
->ts
.type
== BT_COMPLEX
)
128 f
->ts
.type
= BT_REAL
;
130 f
->value
.function
.name
131 = gfc_get_string ("__abs_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
136 gfc_resolve_access (gfc_expr
*f
, gfc_expr
*name ATTRIBUTE_UNUSED
,
137 gfc_expr
*mode ATTRIBUTE_UNUSED
)
139 f
->ts
.type
= BT_INTEGER
;
140 f
->ts
.kind
= gfc_c_int_kind
;
141 f
->value
.function
.name
= PREFIX ("access_func");
146 gfc_resolve_char_achar (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*kind
,
149 f
->ts
.type
= BT_CHARACTER
;
150 f
->ts
.kind
= (kind
== NULL
)
151 ? gfc_default_character_kind
: mpz_get_si (kind
->value
.integer
);
152 f
->ts
.cl
= gfc_get_charlen ();
153 f
->ts
.cl
->next
= gfc_current_ns
->cl_list
;
154 gfc_current_ns
->cl_list
= f
->ts
.cl
;
155 f
->ts
.cl
->length
= gfc_int_expr (1);
157 f
->value
.function
.name
= gfc_get_string (name
, f
->ts
.kind
,
158 gfc_type_letter (x
->ts
.type
),
164 gfc_resolve_achar (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*kind
)
166 gfc_resolve_char_achar (f
, x
, kind
, "__achar_%d_%c%d");
171 gfc_resolve_acos (gfc_expr
*f
, gfc_expr
*x
)
174 f
->value
.function
.name
175 = gfc_get_string ("__acos_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
180 gfc_resolve_acosh (gfc_expr
*f
, gfc_expr
*x
)
183 f
->value
.function
.name
184 = gfc_get_string ("__acosh_%c%d", gfc_type_letter (x
->ts
.type
),
190 gfc_resolve_aimag (gfc_expr
*f
, gfc_expr
*x
)
192 f
->ts
.type
= BT_REAL
;
193 f
->ts
.kind
= x
->ts
.kind
;
194 f
->value
.function
.name
195 = gfc_get_string ("__aimag_%c%d", gfc_type_letter (x
->ts
.type
),
201 gfc_resolve_and (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
203 f
->ts
.type
= i
->ts
.type
;
204 f
->ts
.kind
= gfc_kind_max (i
, j
);
206 if (i
->ts
.kind
!= j
->ts
.kind
)
208 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
209 gfc_convert_type (j
, &i
->ts
, 2);
211 gfc_convert_type (i
, &j
->ts
, 2);
214 f
->value
.function
.name
215 = gfc_get_string ("__and_%c%d", gfc_type_letter (i
->ts
.type
), f
->ts
.kind
);
220 gfc_resolve_aint (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
224 f
->ts
.type
= a
->ts
.type
;
225 f
->ts
.kind
= (kind
== NULL
) ? a
->ts
.kind
: mpz_get_si (kind
->value
.integer
);
227 if (a
->ts
.kind
!= f
->ts
.kind
)
229 ts
.type
= f
->ts
.type
;
230 ts
.kind
= f
->ts
.kind
;
231 gfc_convert_type (a
, &ts
, 2);
233 /* The resolved name is only used for specific intrinsics where
234 the return kind is the same as the arg kind. */
235 f
->value
.function
.name
236 = gfc_get_string ("__aint_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
241 gfc_resolve_dint (gfc_expr
*f
, gfc_expr
*a
)
243 gfc_resolve_aint (f
, a
, NULL
);
248 gfc_resolve_all (gfc_expr
*f
, gfc_expr
*mask
, gfc_expr
*dim
)
254 gfc_resolve_dim_arg (dim
);
255 f
->rank
= mask
->rank
- 1;
256 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
259 f
->value
.function
.name
260 = gfc_get_string (PREFIX ("all_%c%d"), gfc_type_letter (mask
->ts
.type
),
266 gfc_resolve_anint (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
270 f
->ts
.type
= a
->ts
.type
;
271 f
->ts
.kind
= (kind
== NULL
) ? a
->ts
.kind
: mpz_get_si (kind
->value
.integer
);
273 if (a
->ts
.kind
!= f
->ts
.kind
)
275 ts
.type
= f
->ts
.type
;
276 ts
.kind
= f
->ts
.kind
;
277 gfc_convert_type (a
, &ts
, 2);
280 /* The resolved name is only used for specific intrinsics where
281 the return kind is the same as the arg kind. */
282 f
->value
.function
.name
283 = gfc_get_string ("__anint_%c%d", gfc_type_letter (a
->ts
.type
),
289 gfc_resolve_dnint (gfc_expr
*f
, gfc_expr
*a
)
291 gfc_resolve_anint (f
, a
, NULL
);
296 gfc_resolve_any (gfc_expr
*f
, gfc_expr
*mask
, gfc_expr
*dim
)
302 gfc_resolve_dim_arg (dim
);
303 f
->rank
= mask
->rank
- 1;
304 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
307 f
->value
.function
.name
308 = gfc_get_string (PREFIX ("any_%c%d"), gfc_type_letter (mask
->ts
.type
),
314 gfc_resolve_asin (gfc_expr
*f
, gfc_expr
*x
)
317 f
->value
.function
.name
318 = gfc_get_string ("__asin_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
322 gfc_resolve_asinh (gfc_expr
*f
, gfc_expr
*x
)
325 f
->value
.function
.name
326 = gfc_get_string ("__asinh_%c%d", gfc_type_letter (x
->ts
.type
),
331 gfc_resolve_atan (gfc_expr
*f
, gfc_expr
*x
)
334 f
->value
.function
.name
335 = gfc_get_string ("__atan_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
339 gfc_resolve_atanh (gfc_expr
*f
, gfc_expr
*x
)
342 f
->value
.function
.name
343 = gfc_get_string ("__atanh_%c%d", gfc_type_letter (x
->ts
.type
),
348 gfc_resolve_atan2 (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y ATTRIBUTE_UNUSED
)
351 f
->value
.function
.name
352 = gfc_get_string ("__atan2_%c%d", gfc_type_letter (x
->ts
.type
),
357 /* Resolve the BESYN and BESJN intrinsics. */
360 gfc_resolve_besn (gfc_expr
*f
, gfc_expr
*n
, gfc_expr
*x
)
365 if (n
->ts
.kind
!= gfc_c_int_kind
)
367 ts
.type
= BT_INTEGER
;
368 ts
.kind
= gfc_c_int_kind
;
369 gfc_convert_type (n
, &ts
, 2);
371 f
->value
.function
.name
= gfc_get_string ("<intrinsic>");
376 gfc_resolve_btest (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos
)
378 f
->ts
.type
= BT_LOGICAL
;
379 f
->ts
.kind
= gfc_default_logical_kind
;
380 f
->value
.function
.name
381 = gfc_get_string ("__btest_%d_%d", i
->ts
.kind
, pos
->ts
.kind
);
386 gfc_resolve_ceiling (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
388 f
->ts
.type
= BT_INTEGER
;
389 f
->ts
.kind
= (kind
== NULL
)
390 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
391 f
->value
.function
.name
392 = gfc_get_string ("__ceiling_%d_%c%d", f
->ts
.kind
,
393 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
398 gfc_resolve_char (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
400 gfc_resolve_char_achar (f
, a
, kind
, "__char_%d_%c%d");
405 gfc_resolve_chdir (gfc_expr
*f
, gfc_expr
*d ATTRIBUTE_UNUSED
)
407 f
->ts
.type
= BT_INTEGER
;
408 f
->ts
.kind
= gfc_default_integer_kind
;
409 f
->value
.function
.name
= gfc_get_string (PREFIX ("chdir_i%d"), f
->ts
.kind
);
414 gfc_resolve_chdir_sub (gfc_code
*c
)
419 if (c
->ext
.actual
->next
->expr
!= NULL
)
420 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
422 kind
= gfc_default_integer_kind
;
424 name
= gfc_get_string (PREFIX ("chdir_i%d_sub"), kind
);
425 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
430 gfc_resolve_chmod (gfc_expr
*f
, gfc_expr
*name ATTRIBUTE_UNUSED
,
431 gfc_expr
*mode ATTRIBUTE_UNUSED
)
433 f
->ts
.type
= BT_INTEGER
;
434 f
->ts
.kind
= gfc_c_int_kind
;
435 f
->value
.function
.name
= PREFIX ("chmod_func");
440 gfc_resolve_chmod_sub (gfc_code
*c
)
445 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
446 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
448 kind
= gfc_default_integer_kind
;
450 name
= gfc_get_string (PREFIX ("chmod_i%d_sub"), kind
);
451 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
456 gfc_resolve_cmplx (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y
, gfc_expr
*kind
)
458 f
->ts
.type
= BT_COMPLEX
;
459 f
->ts
.kind
= (kind
== NULL
)
460 ? gfc_default_real_kind
: mpz_get_si (kind
->value
.integer
);
463 f
->value
.function
.name
464 = gfc_get_string ("__cmplx0_%d_%c%d", f
->ts
.kind
,
465 gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
467 f
->value
.function
.name
468 = gfc_get_string ("__cmplx1_%d_%c%d_%c%d", f
->ts
.kind
,
469 gfc_type_letter (x
->ts
.type
), x
->ts
.kind
,
470 gfc_type_letter (y
->ts
.type
), y
->ts
.kind
);
475 gfc_resolve_dcmplx (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y
)
477 gfc_resolve_cmplx (f
, x
, y
, gfc_int_expr (gfc_default_double_kind
));
482 gfc_resolve_complex (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y
)
486 if (x
->ts
.type
== BT_INTEGER
)
488 if (y
->ts
.type
== BT_INTEGER
)
489 kind
= gfc_default_real_kind
;
495 if (y
->ts
.type
== BT_REAL
)
496 kind
= (x
->ts
.kind
> y
->ts
.kind
) ? x
->ts
.kind
: y
->ts
.kind
;
501 f
->ts
.type
= BT_COMPLEX
;
503 f
->value
.function
.name
504 = gfc_get_string ("__cmplx1_%d_%c%d_%c%d", f
->ts
.kind
,
505 gfc_type_letter (x
->ts
.type
), x
->ts
.kind
,
506 gfc_type_letter (y
->ts
.type
), y
->ts
.kind
);
511 gfc_resolve_conjg (gfc_expr
*f
, gfc_expr
*x
)
514 f
->value
.function
.name
= gfc_get_string ("__conjg_%d", x
->ts
.kind
);
519 gfc_resolve_cos (gfc_expr
*f
, gfc_expr
*x
)
522 f
->value
.function
.name
523 = gfc_get_string ("__cos_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
528 gfc_resolve_cosh (gfc_expr
*f
, gfc_expr
*x
)
531 f
->value
.function
.name
532 = gfc_get_string ("__cosh_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
537 gfc_resolve_count (gfc_expr
*f
, gfc_expr
*mask
, gfc_expr
*dim
, gfc_expr
*kind
)
539 f
->ts
.type
= BT_INTEGER
;
541 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
543 f
->ts
.kind
= gfc_default_integer_kind
;
547 f
->rank
= mask
->rank
- 1;
548 gfc_resolve_dim_arg (dim
);
549 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
552 f
->value
.function
.name
553 = gfc_get_string (PREFIX ("count_%d_%c%d"), f
->ts
.kind
,
554 gfc_type_letter (mask
->ts
.type
), mask
->ts
.kind
);
559 gfc_resolve_cshift (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*shift
,
564 if (array
->ts
.type
== BT_CHARACTER
&& array
->ref
)
565 gfc_resolve_substring_charlen (array
);
568 f
->rank
= array
->rank
;
569 f
->shape
= gfc_copy_shape (array
->shape
, array
->rank
);
576 /* Convert shift to at least gfc_default_integer_kind, so we don't need
577 kind=1 and kind=2 versions of the library functions. */
578 if (shift
->ts
.kind
< gfc_default_integer_kind
)
581 ts
.type
= BT_INTEGER
;
582 ts
.kind
= gfc_default_integer_kind
;
583 gfc_convert_type_warn (shift
, &ts
, 2, 0);
588 gfc_resolve_dim_arg (dim
);
589 /* Convert dim to shift's kind, so we don't need so many variations. */
590 if (dim
->ts
.kind
!= shift
->ts
.kind
)
591 gfc_convert_type_warn (dim
, &shift
->ts
, 2, 0);
594 f
->value
.function
.name
595 = gfc_get_string (PREFIX ("cshift%d_%d%s"), n
, shift
->ts
.kind
,
596 array
->ts
.type
== BT_CHARACTER
? "_char" : "");
601 gfc_resolve_ctime (gfc_expr
*f
, gfc_expr
*time
)
605 f
->ts
.type
= BT_CHARACTER
;
606 f
->ts
.kind
= gfc_default_character_kind
;
608 /* ctime TIME argument is a INTEGER(KIND=8), says the doc */
609 if (time
->ts
.kind
!= 8)
611 ts
.type
= BT_INTEGER
;
615 gfc_convert_type (time
, &ts
, 2);
618 f
->value
.function
.name
= gfc_get_string (PREFIX ("ctime"));
623 gfc_resolve_dble (gfc_expr
*f
, gfc_expr
*a
)
625 f
->ts
.type
= BT_REAL
;
626 f
->ts
.kind
= gfc_default_double_kind
;
627 f
->value
.function
.name
628 = gfc_get_string ("__dble_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
633 gfc_resolve_dim (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p
)
635 f
->ts
.type
= a
->ts
.type
;
637 f
->ts
.kind
= gfc_kind_max (a
,p
);
639 f
->ts
.kind
= a
->ts
.kind
;
641 if (p
!= NULL
&& a
->ts
.kind
!= p
->ts
.kind
)
643 if (a
->ts
.kind
== gfc_kind_max (a
,p
))
644 gfc_convert_type (p
, &a
->ts
, 2);
646 gfc_convert_type (a
, &p
->ts
, 2);
649 f
->value
.function
.name
650 = gfc_get_string ("__dim_%c%d", gfc_type_letter (f
->ts
.type
), f
->ts
.kind
);
655 gfc_resolve_dot_product (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*b
)
659 temp
.expr_type
= EXPR_OP
;
660 gfc_clear_ts (&temp
.ts
);
661 temp
.value
.op
.operator = INTRINSIC_NONE
;
662 temp
.value
.op
.op1
= a
;
663 temp
.value
.op
.op2
= b
;
664 gfc_type_convert_binary (&temp
);
666 f
->value
.function
.name
667 = gfc_get_string (PREFIX ("dot_product_%c%d"),
668 gfc_type_letter (f
->ts
.type
), f
->ts
.kind
);
673 gfc_resolve_dprod (gfc_expr
*f
, gfc_expr
*a ATTRIBUTE_UNUSED
,
674 gfc_expr
*b ATTRIBUTE_UNUSED
)
676 f
->ts
.kind
= gfc_default_double_kind
;
677 f
->ts
.type
= BT_REAL
;
678 f
->value
.function
.name
= gfc_get_string ("__dprod_r%d", f
->ts
.kind
);
683 gfc_resolve_eoshift (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*shift
,
684 gfc_expr
*boundary
, gfc_expr
*dim
)
688 if (array
->ts
.type
== BT_CHARACTER
&& array
->ref
)
689 gfc_resolve_substring_charlen (array
);
692 f
->rank
= array
->rank
;
693 f
->shape
= gfc_copy_shape (array
->shape
, array
->rank
);
698 if (boundary
&& boundary
->rank
> 0)
701 /* Convert shift to at least gfc_default_integer_kind, so we don't need
702 kind=1 and kind=2 versions of the library functions. */
703 if (shift
->ts
.kind
< gfc_default_integer_kind
)
706 ts
.type
= BT_INTEGER
;
707 ts
.kind
= gfc_default_integer_kind
;
708 gfc_convert_type_warn (shift
, &ts
, 2, 0);
713 gfc_resolve_dim_arg (dim
);
714 /* Convert dim to shift's kind, so we don't need so many variations. */
715 if (dim
->ts
.kind
!= shift
->ts
.kind
)
716 gfc_convert_type_warn (dim
, &shift
->ts
, 2, 0);
719 f
->value
.function
.name
720 = gfc_get_string (PREFIX ("eoshift%d_%d%s"), n
, shift
->ts
.kind
,
721 array
->ts
.type
== BT_CHARACTER
? "_char" : "");
726 gfc_resolve_exp (gfc_expr
*f
, gfc_expr
*x
)
729 f
->value
.function
.name
730 = gfc_get_string ("__exp_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
735 gfc_resolve_exponent (gfc_expr
*f
, gfc_expr
*x
)
737 f
->ts
.type
= BT_INTEGER
;
738 f
->ts
.kind
= gfc_default_integer_kind
;
739 f
->value
.function
.name
= gfc_get_string ("__exponent_%d", x
->ts
.kind
);
744 gfc_resolve_fdate (gfc_expr
*f
)
746 f
->ts
.type
= BT_CHARACTER
;
747 f
->ts
.kind
= gfc_default_character_kind
;
748 f
->value
.function
.name
= gfc_get_string (PREFIX ("fdate"));
753 gfc_resolve_floor (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
755 f
->ts
.type
= BT_INTEGER
;
756 f
->ts
.kind
= (kind
== NULL
)
757 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
758 f
->value
.function
.name
759 = gfc_get_string ("__floor%d_%c%d", f
->ts
.kind
,
760 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
765 gfc_resolve_fnum (gfc_expr
*f
, gfc_expr
*n
)
767 f
->ts
.type
= BT_INTEGER
;
768 f
->ts
.kind
= gfc_default_integer_kind
;
769 if (n
->ts
.kind
!= f
->ts
.kind
)
770 gfc_convert_type (n
, &f
->ts
, 2);
771 f
->value
.function
.name
= gfc_get_string (PREFIX ("fnum_i%d"), f
->ts
.kind
);
776 gfc_resolve_fraction (gfc_expr
*f
, gfc_expr
*x
)
779 f
->value
.function
.name
= gfc_get_string ("__fraction_%d", x
->ts
.kind
);
783 /* Resolve single-argument g77 math intrinsics, eg BESY0, ERF. */
786 gfc_resolve_g77_math1 (gfc_expr
*f
, gfc_expr
*x
)
789 f
->value
.function
.name
= gfc_get_string ("<intrinsic>");
794 gfc_resolve_gamma (gfc_expr
*f
, gfc_expr
*x
)
797 f
->value
.function
.name
798 = gfc_get_string ("__gamma_%d", x
->ts
.kind
);
803 gfc_resolve_getcwd (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
805 f
->ts
.type
= BT_INTEGER
;
807 f
->value
.function
.name
= gfc_get_string (PREFIX ("getcwd"));
812 gfc_resolve_getgid (gfc_expr
*f
)
814 f
->ts
.type
= BT_INTEGER
;
816 f
->value
.function
.name
= gfc_get_string (PREFIX ("getgid"));
821 gfc_resolve_getpid (gfc_expr
*f
)
823 f
->ts
.type
= BT_INTEGER
;
825 f
->value
.function
.name
= gfc_get_string (PREFIX ("getpid"));
830 gfc_resolve_getuid (gfc_expr
*f
)
832 f
->ts
.type
= BT_INTEGER
;
834 f
->value
.function
.name
= gfc_get_string (PREFIX ("getuid"));
839 gfc_resolve_hostnm (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
841 f
->ts
.type
= BT_INTEGER
;
843 f
->value
.function
.name
= gfc_get_string (PREFIX ("hostnm"));
848 gfc_resolve_iand (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
850 /* If the kind of i and j are different, then g77 cross-promoted the
851 kinds to the largest value. The Fortran 95 standard requires the
853 if (i
->ts
.kind
!= j
->ts
.kind
)
855 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
856 gfc_convert_type (j
, &i
->ts
, 2);
858 gfc_convert_type (i
, &j
->ts
, 2);
862 f
->value
.function
.name
= gfc_get_string ("__iand_%d", i
->ts
.kind
);
867 gfc_resolve_ibclr (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos ATTRIBUTE_UNUSED
)
870 f
->value
.function
.name
= gfc_get_string ("__ibclr_%d", i
->ts
.kind
);
875 gfc_resolve_ibits (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos ATTRIBUTE_UNUSED
,
876 gfc_expr
*len ATTRIBUTE_UNUSED
)
879 f
->value
.function
.name
= gfc_get_string ("__ibits_%d", i
->ts
.kind
);
884 gfc_resolve_ibset (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos ATTRIBUTE_UNUSED
)
887 f
->value
.function
.name
= gfc_get_string ("__ibset_%d", i
->ts
.kind
);
892 gfc_resolve_iachar (gfc_expr
*f
, gfc_expr
*c
, gfc_expr
*kind
)
894 f
->ts
.type
= BT_INTEGER
;
896 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
898 f
->ts
.kind
= gfc_default_integer_kind
;
899 f
->value
.function
.name
= gfc_get_string ("__ichar_%d", c
->ts
.kind
);
904 gfc_resolve_ichar (gfc_expr
*f
, gfc_expr
*c
, gfc_expr
*kind
)
906 f
->ts
.type
= BT_INTEGER
;
908 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
910 f
->ts
.kind
= gfc_default_integer_kind
;
911 f
->value
.function
.name
= gfc_get_string ("__ichar_%d", c
->ts
.kind
);
916 gfc_resolve_idnint (gfc_expr
*f
, gfc_expr
*a
)
918 gfc_resolve_nint (f
, a
, NULL
);
923 gfc_resolve_ierrno (gfc_expr
*f
)
925 f
->ts
.type
= BT_INTEGER
;
926 f
->ts
.kind
= gfc_default_integer_kind
;
927 f
->value
.function
.name
= gfc_get_string (PREFIX ("ierrno_i%d"), f
->ts
.kind
);
932 gfc_resolve_ieor (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
934 /* If the kind of i and j are different, then g77 cross-promoted the
935 kinds to the largest value. The Fortran 95 standard requires the
937 if (i
->ts
.kind
!= j
->ts
.kind
)
939 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
940 gfc_convert_type (j
, &i
->ts
, 2);
942 gfc_convert_type (i
, &j
->ts
, 2);
946 f
->value
.function
.name
= gfc_get_string ("__ieor_%d", i
->ts
.kind
);
951 gfc_resolve_ior (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
953 /* If the kind of i and j are different, then g77 cross-promoted the
954 kinds to the largest value. The Fortran 95 standard requires the
956 if (i
->ts
.kind
!= j
->ts
.kind
)
958 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
959 gfc_convert_type (j
, &i
->ts
, 2);
961 gfc_convert_type (i
, &j
->ts
, 2);
965 f
->value
.function
.name
= gfc_get_string ("__ior_%d", i
->ts
.kind
);
970 gfc_resolve_index_func (gfc_expr
*f
, gfc_expr
*str
,
971 gfc_expr
*sub_str ATTRIBUTE_UNUSED
, gfc_expr
*back
,
976 f
->ts
.type
= BT_INTEGER
;
978 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
980 f
->ts
.kind
= gfc_default_integer_kind
;
982 if (back
&& back
->ts
.kind
!= gfc_default_integer_kind
)
984 ts
.type
= BT_LOGICAL
;
985 ts
.kind
= gfc_default_integer_kind
;
988 gfc_convert_type (back
, &ts
, 2);
991 f
->value
.function
.name
992 = gfc_get_string ("__index_%d_i%d", str
->ts
.kind
, f
->ts
.kind
);
997 gfc_resolve_int (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
999 f
->ts
.type
= BT_INTEGER
;
1000 f
->ts
.kind
= (kind
== NULL
)
1001 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
1002 f
->value
.function
.name
1003 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1004 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1009 gfc_resolve_int2 (gfc_expr
*f
, gfc_expr
*a
)
1011 f
->ts
.type
= BT_INTEGER
;
1013 f
->value
.function
.name
1014 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1015 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1020 gfc_resolve_int8 (gfc_expr
*f
, gfc_expr
*a
)
1022 f
->ts
.type
= BT_INTEGER
;
1024 f
->value
.function
.name
1025 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1026 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1031 gfc_resolve_long (gfc_expr
*f
, gfc_expr
*a
)
1033 f
->ts
.type
= BT_INTEGER
;
1035 f
->value
.function
.name
1036 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1037 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1042 gfc_resolve_isatty (gfc_expr
*f
, gfc_expr
*u
)
1046 f
->ts
.type
= BT_LOGICAL
;
1047 f
->ts
.kind
= gfc_default_integer_kind
;
1048 if (u
->ts
.kind
!= gfc_c_int_kind
)
1050 ts
.type
= BT_INTEGER
;
1051 ts
.kind
= gfc_c_int_kind
;
1054 gfc_convert_type (u
, &ts
, 2);
1057 f
->value
.function
.name
= gfc_get_string (PREFIX ("isatty_l%d"), f
->ts
.kind
);
1062 gfc_resolve_ishft (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
)
1065 f
->value
.function
.name
1066 = gfc_get_string ("__ishft_%d_%d", i
->ts
.kind
, shift
->ts
.kind
);
1071 gfc_resolve_rshift (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
)
1074 f
->value
.function
.name
1075 = gfc_get_string ("__rshift_%d_%d", i
->ts
.kind
, shift
->ts
.kind
);
1080 gfc_resolve_lshift (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
)
1083 f
->value
.function
.name
1084 = gfc_get_string ("__lshift_%d_%d", i
->ts
.kind
, shift
->ts
.kind
);
1089 gfc_resolve_ishftc (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
, gfc_expr
*size
)
1093 s_kind
= (size
== NULL
) ? gfc_default_integer_kind
: size
->ts
.kind
;
1096 f
->value
.function
.name
1097 = gfc_get_string ("__ishftc_%d_%d_%d", i
->ts
.kind
, shift
->ts
.kind
, s_kind
);
1102 gfc_resolve_kill (gfc_expr
*f
, gfc_expr
*p ATTRIBUTE_UNUSED
,
1103 gfc_expr
*s ATTRIBUTE_UNUSED
)
1105 f
->ts
.type
= BT_INTEGER
;
1106 f
->ts
.kind
= gfc_default_integer_kind
;
1107 f
->value
.function
.name
= gfc_get_string (PREFIX ("kill_i%d"), f
->ts
.kind
);
1112 gfc_resolve_lbound (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
1114 static char lbound
[] = "__lbound";
1116 f
->ts
.type
= BT_INTEGER
;
1118 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1120 f
->ts
.kind
= gfc_default_integer_kind
;
1125 f
->shape
= gfc_get_shape (1);
1126 mpz_init_set_ui (f
->shape
[0], array
->rank
);
1129 f
->value
.function
.name
= lbound
;
1134 gfc_resolve_len (gfc_expr
*f
, gfc_expr
*string
, gfc_expr
*kind
)
1136 f
->ts
.type
= BT_INTEGER
;
1138 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1140 f
->ts
.kind
= gfc_default_integer_kind
;
1141 f
->value
.function
.name
1142 = gfc_get_string ("__len_%d_i%d", string
->ts
.kind
,
1143 gfc_default_integer_kind
);
1148 gfc_resolve_len_trim (gfc_expr
*f
, gfc_expr
*string
, gfc_expr
*kind
)
1150 f
->ts
.type
= BT_INTEGER
;
1152 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1154 f
->ts
.kind
= gfc_default_integer_kind
;
1155 f
->value
.function
.name
= gfc_get_string ("__len_trim%d", string
->ts
.kind
);
1160 gfc_resolve_lgamma (gfc_expr
*f
, gfc_expr
*x
)
1163 f
->value
.function
.name
1164 = gfc_get_string ("__lgamma_%d", x
->ts
.kind
);
1169 gfc_resolve_link (gfc_expr
*f
, gfc_expr
*p1 ATTRIBUTE_UNUSED
,
1170 gfc_expr
*p2 ATTRIBUTE_UNUSED
)
1172 f
->ts
.type
= BT_INTEGER
;
1173 f
->ts
.kind
= gfc_default_integer_kind
;
1174 f
->value
.function
.name
= gfc_get_string (PREFIX ("link_i%d"), f
->ts
.kind
);
1179 gfc_resolve_loc (gfc_expr
*f
, gfc_expr
*x
)
1181 f
->ts
.type
= BT_INTEGER
;
1182 f
->ts
.kind
= gfc_index_integer_kind
;
1183 f
->value
.function
.name
= gfc_get_string ("__loc_%d", x
->ts
.kind
);
1188 gfc_resolve_log (gfc_expr
*f
, gfc_expr
*x
)
1191 f
->value
.function
.name
1192 = gfc_get_string ("__log_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
1197 gfc_resolve_log10 (gfc_expr
*f
, gfc_expr
*x
)
1200 f
->value
.function
.name
1201 = gfc_get_string ("__log10_%c%d", gfc_type_letter (x
->ts
.type
),
1207 gfc_resolve_logical (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
1209 f
->ts
.type
= BT_LOGICAL
;
1210 f
->ts
.kind
= (kind
== NULL
)
1211 ? gfc_default_logical_kind
: mpz_get_si (kind
->value
.integer
);
1214 f
->value
.function
.name
1215 = gfc_get_string ("__logical_%d_%c%d", f
->ts
.kind
,
1216 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1221 gfc_resolve_malloc (gfc_expr
*f
, gfc_expr
*size
)
1223 if (size
->ts
.kind
< gfc_index_integer_kind
)
1227 ts
.type
= BT_INTEGER
;
1228 ts
.kind
= gfc_index_integer_kind
;
1229 gfc_convert_type_warn (size
, &ts
, 2, 0);
1232 f
->ts
.type
= BT_INTEGER
;
1233 f
->ts
.kind
= gfc_index_integer_kind
;
1234 f
->value
.function
.name
= gfc_get_string (PREFIX ("malloc"));
1239 gfc_resolve_matmul (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*b
)
1243 if (a
->ts
.type
== BT_LOGICAL
&& b
->ts
.type
== BT_LOGICAL
)
1245 f
->ts
.type
= BT_LOGICAL
;
1246 f
->ts
.kind
= gfc_default_logical_kind
;
1250 temp
.expr_type
= EXPR_OP
;
1251 gfc_clear_ts (&temp
.ts
);
1252 temp
.value
.op
.operator = INTRINSIC_NONE
;
1253 temp
.value
.op
.op1
= a
;
1254 temp
.value
.op
.op2
= b
;
1255 gfc_type_convert_binary (&temp
);
1259 f
->rank
= (a
->rank
== 2 && b
->rank
== 2) ? 2 : 1;
1261 f
->value
.function
.name
1262 = gfc_get_string (PREFIX ("matmul_%c%d"), gfc_type_letter (f
->ts
.type
),
1268 gfc_resolve_minmax (const char *name
, gfc_expr
*f
, gfc_actual_arglist
*args
)
1270 gfc_actual_arglist
*a
;
1272 f
->ts
.type
= args
->expr
->ts
.type
;
1273 f
->ts
.kind
= args
->expr
->ts
.kind
;
1274 /* Find the largest type kind. */
1275 for (a
= args
->next
; a
; a
= a
->next
)
1277 if (a
->expr
->ts
.kind
> f
->ts
.kind
)
1278 f
->ts
.kind
= a
->expr
->ts
.kind
;
1281 /* Convert all parameters to the required kind. */
1282 for (a
= args
; a
; a
= a
->next
)
1284 if (a
->expr
->ts
.kind
!= f
->ts
.kind
)
1285 gfc_convert_type (a
->expr
, &f
->ts
, 2);
1288 f
->value
.function
.name
1289 = gfc_get_string (name
, gfc_type_letter (f
->ts
.type
), f
->ts
.kind
);
1294 gfc_resolve_max (gfc_expr
*f
, gfc_actual_arglist
*args
)
1296 gfc_resolve_minmax ("__max_%c%d", f
, args
);
1301 gfc_resolve_maxloc (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
1307 f
->ts
.type
= BT_INTEGER
;
1308 f
->ts
.kind
= gfc_default_integer_kind
;
1313 f
->shape
= gfc_get_shape (1);
1314 mpz_init_set_si (f
->shape
[0], array
->rank
);
1318 f
->rank
= array
->rank
- 1;
1319 gfc_resolve_dim_arg (dim
);
1320 if (array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
1322 idim
= (int) mpz_get_si (dim
->value
.integer
);
1323 f
->shape
= gfc_get_shape (f
->rank
);
1324 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
1326 if (i
== (idim
- 1))
1328 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
1335 if (mask
->rank
== 0)
1340 resolve_mask_arg (mask
);
1345 f
->value
.function
.name
1346 = gfc_get_string (PREFIX ("%s%d_%d_%c%d"), name
, dim
!= NULL
, f
->ts
.kind
,
1347 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1352 gfc_resolve_maxval (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
1362 f
->rank
= array
->rank
- 1;
1363 gfc_resolve_dim_arg (dim
);
1365 if (f
->rank
&& array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
1367 idim
= (int) mpz_get_si (dim
->value
.integer
);
1368 f
->shape
= gfc_get_shape (f
->rank
);
1369 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
1371 if (i
== (idim
- 1))
1373 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
1380 if (mask
->rank
== 0)
1385 resolve_mask_arg (mask
);
1390 f
->value
.function
.name
1391 = gfc_get_string (PREFIX ("%s_%c%d"), name
,
1392 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1397 gfc_resolve_mclock (gfc_expr
*f
)
1399 f
->ts
.type
= BT_INTEGER
;
1401 f
->value
.function
.name
= PREFIX ("mclock");
1406 gfc_resolve_mclock8 (gfc_expr
*f
)
1408 f
->ts
.type
= BT_INTEGER
;
1410 f
->value
.function
.name
= PREFIX ("mclock8");
1415 gfc_resolve_merge (gfc_expr
*f
, gfc_expr
*tsource
,
1416 gfc_expr
*fsource ATTRIBUTE_UNUSED
,
1417 gfc_expr
*mask ATTRIBUTE_UNUSED
)
1419 if (tsource
->ts
.type
== BT_CHARACTER
&& tsource
->ref
)
1420 gfc_resolve_substring_charlen (tsource
);
1422 if (fsource
->ts
.type
== BT_CHARACTER
&& fsource
->ref
)
1423 gfc_resolve_substring_charlen (fsource
);
1425 if (tsource
->ts
.type
== BT_CHARACTER
)
1426 check_charlen_present (tsource
);
1428 f
->ts
= tsource
->ts
;
1429 f
->value
.function
.name
1430 = gfc_get_string ("__merge_%c%d", gfc_type_letter (tsource
->ts
.type
),
1436 gfc_resolve_min (gfc_expr
*f
, gfc_actual_arglist
*args
)
1438 gfc_resolve_minmax ("__min_%c%d", f
, args
);
1443 gfc_resolve_minloc (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
1449 f
->ts
.type
= BT_INTEGER
;
1450 f
->ts
.kind
= gfc_default_integer_kind
;
1455 f
->shape
= gfc_get_shape (1);
1456 mpz_init_set_si (f
->shape
[0], array
->rank
);
1460 f
->rank
= array
->rank
- 1;
1461 gfc_resolve_dim_arg (dim
);
1462 if (array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
1464 idim
= (int) mpz_get_si (dim
->value
.integer
);
1465 f
->shape
= gfc_get_shape (f
->rank
);
1466 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
1468 if (i
== (idim
- 1))
1470 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
1477 if (mask
->rank
== 0)
1482 resolve_mask_arg (mask
);
1487 f
->value
.function
.name
1488 = gfc_get_string (PREFIX ("%s%d_%d_%c%d"), name
, dim
!= NULL
, f
->ts
.kind
,
1489 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1494 gfc_resolve_minval (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
1504 f
->rank
= array
->rank
- 1;
1505 gfc_resolve_dim_arg (dim
);
1507 if (f
->rank
&& array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
1509 idim
= (int) mpz_get_si (dim
->value
.integer
);
1510 f
->shape
= gfc_get_shape (f
->rank
);
1511 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
1513 if (i
== (idim
- 1))
1515 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
1522 if (mask
->rank
== 0)
1527 resolve_mask_arg (mask
);
1532 f
->value
.function
.name
1533 = gfc_get_string (PREFIX ("%s_%c%d"), name
,
1534 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1539 gfc_resolve_mod (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p
)
1541 f
->ts
.type
= a
->ts
.type
;
1543 f
->ts
.kind
= gfc_kind_max (a
,p
);
1545 f
->ts
.kind
= a
->ts
.kind
;
1547 if (p
!= NULL
&& a
->ts
.kind
!= p
->ts
.kind
)
1549 if (a
->ts
.kind
== gfc_kind_max (a
,p
))
1550 gfc_convert_type (p
, &a
->ts
, 2);
1552 gfc_convert_type (a
, &p
->ts
, 2);
1555 f
->value
.function
.name
1556 = gfc_get_string ("__mod_%c%d", gfc_type_letter (f
->ts
.type
), f
->ts
.kind
);
1561 gfc_resolve_modulo (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p
)
1563 f
->ts
.type
= a
->ts
.type
;
1565 f
->ts
.kind
= gfc_kind_max (a
,p
);
1567 f
->ts
.kind
= a
->ts
.kind
;
1569 if (p
!= NULL
&& a
->ts
.kind
!= p
->ts
.kind
)
1571 if (a
->ts
.kind
== gfc_kind_max (a
,p
))
1572 gfc_convert_type (p
, &a
->ts
, 2);
1574 gfc_convert_type (a
, &p
->ts
, 2);
1577 f
->value
.function
.name
1578 = gfc_get_string ("__modulo_%c%d", gfc_type_letter (f
->ts
.type
),
1583 gfc_resolve_nearest (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p ATTRIBUTE_UNUSED
)
1586 f
->value
.function
.name
1587 = gfc_get_string ("__nearest_%c%d", gfc_type_letter (a
->ts
.type
),
1592 gfc_resolve_nint (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
1594 f
->ts
.type
= BT_INTEGER
;
1595 f
->ts
.kind
= (kind
== NULL
)
1596 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
1597 f
->value
.function
.name
1598 = gfc_get_string ("__nint_%d_%d", f
->ts
.kind
, a
->ts
.kind
);
1603 gfc_resolve_not (gfc_expr
*f
, gfc_expr
*i
)
1606 f
->value
.function
.name
= gfc_get_string ("__not_%d", i
->ts
.kind
);
1611 gfc_resolve_or (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
1613 f
->ts
.type
= i
->ts
.type
;
1614 f
->ts
.kind
= gfc_kind_max (i
, j
);
1616 if (i
->ts
.kind
!= j
->ts
.kind
)
1618 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
1619 gfc_convert_type (j
, &i
->ts
, 2);
1621 gfc_convert_type (i
, &j
->ts
, 2);
1624 f
->value
.function
.name
1625 = gfc_get_string ("__or_%c%d", gfc_type_letter (i
->ts
.type
), f
->ts
.kind
);
1630 gfc_resolve_pack (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*mask
,
1631 gfc_expr
*vector ATTRIBUTE_UNUSED
)
1633 if (array
->ts
.type
== BT_CHARACTER
&& array
->ref
)
1634 gfc_resolve_substring_charlen (array
);
1639 resolve_mask_arg (mask
);
1641 if (mask
->rank
!= 0)
1642 f
->value
.function
.name
= (array
->ts
.type
== BT_CHARACTER
1643 ? PREFIX ("pack_char") : PREFIX ("pack"));
1645 f
->value
.function
.name
= (array
->ts
.type
== BT_CHARACTER
1646 ? PREFIX ("pack_s_char") : PREFIX ("pack_s"));
1651 gfc_resolve_product (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
1660 f
->rank
= array
->rank
- 1;
1661 gfc_resolve_dim_arg (dim
);
1666 if (mask
->rank
== 0)
1671 resolve_mask_arg (mask
);
1676 f
->value
.function
.name
1677 = gfc_get_string (PREFIX ("%s_%c%d"), name
,
1678 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1683 gfc_resolve_real (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
1685 f
->ts
.type
= BT_REAL
;
1688 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1690 f
->ts
.kind
= (a
->ts
.type
== BT_COMPLEX
)
1691 ? a
->ts
.kind
: gfc_default_real_kind
;
1693 f
->value
.function
.name
1694 = gfc_get_string ("__real_%d_%c%d", f
->ts
.kind
,
1695 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1700 gfc_resolve_realpart (gfc_expr
*f
, gfc_expr
*a
)
1702 f
->ts
.type
= BT_REAL
;
1703 f
->ts
.kind
= a
->ts
.kind
;
1704 f
->value
.function
.name
1705 = gfc_get_string ("__real_%d_%c%d", f
->ts
.kind
,
1706 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1711 gfc_resolve_rename (gfc_expr
*f
, gfc_expr
*p1 ATTRIBUTE_UNUSED
,
1712 gfc_expr
*p2 ATTRIBUTE_UNUSED
)
1714 f
->ts
.type
= BT_INTEGER
;
1715 f
->ts
.kind
= gfc_default_integer_kind
;
1716 f
->value
.function
.name
= gfc_get_string (PREFIX ("rename_i%d"), f
->ts
.kind
);
1721 gfc_resolve_repeat (gfc_expr
*f
, gfc_expr
*string
,
1722 gfc_expr
*ncopies ATTRIBUTE_UNUSED
)
1724 f
->ts
.type
= BT_CHARACTER
;
1725 f
->ts
.kind
= string
->ts
.kind
;
1726 f
->value
.function
.name
= gfc_get_string ("__repeat_%d", string
->ts
.kind
);
1731 gfc_resolve_reshape (gfc_expr
*f
, gfc_expr
*source
, gfc_expr
*shape
,
1732 gfc_expr
*pad ATTRIBUTE_UNUSED
,
1733 gfc_expr
*order ATTRIBUTE_UNUSED
)
1739 if (source
->ts
.type
== BT_CHARACTER
&& source
->ref
)
1740 gfc_resolve_substring_charlen (source
);
1744 gfc_array_size (shape
, &rank
);
1745 f
->rank
= mpz_get_si (rank
);
1747 switch (source
->ts
.type
)
1753 kind
= source
->ts
.kind
;
1767 if (source
->ts
.type
== BT_COMPLEX
|| source
->ts
.type
== BT_REAL
)
1768 f
->value
.function
.name
1769 = gfc_get_string (PREFIX ("reshape_%c%d"),
1770 gfc_type_letter (source
->ts
.type
),
1773 f
->value
.function
.name
1774 = gfc_get_string (PREFIX ("reshape_%d"), source
->ts
.kind
);
1779 f
->value
.function
.name
= (source
->ts
.type
== BT_CHARACTER
1780 ? PREFIX ("reshape_char") : PREFIX ("reshape"));
1784 /* TODO: Make this work with a constant ORDER parameter. */
1785 if (shape
->expr_type
== EXPR_ARRAY
1786 && gfc_is_constant_expr (shape
)
1790 f
->shape
= gfc_get_shape (f
->rank
);
1791 c
= shape
->value
.constructor
;
1792 for (i
= 0; i
< f
->rank
; i
++)
1794 mpz_init_set (f
->shape
[i
], c
->expr
->value
.integer
);
1799 /* Force-convert both SHAPE and ORDER to index_kind so that we don't need
1800 so many runtime variations. */
1801 if (shape
->ts
.kind
!= gfc_index_integer_kind
)
1803 gfc_typespec ts
= shape
->ts
;
1804 ts
.kind
= gfc_index_integer_kind
;
1805 gfc_convert_type_warn (shape
, &ts
, 2, 0);
1807 if (order
&& order
->ts
.kind
!= gfc_index_integer_kind
)
1808 gfc_convert_type_warn (order
, &shape
->ts
, 2, 0);
1813 gfc_resolve_rrspacing (gfc_expr
*f
, gfc_expr
*x
)
1816 gfc_actual_arglist
*prec
;
1819 f
->value
.function
.name
= gfc_get_string ("__rrspacing_%d", x
->ts
.kind
);
1821 /* Create a hidden argument to the library routines for rrspacing. This
1822 hidden argument is the precision of x. */
1823 k
= gfc_validate_kind (BT_REAL
, x
->ts
.kind
, false);
1824 prec
= gfc_get_actual_arglist ();
1826 prec
->expr
= gfc_int_expr (gfc_real_kinds
[k
].digits
);
1827 /* The library routine expects INTEGER(4). */
1828 if (prec
->expr
->ts
.kind
!= gfc_c_int_kind
)
1831 ts
.type
= BT_INTEGER
;
1832 ts
.kind
= gfc_c_int_kind
;
1833 gfc_convert_type (prec
->expr
, &ts
, 2);
1835 f
->value
.function
.actual
->next
= prec
;
1840 gfc_resolve_scale (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*i
)
1844 /* The implementation calls scalbn which takes an int as the
1846 if (i
->ts
.kind
!= gfc_c_int_kind
)
1849 ts
.type
= BT_INTEGER
;
1850 ts
.kind
= gfc_c_int_kind
;
1851 gfc_convert_type_warn (i
, &ts
, 2, 0);
1854 f
->value
.function
.name
= gfc_get_string ("__scale_%d", x
->ts
.kind
);
1859 gfc_resolve_scan (gfc_expr
*f
, gfc_expr
*string
,
1860 gfc_expr
*set ATTRIBUTE_UNUSED
,
1861 gfc_expr
*back ATTRIBUTE_UNUSED
, gfc_expr
*kind
)
1863 f
->ts
.type
= BT_INTEGER
;
1865 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1867 f
->ts
.kind
= gfc_default_integer_kind
;
1868 f
->value
.function
.name
= gfc_get_string ("__scan_%d", string
->ts
.kind
);
1873 gfc_resolve_secnds (gfc_expr
*t1
, gfc_expr
*t0
)
1876 t1
->value
.function
.name
= gfc_get_string (PREFIX ("secnds"));
1881 gfc_resolve_set_exponent (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*i
)
1885 /* The library implementation uses GFC_INTEGER_4 unconditionally,
1886 convert type so we don't have to implement all possible
1888 if (i
->ts
.kind
!= gfc_c_int_kind
)
1891 ts
.type
= BT_INTEGER
;
1892 ts
.kind
= gfc_c_int_kind
;
1893 gfc_convert_type_warn (i
, &ts
, 2, 0);
1896 f
->value
.function
.name
= gfc_get_string ("__set_exponent_%d", x
->ts
.kind
);
1901 gfc_resolve_shape (gfc_expr
*f
, gfc_expr
*array
)
1903 f
->ts
.type
= BT_INTEGER
;
1904 f
->ts
.kind
= gfc_default_integer_kind
;
1906 f
->shape
= gfc_get_shape (1);
1907 mpz_init_set_ui (f
->shape
[0], array
->rank
);
1908 f
->value
.function
.name
= gfc_get_string (PREFIX ("shape_%d"), f
->ts
.kind
);
1913 gfc_resolve_sign (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*b ATTRIBUTE_UNUSED
)
1916 f
->value
.function
.name
1917 = gfc_get_string ("__sign_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1922 gfc_resolve_signal (gfc_expr
*f
, gfc_expr
*number
, gfc_expr
*handler
)
1924 f
->ts
.type
= BT_INTEGER
;
1925 f
->ts
.kind
= gfc_c_int_kind
;
1927 /* handler can be either BT_INTEGER or BT_PROCEDURE */
1928 if (handler
->ts
.type
== BT_INTEGER
)
1930 if (handler
->ts
.kind
!= gfc_c_int_kind
)
1931 gfc_convert_type (handler
, &f
->ts
, 2);
1932 f
->value
.function
.name
= gfc_get_string (PREFIX ("signal_func_int"));
1935 f
->value
.function
.name
= gfc_get_string (PREFIX ("signal_func"));
1937 if (number
->ts
.kind
!= gfc_c_int_kind
)
1938 gfc_convert_type (number
, &f
->ts
, 2);
1943 gfc_resolve_sin (gfc_expr
*f
, gfc_expr
*x
)
1946 f
->value
.function
.name
1947 = gfc_get_string ("__sin_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
1952 gfc_resolve_sinh (gfc_expr
*f
, gfc_expr
*x
)
1955 f
->value
.function
.name
1956 = gfc_get_string ("__sinh_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
1961 gfc_resolve_size (gfc_expr
*f
, gfc_expr
*array ATTRIBUTE_UNUSED
,
1962 gfc_expr
*dim ATTRIBUTE_UNUSED
, gfc_expr
*kind
)
1964 f
->ts
.type
= BT_INTEGER
;
1966 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1968 f
->ts
.kind
= gfc_default_integer_kind
;
1973 gfc_resolve_spacing (gfc_expr
*f
, gfc_expr
*x
)
1976 gfc_actual_arglist
*prec
, *tiny
, *emin_1
;
1979 f
->value
.function
.name
= gfc_get_string ("__spacing_%d", x
->ts
.kind
);
1981 /* Create hidden arguments to the library routine for spacing. These
1982 hidden arguments are tiny(x), min_exponent - 1, and the precision
1985 k
= gfc_validate_kind (BT_REAL
, x
->ts
.kind
, false);
1987 tiny
= gfc_get_actual_arglist ();
1988 tiny
->name
= "tiny";
1989 tiny
->expr
= gfc_get_expr ();
1990 tiny
->expr
->expr_type
= EXPR_CONSTANT
;
1991 tiny
->expr
->where
= gfc_current_locus
;
1992 tiny
->expr
->ts
.type
= x
->ts
.type
;
1993 tiny
->expr
->ts
.kind
= x
->ts
.kind
;
1994 mpfr_init (tiny
->expr
->value
.real
);
1995 mpfr_set (tiny
->expr
->value
.real
, gfc_real_kinds
[k
].tiny
, GFC_RND_MODE
);
1997 emin_1
= gfc_get_actual_arglist ();
1998 emin_1
->name
= "emin";
1999 emin_1
->expr
= gfc_int_expr (gfc_real_kinds
[k
].min_exponent
- 1);
2001 /* The library routine expects INTEGER(4). */
2002 if (emin_1
->expr
->ts
.kind
!= gfc_c_int_kind
)
2005 ts
.type
= BT_INTEGER
;
2006 ts
.kind
= gfc_c_int_kind
;
2007 gfc_convert_type (emin_1
->expr
, &ts
, 2);
2009 emin_1
->next
= tiny
;
2011 prec
= gfc_get_actual_arglist ();
2012 prec
->name
= "prec";
2013 prec
->expr
= gfc_int_expr (gfc_real_kinds
[k
].digits
);
2015 /* The library routine expects INTEGER(4). */
2016 if (prec
->expr
->ts
.kind
!= gfc_c_int_kind
)
2019 ts
.type
= BT_INTEGER
;
2020 ts
.kind
= gfc_c_int_kind
;
2021 gfc_convert_type (prec
->expr
, &ts
, 2);
2023 prec
->next
= emin_1
;
2025 f
->value
.function
.actual
->next
= prec
;
2030 gfc_resolve_spread (gfc_expr
*f
, gfc_expr
*source
, gfc_expr
*dim
,
2033 if (source
->ts
.type
== BT_CHARACTER
&& source
->ref
)
2034 gfc_resolve_substring_charlen (source
);
2036 if (source
->ts
.type
== BT_CHARACTER
)
2037 check_charlen_present (source
);
2040 f
->rank
= source
->rank
+ 1;
2041 if (source
->rank
== 0)
2042 f
->value
.function
.name
= (source
->ts
.type
== BT_CHARACTER
2043 ? PREFIX ("spread_char_scalar")
2044 : PREFIX ("spread_scalar"));
2046 f
->value
.function
.name
= (source
->ts
.type
== BT_CHARACTER
2047 ? PREFIX ("spread_char")
2048 : PREFIX ("spread"));
2050 if (dim
&& gfc_is_constant_expr (dim
)
2051 && ncopies
&& gfc_is_constant_expr (ncopies
) && source
->shape
[0])
2054 idim
= mpz_get_ui (dim
->value
.integer
);
2055 f
->shape
= gfc_get_shape (f
->rank
);
2056 for (i
= 0; i
< (idim
- 1); i
++)
2057 mpz_init_set (f
->shape
[i
], source
->shape
[i
]);
2059 mpz_init_set (f
->shape
[idim
- 1], ncopies
->value
.integer
);
2061 for (i
= idim
; i
< f
->rank
; i
++)
2062 mpz_init_set (f
->shape
[i
], source
->shape
[i
-1]);
2066 gfc_resolve_dim_arg (dim
);
2067 gfc_resolve_index (ncopies
, 1);
2072 gfc_resolve_sqrt (gfc_expr
*f
, gfc_expr
*x
)
2075 f
->value
.function
.name
2076 = gfc_get_string ("__sqrt_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
2080 /* Resolve the g77 compatibility function STAT AND FSTAT. */
2083 gfc_resolve_stat (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
,
2084 gfc_expr
*a ATTRIBUTE_UNUSED
)
2086 f
->ts
.type
= BT_INTEGER
;
2087 f
->ts
.kind
= gfc_default_integer_kind
;
2088 f
->value
.function
.name
= gfc_get_string (PREFIX ("stat_i%d"), f
->ts
.kind
);
2093 gfc_resolve_lstat (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
,
2094 gfc_expr
*a ATTRIBUTE_UNUSED
)
2096 f
->ts
.type
= BT_INTEGER
;
2097 f
->ts
.kind
= gfc_default_integer_kind
;
2098 f
->value
.function
.name
= gfc_get_string (PREFIX ("lstat_i%d"), f
->ts
.kind
);
2103 gfc_resolve_fstat (gfc_expr
*f
, gfc_expr
*n
, gfc_expr
*a ATTRIBUTE_UNUSED
)
2105 f
->ts
.type
= BT_INTEGER
;
2106 f
->ts
.kind
= gfc_default_integer_kind
;
2107 if (n
->ts
.kind
!= f
->ts
.kind
)
2108 gfc_convert_type (n
, &f
->ts
, 2);
2110 f
->value
.function
.name
= gfc_get_string (PREFIX ("fstat_i%d"), f
->ts
.kind
);
2115 gfc_resolve_fgetc (gfc_expr
*f
, gfc_expr
*u
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2119 f
->ts
.type
= BT_INTEGER
;
2120 f
->ts
.kind
= gfc_c_int_kind
;
2121 if (u
->ts
.kind
!= gfc_c_int_kind
)
2123 ts
.type
= BT_INTEGER
;
2124 ts
.kind
= gfc_c_int_kind
;
2127 gfc_convert_type (u
, &ts
, 2);
2130 f
->value
.function
.name
= gfc_get_string (PREFIX ("fgetc"));
2135 gfc_resolve_fget (gfc_expr
*f
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2137 f
->ts
.type
= BT_INTEGER
;
2138 f
->ts
.kind
= gfc_c_int_kind
;
2139 f
->value
.function
.name
= gfc_get_string (PREFIX ("fget"));
2144 gfc_resolve_fputc (gfc_expr
*f
, gfc_expr
*u
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2148 f
->ts
.type
= BT_INTEGER
;
2149 f
->ts
.kind
= gfc_c_int_kind
;
2150 if (u
->ts
.kind
!= gfc_c_int_kind
)
2152 ts
.type
= BT_INTEGER
;
2153 ts
.kind
= gfc_c_int_kind
;
2156 gfc_convert_type (u
, &ts
, 2);
2159 f
->value
.function
.name
= gfc_get_string (PREFIX ("fputc"));
2164 gfc_resolve_fput (gfc_expr
*f
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2166 f
->ts
.type
= BT_INTEGER
;
2167 f
->ts
.kind
= gfc_c_int_kind
;
2168 f
->value
.function
.name
= gfc_get_string (PREFIX ("fput"));
2173 gfc_resolve_ftell (gfc_expr
*f
, gfc_expr
*u
)
2177 f
->ts
.type
= BT_INTEGER
;
2178 f
->ts
.kind
= gfc_index_integer_kind
;
2179 if (u
->ts
.kind
!= gfc_c_int_kind
)
2181 ts
.type
= BT_INTEGER
;
2182 ts
.kind
= gfc_c_int_kind
;
2185 gfc_convert_type (u
, &ts
, 2);
2188 f
->value
.function
.name
= gfc_get_string (PREFIX ("ftell"));
2193 gfc_resolve_sum (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*mask
)
2201 if (mask
->rank
== 0)
2206 resolve_mask_arg (mask
);
2213 f
->rank
= array
->rank
- 1;
2214 gfc_resolve_dim_arg (dim
);
2217 f
->value
.function
.name
2218 = gfc_get_string (PREFIX ("%s_%c%d"), name
,
2219 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
2224 gfc_resolve_symlnk (gfc_expr
*f
, gfc_expr
*p1 ATTRIBUTE_UNUSED
,
2225 gfc_expr
*p2 ATTRIBUTE_UNUSED
)
2227 f
->ts
.type
= BT_INTEGER
;
2228 f
->ts
.kind
= gfc_default_integer_kind
;
2229 f
->value
.function
.name
= gfc_get_string (PREFIX ("symlnk_i%d"), f
->ts
.kind
);
2233 /* Resolve the g77 compatibility function SYSTEM. */
2236 gfc_resolve_system (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
2238 f
->ts
.type
= BT_INTEGER
;
2240 f
->value
.function
.name
= gfc_get_string (PREFIX ("system"));
2245 gfc_resolve_tan (gfc_expr
*f
, gfc_expr
*x
)
2248 f
->value
.function
.name
2249 = gfc_get_string ("__tan_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
2254 gfc_resolve_tanh (gfc_expr
*f
, gfc_expr
*x
)
2257 f
->value
.function
.name
2258 = gfc_get_string ("__tanh_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
2263 gfc_resolve_time (gfc_expr
*f
)
2265 f
->ts
.type
= BT_INTEGER
;
2267 f
->value
.function
.name
= gfc_get_string (PREFIX ("time_func"));
2272 gfc_resolve_time8 (gfc_expr
*f
)
2274 f
->ts
.type
= BT_INTEGER
;
2276 f
->value
.function
.name
= gfc_get_string (PREFIX ("time8_func"));
2281 gfc_resolve_transfer (gfc_expr
*f
, gfc_expr
*source ATTRIBUTE_UNUSED
,
2282 gfc_expr
*mold
, gfc_expr
*size
)
2284 /* TODO: Make this do something meaningful. */
2285 static char transfer0
[] = "__transfer0", transfer1
[] = "__transfer1";
2287 if (mold
->ts
.type
== BT_CHARACTER
&& !mold
->ts
.cl
->length
2288 && !(mold
->expr_type
== EXPR_VARIABLE
&& mold
->symtree
->n
.sym
->attr
.dummy
))
2289 mold
->ts
.cl
->length
= gfc_int_expr (mold
->value
.character
.length
);
2293 if (size
== NULL
&& mold
->rank
== 0)
2296 f
->value
.function
.name
= transfer0
;
2301 f
->value
.function
.name
= transfer1
;
2302 if (size
&& gfc_is_constant_expr (size
))
2304 f
->shape
= gfc_get_shape (1);
2305 mpz_init_set (f
->shape
[0], size
->value
.integer
);
2312 gfc_resolve_transpose (gfc_expr
*f
, gfc_expr
*matrix
)
2315 if (matrix
->ts
.type
== BT_CHARACTER
&& matrix
->ref
)
2316 gfc_resolve_substring_charlen (matrix
);
2322 f
->shape
= gfc_get_shape (2);
2323 mpz_init_set (f
->shape
[0], matrix
->shape
[1]);
2324 mpz_init_set (f
->shape
[1], matrix
->shape
[0]);
2327 switch (matrix
->ts
.kind
)
2333 switch (matrix
->ts
.type
)
2337 f
->value
.function
.name
2338 = gfc_get_string (PREFIX ("transpose_%c%d"),
2339 gfc_type_letter (matrix
->ts
.type
),
2345 /* Use the integer routines for real and logical cases. This
2346 assumes they all have the same alignment requirements. */
2347 f
->value
.function
.name
2348 = gfc_get_string (PREFIX ("transpose_i%d"), matrix
->ts
.kind
);
2352 f
->value
.function
.name
= PREFIX ("transpose");
2358 f
->value
.function
.name
= (matrix
->ts
.type
== BT_CHARACTER
2359 ? PREFIX ("transpose_char")
2360 : PREFIX ("transpose"));
2367 gfc_resolve_trim (gfc_expr
*f
, gfc_expr
*string
)
2369 f
->ts
.type
= BT_CHARACTER
;
2370 f
->ts
.kind
= string
->ts
.kind
;
2371 f
->value
.function
.name
= gfc_get_string ("__trim_%d", string
->ts
.kind
);
2376 gfc_resolve_ubound (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
2378 static char ubound
[] = "__ubound";
2380 f
->ts
.type
= BT_INTEGER
;
2382 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2384 f
->ts
.kind
= gfc_default_integer_kind
;
2389 f
->shape
= gfc_get_shape (1);
2390 mpz_init_set_ui (f
->shape
[0], array
->rank
);
2393 f
->value
.function
.name
= ubound
;
2397 /* Resolve the g77 compatibility function UMASK. */
2400 gfc_resolve_umask (gfc_expr
*f
, gfc_expr
*n
)
2402 f
->ts
.type
= BT_INTEGER
;
2403 f
->ts
.kind
= n
->ts
.kind
;
2404 f
->value
.function
.name
= gfc_get_string (PREFIX ("umask_i%d"), n
->ts
.kind
);
2408 /* Resolve the g77 compatibility function UNLINK. */
2411 gfc_resolve_unlink (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
2413 f
->ts
.type
= BT_INTEGER
;
2415 f
->value
.function
.name
= gfc_get_string (PREFIX ("unlink"));
2420 gfc_resolve_ttynam (gfc_expr
*f
, gfc_expr
*unit
)
2424 f
->ts
.type
= BT_CHARACTER
;
2425 f
->ts
.kind
= gfc_default_character_kind
;
2427 if (unit
->ts
.kind
!= gfc_c_int_kind
)
2429 ts
.type
= BT_INTEGER
;
2430 ts
.kind
= gfc_c_int_kind
;
2433 gfc_convert_type (unit
, &ts
, 2);
2436 f
->value
.function
.name
= gfc_get_string (PREFIX ("ttynam"));
2441 gfc_resolve_unpack (gfc_expr
*f
, gfc_expr
*vector
, gfc_expr
*mask
,
2442 gfc_expr
*field ATTRIBUTE_UNUSED
)
2444 if (vector
->ts
.type
== BT_CHARACTER
&& vector
->ref
)
2445 gfc_resolve_substring_charlen (vector
);
2448 f
->rank
= mask
->rank
;
2449 resolve_mask_arg (mask
);
2451 f
->value
.function
.name
2452 = gfc_get_string (PREFIX ("unpack%d%s"), field
->rank
> 0 ? 1 : 0,
2453 vector
->ts
.type
== BT_CHARACTER
? "_char" : "");
2458 gfc_resolve_verify (gfc_expr
*f
, gfc_expr
*string
,
2459 gfc_expr
*set ATTRIBUTE_UNUSED
,
2460 gfc_expr
*back ATTRIBUTE_UNUSED
, gfc_expr
*kind
)
2462 f
->ts
.type
= BT_INTEGER
;
2464 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2466 f
->ts
.kind
= gfc_default_integer_kind
;
2467 f
->value
.function
.name
= gfc_get_string ("__verify_%d", string
->ts
.kind
);
2472 gfc_resolve_xor (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
2474 f
->ts
.type
= i
->ts
.type
;
2475 f
->ts
.kind
= gfc_kind_max (i
, j
);
2477 if (i
->ts
.kind
!= j
->ts
.kind
)
2479 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
2480 gfc_convert_type (j
, &i
->ts
, 2);
2482 gfc_convert_type (i
, &j
->ts
, 2);
2485 f
->value
.function
.name
2486 = gfc_get_string ("__xor_%c%d", gfc_type_letter (i
->ts
.type
), f
->ts
.kind
);
2490 /* Intrinsic subroutine resolution. */
2493 gfc_resolve_alarm_sub (gfc_code
*c
)
2496 gfc_expr
*seconds
, *handler
, *status
;
2499 seconds
= c
->ext
.actual
->expr
;
2500 handler
= c
->ext
.actual
->next
->expr
;
2501 status
= c
->ext
.actual
->next
->next
->expr
;
2502 ts
.type
= BT_INTEGER
;
2503 ts
.kind
= gfc_c_int_kind
;
2505 /* handler can be either BT_INTEGER or BT_PROCEDURE.
2506 In all cases, the status argument is of default integer kind
2507 (enforced in check.c) so that the function suffix is fixed. */
2508 if (handler
->ts
.type
== BT_INTEGER
)
2510 if (handler
->ts
.kind
!= gfc_c_int_kind
)
2511 gfc_convert_type (handler
, &ts
, 2);
2512 name
= gfc_get_string (PREFIX ("alarm_sub_int_i%d"),
2513 gfc_default_integer_kind
);
2516 name
= gfc_get_string (PREFIX ("alarm_sub_i%d"),
2517 gfc_default_integer_kind
);
2519 if (seconds
->ts
.kind
!= gfc_c_int_kind
)
2520 gfc_convert_type (seconds
, &ts
, 2);
2522 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2526 gfc_resolve_cpu_time (gfc_code
*c
)
2529 name
= gfc_get_string (PREFIX ("cpu_time_%d"), c
->ext
.actual
->expr
->ts
.kind
);
2530 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2535 gfc_resolve_mvbits (gfc_code
*c
)
2540 /* FROMPOS, LEN and TOPOS are restricted to small values. As such,
2541 they will be converted so that they fit into a C int. */
2542 ts
.type
= BT_INTEGER
;
2543 ts
.kind
= gfc_c_int_kind
;
2544 if (c
->ext
.actual
->next
->expr
->ts
.kind
!= gfc_c_int_kind
)
2545 gfc_convert_type (c
->ext
.actual
->next
->expr
, &ts
, 2);
2546 if (c
->ext
.actual
->next
->next
->expr
->ts
.kind
!= gfc_c_int_kind
)
2547 gfc_convert_type (c
->ext
.actual
->next
->next
->expr
, &ts
, 2);
2548 if (c
->ext
.actual
->next
->next
->next
->next
->expr
->ts
.kind
!= gfc_c_int_kind
)
2549 gfc_convert_type (c
->ext
.actual
->next
->next
->next
->next
->expr
, &ts
, 2);
2551 /* TO and FROM are guaranteed to have the same kind parameter. */
2552 name
= gfc_get_string (PREFIX ("mvbits_i%d"),
2553 c
->ext
.actual
->expr
->ts
.kind
);
2554 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2559 gfc_resolve_random_number (gfc_code
*c
)
2564 kind
= c
->ext
.actual
->expr
->ts
.kind
;
2565 if (c
->ext
.actual
->expr
->rank
== 0)
2566 name
= gfc_get_string (PREFIX ("random_r%d"), kind
);
2568 name
= gfc_get_string (PREFIX ("arandom_r%d"), kind
);
2570 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2575 gfc_resolve_random_seed (gfc_code
*c
)
2579 name
= gfc_get_string (PREFIX ("random_seed_i%d"), gfc_default_integer_kind
);
2580 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2585 gfc_resolve_rename_sub (gfc_code
*c
)
2590 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
2591 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
2593 kind
= gfc_default_integer_kind
;
2595 name
= gfc_get_string (PREFIX ("rename_i%d_sub"), kind
);
2596 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2601 gfc_resolve_kill_sub (gfc_code
*c
)
2606 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
2607 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
2609 kind
= gfc_default_integer_kind
;
2611 name
= gfc_get_string (PREFIX ("kill_i%d_sub"), kind
);
2612 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2617 gfc_resolve_link_sub (gfc_code
*c
)
2622 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
2623 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
2625 kind
= gfc_default_integer_kind
;
2627 name
= gfc_get_string (PREFIX ("link_i%d_sub"), kind
);
2628 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2633 gfc_resolve_symlnk_sub (gfc_code
*c
)
2638 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
2639 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
2641 kind
= gfc_default_integer_kind
;
2643 name
= gfc_get_string (PREFIX ("symlnk_i%d_sub"), kind
);
2644 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2648 /* G77 compatibility subroutines etime() and dtime(). */
2651 gfc_resolve_etime_sub (gfc_code
*c
)
2654 name
= gfc_get_string (PREFIX ("etime_sub"));
2655 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2659 /* G77 compatibility subroutines itime(), idate(), ltime() and gmtime(). */
2662 gfc_resolve_itime (gfc_code
*c
)
2665 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("itime_i%d"),
2666 gfc_default_integer_kind
));
2670 gfc_resolve_idate (gfc_code
*c
)
2673 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("idate_i%d"),
2674 gfc_default_integer_kind
));
2678 gfc_resolve_ltime (gfc_code
*c
)
2681 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("ltime_i%d"),
2682 gfc_default_integer_kind
));
2686 gfc_resolve_gmtime (gfc_code
*c
)
2689 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("gmtime_i%d"),
2690 gfc_default_integer_kind
));
2694 /* G77 compatibility subroutine second(). */
2697 gfc_resolve_second_sub (gfc_code
*c
)
2700 name
= gfc_get_string (PREFIX ("second_sub"));
2701 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2706 gfc_resolve_sleep_sub (gfc_code
*c
)
2711 if (c
->ext
.actual
->expr
!= NULL
)
2712 kind
= c
->ext
.actual
->expr
->ts
.kind
;
2714 kind
= gfc_default_integer_kind
;
2716 name
= gfc_get_string (PREFIX ("sleep_i%d_sub"), kind
);
2717 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2721 /* G77 compatibility function srand(). */
2724 gfc_resolve_srand (gfc_code
*c
)
2727 name
= gfc_get_string (PREFIX ("srand"));
2728 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2732 /* Resolve the getarg intrinsic subroutine. */
2735 gfc_resolve_getarg (gfc_code
*c
)
2739 if (c
->ext
.actual
->expr
->ts
.kind
!= gfc_default_integer_kind
)
2743 ts
.type
= BT_INTEGER
;
2744 ts
.kind
= gfc_default_integer_kind
;
2746 gfc_convert_type (c
->ext
.actual
->expr
, &ts
, 2);
2749 name
= gfc_get_string (PREFIX ("getarg_i%d"), gfc_default_integer_kind
);
2750 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2754 /* Resolve the getcwd intrinsic subroutine. */
2757 gfc_resolve_getcwd_sub (gfc_code
*c
)
2762 if (c
->ext
.actual
->next
->expr
!= NULL
)
2763 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
2765 kind
= gfc_default_integer_kind
;
2767 name
= gfc_get_string (PREFIX ("getcwd_i%d_sub"), kind
);
2768 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2772 /* Resolve the get_command intrinsic subroutine. */
2775 gfc_resolve_get_command (gfc_code
*c
)
2779 kind
= gfc_default_integer_kind
;
2780 name
= gfc_get_string (PREFIX ("get_command_i%d"), kind
);
2781 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2785 /* Resolve the get_command_argument intrinsic subroutine. */
2788 gfc_resolve_get_command_argument (gfc_code
*c
)
2792 kind
= gfc_default_integer_kind
;
2793 name
= gfc_get_string (PREFIX ("get_command_argument_i%d"), kind
);
2794 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2798 /* Resolve the get_environment_variable intrinsic subroutine. */
2801 gfc_resolve_get_environment_variable (gfc_code
*code
)
2805 kind
= gfc_default_integer_kind
;
2806 name
= gfc_get_string (PREFIX ("get_environment_variable_i%d"), kind
);
2807 code
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2812 gfc_resolve_signal_sub (gfc_code
*c
)
2815 gfc_expr
*number
, *handler
, *status
;
2818 number
= c
->ext
.actual
->expr
;
2819 handler
= c
->ext
.actual
->next
->expr
;
2820 status
= c
->ext
.actual
->next
->next
->expr
;
2821 ts
.type
= BT_INTEGER
;
2822 ts
.kind
= gfc_c_int_kind
;
2824 /* handler can be either BT_INTEGER or BT_PROCEDURE */
2825 if (handler
->ts
.type
== BT_INTEGER
)
2827 if (handler
->ts
.kind
!= gfc_c_int_kind
)
2828 gfc_convert_type (handler
, &ts
, 2);
2829 name
= gfc_get_string (PREFIX ("signal_sub_int"));
2832 name
= gfc_get_string (PREFIX ("signal_sub"));
2834 if (number
->ts
.kind
!= gfc_c_int_kind
)
2835 gfc_convert_type (number
, &ts
, 2);
2836 if (status
!= NULL
&& status
->ts
.kind
!= gfc_c_int_kind
)
2837 gfc_convert_type (status
, &ts
, 2);
2839 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2843 /* Resolve the SYSTEM intrinsic subroutine. */
2846 gfc_resolve_system_sub (gfc_code
*c
)
2849 name
= gfc_get_string (PREFIX ("system_sub"));
2850 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2854 /* Determine if the arguments to SYSTEM_CLOCK are INTEGER(4) or INTEGER(8) */
2857 gfc_resolve_system_clock (gfc_code
*c
)
2862 if (c
->ext
.actual
->expr
!= NULL
)
2863 kind
= c
->ext
.actual
->expr
->ts
.kind
;
2864 else if (c
->ext
.actual
->next
->expr
!= NULL
)
2865 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
2866 else if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
2867 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
2869 kind
= gfc_default_integer_kind
;
2871 name
= gfc_get_string (PREFIX ("system_clock_%d"), kind
);
2872 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2876 /* Resolve the EXIT intrinsic subroutine. */
2879 gfc_resolve_exit (gfc_code
*c
)
2885 /* The STATUS argument has to be of default kind. If it is not,
2887 ts
.type
= BT_INTEGER
;
2888 ts
.kind
= gfc_default_integer_kind
;
2889 n
= c
->ext
.actual
->expr
;
2890 if (n
!= NULL
&& n
->ts
.kind
!= ts
.kind
)
2891 gfc_convert_type (n
, &ts
, 2);
2893 name
= gfc_get_string (PREFIX ("exit_i%d"), ts
.kind
);
2894 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2898 /* Resolve the FLUSH intrinsic subroutine. */
2901 gfc_resolve_flush (gfc_code
*c
)
2907 ts
.type
= BT_INTEGER
;
2908 ts
.kind
= gfc_default_integer_kind
;
2909 n
= c
->ext
.actual
->expr
;
2910 if (n
!= NULL
&& n
->ts
.kind
!= ts
.kind
)
2911 gfc_convert_type (n
, &ts
, 2);
2913 name
= gfc_get_string (PREFIX ("flush_i%d"), ts
.kind
);
2914 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2919 gfc_resolve_free (gfc_code
*c
)
2924 ts
.type
= BT_INTEGER
;
2925 ts
.kind
= gfc_index_integer_kind
;
2926 n
= c
->ext
.actual
->expr
;
2927 if (n
->ts
.kind
!= ts
.kind
)
2928 gfc_convert_type (n
, &ts
, 2);
2930 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("free"));
2935 gfc_resolve_ctime_sub (gfc_code
*c
)
2939 /* ctime TIME argument is a INTEGER(KIND=8), says the doc */
2940 if (c
->ext
.actual
->expr
->ts
.kind
!= 8)
2942 ts
.type
= BT_INTEGER
;
2946 gfc_convert_type (c
->ext
.actual
->expr
, &ts
, 2);
2949 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("ctime_sub"));
2954 gfc_resolve_fdate_sub (gfc_code
*c
)
2956 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("fdate_sub"));
2961 gfc_resolve_gerror (gfc_code
*c
)
2963 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("gerror"));
2968 gfc_resolve_getlog (gfc_code
*c
)
2970 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("getlog"));
2975 gfc_resolve_hostnm_sub (gfc_code
*c
)
2980 if (c
->ext
.actual
->next
->expr
!= NULL
)
2981 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
2983 kind
= gfc_default_integer_kind
;
2985 name
= gfc_get_string (PREFIX ("hostnm_i%d_sub"), kind
);
2986 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2991 gfc_resolve_perror (gfc_code
*c
)
2993 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("perror_sub"));
2996 /* Resolve the STAT and FSTAT intrinsic subroutines. */
2999 gfc_resolve_stat_sub (gfc_code
*c
)
3002 name
= gfc_get_string (PREFIX ("stat_i%d_sub"), gfc_default_integer_kind
);
3003 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3008 gfc_resolve_lstat_sub (gfc_code
*c
)
3011 name
= gfc_get_string (PREFIX ("lstat_i%d_sub"), gfc_default_integer_kind
);
3012 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3017 gfc_resolve_fstat_sub (gfc_code
*c
)
3023 u
= c
->ext
.actual
->expr
;
3024 ts
= &c
->ext
.actual
->next
->expr
->ts
;
3025 if (u
->ts
.kind
!= ts
->kind
)
3026 gfc_convert_type (u
, ts
, 2);
3027 name
= gfc_get_string (PREFIX ("fstat_i%d_sub"), ts
->kind
);
3028 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3033 gfc_resolve_fgetc_sub (gfc_code
*c
)
3039 u
= c
->ext
.actual
->expr
;
3040 st
= c
->ext
.actual
->next
->next
->expr
;
3042 if (u
->ts
.kind
!= gfc_c_int_kind
)
3044 ts
.type
= BT_INTEGER
;
3045 ts
.kind
= gfc_c_int_kind
;
3048 gfc_convert_type (u
, &ts
, 2);
3052 name
= gfc_get_string (PREFIX ("fgetc_i%d_sub"), st
->ts
.kind
);
3054 name
= gfc_get_string (PREFIX ("fgetc_i%d_sub"), gfc_default_integer_kind
);
3056 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3061 gfc_resolve_fget_sub (gfc_code
*c
)
3066 st
= c
->ext
.actual
->next
->expr
;
3068 name
= gfc_get_string (PREFIX ("fget_i%d_sub"), st
->ts
.kind
);
3070 name
= gfc_get_string (PREFIX ("fget_i%d_sub"), gfc_default_integer_kind
);
3072 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3077 gfc_resolve_fputc_sub (gfc_code
*c
)
3083 u
= c
->ext
.actual
->expr
;
3084 st
= c
->ext
.actual
->next
->next
->expr
;
3086 if (u
->ts
.kind
!= gfc_c_int_kind
)
3088 ts
.type
= BT_INTEGER
;
3089 ts
.kind
= gfc_c_int_kind
;
3092 gfc_convert_type (u
, &ts
, 2);
3096 name
= gfc_get_string (PREFIX ("fputc_i%d_sub"), st
->ts
.kind
);
3098 name
= gfc_get_string (PREFIX ("fputc_i%d_sub"), gfc_default_integer_kind
);
3100 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3105 gfc_resolve_fput_sub (gfc_code
*c
)
3110 st
= c
->ext
.actual
->next
->expr
;
3112 name
= gfc_get_string (PREFIX ("fput_i%d_sub"), st
->ts
.kind
);
3114 name
= gfc_get_string (PREFIX ("fput_i%d_sub"), gfc_default_integer_kind
);
3116 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3121 gfc_resolve_fseek_sub (gfc_code
*c
)
3129 unit
= c
->ext
.actual
->expr
;
3130 offset
= c
->ext
.actual
->next
->expr
;
3131 whence
= c
->ext
.actual
->next
->next
->expr
;
3132 status
= c
->ext
.actual
->next
->next
->next
->expr
;
3134 if (unit
->ts
.kind
!= gfc_c_int_kind
)
3136 ts
.type
= BT_INTEGER
;
3137 ts
.kind
= gfc_c_int_kind
;
3140 gfc_convert_type (unit
, &ts
, 2);
3143 if (offset
->ts
.kind
!= gfc_intio_kind
)
3145 ts
.type
= BT_INTEGER
;
3146 ts
.kind
= gfc_intio_kind
;
3149 gfc_convert_type (offset
, &ts
, 2);
3152 if (whence
->ts
.kind
!= gfc_c_int_kind
)
3154 ts
.type
= BT_INTEGER
;
3155 ts
.kind
= gfc_c_int_kind
;
3158 gfc_convert_type (whence
, &ts
, 2);
3161 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("fseek_sub"));
3165 gfc_resolve_ftell_sub (gfc_code
*c
)
3172 unit
= c
->ext
.actual
->expr
;
3173 offset
= c
->ext
.actual
->next
->expr
;
3175 if (unit
->ts
.kind
!= gfc_c_int_kind
)
3177 ts
.type
= BT_INTEGER
;
3178 ts
.kind
= gfc_c_int_kind
;
3181 gfc_convert_type (unit
, &ts
, 2);
3184 name
= gfc_get_string (PREFIX ("ftell_i%d_sub"), offset
->ts
.kind
);
3185 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3190 gfc_resolve_ttynam_sub (gfc_code
*c
)
3194 if (c
->ext
.actual
->expr
->ts
.kind
!= gfc_c_int_kind
)
3196 ts
.type
= BT_INTEGER
;
3197 ts
.kind
= gfc_c_int_kind
;
3200 gfc_convert_type (c
->ext
.actual
->expr
, &ts
, 2);
3203 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("ttynam_sub"));
3207 /* Resolve the UMASK intrinsic subroutine. */
3210 gfc_resolve_umask_sub (gfc_code
*c
)
3215 if (c
->ext
.actual
->next
->expr
!= NULL
)
3216 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
3218 kind
= gfc_default_integer_kind
;
3220 name
= gfc_get_string (PREFIX ("umask_i%d_sub"), kind
);
3221 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3224 /* Resolve the UNLINK intrinsic subroutine. */
3227 gfc_resolve_unlink_sub (gfc_code
*c
)
3232 if (c
->ext
.actual
->next
->expr
!= NULL
)
3233 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
3235 kind
= gfc_default_integer_kind
;
3237 name
= gfc_get_string (PREFIX ("unlink_i%d_sub"), kind
);
3238 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);