1 /* Intrinsic function resolution.
2 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
4 Free Software Foundation, Inc.
5 Contributed by Andy Vaught & Katherine Holcomb
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 3, or (at your option) any later
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
24 /* Assign name and types to intrinsic procedures. For functions, the
25 first argument to a resolution function is an expression pointer to
26 the original function node and the rest are pointers to the
27 arguments of the function call. For subroutines, a pointer to the
28 code node is passed. The result type and library subroutine name
29 are generally set according to the function arguments. */
33 #include "coretypes.h"
36 #include "intrinsic.h"
38 /* Given printf-like arguments, return a stable version of the result string.
40 We already have a working, optimized string hashing table in the form of
41 the identifier table. Reusing this table is likely not to be wasted,
42 since if the function name makes it to the gimple output of the frontend,
43 we'll have to create the identifier anyway. */
46 gfc_get_string (const char *format
, ...)
52 va_start (ap
, format
);
53 vsnprintf (temp_name
, sizeof (temp_name
), format
, ap
);
55 temp_name
[sizeof (temp_name
) - 1] = 0;
57 ident
= get_identifier (temp_name
);
58 return IDENTIFIER_POINTER (ident
);
61 /* MERGE and SPREAD need to have source charlen's present for passing
62 to the result expression. */
64 check_charlen_present (gfc_expr
*source
)
66 if (source
->ts
.u
.cl
== NULL
)
67 source
->ts
.u
.cl
= gfc_new_charlen (gfc_current_ns
, NULL
);
69 if (source
->expr_type
== EXPR_CONSTANT
)
71 source
->ts
.u
.cl
->length
= gfc_int_expr (source
->value
.character
.length
);
74 else if (source
->expr_type
== EXPR_ARRAY
)
75 source
->ts
.u
.cl
->length
=
76 gfc_int_expr (source
->value
.constructor
->expr
->value
.character
.length
);
79 /* Helper function for resolving the "mask" argument. */
82 resolve_mask_arg (gfc_expr
*mask
)
90 /* For the scalar case, coerce the mask to kind=4 unconditionally
91 (because this is the only kind we have a library function
94 if (mask
->ts
.kind
!= 4)
98 gfc_convert_type (mask
, &ts
, 2);
103 /* In the library, we access the mask with a GFC_LOGICAL_1
104 argument. No need to waste memory if we are about to create
105 a temporary array. */
106 if (mask
->expr_type
== EXPR_OP
&& mask
->ts
.kind
!= 1)
108 ts
.type
= BT_LOGICAL
;
110 gfc_convert_type_warn (mask
, &ts
, 2, 0);
115 /********************** Resolution functions **********************/
119 gfc_resolve_abs (gfc_expr
*f
, gfc_expr
*a
)
122 if (f
->ts
.type
== BT_COMPLEX
)
123 f
->ts
.type
= BT_REAL
;
125 f
->value
.function
.name
126 = gfc_get_string ("__abs_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
131 gfc_resolve_access (gfc_expr
*f
, gfc_expr
*name ATTRIBUTE_UNUSED
,
132 gfc_expr
*mode ATTRIBUTE_UNUSED
)
134 f
->ts
.type
= BT_INTEGER
;
135 f
->ts
.kind
= gfc_c_int_kind
;
136 f
->value
.function
.name
= PREFIX ("access_func");
141 gfc_resolve_adjustl (gfc_expr
*f
, gfc_expr
*string
)
143 f
->ts
.type
= BT_CHARACTER
;
144 f
->ts
.kind
= string
->ts
.kind
;
145 f
->value
.function
.name
= gfc_get_string ("__adjustl_s%d", f
->ts
.kind
);
150 gfc_resolve_adjustr (gfc_expr
*f
, gfc_expr
*string
)
152 f
->ts
.type
= BT_CHARACTER
;
153 f
->ts
.kind
= string
->ts
.kind
;
154 f
->value
.function
.name
= gfc_get_string ("__adjustr_s%d", f
->ts
.kind
);
159 gfc_resolve_char_achar (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*kind
,
162 f
->ts
.type
= BT_CHARACTER
;
163 f
->ts
.kind
= (kind
== NULL
)
164 ? gfc_default_character_kind
: mpz_get_si (kind
->value
.integer
);
165 f
->ts
.u
.cl
= gfc_new_charlen (gfc_current_ns
, NULL
);
166 f
->ts
.u
.cl
->length
= gfc_int_expr (1);
168 f
->value
.function
.name
= gfc_get_string (name
, f
->ts
.kind
,
169 gfc_type_letter (x
->ts
.type
),
175 gfc_resolve_achar (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*kind
)
177 gfc_resolve_char_achar (f
, x
, kind
, "__achar_%d_%c%d");
182 gfc_resolve_acos (gfc_expr
*f
, gfc_expr
*x
)
185 f
->value
.function
.name
186 = gfc_get_string ("__acos_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
191 gfc_resolve_acosh (gfc_expr
*f
, gfc_expr
*x
)
194 f
->value
.function
.name
195 = gfc_get_string ("__acosh_%c%d", gfc_type_letter (x
->ts
.type
),
201 gfc_resolve_aimag (gfc_expr
*f
, gfc_expr
*x
)
203 f
->ts
.type
= BT_REAL
;
204 f
->ts
.kind
= x
->ts
.kind
;
205 f
->value
.function
.name
206 = gfc_get_string ("__aimag_%c%d", gfc_type_letter (x
->ts
.type
),
212 gfc_resolve_and (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
214 f
->ts
.type
= i
->ts
.type
;
215 f
->ts
.kind
= gfc_kind_max (i
, j
);
217 if (i
->ts
.kind
!= j
->ts
.kind
)
219 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
220 gfc_convert_type (j
, &i
->ts
, 2);
222 gfc_convert_type (i
, &j
->ts
, 2);
225 f
->value
.function
.name
226 = gfc_get_string ("__and_%c%d", gfc_type_letter (i
->ts
.type
), f
->ts
.kind
);
231 gfc_resolve_aint (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
236 f
->ts
.type
= a
->ts
.type
;
237 f
->ts
.kind
= (kind
== NULL
) ? a
->ts
.kind
: mpz_get_si (kind
->value
.integer
);
239 if (a
->ts
.kind
!= f
->ts
.kind
)
241 ts
.type
= f
->ts
.type
;
242 ts
.kind
= f
->ts
.kind
;
243 gfc_convert_type (a
, &ts
, 2);
245 /* The resolved name is only used for specific intrinsics where
246 the return kind is the same as the arg kind. */
247 f
->value
.function
.name
248 = gfc_get_string ("__aint_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
253 gfc_resolve_dint (gfc_expr
*f
, gfc_expr
*a
)
255 gfc_resolve_aint (f
, a
, NULL
);
260 gfc_resolve_all (gfc_expr
*f
, gfc_expr
*mask
, gfc_expr
*dim
)
266 gfc_resolve_dim_arg (dim
);
267 f
->rank
= mask
->rank
- 1;
268 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
271 f
->value
.function
.name
272 = gfc_get_string (PREFIX ("all_%c%d"), gfc_type_letter (mask
->ts
.type
),
278 gfc_resolve_anint (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
283 f
->ts
.type
= a
->ts
.type
;
284 f
->ts
.kind
= (kind
== NULL
) ? a
->ts
.kind
: mpz_get_si (kind
->value
.integer
);
286 if (a
->ts
.kind
!= f
->ts
.kind
)
288 ts
.type
= f
->ts
.type
;
289 ts
.kind
= f
->ts
.kind
;
290 gfc_convert_type (a
, &ts
, 2);
293 /* The resolved name is only used for specific intrinsics where
294 the return kind is the same as the arg kind. */
295 f
->value
.function
.name
296 = gfc_get_string ("__anint_%c%d", gfc_type_letter (a
->ts
.type
),
302 gfc_resolve_dnint (gfc_expr
*f
, gfc_expr
*a
)
304 gfc_resolve_anint (f
, a
, NULL
);
309 gfc_resolve_any (gfc_expr
*f
, gfc_expr
*mask
, gfc_expr
*dim
)
315 gfc_resolve_dim_arg (dim
);
316 f
->rank
= mask
->rank
- 1;
317 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
320 f
->value
.function
.name
321 = gfc_get_string (PREFIX ("any_%c%d"), gfc_type_letter (mask
->ts
.type
),
327 gfc_resolve_asin (gfc_expr
*f
, gfc_expr
*x
)
330 f
->value
.function
.name
331 = gfc_get_string ("__asin_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
335 gfc_resolve_asinh (gfc_expr
*f
, gfc_expr
*x
)
338 f
->value
.function
.name
339 = gfc_get_string ("__asinh_%c%d", gfc_type_letter (x
->ts
.type
),
344 gfc_resolve_atan (gfc_expr
*f
, gfc_expr
*x
)
347 f
->value
.function
.name
348 = gfc_get_string ("__atan_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
352 gfc_resolve_atanh (gfc_expr
*f
, gfc_expr
*x
)
355 f
->value
.function
.name
356 = gfc_get_string ("__atanh_%c%d", gfc_type_letter (x
->ts
.type
),
361 gfc_resolve_atan2 (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y ATTRIBUTE_UNUSED
)
364 f
->value
.function
.name
365 = gfc_get_string ("__atan2_%c%d", gfc_type_letter (x
->ts
.type
),
370 /* Resolve the BESYN and BESJN intrinsics. */
373 gfc_resolve_besn (gfc_expr
*f
, gfc_expr
*n
, gfc_expr
*x
)
379 if (n
->ts
.kind
!= gfc_c_int_kind
)
381 ts
.type
= BT_INTEGER
;
382 ts
.kind
= gfc_c_int_kind
;
383 gfc_convert_type (n
, &ts
, 2);
385 f
->value
.function
.name
= gfc_get_string ("<intrinsic>");
390 gfc_resolve_btest (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos
)
392 f
->ts
.type
= BT_LOGICAL
;
393 f
->ts
.kind
= gfc_default_logical_kind
;
394 f
->value
.function
.name
395 = gfc_get_string ("__btest_%d_%d", i
->ts
.kind
, pos
->ts
.kind
);
400 gfc_resolve_ceiling (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
402 f
->ts
.type
= BT_INTEGER
;
403 f
->ts
.kind
= (kind
== NULL
)
404 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
405 f
->value
.function
.name
406 = gfc_get_string ("__ceiling_%d_%c%d", f
->ts
.kind
,
407 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
412 gfc_resolve_char (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
414 gfc_resolve_char_achar (f
, a
, kind
, "__char_%d_%c%d");
419 gfc_resolve_chdir (gfc_expr
*f
, gfc_expr
*d ATTRIBUTE_UNUSED
)
421 f
->ts
.type
= BT_INTEGER
;
422 f
->ts
.kind
= gfc_default_integer_kind
;
423 f
->value
.function
.name
= gfc_get_string (PREFIX ("chdir_i%d"), f
->ts
.kind
);
428 gfc_resolve_chdir_sub (gfc_code
*c
)
433 if (c
->ext
.actual
->next
->expr
!= NULL
)
434 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
436 kind
= gfc_default_integer_kind
;
438 name
= gfc_get_string (PREFIX ("chdir_i%d_sub"), kind
);
439 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
444 gfc_resolve_chmod (gfc_expr
*f
, gfc_expr
*name ATTRIBUTE_UNUSED
,
445 gfc_expr
*mode ATTRIBUTE_UNUSED
)
447 f
->ts
.type
= BT_INTEGER
;
448 f
->ts
.kind
= gfc_c_int_kind
;
449 f
->value
.function
.name
= PREFIX ("chmod_func");
454 gfc_resolve_chmod_sub (gfc_code
*c
)
459 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
460 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
462 kind
= gfc_default_integer_kind
;
464 name
= gfc_get_string (PREFIX ("chmod_i%d_sub"), kind
);
465 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
470 gfc_resolve_cmplx (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y
, gfc_expr
*kind
)
472 f
->ts
.type
= BT_COMPLEX
;
473 f
->ts
.kind
= (kind
== NULL
)
474 ? gfc_default_real_kind
: mpz_get_si (kind
->value
.integer
);
477 f
->value
.function
.name
478 = gfc_get_string ("__cmplx0_%d_%c%d", f
->ts
.kind
,
479 gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
481 f
->value
.function
.name
482 = gfc_get_string ("__cmplx1_%d_%c%d_%c%d", f
->ts
.kind
,
483 gfc_type_letter (x
->ts
.type
), x
->ts
.kind
,
484 gfc_type_letter (y
->ts
.type
), y
->ts
.kind
);
489 gfc_resolve_dcmplx (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y
)
491 gfc_resolve_cmplx (f
, x
, y
, gfc_int_expr (gfc_default_double_kind
));
496 gfc_resolve_complex (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y
)
500 if (x
->ts
.type
== BT_INTEGER
)
502 if (y
->ts
.type
== BT_INTEGER
)
503 kind
= gfc_default_real_kind
;
509 if (y
->ts
.type
== BT_REAL
)
510 kind
= (x
->ts
.kind
> y
->ts
.kind
) ? x
->ts
.kind
: y
->ts
.kind
;
515 f
->ts
.type
= BT_COMPLEX
;
517 f
->value
.function
.name
518 = gfc_get_string ("__cmplx1_%d_%c%d_%c%d", f
->ts
.kind
,
519 gfc_type_letter (x
->ts
.type
), x
->ts
.kind
,
520 gfc_type_letter (y
->ts
.type
), y
->ts
.kind
);
525 gfc_resolve_conjg (gfc_expr
*f
, gfc_expr
*x
)
528 f
->value
.function
.name
= gfc_get_string ("__conjg_%d", x
->ts
.kind
);
533 gfc_resolve_cos (gfc_expr
*f
, gfc_expr
*x
)
536 f
->value
.function
.name
537 = gfc_get_string ("__cos_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
542 gfc_resolve_cosh (gfc_expr
*f
, gfc_expr
*x
)
545 f
->value
.function
.name
546 = gfc_get_string ("__cosh_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
551 gfc_resolve_count (gfc_expr
*f
, gfc_expr
*mask
, gfc_expr
*dim
, gfc_expr
*kind
)
553 f
->ts
.type
= BT_INTEGER
;
555 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
557 f
->ts
.kind
= gfc_default_integer_kind
;
561 f
->rank
= mask
->rank
- 1;
562 gfc_resolve_dim_arg (dim
);
563 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
566 resolve_mask_arg (mask
);
568 f
->value
.function
.name
569 = gfc_get_string (PREFIX ("count_%d_%c"), f
->ts
.kind
,
570 gfc_type_letter (mask
->ts
.type
));
575 gfc_resolve_cshift (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*shift
,
580 if (array
->ts
.type
== BT_CHARACTER
&& array
->ref
)
581 gfc_resolve_substring_charlen (array
);
584 f
->rank
= array
->rank
;
585 f
->shape
= gfc_copy_shape (array
->shape
, array
->rank
);
592 /* If dim kind is greater than default integer we need to use the larger. */
593 m
= gfc_default_integer_kind
;
595 m
= m
< dim
->ts
.kind
? dim
->ts
.kind
: m
;
597 /* Convert shift to at least m, so we don't need
598 kind=1 and kind=2 versions of the library functions. */
599 if (shift
->ts
.kind
< m
)
603 ts
.type
= BT_INTEGER
;
605 gfc_convert_type_warn (shift
, &ts
, 2, 0);
610 if (dim
->expr_type
!= EXPR_CONSTANT
&& dim
->symtree
!= NULL
611 && dim
->symtree
->n
.sym
->attr
.optional
)
613 /* Mark this for later setting the type in gfc_conv_missing_dummy. */
614 dim
->representation
.length
= shift
->ts
.kind
;
618 gfc_resolve_dim_arg (dim
);
619 /* Convert dim to shift's kind to reduce variations. */
620 if (dim
->ts
.kind
!= shift
->ts
.kind
)
621 gfc_convert_type_warn (dim
, &shift
->ts
, 2, 0);
625 if (array
->ts
.type
== BT_CHARACTER
)
627 if (array
->ts
.kind
== gfc_default_character_kind
)
628 f
->value
.function
.name
629 = gfc_get_string (PREFIX ("cshift%d_%d_char"), n
, shift
->ts
.kind
);
631 f
->value
.function
.name
632 = gfc_get_string (PREFIX ("cshift%d_%d_char%d"), n
, shift
->ts
.kind
,
636 f
->value
.function
.name
637 = gfc_get_string (PREFIX ("cshift%d_%d"), n
, shift
->ts
.kind
);
642 gfc_resolve_ctime (gfc_expr
*f
, gfc_expr
*time
)
647 f
->ts
.type
= BT_CHARACTER
;
648 f
->ts
.kind
= gfc_default_character_kind
;
650 /* ctime TIME argument is a INTEGER(KIND=8), says the doc */
651 if (time
->ts
.kind
!= 8)
653 ts
.type
= BT_INTEGER
;
657 gfc_convert_type (time
, &ts
, 2);
660 f
->value
.function
.name
= gfc_get_string (PREFIX ("ctime"));
665 gfc_resolve_dble (gfc_expr
*f
, gfc_expr
*a
)
667 f
->ts
.type
= BT_REAL
;
668 f
->ts
.kind
= gfc_default_double_kind
;
669 f
->value
.function
.name
670 = gfc_get_string ("__dble_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
675 gfc_resolve_dim (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p
)
677 f
->ts
.type
= a
->ts
.type
;
679 f
->ts
.kind
= gfc_kind_max (a
,p
);
681 f
->ts
.kind
= a
->ts
.kind
;
683 if (p
!= NULL
&& a
->ts
.kind
!= p
->ts
.kind
)
685 if (a
->ts
.kind
== gfc_kind_max (a
,p
))
686 gfc_convert_type (p
, &a
->ts
, 2);
688 gfc_convert_type (a
, &p
->ts
, 2);
691 f
->value
.function
.name
692 = gfc_get_string ("__dim_%c%d", gfc_type_letter (f
->ts
.type
), f
->ts
.kind
);
697 gfc_resolve_dot_product (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*b
)
701 temp
.expr_type
= EXPR_OP
;
702 gfc_clear_ts (&temp
.ts
);
703 temp
.value
.op
.op
= INTRINSIC_NONE
;
704 temp
.value
.op
.op1
= a
;
705 temp
.value
.op
.op2
= b
;
706 gfc_type_convert_binary (&temp
, 1);
708 f
->value
.function
.name
709 = gfc_get_string (PREFIX ("dot_product_%c%d"),
710 gfc_type_letter (f
->ts
.type
), f
->ts
.kind
);
715 gfc_resolve_dprod (gfc_expr
*f
, gfc_expr
*a ATTRIBUTE_UNUSED
,
716 gfc_expr
*b ATTRIBUTE_UNUSED
)
718 f
->ts
.kind
= gfc_default_double_kind
;
719 f
->ts
.type
= BT_REAL
;
720 f
->value
.function
.name
= gfc_get_string ("__dprod_r%d", f
->ts
.kind
);
725 gfc_resolve_eoshift (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*shift
,
726 gfc_expr
*boundary
, gfc_expr
*dim
)
730 if (array
->ts
.type
== BT_CHARACTER
&& array
->ref
)
731 gfc_resolve_substring_charlen (array
);
734 f
->rank
= array
->rank
;
735 f
->shape
= gfc_copy_shape (array
->shape
, array
->rank
);
740 if (boundary
&& boundary
->rank
> 0)
743 /* If dim kind is greater than default integer we need to use the larger. */
744 m
= gfc_default_integer_kind
;
746 m
= m
< dim
->ts
.kind
? dim
->ts
.kind
: m
;
748 /* Convert shift to at least m, so we don't need
749 kind=1 and kind=2 versions of the library functions. */
750 if (shift
->ts
.kind
< m
)
754 ts
.type
= BT_INTEGER
;
756 gfc_convert_type_warn (shift
, &ts
, 2, 0);
761 if (dim
->expr_type
!= EXPR_CONSTANT
&& dim
->symtree
!= NULL
762 && dim
->symtree
->n
.sym
->attr
.optional
)
764 /* Mark this for later setting the type in gfc_conv_missing_dummy. */
765 dim
->representation
.length
= shift
->ts
.kind
;
769 gfc_resolve_dim_arg (dim
);
770 /* Convert dim to shift's kind to reduce variations. */
771 if (dim
->ts
.kind
!= shift
->ts
.kind
)
772 gfc_convert_type_warn (dim
, &shift
->ts
, 2, 0);
776 if (array
->ts
.type
== BT_CHARACTER
)
778 if (array
->ts
.kind
== gfc_default_character_kind
)
779 f
->value
.function
.name
780 = gfc_get_string (PREFIX ("eoshift%d_%d_char"), n
, shift
->ts
.kind
);
782 f
->value
.function
.name
783 = gfc_get_string (PREFIX ("eoshift%d_%d_char%d"), n
, shift
->ts
.kind
,
787 f
->value
.function
.name
788 = gfc_get_string (PREFIX ("eoshift%d_%d"), n
, shift
->ts
.kind
);
793 gfc_resolve_exp (gfc_expr
*f
, gfc_expr
*x
)
796 f
->value
.function
.name
797 = gfc_get_string ("__exp_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
802 gfc_resolve_exponent (gfc_expr
*f
, gfc_expr
*x
)
804 f
->ts
.type
= BT_INTEGER
;
805 f
->ts
.kind
= gfc_default_integer_kind
;
806 f
->value
.function
.name
= gfc_get_string ("__exponent_%d", x
->ts
.kind
);
810 /* Resolve the EXTENDS_TYPE_OF intrinsic function. */
813 gfc_resolve_extends_type_of (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*mo
)
818 /* Prevent double resolution. */
819 if (f
->ts
.type
== BT_LOGICAL
)
822 /* Replace the first argument with the corresponding vtab. */
823 if (a
->ts
.type
== BT_CLASS
)
824 gfc_add_component_ref (a
, "$vptr");
825 else if (a
->ts
.type
== BT_DERIVED
)
827 vtab
= gfc_find_derived_vtab (a
->ts
.u
.derived
);
828 /* Clear the old expr. */
829 gfc_free_ref_list (a
->ref
);
830 memset (a
, '\0', sizeof (gfc_expr
));
831 /* Construct a new one. */
832 a
->expr_type
= EXPR_VARIABLE
;
833 st
= gfc_find_symtree (vtab
->ns
->sym_root
, vtab
->name
);
838 /* Replace the second argument with the corresponding vtab. */
839 if (mo
->ts
.type
== BT_CLASS
)
840 gfc_add_component_ref (mo
, "$vptr");
841 else if (mo
->ts
.type
== BT_DERIVED
)
843 vtab
= gfc_find_derived_vtab (mo
->ts
.u
.derived
);
844 /* Clear the old expr. */
845 gfc_free_ref_list (mo
->ref
);
846 memset (mo
, '\0', sizeof (gfc_expr
));
847 /* Construct a new one. */
848 mo
->expr_type
= EXPR_VARIABLE
;
849 st
= gfc_find_symtree (vtab
->ns
->sym_root
, vtab
->name
);
854 f
->ts
.type
= BT_LOGICAL
;
856 /* Call library function. */
857 f
->value
.function
.name
= gfc_get_string (PREFIX ("is_extension_of"));
862 gfc_resolve_fdate (gfc_expr
*f
)
864 f
->ts
.type
= BT_CHARACTER
;
865 f
->ts
.kind
= gfc_default_character_kind
;
866 f
->value
.function
.name
= gfc_get_string (PREFIX ("fdate"));
871 gfc_resolve_floor (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
873 f
->ts
.type
= BT_INTEGER
;
874 f
->ts
.kind
= (kind
== NULL
)
875 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
876 f
->value
.function
.name
877 = gfc_get_string ("__floor%d_%c%d", f
->ts
.kind
,
878 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
883 gfc_resolve_fnum (gfc_expr
*f
, gfc_expr
*n
)
885 f
->ts
.type
= BT_INTEGER
;
886 f
->ts
.kind
= gfc_default_integer_kind
;
887 if (n
->ts
.kind
!= f
->ts
.kind
)
888 gfc_convert_type (n
, &f
->ts
, 2);
889 f
->value
.function
.name
= gfc_get_string (PREFIX ("fnum_i%d"), f
->ts
.kind
);
894 gfc_resolve_fraction (gfc_expr
*f
, gfc_expr
*x
)
897 f
->value
.function
.name
= gfc_get_string ("__fraction_%d", x
->ts
.kind
);
901 /* Resolve single-argument g77 math intrinsics, eg BESY0, ERF. */
904 gfc_resolve_g77_math1 (gfc_expr
*f
, gfc_expr
*x
)
907 f
->value
.function
.name
= gfc_get_string ("<intrinsic>");
912 gfc_resolve_gamma (gfc_expr
*f
, gfc_expr
*x
)
915 f
->value
.function
.name
916 = gfc_get_string ("__tgamma_%d", x
->ts
.kind
);
921 gfc_resolve_getcwd (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
923 f
->ts
.type
= BT_INTEGER
;
925 f
->value
.function
.name
= gfc_get_string (PREFIX ("getcwd"));
930 gfc_resolve_getgid (gfc_expr
*f
)
932 f
->ts
.type
= BT_INTEGER
;
934 f
->value
.function
.name
= gfc_get_string (PREFIX ("getgid"));
939 gfc_resolve_getpid (gfc_expr
*f
)
941 f
->ts
.type
= BT_INTEGER
;
943 f
->value
.function
.name
= gfc_get_string (PREFIX ("getpid"));
948 gfc_resolve_getuid (gfc_expr
*f
)
950 f
->ts
.type
= BT_INTEGER
;
952 f
->value
.function
.name
= gfc_get_string (PREFIX ("getuid"));
957 gfc_resolve_hostnm (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
959 f
->ts
.type
= BT_INTEGER
;
961 f
->value
.function
.name
= gfc_get_string (PREFIX ("hostnm"));
966 gfc_resolve_hypot (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y ATTRIBUTE_UNUSED
)
969 f
->value
.function
.name
= gfc_get_string ("__hypot_r%d", x
->ts
.kind
);
974 gfc_resolve_iand (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
976 /* If the kind of i and j are different, then g77 cross-promoted the
977 kinds to the largest value. The Fortran 95 standard requires the
979 if (i
->ts
.kind
!= j
->ts
.kind
)
981 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
982 gfc_convert_type (j
, &i
->ts
, 2);
984 gfc_convert_type (i
, &j
->ts
, 2);
988 f
->value
.function
.name
= gfc_get_string ("__iand_%d", i
->ts
.kind
);
993 gfc_resolve_ibclr (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos ATTRIBUTE_UNUSED
)
996 f
->value
.function
.name
= gfc_get_string ("__ibclr_%d", i
->ts
.kind
);
1001 gfc_resolve_ibits (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos ATTRIBUTE_UNUSED
,
1002 gfc_expr
*len ATTRIBUTE_UNUSED
)
1005 f
->value
.function
.name
= gfc_get_string ("__ibits_%d", i
->ts
.kind
);
1010 gfc_resolve_ibset (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos ATTRIBUTE_UNUSED
)
1013 f
->value
.function
.name
= gfc_get_string ("__ibset_%d", i
->ts
.kind
);
1018 gfc_resolve_iachar (gfc_expr
*f
, gfc_expr
*c
, gfc_expr
*kind
)
1020 f
->ts
.type
= BT_INTEGER
;
1022 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1024 f
->ts
.kind
= gfc_default_integer_kind
;
1025 f
->value
.function
.name
= gfc_get_string ("__ichar_%d", c
->ts
.kind
);
1030 gfc_resolve_ichar (gfc_expr
*f
, gfc_expr
*c
, gfc_expr
*kind
)
1032 f
->ts
.type
= BT_INTEGER
;
1034 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1036 f
->ts
.kind
= gfc_default_integer_kind
;
1037 f
->value
.function
.name
= gfc_get_string ("__ichar_%d", c
->ts
.kind
);
1042 gfc_resolve_idnint (gfc_expr
*f
, gfc_expr
*a
)
1044 gfc_resolve_nint (f
, a
, NULL
);
1049 gfc_resolve_ierrno (gfc_expr
*f
)
1051 f
->ts
.type
= BT_INTEGER
;
1052 f
->ts
.kind
= gfc_default_integer_kind
;
1053 f
->value
.function
.name
= gfc_get_string (PREFIX ("ierrno_i%d"), f
->ts
.kind
);
1058 gfc_resolve_ieor (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
1060 /* If the kind of i and j are different, then g77 cross-promoted the
1061 kinds to the largest value. The Fortran 95 standard requires the
1063 if (i
->ts
.kind
!= j
->ts
.kind
)
1065 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
1066 gfc_convert_type (j
, &i
->ts
, 2);
1068 gfc_convert_type (i
, &j
->ts
, 2);
1072 f
->value
.function
.name
= gfc_get_string ("__ieor_%d", i
->ts
.kind
);
1077 gfc_resolve_ior (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
1079 /* If the kind of i and j are different, then g77 cross-promoted the
1080 kinds to the largest value. The Fortran 95 standard requires the
1082 if (i
->ts
.kind
!= j
->ts
.kind
)
1084 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
1085 gfc_convert_type (j
, &i
->ts
, 2);
1087 gfc_convert_type (i
, &j
->ts
, 2);
1091 f
->value
.function
.name
= gfc_get_string ("__ior_%d", i
->ts
.kind
);
1096 gfc_resolve_index_func (gfc_expr
*f
, gfc_expr
*str
,
1097 gfc_expr
*sub_str ATTRIBUTE_UNUSED
, gfc_expr
*back
,
1103 f
->ts
.type
= BT_INTEGER
;
1105 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1107 f
->ts
.kind
= gfc_default_integer_kind
;
1109 if (back
&& back
->ts
.kind
!= gfc_default_integer_kind
)
1111 ts
.type
= BT_LOGICAL
;
1112 ts
.kind
= gfc_default_integer_kind
;
1113 ts
.u
.derived
= NULL
;
1115 gfc_convert_type (back
, &ts
, 2);
1118 f
->value
.function
.name
1119 = gfc_get_string ("__index_%d_i%d", str
->ts
.kind
, f
->ts
.kind
);
1124 gfc_resolve_int (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
1126 f
->ts
.type
= BT_INTEGER
;
1127 f
->ts
.kind
= (kind
== NULL
)
1128 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
1129 f
->value
.function
.name
1130 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1131 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1136 gfc_resolve_int2 (gfc_expr
*f
, gfc_expr
*a
)
1138 f
->ts
.type
= BT_INTEGER
;
1140 f
->value
.function
.name
1141 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1142 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1147 gfc_resolve_int8 (gfc_expr
*f
, gfc_expr
*a
)
1149 f
->ts
.type
= BT_INTEGER
;
1151 f
->value
.function
.name
1152 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1153 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1158 gfc_resolve_long (gfc_expr
*f
, gfc_expr
*a
)
1160 f
->ts
.type
= BT_INTEGER
;
1162 f
->value
.function
.name
1163 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1164 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1169 gfc_resolve_isatty (gfc_expr
*f
, gfc_expr
*u
)
1174 f
->ts
.type
= BT_LOGICAL
;
1175 f
->ts
.kind
= gfc_default_integer_kind
;
1176 if (u
->ts
.kind
!= gfc_c_int_kind
)
1178 ts
.type
= BT_INTEGER
;
1179 ts
.kind
= gfc_c_int_kind
;
1180 ts
.u
.derived
= NULL
;
1182 gfc_convert_type (u
, &ts
, 2);
1185 f
->value
.function
.name
= gfc_get_string (PREFIX ("isatty_l%d"), f
->ts
.kind
);
1190 gfc_resolve_ishft (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
)
1193 f
->value
.function
.name
1194 = gfc_get_string ("__ishft_%d_%d", i
->ts
.kind
, shift
->ts
.kind
);
1199 gfc_resolve_rshift (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
)
1202 f
->value
.function
.name
1203 = gfc_get_string ("__rshift_%d_%d", i
->ts
.kind
, shift
->ts
.kind
);
1208 gfc_resolve_lshift (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
)
1211 f
->value
.function
.name
1212 = gfc_get_string ("__lshift_%d_%d", i
->ts
.kind
, shift
->ts
.kind
);
1217 gfc_resolve_ishftc (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
, gfc_expr
*size
)
1221 s_kind
= (size
== NULL
) ? gfc_default_integer_kind
: size
->ts
.kind
;
1224 f
->value
.function
.name
1225 = gfc_get_string ("__ishftc_%d_%d_%d", i
->ts
.kind
, shift
->ts
.kind
, s_kind
);
1230 gfc_resolve_kill (gfc_expr
*f
, gfc_expr
*p ATTRIBUTE_UNUSED
,
1231 gfc_expr
*s ATTRIBUTE_UNUSED
)
1233 f
->ts
.type
= BT_INTEGER
;
1234 f
->ts
.kind
= gfc_default_integer_kind
;
1235 f
->value
.function
.name
= gfc_get_string (PREFIX ("kill_i%d"), f
->ts
.kind
);
1240 gfc_resolve_lbound (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
1242 static char lbound
[] = "__lbound";
1244 f
->ts
.type
= BT_INTEGER
;
1246 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1248 f
->ts
.kind
= gfc_default_integer_kind
;
1253 f
->shape
= gfc_get_shape (1);
1254 mpz_init_set_ui (f
->shape
[0], array
->rank
);
1257 f
->value
.function
.name
= lbound
;
1262 gfc_resolve_len (gfc_expr
*f
, gfc_expr
*string
, gfc_expr
*kind
)
1264 f
->ts
.type
= BT_INTEGER
;
1266 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1268 f
->ts
.kind
= gfc_default_integer_kind
;
1269 f
->value
.function
.name
1270 = gfc_get_string ("__len_%d_i%d", string
->ts
.kind
,
1271 gfc_default_integer_kind
);
1276 gfc_resolve_len_trim (gfc_expr
*f
, gfc_expr
*string
, gfc_expr
*kind
)
1278 f
->ts
.type
= BT_INTEGER
;
1280 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1282 f
->ts
.kind
= gfc_default_integer_kind
;
1283 f
->value
.function
.name
= gfc_get_string ("__len_trim%d", string
->ts
.kind
);
1288 gfc_resolve_lgamma (gfc_expr
*f
, gfc_expr
*x
)
1291 f
->value
.function
.name
1292 = gfc_get_string ("__lgamma_%d", x
->ts
.kind
);
1297 gfc_resolve_link (gfc_expr
*f
, gfc_expr
*p1 ATTRIBUTE_UNUSED
,
1298 gfc_expr
*p2 ATTRIBUTE_UNUSED
)
1300 f
->ts
.type
= BT_INTEGER
;
1301 f
->ts
.kind
= gfc_default_integer_kind
;
1302 f
->value
.function
.name
= gfc_get_string (PREFIX ("link_i%d"), f
->ts
.kind
);
1307 gfc_resolve_loc (gfc_expr
*f
, gfc_expr
*x
)
1309 f
->ts
.type
= BT_INTEGER
;
1310 f
->ts
.kind
= gfc_index_integer_kind
;
1311 f
->value
.function
.name
= gfc_get_string ("__loc_%d", x
->ts
.kind
);
1316 gfc_resolve_log (gfc_expr
*f
, gfc_expr
*x
)
1319 f
->value
.function
.name
1320 = gfc_get_string ("__log_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
1325 gfc_resolve_log10 (gfc_expr
*f
, gfc_expr
*x
)
1328 f
->value
.function
.name
1329 = gfc_get_string ("__log10_%c%d", gfc_type_letter (x
->ts
.type
),
1335 gfc_resolve_logical (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
1337 f
->ts
.type
= BT_LOGICAL
;
1338 f
->ts
.kind
= (kind
== NULL
)
1339 ? gfc_default_logical_kind
: mpz_get_si (kind
->value
.integer
);
1342 f
->value
.function
.name
1343 = gfc_get_string ("__logical_%d_%c%d", f
->ts
.kind
,
1344 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1349 gfc_resolve_malloc (gfc_expr
*f
, gfc_expr
*size
)
1351 if (size
->ts
.kind
< gfc_index_integer_kind
)
1356 ts
.type
= BT_INTEGER
;
1357 ts
.kind
= gfc_index_integer_kind
;
1358 gfc_convert_type_warn (size
, &ts
, 2, 0);
1361 f
->ts
.type
= BT_INTEGER
;
1362 f
->ts
.kind
= gfc_index_integer_kind
;
1363 f
->value
.function
.name
= gfc_get_string (PREFIX ("malloc"));
1368 gfc_resolve_matmul (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*b
)
1372 if (a
->ts
.type
== BT_LOGICAL
&& b
->ts
.type
== BT_LOGICAL
)
1374 f
->ts
.type
= BT_LOGICAL
;
1375 f
->ts
.kind
= gfc_default_logical_kind
;
1379 temp
.expr_type
= EXPR_OP
;
1380 gfc_clear_ts (&temp
.ts
);
1381 temp
.value
.op
.op
= INTRINSIC_NONE
;
1382 temp
.value
.op
.op1
= a
;
1383 temp
.value
.op
.op2
= b
;
1384 gfc_type_convert_binary (&temp
, 1);
1388 f
->rank
= (a
->rank
== 2 && b
->rank
== 2) ? 2 : 1;
1390 if (a
->rank
== 2 && b
->rank
== 2)
1392 if (a
->shape
&& b
->shape
)
1394 f
->shape
= gfc_get_shape (f
->rank
);
1395 mpz_init_set (f
->shape
[0], a
->shape
[0]);
1396 mpz_init_set (f
->shape
[1], b
->shape
[1]);
1399 else if (a
->rank
== 1)
1403 f
->shape
= gfc_get_shape (f
->rank
);
1404 mpz_init_set (f
->shape
[0], b
->shape
[1]);
1409 /* b->rank == 1 and a->rank == 2 here, all other cases have
1410 been caught in check.c. */
1413 f
->shape
= gfc_get_shape (f
->rank
);
1414 mpz_init_set (f
->shape
[0], a
->shape
[0]);
1418 f
->value
.function
.name
1419 = gfc_get_string (PREFIX ("matmul_%c%d"), gfc_type_letter (f
->ts
.type
),
1425 gfc_resolve_minmax (const char *name
, gfc_expr
*f
, gfc_actual_arglist
*args
)
1427 gfc_actual_arglist
*a
;
1429 f
->ts
.type
= args
->expr
->ts
.type
;
1430 f
->ts
.kind
= args
->expr
->ts
.kind
;
1431 /* Find the largest type kind. */
1432 for (a
= args
->next
; a
; a
= a
->next
)
1434 if (a
->expr
->ts
.kind
> f
->ts
.kind
)
1435 f
->ts
.kind
= a
->expr
->ts
.kind
;
1438 /* Convert all parameters to the required kind. */
1439 for (a
= args
; a
; a
= a
->next
)
1441 if (a
->expr
->ts
.kind
!= f
->ts
.kind
)
1442 gfc_convert_type (a
->expr
, &f
->ts
, 2);
1445 f
->value
.function
.name
1446 = gfc_get_string (name
, gfc_type_letter (f
->ts
.type
), f
->ts
.kind
);
1451 gfc_resolve_max (gfc_expr
*f
, gfc_actual_arglist
*args
)
1453 gfc_resolve_minmax ("__max_%c%d", f
, args
);
1458 gfc_resolve_maxloc (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
1464 f
->ts
.type
= BT_INTEGER
;
1465 f
->ts
.kind
= gfc_default_integer_kind
;
1470 f
->shape
= gfc_get_shape (1);
1471 mpz_init_set_si (f
->shape
[0], array
->rank
);
1475 f
->rank
= array
->rank
- 1;
1476 gfc_resolve_dim_arg (dim
);
1477 if (array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
1479 idim
= (int) mpz_get_si (dim
->value
.integer
);
1480 f
->shape
= gfc_get_shape (f
->rank
);
1481 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
1483 if (i
== (idim
- 1))
1485 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
1492 if (mask
->rank
== 0)
1497 resolve_mask_arg (mask
);
1502 f
->value
.function
.name
1503 = gfc_get_string (PREFIX ("%s%d_%d_%c%d"), name
, dim
!= NULL
, f
->ts
.kind
,
1504 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1509 gfc_resolve_maxval (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
1519 f
->rank
= array
->rank
- 1;
1520 gfc_resolve_dim_arg (dim
);
1522 if (f
->rank
&& array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
1524 idim
= (int) mpz_get_si (dim
->value
.integer
);
1525 f
->shape
= gfc_get_shape (f
->rank
);
1526 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
1528 if (i
== (idim
- 1))
1530 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
1537 if (mask
->rank
== 0)
1542 resolve_mask_arg (mask
);
1547 f
->value
.function
.name
1548 = gfc_get_string (PREFIX ("%s_%c%d"), name
,
1549 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1554 gfc_resolve_mclock (gfc_expr
*f
)
1556 f
->ts
.type
= BT_INTEGER
;
1558 f
->value
.function
.name
= PREFIX ("mclock");
1563 gfc_resolve_mclock8 (gfc_expr
*f
)
1565 f
->ts
.type
= BT_INTEGER
;
1567 f
->value
.function
.name
= PREFIX ("mclock8");
1572 gfc_resolve_merge (gfc_expr
*f
, gfc_expr
*tsource
,
1573 gfc_expr
*fsource ATTRIBUTE_UNUSED
,
1574 gfc_expr
*mask ATTRIBUTE_UNUSED
)
1576 if (tsource
->ts
.type
== BT_CHARACTER
&& tsource
->ref
)
1577 gfc_resolve_substring_charlen (tsource
);
1579 if (fsource
->ts
.type
== BT_CHARACTER
&& fsource
->ref
)
1580 gfc_resolve_substring_charlen (fsource
);
1582 if (tsource
->ts
.type
== BT_CHARACTER
)
1583 check_charlen_present (tsource
);
1585 f
->ts
= tsource
->ts
;
1586 f
->value
.function
.name
1587 = gfc_get_string ("__merge_%c%d", gfc_type_letter (tsource
->ts
.type
),
1593 gfc_resolve_min (gfc_expr
*f
, gfc_actual_arglist
*args
)
1595 gfc_resolve_minmax ("__min_%c%d", f
, args
);
1600 gfc_resolve_minloc (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
1606 f
->ts
.type
= BT_INTEGER
;
1607 f
->ts
.kind
= gfc_default_integer_kind
;
1612 f
->shape
= gfc_get_shape (1);
1613 mpz_init_set_si (f
->shape
[0], array
->rank
);
1617 f
->rank
= array
->rank
- 1;
1618 gfc_resolve_dim_arg (dim
);
1619 if (array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
1621 idim
= (int) mpz_get_si (dim
->value
.integer
);
1622 f
->shape
= gfc_get_shape (f
->rank
);
1623 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
1625 if (i
== (idim
- 1))
1627 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
1634 if (mask
->rank
== 0)
1639 resolve_mask_arg (mask
);
1644 f
->value
.function
.name
1645 = gfc_get_string (PREFIX ("%s%d_%d_%c%d"), name
, dim
!= NULL
, f
->ts
.kind
,
1646 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1651 gfc_resolve_minval (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
1661 f
->rank
= array
->rank
- 1;
1662 gfc_resolve_dim_arg (dim
);
1664 if (f
->rank
&& array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
1666 idim
= (int) mpz_get_si (dim
->value
.integer
);
1667 f
->shape
= gfc_get_shape (f
->rank
);
1668 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
1670 if (i
== (idim
- 1))
1672 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
1679 if (mask
->rank
== 0)
1684 resolve_mask_arg (mask
);
1689 f
->value
.function
.name
1690 = gfc_get_string (PREFIX ("%s_%c%d"), name
,
1691 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1696 gfc_resolve_mod (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p
)
1698 f
->ts
.type
= a
->ts
.type
;
1700 f
->ts
.kind
= gfc_kind_max (a
,p
);
1702 f
->ts
.kind
= a
->ts
.kind
;
1704 if (p
!= NULL
&& a
->ts
.kind
!= p
->ts
.kind
)
1706 if (a
->ts
.kind
== gfc_kind_max (a
,p
))
1707 gfc_convert_type (p
, &a
->ts
, 2);
1709 gfc_convert_type (a
, &p
->ts
, 2);
1712 f
->value
.function
.name
1713 = gfc_get_string ("__mod_%c%d", gfc_type_letter (f
->ts
.type
), f
->ts
.kind
);
1718 gfc_resolve_modulo (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p
)
1720 f
->ts
.type
= a
->ts
.type
;
1722 f
->ts
.kind
= gfc_kind_max (a
,p
);
1724 f
->ts
.kind
= a
->ts
.kind
;
1726 if (p
!= NULL
&& a
->ts
.kind
!= p
->ts
.kind
)
1728 if (a
->ts
.kind
== gfc_kind_max (a
,p
))
1729 gfc_convert_type (p
, &a
->ts
, 2);
1731 gfc_convert_type (a
, &p
->ts
, 2);
1734 f
->value
.function
.name
1735 = gfc_get_string ("__modulo_%c%d", gfc_type_letter (f
->ts
.type
),
1740 gfc_resolve_nearest (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p
)
1742 if (p
->ts
.kind
!= a
->ts
.kind
)
1743 gfc_convert_type (p
, &a
->ts
, 2);
1746 f
->value
.function
.name
1747 = gfc_get_string ("__nearest_%c%d", gfc_type_letter (a
->ts
.type
),
1752 gfc_resolve_nint (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
1754 f
->ts
.type
= BT_INTEGER
;
1755 f
->ts
.kind
= (kind
== NULL
)
1756 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
1757 f
->value
.function
.name
1758 = gfc_get_string ("__nint_%d_%d", f
->ts
.kind
, a
->ts
.kind
);
1763 gfc_resolve_not (gfc_expr
*f
, gfc_expr
*i
)
1766 f
->value
.function
.name
= gfc_get_string ("__not_%d", i
->ts
.kind
);
1771 gfc_resolve_or (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
1773 f
->ts
.type
= i
->ts
.type
;
1774 f
->ts
.kind
= gfc_kind_max (i
, j
);
1776 if (i
->ts
.kind
!= j
->ts
.kind
)
1778 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
1779 gfc_convert_type (j
, &i
->ts
, 2);
1781 gfc_convert_type (i
, &j
->ts
, 2);
1784 f
->value
.function
.name
1785 = gfc_get_string ("__or_%c%d", gfc_type_letter (i
->ts
.type
), f
->ts
.kind
);
1790 gfc_resolve_pack (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*mask
,
1791 gfc_expr
*vector ATTRIBUTE_UNUSED
)
1793 if (array
->ts
.type
== BT_CHARACTER
&& array
->ref
)
1794 gfc_resolve_substring_charlen (array
);
1799 resolve_mask_arg (mask
);
1801 if (mask
->rank
!= 0)
1803 if (array
->ts
.type
== BT_CHARACTER
)
1804 f
->value
.function
.name
1805 = array
->ts
.kind
== 1 ? PREFIX ("pack_char")
1807 (PREFIX ("pack_char%d"),
1810 f
->value
.function
.name
= PREFIX ("pack");
1814 if (array
->ts
.type
== BT_CHARACTER
)
1815 f
->value
.function
.name
1816 = array
->ts
.kind
== 1 ? PREFIX ("pack_s_char")
1818 (PREFIX ("pack_s_char%d"),
1821 f
->value
.function
.name
= PREFIX ("pack_s");
1827 gfc_resolve_product (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
1836 f
->rank
= array
->rank
- 1;
1837 f
->shape
= gfc_copy_shape_excluding (array
->shape
, array
->rank
, dim
);
1838 gfc_resolve_dim_arg (dim
);
1843 if (mask
->rank
== 0)
1848 resolve_mask_arg (mask
);
1853 f
->value
.function
.name
1854 = gfc_get_string (PREFIX ("%s_%c%d"), name
,
1855 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1860 gfc_resolve_real (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
1862 f
->ts
.type
= BT_REAL
;
1865 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1867 f
->ts
.kind
= (a
->ts
.type
== BT_COMPLEX
)
1868 ? a
->ts
.kind
: gfc_default_real_kind
;
1870 f
->value
.function
.name
1871 = gfc_get_string ("__real_%d_%c%d", f
->ts
.kind
,
1872 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1877 gfc_resolve_realpart (gfc_expr
*f
, gfc_expr
*a
)
1879 f
->ts
.type
= BT_REAL
;
1880 f
->ts
.kind
= a
->ts
.kind
;
1881 f
->value
.function
.name
1882 = gfc_get_string ("__real_%d_%c%d", f
->ts
.kind
,
1883 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1888 gfc_resolve_rename (gfc_expr
*f
, gfc_expr
*p1 ATTRIBUTE_UNUSED
,
1889 gfc_expr
*p2 ATTRIBUTE_UNUSED
)
1891 f
->ts
.type
= BT_INTEGER
;
1892 f
->ts
.kind
= gfc_default_integer_kind
;
1893 f
->value
.function
.name
= gfc_get_string (PREFIX ("rename_i%d"), f
->ts
.kind
);
1898 gfc_resolve_repeat (gfc_expr
*f
, gfc_expr
*string
,
1899 gfc_expr
*ncopies ATTRIBUTE_UNUSED
)
1901 f
->ts
.type
= BT_CHARACTER
;
1902 f
->ts
.kind
= string
->ts
.kind
;
1903 f
->value
.function
.name
= gfc_get_string ("__repeat_%d", string
->ts
.kind
);
1908 gfc_resolve_reshape (gfc_expr
*f
, gfc_expr
*source
, gfc_expr
*shape
,
1909 gfc_expr
*pad ATTRIBUTE_UNUSED
,
1910 gfc_expr
*order ATTRIBUTE_UNUSED
)
1916 if (source
->ts
.type
== BT_CHARACTER
&& source
->ref
)
1917 gfc_resolve_substring_charlen (source
);
1921 gfc_array_size (shape
, &rank
);
1922 f
->rank
= mpz_get_si (rank
);
1924 switch (source
->ts
.type
)
1931 kind
= source
->ts
.kind
;
1945 if (source
->ts
.type
== BT_COMPLEX
|| source
->ts
.type
== BT_REAL
)
1946 f
->value
.function
.name
1947 = gfc_get_string (PREFIX ("reshape_%c%d"),
1948 gfc_type_letter (source
->ts
.type
),
1950 else if (source
->ts
.type
== BT_CHARACTER
)
1951 f
->value
.function
.name
= gfc_get_string (PREFIX ("reshape_char%d"),
1954 f
->value
.function
.name
1955 = gfc_get_string (PREFIX ("reshape_%d"), source
->ts
.kind
);
1959 f
->value
.function
.name
= (source
->ts
.type
== BT_CHARACTER
1960 ? PREFIX ("reshape_char") : PREFIX ("reshape"));
1964 /* TODO: Make this work with a constant ORDER parameter. */
1965 if (shape
->expr_type
== EXPR_ARRAY
1966 && gfc_is_constant_expr (shape
)
1970 f
->shape
= gfc_get_shape (f
->rank
);
1971 c
= shape
->value
.constructor
;
1972 for (i
= 0; i
< f
->rank
; i
++)
1974 mpz_init_set (f
->shape
[i
], c
->expr
->value
.integer
);
1979 /* Force-convert both SHAPE and ORDER to index_kind so that we don't need
1980 so many runtime variations. */
1981 if (shape
->ts
.kind
!= gfc_index_integer_kind
)
1983 gfc_typespec ts
= shape
->ts
;
1984 ts
.kind
= gfc_index_integer_kind
;
1985 gfc_convert_type_warn (shape
, &ts
, 2, 0);
1987 if (order
&& order
->ts
.kind
!= gfc_index_integer_kind
)
1988 gfc_convert_type_warn (order
, &shape
->ts
, 2, 0);
1993 gfc_resolve_rrspacing (gfc_expr
*f
, gfc_expr
*x
)
1996 f
->value
.function
.name
= gfc_get_string ("__rrspacing_%d", x
->ts
.kind
);
2001 gfc_resolve_scale (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*i ATTRIBUTE_UNUSED
)
2004 f
->value
.function
.name
= gfc_get_string ("__scale_%d", x
->ts
.kind
);
2009 gfc_resolve_scan (gfc_expr
*f
, gfc_expr
*string
,
2010 gfc_expr
*set ATTRIBUTE_UNUSED
,
2011 gfc_expr
*back ATTRIBUTE_UNUSED
, gfc_expr
*kind
)
2013 f
->ts
.type
= BT_INTEGER
;
2015 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2017 f
->ts
.kind
= gfc_default_integer_kind
;
2018 f
->value
.function
.name
= gfc_get_string ("__scan_%d", string
->ts
.kind
);
2023 gfc_resolve_secnds (gfc_expr
*t1
, gfc_expr
*t0
)
2026 t1
->value
.function
.name
= gfc_get_string (PREFIX ("secnds"));
2031 gfc_resolve_set_exponent (gfc_expr
*f
, gfc_expr
*x
,
2032 gfc_expr
*i ATTRIBUTE_UNUSED
)
2035 f
->value
.function
.name
= gfc_get_string ("__set_exponent_%d", x
->ts
.kind
);
2040 gfc_resolve_shape (gfc_expr
*f
, gfc_expr
*array
)
2042 f
->ts
.type
= BT_INTEGER
;
2043 f
->ts
.kind
= gfc_default_integer_kind
;
2045 f
->shape
= gfc_get_shape (1);
2046 mpz_init_set_ui (f
->shape
[0], array
->rank
);
2047 f
->value
.function
.name
= gfc_get_string (PREFIX ("shape_%d"), f
->ts
.kind
);
2052 gfc_resolve_sign (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*b ATTRIBUTE_UNUSED
)
2055 f
->value
.function
.name
2056 = gfc_get_string ("__sign_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
2061 gfc_resolve_signal (gfc_expr
*f
, gfc_expr
*number
, gfc_expr
*handler
)
2063 f
->ts
.type
= BT_INTEGER
;
2064 f
->ts
.kind
= gfc_c_int_kind
;
2066 /* handler can be either BT_INTEGER or BT_PROCEDURE */
2067 if (handler
->ts
.type
== BT_INTEGER
)
2069 if (handler
->ts
.kind
!= gfc_c_int_kind
)
2070 gfc_convert_type (handler
, &f
->ts
, 2);
2071 f
->value
.function
.name
= gfc_get_string (PREFIX ("signal_func_int"));
2074 f
->value
.function
.name
= gfc_get_string (PREFIX ("signal_func"));
2076 if (number
->ts
.kind
!= gfc_c_int_kind
)
2077 gfc_convert_type (number
, &f
->ts
, 2);
2082 gfc_resolve_sin (gfc_expr
*f
, gfc_expr
*x
)
2085 f
->value
.function
.name
2086 = gfc_get_string ("__sin_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
2091 gfc_resolve_sinh (gfc_expr
*f
, gfc_expr
*x
)
2094 f
->value
.function
.name
2095 = gfc_get_string ("__sinh_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
2100 gfc_resolve_size (gfc_expr
*f
, gfc_expr
*array ATTRIBUTE_UNUSED
,
2101 gfc_expr
*dim ATTRIBUTE_UNUSED
, gfc_expr
*kind
)
2103 f
->ts
.type
= BT_INTEGER
;
2105 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2107 f
->ts
.kind
= gfc_default_integer_kind
;
2112 gfc_resolve_spacing (gfc_expr
*f
, gfc_expr
*x
)
2115 f
->value
.function
.name
= gfc_get_string ("__spacing_%d", x
->ts
.kind
);
2120 gfc_resolve_spread (gfc_expr
*f
, gfc_expr
*source
, gfc_expr
*dim
,
2123 if (source
->ts
.type
== BT_CHARACTER
&& source
->ref
)
2124 gfc_resolve_substring_charlen (source
);
2126 if (source
->ts
.type
== BT_CHARACTER
)
2127 check_charlen_present (source
);
2130 f
->rank
= source
->rank
+ 1;
2131 if (source
->rank
== 0)
2133 if (source
->ts
.type
== BT_CHARACTER
)
2134 f
->value
.function
.name
2135 = source
->ts
.kind
== 1 ? PREFIX ("spread_char_scalar")
2137 (PREFIX ("spread_char%d_scalar"),
2140 f
->value
.function
.name
= PREFIX ("spread_scalar");
2144 if (source
->ts
.type
== BT_CHARACTER
)
2145 f
->value
.function
.name
2146 = source
->ts
.kind
== 1 ? PREFIX ("spread_char")
2148 (PREFIX ("spread_char%d"),
2151 f
->value
.function
.name
= PREFIX ("spread");
2154 if (dim
&& gfc_is_constant_expr (dim
)
2155 && ncopies
&& gfc_is_constant_expr (ncopies
) && source
->shape
[0])
2158 idim
= mpz_get_ui (dim
->value
.integer
);
2159 f
->shape
= gfc_get_shape (f
->rank
);
2160 for (i
= 0; i
< (idim
- 1); i
++)
2161 mpz_init_set (f
->shape
[i
], source
->shape
[i
]);
2163 mpz_init_set (f
->shape
[idim
- 1], ncopies
->value
.integer
);
2165 for (i
= idim
; i
< f
->rank
; i
++)
2166 mpz_init_set (f
->shape
[i
], source
->shape
[i
-1]);
2170 gfc_resolve_dim_arg (dim
);
2171 gfc_resolve_index (ncopies
, 1);
2176 gfc_resolve_sqrt (gfc_expr
*f
, gfc_expr
*x
)
2179 f
->value
.function
.name
2180 = gfc_get_string ("__sqrt_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
2184 /* Resolve the g77 compatibility function STAT AND FSTAT. */
2187 gfc_resolve_stat (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
,
2188 gfc_expr
*a ATTRIBUTE_UNUSED
)
2190 f
->ts
.type
= BT_INTEGER
;
2191 f
->ts
.kind
= gfc_default_integer_kind
;
2192 f
->value
.function
.name
= gfc_get_string (PREFIX ("stat_i%d"), f
->ts
.kind
);
2197 gfc_resolve_lstat (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
,
2198 gfc_expr
*a ATTRIBUTE_UNUSED
)
2200 f
->ts
.type
= BT_INTEGER
;
2201 f
->ts
.kind
= gfc_default_integer_kind
;
2202 f
->value
.function
.name
= gfc_get_string (PREFIX ("lstat_i%d"), f
->ts
.kind
);
2207 gfc_resolve_fstat (gfc_expr
*f
, gfc_expr
*n
, gfc_expr
*a ATTRIBUTE_UNUSED
)
2209 f
->ts
.type
= BT_INTEGER
;
2210 f
->ts
.kind
= gfc_default_integer_kind
;
2211 if (n
->ts
.kind
!= f
->ts
.kind
)
2212 gfc_convert_type (n
, &f
->ts
, 2);
2214 f
->value
.function
.name
= gfc_get_string (PREFIX ("fstat_i%d"), f
->ts
.kind
);
2219 gfc_resolve_fgetc (gfc_expr
*f
, gfc_expr
*u
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2224 f
->ts
.type
= BT_INTEGER
;
2225 f
->ts
.kind
= gfc_c_int_kind
;
2226 if (u
->ts
.kind
!= gfc_c_int_kind
)
2228 ts
.type
= BT_INTEGER
;
2229 ts
.kind
= gfc_c_int_kind
;
2230 ts
.u
.derived
= NULL
;
2232 gfc_convert_type (u
, &ts
, 2);
2235 f
->value
.function
.name
= gfc_get_string (PREFIX ("fgetc"));
2240 gfc_resolve_fget (gfc_expr
*f
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2242 f
->ts
.type
= BT_INTEGER
;
2243 f
->ts
.kind
= gfc_c_int_kind
;
2244 f
->value
.function
.name
= gfc_get_string (PREFIX ("fget"));
2249 gfc_resolve_fputc (gfc_expr
*f
, gfc_expr
*u
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2254 f
->ts
.type
= BT_INTEGER
;
2255 f
->ts
.kind
= gfc_c_int_kind
;
2256 if (u
->ts
.kind
!= gfc_c_int_kind
)
2258 ts
.type
= BT_INTEGER
;
2259 ts
.kind
= gfc_c_int_kind
;
2260 ts
.u
.derived
= NULL
;
2262 gfc_convert_type (u
, &ts
, 2);
2265 f
->value
.function
.name
= gfc_get_string (PREFIX ("fputc"));
2270 gfc_resolve_fput (gfc_expr
*f
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2272 f
->ts
.type
= BT_INTEGER
;
2273 f
->ts
.kind
= gfc_c_int_kind
;
2274 f
->value
.function
.name
= gfc_get_string (PREFIX ("fput"));
2279 gfc_resolve_ftell (gfc_expr
*f
, gfc_expr
*u
)
2284 f
->ts
.type
= BT_INTEGER
;
2285 f
->ts
.kind
= gfc_index_integer_kind
;
2286 if (u
->ts
.kind
!= gfc_c_int_kind
)
2288 ts
.type
= BT_INTEGER
;
2289 ts
.kind
= gfc_c_int_kind
;
2290 ts
.u
.derived
= NULL
;
2292 gfc_convert_type (u
, &ts
, 2);
2295 f
->value
.function
.name
= gfc_get_string (PREFIX ("ftell"));
2300 gfc_resolve_sum (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*mask
)
2308 if (mask
->rank
== 0)
2313 resolve_mask_arg (mask
);
2320 f
->rank
= array
->rank
- 1;
2321 f
->shape
= gfc_copy_shape_excluding (array
->shape
, array
->rank
, dim
);
2322 gfc_resolve_dim_arg (dim
);
2325 f
->value
.function
.name
2326 = gfc_get_string (PREFIX ("%s_%c%d"), name
,
2327 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
2332 gfc_resolve_symlnk (gfc_expr
*f
, gfc_expr
*p1 ATTRIBUTE_UNUSED
,
2333 gfc_expr
*p2 ATTRIBUTE_UNUSED
)
2335 f
->ts
.type
= BT_INTEGER
;
2336 f
->ts
.kind
= gfc_default_integer_kind
;
2337 f
->value
.function
.name
= gfc_get_string (PREFIX ("symlnk_i%d"), f
->ts
.kind
);
2341 /* Resolve the g77 compatibility function SYSTEM. */
2344 gfc_resolve_system (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
2346 f
->ts
.type
= BT_INTEGER
;
2348 f
->value
.function
.name
= gfc_get_string (PREFIX ("system"));
2353 gfc_resolve_tan (gfc_expr
*f
, gfc_expr
*x
)
2356 f
->value
.function
.name
2357 = gfc_get_string ("__tan_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
2362 gfc_resolve_tanh (gfc_expr
*f
, gfc_expr
*x
)
2365 f
->value
.function
.name
2366 = gfc_get_string ("__tanh_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
2371 gfc_resolve_time (gfc_expr
*f
)
2373 f
->ts
.type
= BT_INTEGER
;
2375 f
->value
.function
.name
= gfc_get_string (PREFIX ("time_func"));
2380 gfc_resolve_time8 (gfc_expr
*f
)
2382 f
->ts
.type
= BT_INTEGER
;
2384 f
->value
.function
.name
= gfc_get_string (PREFIX ("time8_func"));
2389 gfc_resolve_transfer (gfc_expr
*f
, gfc_expr
*source ATTRIBUTE_UNUSED
,
2390 gfc_expr
*mold
, gfc_expr
*size
)
2392 /* TODO: Make this do something meaningful. */
2393 static char transfer0
[] = "__transfer0", transfer1
[] = "__transfer1";
2395 if (mold
->ts
.type
== BT_CHARACTER
2396 && !mold
->ts
.u
.cl
->length
2397 && gfc_is_constant_expr (mold
))
2400 if (mold
->expr_type
== EXPR_CONSTANT
)
2401 mold
->ts
.u
.cl
->length
= gfc_int_expr (mold
->value
.character
.length
);
2404 len
= mold
->value
.constructor
->expr
->value
.character
.length
;
2405 mold
->ts
.u
.cl
->length
= gfc_int_expr (len
);
2411 if (size
== NULL
&& mold
->rank
== 0)
2414 f
->value
.function
.name
= transfer0
;
2419 f
->value
.function
.name
= transfer1
;
2420 if (size
&& gfc_is_constant_expr (size
))
2422 f
->shape
= gfc_get_shape (1);
2423 mpz_init_set (f
->shape
[0], size
->value
.integer
);
2430 gfc_resolve_transpose (gfc_expr
*f
, gfc_expr
*matrix
)
2433 if (matrix
->ts
.type
== BT_CHARACTER
&& matrix
->ref
)
2434 gfc_resolve_substring_charlen (matrix
);
2440 f
->shape
= gfc_get_shape (2);
2441 mpz_init_set (f
->shape
[0], matrix
->shape
[1]);
2442 mpz_init_set (f
->shape
[1], matrix
->shape
[0]);
2445 switch (matrix
->ts
.kind
)
2451 switch (matrix
->ts
.type
)
2455 f
->value
.function
.name
2456 = gfc_get_string (PREFIX ("transpose_%c%d"),
2457 gfc_type_letter (matrix
->ts
.type
),
2463 /* Use the integer routines for real and logical cases. This
2464 assumes they all have the same alignment requirements. */
2465 f
->value
.function
.name
2466 = gfc_get_string (PREFIX ("transpose_i%d"), matrix
->ts
.kind
);
2470 if (matrix
->ts
.type
== BT_CHARACTER
&& matrix
->ts
.kind
== 4)
2471 f
->value
.function
.name
= PREFIX ("transpose_char4");
2473 f
->value
.function
.name
= PREFIX ("transpose");
2479 f
->value
.function
.name
= (matrix
->ts
.type
== BT_CHARACTER
2480 ? PREFIX ("transpose_char")
2481 : PREFIX ("transpose"));
2488 gfc_resolve_trim (gfc_expr
*f
, gfc_expr
*string
)
2490 f
->ts
.type
= BT_CHARACTER
;
2491 f
->ts
.kind
= string
->ts
.kind
;
2492 f
->value
.function
.name
= gfc_get_string ("__trim_%d", string
->ts
.kind
);
2497 gfc_resolve_ubound (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
2499 static char ubound
[] = "__ubound";
2501 f
->ts
.type
= BT_INTEGER
;
2503 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2505 f
->ts
.kind
= gfc_default_integer_kind
;
2510 f
->shape
= gfc_get_shape (1);
2511 mpz_init_set_ui (f
->shape
[0], array
->rank
);
2514 f
->value
.function
.name
= ubound
;
2518 /* Resolve the g77 compatibility function UMASK. */
2521 gfc_resolve_umask (gfc_expr
*f
, gfc_expr
*n
)
2523 f
->ts
.type
= BT_INTEGER
;
2524 f
->ts
.kind
= n
->ts
.kind
;
2525 f
->value
.function
.name
= gfc_get_string (PREFIX ("umask_i%d"), n
->ts
.kind
);
2529 /* Resolve the g77 compatibility function UNLINK. */
2532 gfc_resolve_unlink (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
2534 f
->ts
.type
= BT_INTEGER
;
2536 f
->value
.function
.name
= gfc_get_string (PREFIX ("unlink"));
2541 gfc_resolve_ttynam (gfc_expr
*f
, gfc_expr
*unit
)
2546 f
->ts
.type
= BT_CHARACTER
;
2547 f
->ts
.kind
= gfc_default_character_kind
;
2549 if (unit
->ts
.kind
!= gfc_c_int_kind
)
2551 ts
.type
= BT_INTEGER
;
2552 ts
.kind
= gfc_c_int_kind
;
2553 ts
.u
.derived
= NULL
;
2555 gfc_convert_type (unit
, &ts
, 2);
2558 f
->value
.function
.name
= gfc_get_string (PREFIX ("ttynam"));
2563 gfc_resolve_unpack (gfc_expr
*f
, gfc_expr
*vector
, gfc_expr
*mask
,
2564 gfc_expr
*field ATTRIBUTE_UNUSED
)
2566 if (vector
->ts
.type
== BT_CHARACTER
&& vector
->ref
)
2567 gfc_resolve_substring_charlen (vector
);
2570 f
->rank
= mask
->rank
;
2571 resolve_mask_arg (mask
);
2573 if (vector
->ts
.type
== BT_CHARACTER
)
2575 if (vector
->ts
.kind
== 1)
2576 f
->value
.function
.name
2577 = gfc_get_string (PREFIX ("unpack%d_char"), field
->rank
> 0 ? 1 : 0);
2579 f
->value
.function
.name
2580 = gfc_get_string (PREFIX ("unpack%d_char%d"),
2581 field
->rank
> 0 ? 1 : 0, vector
->ts
.kind
);
2584 f
->value
.function
.name
2585 = gfc_get_string (PREFIX ("unpack%d"), field
->rank
> 0 ? 1 : 0);
2590 gfc_resolve_verify (gfc_expr
*f
, gfc_expr
*string
,
2591 gfc_expr
*set ATTRIBUTE_UNUSED
,
2592 gfc_expr
*back ATTRIBUTE_UNUSED
, gfc_expr
*kind
)
2594 f
->ts
.type
= BT_INTEGER
;
2596 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2598 f
->ts
.kind
= gfc_default_integer_kind
;
2599 f
->value
.function
.name
= gfc_get_string ("__verify_%d", string
->ts
.kind
);
2604 gfc_resolve_xor (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
2606 f
->ts
.type
= i
->ts
.type
;
2607 f
->ts
.kind
= gfc_kind_max (i
, j
);
2609 if (i
->ts
.kind
!= j
->ts
.kind
)
2611 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
2612 gfc_convert_type (j
, &i
->ts
, 2);
2614 gfc_convert_type (i
, &j
->ts
, 2);
2617 f
->value
.function
.name
2618 = gfc_get_string ("__xor_%c%d", gfc_type_letter (i
->ts
.type
), f
->ts
.kind
);
2622 /* Intrinsic subroutine resolution. */
2625 gfc_resolve_alarm_sub (gfc_code
*c
)
2628 gfc_expr
*seconds
, *handler
;
2632 seconds
= c
->ext
.actual
->expr
;
2633 handler
= c
->ext
.actual
->next
->expr
;
2634 ts
.type
= BT_INTEGER
;
2635 ts
.kind
= gfc_c_int_kind
;
2637 /* handler can be either BT_INTEGER or BT_PROCEDURE.
2638 In all cases, the status argument is of default integer kind
2639 (enforced in check.c) so that the function suffix is fixed. */
2640 if (handler
->ts
.type
== BT_INTEGER
)
2642 if (handler
->ts
.kind
!= gfc_c_int_kind
)
2643 gfc_convert_type (handler
, &ts
, 2);
2644 name
= gfc_get_string (PREFIX ("alarm_sub_int_i%d"),
2645 gfc_default_integer_kind
);
2648 name
= gfc_get_string (PREFIX ("alarm_sub_i%d"),
2649 gfc_default_integer_kind
);
2651 if (seconds
->ts
.kind
!= gfc_c_int_kind
)
2652 gfc_convert_type (seconds
, &ts
, 2);
2654 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2658 gfc_resolve_cpu_time (gfc_code
*c
)
2661 name
= gfc_get_string (PREFIX ("cpu_time_%d"), c
->ext
.actual
->expr
->ts
.kind
);
2662 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2666 /* Create a formal arglist based on an actual one and set the INTENTs given. */
2668 static gfc_formal_arglist
*
2669 create_formal_for_intents (gfc_actual_arglist
* actual
, const sym_intent
* ints
)
2671 gfc_formal_arglist
* head
;
2672 gfc_formal_arglist
* tail
;
2678 head
= tail
= gfc_get_formal_arglist ();
2679 for (i
= 0; actual
; actual
= actual
->next
, tail
= tail
->next
, ++i
)
2683 sym
= gfc_new_symbol ("dummyarg", NULL
);
2684 sym
->ts
= actual
->expr
->ts
;
2686 sym
->attr
.intent
= ints
[i
];
2690 tail
->next
= gfc_get_formal_arglist ();
2698 gfc_resolve_mvbits (gfc_code
*c
)
2700 static const sym_intent INTENTS
[] = {INTENT_IN
, INTENT_IN
, INTENT_IN
,
2701 INTENT_INOUT
, INTENT_IN
};
2707 /* FROMPOS, LEN and TOPOS are restricted to small values. As such,
2708 they will be converted so that they fit into a C int. */
2709 ts
.type
= BT_INTEGER
;
2710 ts
.kind
= gfc_c_int_kind
;
2711 if (c
->ext
.actual
->next
->expr
->ts
.kind
!= gfc_c_int_kind
)
2712 gfc_convert_type (c
->ext
.actual
->next
->expr
, &ts
, 2);
2713 if (c
->ext
.actual
->next
->next
->expr
->ts
.kind
!= gfc_c_int_kind
)
2714 gfc_convert_type (c
->ext
.actual
->next
->next
->expr
, &ts
, 2);
2715 if (c
->ext
.actual
->next
->next
->next
->next
->expr
->ts
.kind
!= gfc_c_int_kind
)
2716 gfc_convert_type (c
->ext
.actual
->next
->next
->next
->next
->expr
, &ts
, 2);
2718 /* TO and FROM are guaranteed to have the same kind parameter. */
2719 name
= gfc_get_string (PREFIX ("mvbits_i%d"),
2720 c
->ext
.actual
->expr
->ts
.kind
);
2721 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2722 /* Mark as elemental subroutine as this does not happen automatically. */
2723 c
->resolved_sym
->attr
.elemental
= 1;
2725 /* Create a dummy formal arglist so the INTENTs are known later for purpose
2726 of creating temporaries. */
2727 c
->resolved_sym
->formal
= create_formal_for_intents (c
->ext
.actual
, INTENTS
);
2732 gfc_resolve_random_number (gfc_code
*c
)
2737 kind
= c
->ext
.actual
->expr
->ts
.kind
;
2738 if (c
->ext
.actual
->expr
->rank
== 0)
2739 name
= gfc_get_string (PREFIX ("random_r%d"), kind
);
2741 name
= gfc_get_string (PREFIX ("arandom_r%d"), kind
);
2743 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2748 gfc_resolve_random_seed (gfc_code
*c
)
2752 name
= gfc_get_string (PREFIX ("random_seed_i%d"), gfc_default_integer_kind
);
2753 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2758 gfc_resolve_rename_sub (gfc_code
*c
)
2763 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
2764 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
2766 kind
= gfc_default_integer_kind
;
2768 name
= gfc_get_string (PREFIX ("rename_i%d_sub"), kind
);
2769 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2774 gfc_resolve_kill_sub (gfc_code
*c
)
2779 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
2780 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
2782 kind
= gfc_default_integer_kind
;
2784 name
= gfc_get_string (PREFIX ("kill_i%d_sub"), kind
);
2785 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2790 gfc_resolve_link_sub (gfc_code
*c
)
2795 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
2796 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
2798 kind
= gfc_default_integer_kind
;
2800 name
= gfc_get_string (PREFIX ("link_i%d_sub"), kind
);
2801 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2806 gfc_resolve_symlnk_sub (gfc_code
*c
)
2811 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
2812 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
2814 kind
= gfc_default_integer_kind
;
2816 name
= gfc_get_string (PREFIX ("symlnk_i%d_sub"), kind
);
2817 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2821 /* G77 compatibility subroutines dtime() and etime(). */
2824 gfc_resolve_dtime_sub (gfc_code
*c
)
2827 name
= gfc_get_string (PREFIX ("dtime_sub"));
2828 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2832 gfc_resolve_etime_sub (gfc_code
*c
)
2835 name
= gfc_get_string (PREFIX ("etime_sub"));
2836 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2840 /* G77 compatibility subroutines itime(), idate(), ltime() and gmtime(). */
2843 gfc_resolve_itime (gfc_code
*c
)
2846 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("itime_i%d"),
2847 gfc_default_integer_kind
));
2851 gfc_resolve_idate (gfc_code
*c
)
2854 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("idate_i%d"),
2855 gfc_default_integer_kind
));
2859 gfc_resolve_ltime (gfc_code
*c
)
2862 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("ltime_i%d"),
2863 gfc_default_integer_kind
));
2867 gfc_resolve_gmtime (gfc_code
*c
)
2870 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("gmtime_i%d"),
2871 gfc_default_integer_kind
));
2875 /* G77 compatibility subroutine second(). */
2878 gfc_resolve_second_sub (gfc_code
*c
)
2881 name
= gfc_get_string (PREFIX ("second_sub"));
2882 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2887 gfc_resolve_sleep_sub (gfc_code
*c
)
2892 if (c
->ext
.actual
->expr
!= NULL
)
2893 kind
= c
->ext
.actual
->expr
->ts
.kind
;
2895 kind
= gfc_default_integer_kind
;
2897 name
= gfc_get_string (PREFIX ("sleep_i%d_sub"), kind
);
2898 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2902 /* G77 compatibility function srand(). */
2905 gfc_resolve_srand (gfc_code
*c
)
2908 name
= gfc_get_string (PREFIX ("srand"));
2909 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2913 /* Resolve the getarg intrinsic subroutine. */
2916 gfc_resolve_getarg (gfc_code
*c
)
2920 if (c
->ext
.actual
->expr
->ts
.kind
!= gfc_default_integer_kind
)
2925 ts
.type
= BT_INTEGER
;
2926 ts
.kind
= gfc_default_integer_kind
;
2928 gfc_convert_type (c
->ext
.actual
->expr
, &ts
, 2);
2931 name
= gfc_get_string (PREFIX ("getarg_i%d"), gfc_default_integer_kind
);
2932 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2936 /* Resolve the getcwd intrinsic subroutine. */
2939 gfc_resolve_getcwd_sub (gfc_code
*c
)
2944 if (c
->ext
.actual
->next
->expr
!= NULL
)
2945 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
2947 kind
= gfc_default_integer_kind
;
2949 name
= gfc_get_string (PREFIX ("getcwd_i%d_sub"), kind
);
2950 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2954 /* Resolve the get_command intrinsic subroutine. */
2957 gfc_resolve_get_command (gfc_code
*c
)
2961 kind
= gfc_default_integer_kind
;
2962 name
= gfc_get_string (PREFIX ("get_command_i%d"), kind
);
2963 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2967 /* Resolve the get_command_argument intrinsic subroutine. */
2970 gfc_resolve_get_command_argument (gfc_code
*c
)
2974 kind
= gfc_default_integer_kind
;
2975 name
= gfc_get_string (PREFIX ("get_command_argument_i%d"), kind
);
2976 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2980 /* Resolve the get_environment_variable intrinsic subroutine. */
2983 gfc_resolve_get_environment_variable (gfc_code
*code
)
2987 kind
= gfc_default_integer_kind
;
2988 name
= gfc_get_string (PREFIX ("get_environment_variable_i%d"), kind
);
2989 code
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2994 gfc_resolve_signal_sub (gfc_code
*c
)
2997 gfc_expr
*number
, *handler
, *status
;
3001 number
= c
->ext
.actual
->expr
;
3002 handler
= c
->ext
.actual
->next
->expr
;
3003 status
= c
->ext
.actual
->next
->next
->expr
;
3004 ts
.type
= BT_INTEGER
;
3005 ts
.kind
= gfc_c_int_kind
;
3007 /* handler can be either BT_INTEGER or BT_PROCEDURE */
3008 if (handler
->ts
.type
== BT_INTEGER
)
3010 if (handler
->ts
.kind
!= gfc_c_int_kind
)
3011 gfc_convert_type (handler
, &ts
, 2);
3012 name
= gfc_get_string (PREFIX ("signal_sub_int"));
3015 name
= gfc_get_string (PREFIX ("signal_sub"));
3017 if (number
->ts
.kind
!= gfc_c_int_kind
)
3018 gfc_convert_type (number
, &ts
, 2);
3019 if (status
!= NULL
&& status
->ts
.kind
!= gfc_c_int_kind
)
3020 gfc_convert_type (status
, &ts
, 2);
3022 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3026 /* Resolve the SYSTEM intrinsic subroutine. */
3029 gfc_resolve_system_sub (gfc_code
*c
)
3032 name
= gfc_get_string (PREFIX ("system_sub"));
3033 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3037 /* Determine if the arguments to SYSTEM_CLOCK are INTEGER(4) or INTEGER(8) */
3040 gfc_resolve_system_clock (gfc_code
*c
)
3045 if (c
->ext
.actual
->expr
!= NULL
)
3046 kind
= c
->ext
.actual
->expr
->ts
.kind
;
3047 else if (c
->ext
.actual
->next
->expr
!= NULL
)
3048 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
3049 else if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
3050 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
3052 kind
= gfc_default_integer_kind
;
3054 name
= gfc_get_string (PREFIX ("system_clock_%d"), kind
);
3055 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3059 /* Resolve the EXIT intrinsic subroutine. */
3062 gfc_resolve_exit (gfc_code
*c
)
3069 /* The STATUS argument has to be of default kind. If it is not,
3071 ts
.type
= BT_INTEGER
;
3072 ts
.kind
= gfc_default_integer_kind
;
3073 n
= c
->ext
.actual
->expr
;
3074 if (n
!= NULL
&& n
->ts
.kind
!= ts
.kind
)
3075 gfc_convert_type (n
, &ts
, 2);
3077 name
= gfc_get_string (PREFIX ("exit_i%d"), ts
.kind
);
3078 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3082 /* Resolve the FLUSH intrinsic subroutine. */
3085 gfc_resolve_flush (gfc_code
*c
)
3092 ts
.type
= BT_INTEGER
;
3093 ts
.kind
= gfc_default_integer_kind
;
3094 n
= c
->ext
.actual
->expr
;
3095 if (n
!= NULL
&& n
->ts
.kind
!= ts
.kind
)
3096 gfc_convert_type (n
, &ts
, 2);
3098 name
= gfc_get_string (PREFIX ("flush_i%d"), ts
.kind
);
3099 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3104 gfc_resolve_free (gfc_code
*c
)
3110 ts
.type
= BT_INTEGER
;
3111 ts
.kind
= gfc_index_integer_kind
;
3112 n
= c
->ext
.actual
->expr
;
3113 if (n
->ts
.kind
!= ts
.kind
)
3114 gfc_convert_type (n
, &ts
, 2);
3116 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("free"));
3121 gfc_resolve_ctime_sub (gfc_code
*c
)
3126 /* ctime TIME argument is a INTEGER(KIND=8), says the doc */
3127 if (c
->ext
.actual
->expr
->ts
.kind
!= 8)
3129 ts
.type
= BT_INTEGER
;
3131 ts
.u
.derived
= NULL
;
3133 gfc_convert_type (c
->ext
.actual
->expr
, &ts
, 2);
3136 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("ctime_sub"));
3141 gfc_resolve_fdate_sub (gfc_code
*c
)
3143 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("fdate_sub"));
3148 gfc_resolve_gerror (gfc_code
*c
)
3150 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("gerror"));
3155 gfc_resolve_getlog (gfc_code
*c
)
3157 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("getlog"));
3162 gfc_resolve_hostnm_sub (gfc_code
*c
)
3167 if (c
->ext
.actual
->next
->expr
!= NULL
)
3168 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
3170 kind
= gfc_default_integer_kind
;
3172 name
= gfc_get_string (PREFIX ("hostnm_i%d_sub"), kind
);
3173 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3178 gfc_resolve_perror (gfc_code
*c
)
3180 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("perror_sub"));
3183 /* Resolve the STAT and FSTAT intrinsic subroutines. */
3186 gfc_resolve_stat_sub (gfc_code
*c
)
3189 name
= gfc_get_string (PREFIX ("stat_i%d_sub"), gfc_default_integer_kind
);
3190 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3195 gfc_resolve_lstat_sub (gfc_code
*c
)
3198 name
= gfc_get_string (PREFIX ("lstat_i%d_sub"), gfc_default_integer_kind
);
3199 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3204 gfc_resolve_fstat_sub (gfc_code
*c
)
3210 u
= c
->ext
.actual
->expr
;
3211 ts
= &c
->ext
.actual
->next
->expr
->ts
;
3212 if (u
->ts
.kind
!= ts
->kind
)
3213 gfc_convert_type (u
, ts
, 2);
3214 name
= gfc_get_string (PREFIX ("fstat_i%d_sub"), ts
->kind
);
3215 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3220 gfc_resolve_fgetc_sub (gfc_code
*c
)
3227 u
= c
->ext
.actual
->expr
;
3228 st
= c
->ext
.actual
->next
->next
->expr
;
3230 if (u
->ts
.kind
!= gfc_c_int_kind
)
3232 ts
.type
= BT_INTEGER
;
3233 ts
.kind
= gfc_c_int_kind
;
3234 ts
.u
.derived
= NULL
;
3236 gfc_convert_type (u
, &ts
, 2);
3240 name
= gfc_get_string (PREFIX ("fgetc_i%d_sub"), st
->ts
.kind
);
3242 name
= gfc_get_string (PREFIX ("fgetc_i%d_sub"), gfc_default_integer_kind
);
3244 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3249 gfc_resolve_fget_sub (gfc_code
*c
)
3254 st
= c
->ext
.actual
->next
->expr
;
3256 name
= gfc_get_string (PREFIX ("fget_i%d_sub"), st
->ts
.kind
);
3258 name
= gfc_get_string (PREFIX ("fget_i%d_sub"), gfc_default_integer_kind
);
3260 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3265 gfc_resolve_fputc_sub (gfc_code
*c
)
3272 u
= c
->ext
.actual
->expr
;
3273 st
= c
->ext
.actual
->next
->next
->expr
;
3275 if (u
->ts
.kind
!= gfc_c_int_kind
)
3277 ts
.type
= BT_INTEGER
;
3278 ts
.kind
= gfc_c_int_kind
;
3279 ts
.u
.derived
= NULL
;
3281 gfc_convert_type (u
, &ts
, 2);
3285 name
= gfc_get_string (PREFIX ("fputc_i%d_sub"), st
->ts
.kind
);
3287 name
= gfc_get_string (PREFIX ("fputc_i%d_sub"), gfc_default_integer_kind
);
3289 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3294 gfc_resolve_fput_sub (gfc_code
*c
)
3299 st
= c
->ext
.actual
->next
->expr
;
3301 name
= gfc_get_string (PREFIX ("fput_i%d_sub"), st
->ts
.kind
);
3303 name
= gfc_get_string (PREFIX ("fput_i%d_sub"), gfc_default_integer_kind
);
3305 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3310 gfc_resolve_fseek_sub (gfc_code
*c
)
3318 unit
= c
->ext
.actual
->expr
;
3319 offset
= c
->ext
.actual
->next
->expr
;
3320 whence
= c
->ext
.actual
->next
->next
->expr
;
3322 if (unit
->ts
.kind
!= gfc_c_int_kind
)
3324 ts
.type
= BT_INTEGER
;
3325 ts
.kind
= gfc_c_int_kind
;
3326 ts
.u
.derived
= NULL
;
3328 gfc_convert_type (unit
, &ts
, 2);
3331 if (offset
->ts
.kind
!= gfc_intio_kind
)
3333 ts
.type
= BT_INTEGER
;
3334 ts
.kind
= gfc_intio_kind
;
3335 ts
.u
.derived
= NULL
;
3337 gfc_convert_type (offset
, &ts
, 2);
3340 if (whence
->ts
.kind
!= gfc_c_int_kind
)
3342 ts
.type
= BT_INTEGER
;
3343 ts
.kind
= gfc_c_int_kind
;
3344 ts
.u
.derived
= NULL
;
3346 gfc_convert_type (whence
, &ts
, 2);
3349 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("fseek_sub"));
3353 gfc_resolve_ftell_sub (gfc_code
*c
)
3361 unit
= c
->ext
.actual
->expr
;
3362 offset
= c
->ext
.actual
->next
->expr
;
3364 if (unit
->ts
.kind
!= gfc_c_int_kind
)
3366 ts
.type
= BT_INTEGER
;
3367 ts
.kind
= gfc_c_int_kind
;
3368 ts
.u
.derived
= NULL
;
3370 gfc_convert_type (unit
, &ts
, 2);
3373 name
= gfc_get_string (PREFIX ("ftell_i%d_sub"), offset
->ts
.kind
);
3374 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3379 gfc_resolve_ttynam_sub (gfc_code
*c
)
3384 if (c
->ext
.actual
->expr
->ts
.kind
!= gfc_c_int_kind
)
3386 ts
.type
= BT_INTEGER
;
3387 ts
.kind
= gfc_c_int_kind
;
3388 ts
.u
.derived
= NULL
;
3390 gfc_convert_type (c
->ext
.actual
->expr
, &ts
, 2);
3393 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("ttynam_sub"));
3397 /* Resolve the UMASK intrinsic subroutine. */
3400 gfc_resolve_umask_sub (gfc_code
*c
)
3405 if (c
->ext
.actual
->next
->expr
!= NULL
)
3406 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
3408 kind
= gfc_default_integer_kind
;
3410 name
= gfc_get_string (PREFIX ("umask_i%d_sub"), kind
);
3411 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3414 /* Resolve the UNLINK intrinsic subroutine. */
3417 gfc_resolve_unlink_sub (gfc_code
*c
)
3422 if (c
->ext
.actual
->next
->expr
!= NULL
)
3423 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
3425 kind
= gfc_default_integer_kind
;
3427 name
= gfc_get_string (PREFIX ("unlink_i%d_sub"), kind
);
3428 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);