1 /* Intrinsic function resolution.
2 Copyright (C) 2000-2017 Free Software Foundation, Inc.
3 Contributed by Andy Vaught & Katherine Holcomb
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
22 /* Assign name and types to intrinsic procedures. For functions, the
23 first argument to a resolution function is an expression pointer to
24 the original function node and the rest are pointers to the
25 arguments of the function call. For subroutines, a pointer to the
26 code node is passed. The result type and library subroutine name
27 are generally set according to the function arguments. */
31 #include "coretypes.h"
34 #include "stringpool.h"
35 #include "intrinsic.h"
36 #include "constructor.h"
39 /* Given printf-like arguments, return a stable version of the result string.
41 We already have a working, optimized string hashing table in the form of
42 the identifier table. Reusing this table is likely not to be wasted,
43 since if the function name makes it to the gimple output of the frontend,
44 we'll have to create the identifier anyway. */
47 gfc_get_string (const char *format
, ...)
54 /* Handle common case without vsnprintf and temporary buffer. */
55 if (format
[0] == '%' && format
[1] == 's' && format
[2] == '\0')
57 va_start (ap
, format
);
58 str
= va_arg (ap
, const char *);
63 va_start (ap
, format
);
64 vsnprintf (temp_name
, sizeof (temp_name
), format
, ap
);
66 temp_name
[sizeof (temp_name
) - 1] = 0;
70 ident
= get_identifier (str
);
71 return IDENTIFIER_POINTER (ident
);
74 /* MERGE and SPREAD need to have source charlen's present for passing
75 to the result expression. */
77 check_charlen_present (gfc_expr
*source
)
79 if (source
->ts
.u
.cl
== NULL
)
80 source
->ts
.u
.cl
= gfc_new_charlen (gfc_current_ns
, NULL
);
82 if (source
->expr_type
== EXPR_CONSTANT
)
84 source
->ts
.u
.cl
->length
85 = gfc_get_int_expr (gfc_default_integer_kind
, NULL
,
86 source
->value
.character
.length
);
89 else if (source
->expr_type
== EXPR_ARRAY
)
91 gfc_constructor
*c
= gfc_constructor_first (source
->value
.constructor
);
92 source
->ts
.u
.cl
->length
93 = gfc_get_int_expr (gfc_default_integer_kind
, NULL
,
94 c
->expr
->value
.character
.length
);
98 /* Helper function for resolving the "mask" argument. */
101 resolve_mask_arg (gfc_expr
*mask
)
109 /* For the scalar case, coerce the mask to kind=4 unconditionally
110 (because this is the only kind we have a library function
113 if (mask
->ts
.kind
!= 4)
115 ts
.type
= BT_LOGICAL
;
117 gfc_convert_type (mask
, &ts
, 2);
122 /* In the library, we access the mask with a GFC_LOGICAL_1
123 argument. No need to waste memory if we are about to create
124 a temporary array. */
125 if (mask
->expr_type
== EXPR_OP
&& mask
->ts
.kind
!= 1)
127 ts
.type
= BT_LOGICAL
;
129 gfc_convert_type_warn (mask
, &ts
, 2, 0);
136 resolve_bound (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
,
137 const char *name
, bool coarray
)
139 f
->ts
.type
= BT_INTEGER
;
141 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
143 f
->ts
.kind
= gfc_default_integer_kind
;
148 if (array
->rank
!= -1)
150 f
->shape
= gfc_get_shape (1);
151 mpz_init_set_ui (f
->shape
[0], coarray
? gfc_get_corank (array
)
156 f
->value
.function
.name
= gfc_get_string ("%s", name
);
161 resolve_transformational (const char *name
, gfc_expr
*f
, gfc_expr
*array
,
162 gfc_expr
*dim
, gfc_expr
*mask
)
175 resolve_mask_arg (mask
);
182 f
->rank
= array
->rank
- 1;
183 f
->shape
= gfc_copy_shape_excluding (array
->shape
, array
->rank
, dim
);
184 gfc_resolve_dim_arg (dim
);
187 f
->value
.function
.name
188 = gfc_get_string (PREFIX ("%s%s_%c%d"), prefix
, name
,
189 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
193 /********************** Resolution functions **********************/
197 gfc_resolve_abs (gfc_expr
*f
, gfc_expr
*a
)
200 if (f
->ts
.type
== BT_COMPLEX
)
201 f
->ts
.type
= BT_REAL
;
203 f
->value
.function
.name
204 = gfc_get_string ("__abs_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
209 gfc_resolve_access (gfc_expr
*f
, gfc_expr
*name ATTRIBUTE_UNUSED
,
210 gfc_expr
*mode ATTRIBUTE_UNUSED
)
212 f
->ts
.type
= BT_INTEGER
;
213 f
->ts
.kind
= gfc_c_int_kind
;
214 f
->value
.function
.name
= PREFIX ("access_func");
219 gfc_resolve_adjustl (gfc_expr
*f
, gfc_expr
*string
)
221 f
->ts
.type
= BT_CHARACTER
;
222 f
->ts
.kind
= string
->ts
.kind
;
224 f
->ts
.u
.cl
= gfc_new_charlen (gfc_current_ns
, string
->ts
.u
.cl
);
226 f
->value
.function
.name
= gfc_get_string ("__adjustl_s%d", f
->ts
.kind
);
231 gfc_resolve_adjustr (gfc_expr
*f
, gfc_expr
*string
)
233 f
->ts
.type
= BT_CHARACTER
;
234 f
->ts
.kind
= string
->ts
.kind
;
236 f
->ts
.u
.cl
= gfc_new_charlen (gfc_current_ns
, string
->ts
.u
.cl
);
238 f
->value
.function
.name
= gfc_get_string ("__adjustr_s%d", f
->ts
.kind
);
243 gfc_resolve_char_achar (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*kind
,
246 f
->ts
.type
= BT_CHARACTER
;
247 f
->ts
.kind
= (kind
== NULL
)
248 ? gfc_default_character_kind
: mpz_get_si (kind
->value
.integer
);
249 f
->ts
.u
.cl
= gfc_new_charlen (gfc_current_ns
, NULL
);
250 f
->ts
.u
.cl
->length
= gfc_get_int_expr (gfc_default_integer_kind
, NULL
, 1);
252 f
->value
.function
.name
253 = gfc_get_string ("__%schar_%d_%c%d", is_achar
? "a" : "", f
->ts
.kind
,
254 gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
259 gfc_resolve_achar (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*kind
)
261 gfc_resolve_char_achar (f
, x
, kind
, true);
266 gfc_resolve_acos (gfc_expr
*f
, gfc_expr
*x
)
269 f
->value
.function
.name
270 = gfc_get_string ("__acos_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
275 gfc_resolve_acosh (gfc_expr
*f
, gfc_expr
*x
)
278 f
->value
.function
.name
279 = gfc_get_string ("__acosh_%c%d", gfc_type_letter (x
->ts
.type
),
285 gfc_resolve_aimag (gfc_expr
*f
, gfc_expr
*x
)
287 f
->ts
.type
= BT_REAL
;
288 f
->ts
.kind
= x
->ts
.kind
;
289 f
->value
.function
.name
290 = gfc_get_string ("__aimag_%c%d", gfc_type_letter (x
->ts
.type
),
296 gfc_resolve_and (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
298 f
->ts
.type
= i
->ts
.type
;
299 f
->ts
.kind
= gfc_kind_max (i
, j
);
301 if (i
->ts
.kind
!= j
->ts
.kind
)
303 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
304 gfc_convert_type (j
, &i
->ts
, 2);
306 gfc_convert_type (i
, &j
->ts
, 2);
309 f
->value
.function
.name
310 = gfc_get_string ("__and_%c%d", gfc_type_letter (i
->ts
.type
), f
->ts
.kind
);
315 gfc_resolve_aint (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
320 f
->ts
.type
= a
->ts
.type
;
321 f
->ts
.kind
= (kind
== NULL
) ? a
->ts
.kind
: mpz_get_si (kind
->value
.integer
);
323 if (a
->ts
.kind
!= f
->ts
.kind
)
325 ts
.type
= f
->ts
.type
;
326 ts
.kind
= f
->ts
.kind
;
327 gfc_convert_type (a
, &ts
, 2);
329 /* The resolved name is only used for specific intrinsics where
330 the return kind is the same as the arg kind. */
331 f
->value
.function
.name
332 = gfc_get_string ("__aint_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
337 gfc_resolve_dint (gfc_expr
*f
, gfc_expr
*a
)
339 gfc_resolve_aint (f
, a
, NULL
);
344 gfc_resolve_all (gfc_expr
*f
, gfc_expr
*mask
, gfc_expr
*dim
)
350 gfc_resolve_dim_arg (dim
);
351 f
->rank
= mask
->rank
- 1;
352 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
355 f
->value
.function
.name
356 = gfc_get_string (PREFIX ("all_%c%d"), gfc_type_letter (mask
->ts
.type
),
362 gfc_resolve_anint (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
367 f
->ts
.type
= a
->ts
.type
;
368 f
->ts
.kind
= (kind
== NULL
) ? a
->ts
.kind
: mpz_get_si (kind
->value
.integer
);
370 if (a
->ts
.kind
!= f
->ts
.kind
)
372 ts
.type
= f
->ts
.type
;
373 ts
.kind
= f
->ts
.kind
;
374 gfc_convert_type (a
, &ts
, 2);
377 /* The resolved name is only used for specific intrinsics where
378 the return kind is the same as the arg kind. */
379 f
->value
.function
.name
380 = gfc_get_string ("__anint_%c%d", gfc_type_letter (a
->ts
.type
),
386 gfc_resolve_dnint (gfc_expr
*f
, gfc_expr
*a
)
388 gfc_resolve_anint (f
, a
, NULL
);
393 gfc_resolve_any (gfc_expr
*f
, gfc_expr
*mask
, gfc_expr
*dim
)
399 gfc_resolve_dim_arg (dim
);
400 f
->rank
= mask
->rank
- 1;
401 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
404 f
->value
.function
.name
405 = gfc_get_string (PREFIX ("any_%c%d"), gfc_type_letter (mask
->ts
.type
),
411 gfc_resolve_asin (gfc_expr
*f
, gfc_expr
*x
)
414 f
->value
.function
.name
415 = gfc_get_string ("__asin_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
419 gfc_resolve_asinh (gfc_expr
*f
, gfc_expr
*x
)
422 f
->value
.function
.name
423 = gfc_get_string ("__asinh_%c%d", gfc_type_letter (x
->ts
.type
),
428 gfc_resolve_atan (gfc_expr
*f
, gfc_expr
*x
)
431 f
->value
.function
.name
432 = gfc_get_string ("__atan_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
436 gfc_resolve_atanh (gfc_expr
*f
, gfc_expr
*x
)
439 f
->value
.function
.name
440 = gfc_get_string ("__atanh_%c%d", gfc_type_letter (x
->ts
.type
),
445 gfc_resolve_atan2 (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y ATTRIBUTE_UNUSED
)
448 f
->value
.function
.name
449 = gfc_get_string ("__atan2_%c%d", gfc_type_letter (x
->ts
.type
),
454 /* Resolve the BESYN and BESJN intrinsics. */
457 gfc_resolve_besn (gfc_expr
*f
, gfc_expr
*n
, gfc_expr
*x
)
463 if (n
->ts
.kind
!= gfc_c_int_kind
)
465 ts
.type
= BT_INTEGER
;
466 ts
.kind
= gfc_c_int_kind
;
467 gfc_convert_type (n
, &ts
, 2);
469 f
->value
.function
.name
= gfc_get_string ("<intrinsic>");
474 gfc_resolve_bessel_n2 (gfc_expr
*f
, gfc_expr
*n1
, gfc_expr
*n2
, gfc_expr
*x
)
481 if (n1
->expr_type
== EXPR_CONSTANT
&& n2
->expr_type
== EXPR_CONSTANT
)
483 f
->shape
= gfc_get_shape (1);
484 mpz_init (f
->shape
[0]);
485 mpz_sub (f
->shape
[0], n2
->value
.integer
, n1
->value
.integer
);
486 mpz_add_ui (f
->shape
[0], f
->shape
[0], 1);
489 if (n1
->ts
.kind
!= gfc_c_int_kind
)
491 ts
.type
= BT_INTEGER
;
492 ts
.kind
= gfc_c_int_kind
;
493 gfc_convert_type (n1
, &ts
, 2);
496 if (n2
->ts
.kind
!= gfc_c_int_kind
)
498 ts
.type
= BT_INTEGER
;
499 ts
.kind
= gfc_c_int_kind
;
500 gfc_convert_type (n2
, &ts
, 2);
503 if (f
->value
.function
.isym
->id
== GFC_ISYM_JN2
)
504 f
->value
.function
.name
= gfc_get_string (PREFIX ("bessel_jn_r%d"),
507 f
->value
.function
.name
= gfc_get_string (PREFIX ("bessel_yn_r%d"),
513 gfc_resolve_btest (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos
)
515 f
->ts
.type
= BT_LOGICAL
;
516 f
->ts
.kind
= gfc_default_logical_kind
;
517 f
->value
.function
.name
518 = gfc_get_string ("__btest_%d_%d", i
->ts
.kind
, pos
->ts
.kind
);
523 gfc_resolve_c_loc (gfc_expr
*f
, gfc_expr
*x ATTRIBUTE_UNUSED
)
525 f
->ts
= f
->value
.function
.isym
->ts
;
530 gfc_resolve_c_funloc (gfc_expr
*f
, gfc_expr
*x ATTRIBUTE_UNUSED
)
532 f
->ts
= f
->value
.function
.isym
->ts
;
537 gfc_resolve_ceiling (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
539 f
->ts
.type
= BT_INTEGER
;
540 f
->ts
.kind
= (kind
== NULL
)
541 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
542 f
->value
.function
.name
543 = gfc_get_string ("__ceiling_%d_%c%d", f
->ts
.kind
,
544 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
549 gfc_resolve_char (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
551 gfc_resolve_char_achar (f
, a
, kind
, false);
556 gfc_resolve_chdir (gfc_expr
*f
, gfc_expr
*d ATTRIBUTE_UNUSED
)
558 f
->ts
.type
= BT_INTEGER
;
559 f
->ts
.kind
= gfc_default_integer_kind
;
560 f
->value
.function
.name
= gfc_get_string (PREFIX ("chdir_i%d"), f
->ts
.kind
);
565 gfc_resolve_chdir_sub (gfc_code
*c
)
570 if (c
->ext
.actual
->next
->expr
!= NULL
)
571 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
573 kind
= gfc_default_integer_kind
;
575 name
= gfc_get_string (PREFIX ("chdir_i%d_sub"), kind
);
576 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
581 gfc_resolve_chmod (gfc_expr
*f
, gfc_expr
*name ATTRIBUTE_UNUSED
,
582 gfc_expr
*mode ATTRIBUTE_UNUSED
)
584 f
->ts
.type
= BT_INTEGER
;
585 f
->ts
.kind
= gfc_c_int_kind
;
586 f
->value
.function
.name
= PREFIX ("chmod_func");
591 gfc_resolve_chmod_sub (gfc_code
*c
)
596 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
597 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
599 kind
= gfc_default_integer_kind
;
601 name
= gfc_get_string (PREFIX ("chmod_i%d_sub"), kind
);
602 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
607 gfc_resolve_cmplx (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y
, gfc_expr
*kind
)
609 f
->ts
.type
= BT_COMPLEX
;
610 f
->ts
.kind
= (kind
== NULL
)
611 ? gfc_default_real_kind
: mpz_get_si (kind
->value
.integer
);
614 f
->value
.function
.name
615 = gfc_get_string ("__cmplx0_%d_%c%d", f
->ts
.kind
,
616 gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
618 f
->value
.function
.name
619 = gfc_get_string ("__cmplx1_%d_%c%d_%c%d", f
->ts
.kind
,
620 gfc_type_letter (x
->ts
.type
), x
->ts
.kind
,
621 gfc_type_letter (y
->ts
.type
), y
->ts
.kind
);
626 gfc_resolve_dcmplx (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y
)
628 gfc_resolve_cmplx (f
, x
, y
, gfc_get_int_expr (gfc_default_integer_kind
, NULL
,
629 gfc_default_double_kind
));
634 gfc_resolve_complex (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y
)
638 if (x
->ts
.type
== BT_INTEGER
)
640 if (y
->ts
.type
== BT_INTEGER
)
641 kind
= gfc_default_real_kind
;
647 if (y
->ts
.type
== BT_REAL
)
648 kind
= (x
->ts
.kind
> y
->ts
.kind
) ? x
->ts
.kind
: y
->ts
.kind
;
653 f
->ts
.type
= BT_COMPLEX
;
655 f
->value
.function
.name
656 = gfc_get_string ("__cmplx1_%d_%c%d_%c%d", f
->ts
.kind
,
657 gfc_type_letter (x
->ts
.type
), x
->ts
.kind
,
658 gfc_type_letter (y
->ts
.type
), y
->ts
.kind
);
663 gfc_resolve_conjg (gfc_expr
*f
, gfc_expr
*x
)
666 f
->value
.function
.name
= gfc_get_string ("__conjg_%d", x
->ts
.kind
);
671 gfc_resolve_cos (gfc_expr
*f
, gfc_expr
*x
)
674 f
->value
.function
.name
675 = gfc_get_string ("__cos_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
680 gfc_resolve_cosh (gfc_expr
*f
, gfc_expr
*x
)
683 f
->value
.function
.name
684 = gfc_get_string ("__cosh_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
688 /* Our replacement of elements of a trig call with an EXPR_OP (e.g.
689 multiplying the result or operands by a factor to convert to/from degrees)
690 will cause the resolve_* function to be invoked again when resolving the
691 freshly created EXPR_OP. See gfc_resolve_trigd, gfc_resolve_atrigd,
692 gfc_resolve_cotan. We must observe this and avoid recursively creating
693 layers of nested EXPR_OP expressions. */
696 is_trig_resolved (gfc_expr
*f
)
698 /* We know we've already resolved the function if we see the lib call
699 starting with '__'. */
700 return (f
->value
.function
.name
!= NULL
701 && strncmp ("__", f
->value
.function
.name
, 2) == 0);
704 /* Return a shallow copy of the function expression f. The original expression
705 has its pointers cleared so that it may be freed without affecting the
706 shallow copy. This is similar to gfc_copy_expr, but doesn't perform a deep
707 copy of the argument list, allowing it to be reused somewhere else,
708 setting the expression up nicely for gfc_replace_expr. */
711 copy_replace_function_shallow (gfc_expr
*f
)
714 gfc_actual_arglist
*args
;
716 /* The only thing deep-copied in gfc_copy_expr is args. */
717 args
= f
->value
.function
.actual
;
718 f
->value
.function
.actual
= NULL
;
719 fcopy
= gfc_copy_expr (f
);
720 fcopy
->value
.function
.actual
= args
;
722 /* Clear the old function so the shallow copy is not affected if the old
723 expression is freed. */
724 f
->value
.function
.name
= NULL
;
725 f
->value
.function
.isym
= NULL
;
726 f
->value
.function
.actual
= NULL
;
727 f
->value
.function
.esym
= NULL
;
735 /* Resolve cotan = cos / sin. */
738 gfc_resolve_cotan (gfc_expr
*f
, gfc_expr
*x
)
740 gfc_expr
*result
, *fcopy
, *sin
;
741 gfc_actual_arglist
*sin_args
;
743 if (is_trig_resolved (f
))
746 /* Compute cotan (x) = cos (x) / sin (x). */
747 f
->value
.function
.isym
= gfc_intrinsic_function_by_id (GFC_ISYM_COS
);
748 gfc_resolve_cos (f
, x
);
750 sin_args
= gfc_get_actual_arglist ();
751 sin_args
->expr
= gfc_copy_expr (x
);
753 sin
= gfc_get_expr ();
755 sin
->where
= f
->where
;
756 sin
->expr_type
= EXPR_FUNCTION
;
757 sin
->value
.function
.isym
= gfc_intrinsic_function_by_id (GFC_ISYM_SIN
);
758 sin
->value
.function
.actual
= sin_args
;
759 gfc_resolve_sin (sin
, sin_args
->expr
);
761 /* Replace f with cos/sin - we do this in place in f for the caller. */
762 fcopy
= copy_replace_function_shallow (f
);
763 result
= gfc_divide (fcopy
, sin
);
764 gfc_replace_expr (f
, result
);
769 gfc_resolve_count (gfc_expr
*f
, gfc_expr
*mask
, gfc_expr
*dim
, gfc_expr
*kind
)
771 f
->ts
.type
= BT_INTEGER
;
773 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
775 f
->ts
.kind
= gfc_default_integer_kind
;
779 f
->rank
= mask
->rank
- 1;
780 gfc_resolve_dim_arg (dim
);
781 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
784 resolve_mask_arg (mask
);
786 f
->value
.function
.name
787 = gfc_get_string (PREFIX ("count_%d_%c"), f
->ts
.kind
,
788 gfc_type_letter (mask
->ts
.type
));
793 gfc_resolve_cshift (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*shift
,
798 if (array
->ts
.type
== BT_CHARACTER
&& array
->ref
)
799 gfc_resolve_substring_charlen (array
);
802 f
->rank
= array
->rank
;
803 f
->shape
= gfc_copy_shape (array
->shape
, array
->rank
);
810 /* If dim kind is greater than default integer we need to use the larger. */
811 m
= gfc_default_integer_kind
;
813 m
= m
< dim
->ts
.kind
? dim
->ts
.kind
: m
;
815 /* Convert shift to at least m, so we don't need
816 kind=1 and kind=2 versions of the library functions. */
817 if (shift
->ts
.kind
< m
)
821 ts
.type
= BT_INTEGER
;
823 gfc_convert_type_warn (shift
, &ts
, 2, 0);
828 if (dim
->expr_type
!= EXPR_CONSTANT
&& dim
->symtree
!= NULL
829 && dim
->symtree
->n
.sym
->attr
.optional
)
831 /* Mark this for later setting the type in gfc_conv_missing_dummy. */
832 dim
->representation
.length
= shift
->ts
.kind
;
836 gfc_resolve_dim_arg (dim
);
837 /* Convert dim to shift's kind to reduce variations. */
838 if (dim
->ts
.kind
!= shift
->ts
.kind
)
839 gfc_convert_type_warn (dim
, &shift
->ts
, 2, 0);
843 if (array
->ts
.type
== BT_CHARACTER
)
845 if (array
->ts
.kind
== gfc_default_character_kind
)
846 f
->value
.function
.name
847 = gfc_get_string (PREFIX ("cshift%d_%d_char"), n
, shift
->ts
.kind
);
849 f
->value
.function
.name
850 = gfc_get_string (PREFIX ("cshift%d_%d_char%d"), n
, shift
->ts
.kind
,
854 f
->value
.function
.name
855 = gfc_get_string (PREFIX ("cshift%d_%d"), n
, shift
->ts
.kind
);
860 gfc_resolve_ctime (gfc_expr
*f
, gfc_expr
*time
)
865 f
->ts
.type
= BT_CHARACTER
;
866 f
->ts
.kind
= gfc_default_character_kind
;
868 /* ctime TIME argument is a INTEGER(KIND=8), says the doc */
869 if (time
->ts
.kind
!= 8)
871 ts
.type
= BT_INTEGER
;
875 gfc_convert_type (time
, &ts
, 2);
878 f
->value
.function
.name
= gfc_get_string (PREFIX ("ctime"));
883 gfc_resolve_dble (gfc_expr
*f
, gfc_expr
*a
)
885 f
->ts
.type
= BT_REAL
;
886 f
->ts
.kind
= gfc_default_double_kind
;
887 f
->value
.function
.name
888 = gfc_get_string ("__dble_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
893 gfc_resolve_dim (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p
)
895 f
->ts
.type
= a
->ts
.type
;
897 f
->ts
.kind
= gfc_kind_max (a
,p
);
899 f
->ts
.kind
= a
->ts
.kind
;
901 if (p
!= NULL
&& a
->ts
.kind
!= p
->ts
.kind
)
903 if (a
->ts
.kind
== gfc_kind_max (a
,p
))
904 gfc_convert_type (p
, &a
->ts
, 2);
906 gfc_convert_type (a
, &p
->ts
, 2);
909 f
->value
.function
.name
910 = gfc_get_string ("__dim_%c%d", gfc_type_letter (f
->ts
.type
), f
->ts
.kind
);
915 gfc_resolve_dot_product (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*b
)
919 temp
.expr_type
= EXPR_OP
;
920 gfc_clear_ts (&temp
.ts
);
921 temp
.value
.op
.op
= INTRINSIC_NONE
;
922 temp
.value
.op
.op1
= a
;
923 temp
.value
.op
.op2
= b
;
924 gfc_type_convert_binary (&temp
, 1);
926 f
->value
.function
.name
927 = gfc_get_string (PREFIX ("dot_product_%c%d"),
928 gfc_type_letter (f
->ts
.type
), f
->ts
.kind
);
933 gfc_resolve_dprod (gfc_expr
*f
, gfc_expr
*a ATTRIBUTE_UNUSED
,
934 gfc_expr
*b ATTRIBUTE_UNUSED
)
936 f
->ts
.kind
= gfc_default_double_kind
;
937 f
->ts
.type
= BT_REAL
;
938 f
->value
.function
.name
= gfc_get_string ("__dprod_r%d", f
->ts
.kind
);
943 gfc_resolve_dshift (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j ATTRIBUTE_UNUSED
,
944 gfc_expr
*shift ATTRIBUTE_UNUSED
)
947 if (f
->value
.function
.isym
->id
== GFC_ISYM_DSHIFTL
)
948 f
->value
.function
.name
= gfc_get_string ("dshiftl_i%d", f
->ts
.kind
);
949 else if (f
->value
.function
.isym
->id
== GFC_ISYM_DSHIFTR
)
950 f
->value
.function
.name
= gfc_get_string ("dshiftr_i%d", f
->ts
.kind
);
957 gfc_resolve_eoshift (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*shift
,
958 gfc_expr
*boundary
, gfc_expr
*dim
)
962 if (array
->ts
.type
== BT_CHARACTER
&& array
->ref
)
963 gfc_resolve_substring_charlen (array
);
966 f
->rank
= array
->rank
;
967 f
->shape
= gfc_copy_shape (array
->shape
, array
->rank
);
972 if (boundary
&& boundary
->rank
> 0)
975 /* If dim kind is greater than default integer we need to use the larger. */
976 m
= gfc_default_integer_kind
;
978 m
= m
< dim
->ts
.kind
? dim
->ts
.kind
: m
;
980 /* Convert shift to at least m, so we don't need
981 kind=1 and kind=2 versions of the library functions. */
982 if (shift
->ts
.kind
< m
)
986 ts
.type
= BT_INTEGER
;
988 gfc_convert_type_warn (shift
, &ts
, 2, 0);
993 if (dim
->expr_type
!= EXPR_CONSTANT
&& dim
->symtree
!= NULL
994 && dim
->symtree
->n
.sym
->attr
.optional
)
996 /* Mark this for later setting the type in gfc_conv_missing_dummy. */
997 dim
->representation
.length
= shift
->ts
.kind
;
1001 gfc_resolve_dim_arg (dim
);
1002 /* Convert dim to shift's kind to reduce variations. */
1003 if (dim
->ts
.kind
!= shift
->ts
.kind
)
1004 gfc_convert_type_warn (dim
, &shift
->ts
, 2, 0);
1008 if (array
->ts
.type
== BT_CHARACTER
)
1010 if (array
->ts
.kind
== gfc_default_character_kind
)
1011 f
->value
.function
.name
1012 = gfc_get_string (PREFIX ("eoshift%d_%d_char"), n
, shift
->ts
.kind
);
1014 f
->value
.function
.name
1015 = gfc_get_string (PREFIX ("eoshift%d_%d_char%d"), n
, shift
->ts
.kind
,
1019 f
->value
.function
.name
1020 = gfc_get_string (PREFIX ("eoshift%d_%d"), n
, shift
->ts
.kind
);
1025 gfc_resolve_exp (gfc_expr
*f
, gfc_expr
*x
)
1028 f
->value
.function
.name
1029 = gfc_get_string ("__exp_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
1034 gfc_resolve_exponent (gfc_expr
*f
, gfc_expr
*x
)
1036 f
->ts
.type
= BT_INTEGER
;
1037 f
->ts
.kind
= gfc_default_integer_kind
;
1038 f
->value
.function
.name
= gfc_get_string ("__exponent_%d", x
->ts
.kind
);
1042 /* Resolve the EXTENDS_TYPE_OF intrinsic function. */
1045 gfc_resolve_extends_type_of (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*mo
)
1050 /* Prevent double resolution. */
1051 if (f
->ts
.type
== BT_LOGICAL
)
1054 /* Replace the first argument with the corresponding vtab. */
1055 if (a
->ts
.type
== BT_CLASS
)
1056 gfc_add_vptr_component (a
);
1057 else if (a
->ts
.type
== BT_DERIVED
)
1061 vtab
= gfc_find_derived_vtab (a
->ts
.u
.derived
);
1062 /* Clear the old expr. */
1063 gfc_free_ref_list (a
->ref
);
1065 memset (a
, '\0', sizeof (gfc_expr
));
1066 /* Construct a new one. */
1067 a
->expr_type
= EXPR_VARIABLE
;
1068 st
= gfc_find_symtree (vtab
->ns
->sym_root
, vtab
->name
);
1074 /* Replace the second argument with the corresponding vtab. */
1075 if (mo
->ts
.type
== BT_CLASS
)
1076 gfc_add_vptr_component (mo
);
1077 else if (mo
->ts
.type
== BT_DERIVED
)
1081 vtab
= gfc_find_derived_vtab (mo
->ts
.u
.derived
);
1082 /* Clear the old expr. */
1084 gfc_free_ref_list (mo
->ref
);
1085 memset (mo
, '\0', sizeof (gfc_expr
));
1086 /* Construct a new one. */
1087 mo
->expr_type
= EXPR_VARIABLE
;
1088 st
= gfc_find_symtree (vtab
->ns
->sym_root
, vtab
->name
);
1094 f
->ts
.type
= BT_LOGICAL
;
1097 f
->value
.function
.isym
->formal
->ts
= a
->ts
;
1098 f
->value
.function
.isym
->formal
->next
->ts
= mo
->ts
;
1100 /* Call library function. */
1101 f
->value
.function
.name
= gfc_get_string (PREFIX ("is_extension_of"));
1106 gfc_resolve_fdate (gfc_expr
*f
)
1108 f
->ts
.type
= BT_CHARACTER
;
1109 f
->ts
.kind
= gfc_default_character_kind
;
1110 f
->value
.function
.name
= gfc_get_string (PREFIX ("fdate"));
1115 gfc_resolve_floor (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
1117 f
->ts
.type
= BT_INTEGER
;
1118 f
->ts
.kind
= (kind
== NULL
)
1119 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
1120 f
->value
.function
.name
1121 = gfc_get_string ("__floor%d_%c%d", f
->ts
.kind
,
1122 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1127 gfc_resolve_fnum (gfc_expr
*f
, gfc_expr
*n
)
1129 f
->ts
.type
= BT_INTEGER
;
1130 f
->ts
.kind
= gfc_default_integer_kind
;
1131 if (n
->ts
.kind
!= f
->ts
.kind
)
1132 gfc_convert_type (n
, &f
->ts
, 2);
1133 f
->value
.function
.name
= gfc_get_string (PREFIX ("fnum_i%d"), f
->ts
.kind
);
1138 gfc_resolve_fraction (gfc_expr
*f
, gfc_expr
*x
)
1141 f
->value
.function
.name
= gfc_get_string ("__fraction_%d", x
->ts
.kind
);
1145 /* Resolve single-argument g77 math intrinsics, eg BESY0, ERF. */
1148 gfc_resolve_g77_math1 (gfc_expr
*f
, gfc_expr
*x
)
1151 f
->value
.function
.name
= gfc_get_string ("<intrinsic>");
1156 gfc_resolve_gamma (gfc_expr
*f
, gfc_expr
*x
)
1159 f
->value
.function
.name
1160 = gfc_get_string ("__tgamma_%d", x
->ts
.kind
);
1165 gfc_resolve_getcwd (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
1167 f
->ts
.type
= BT_INTEGER
;
1169 f
->value
.function
.name
= gfc_get_string (PREFIX ("getcwd"));
1174 gfc_resolve_getgid (gfc_expr
*f
)
1176 f
->ts
.type
= BT_INTEGER
;
1178 f
->value
.function
.name
= gfc_get_string (PREFIX ("getgid"));
1183 gfc_resolve_getpid (gfc_expr
*f
)
1185 f
->ts
.type
= BT_INTEGER
;
1187 f
->value
.function
.name
= gfc_get_string (PREFIX ("getpid"));
1192 gfc_resolve_getuid (gfc_expr
*f
)
1194 f
->ts
.type
= BT_INTEGER
;
1196 f
->value
.function
.name
= gfc_get_string (PREFIX ("getuid"));
1201 gfc_resolve_hostnm (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
1203 f
->ts
.type
= BT_INTEGER
;
1205 f
->value
.function
.name
= gfc_get_string (PREFIX ("hostnm"));
1210 gfc_resolve_hypot (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y ATTRIBUTE_UNUSED
)
1213 f
->value
.function
.name
= gfc_get_string ("__hypot_r%d", x
->ts
.kind
);
1218 gfc_resolve_iall (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*mask
)
1220 resolve_transformational ("iall", f
, array
, dim
, mask
);
1225 gfc_resolve_iand (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
1227 /* If the kind of i and j are different, then g77 cross-promoted the
1228 kinds to the largest value. The Fortran 95 standard requires the
1230 if (i
->ts
.kind
!= j
->ts
.kind
)
1232 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
1233 gfc_convert_type (j
, &i
->ts
, 2);
1235 gfc_convert_type (i
, &j
->ts
, 2);
1239 f
->value
.function
.name
= gfc_get_string ("__iand_%d", i
->ts
.kind
);
1244 gfc_resolve_iany (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*mask
)
1246 resolve_transformational ("iany", f
, array
, dim
, mask
);
1251 gfc_resolve_ibclr (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos ATTRIBUTE_UNUSED
)
1254 f
->value
.function
.name
= gfc_get_string ("__ibclr_%d", i
->ts
.kind
);
1259 gfc_resolve_ibits (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos ATTRIBUTE_UNUSED
,
1260 gfc_expr
*len ATTRIBUTE_UNUSED
)
1263 f
->value
.function
.name
= gfc_get_string ("__ibits_%d", i
->ts
.kind
);
1268 gfc_resolve_ibset (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*pos ATTRIBUTE_UNUSED
)
1271 f
->value
.function
.name
= gfc_get_string ("__ibset_%d", i
->ts
.kind
);
1276 gfc_resolve_iachar (gfc_expr
*f
, gfc_expr
*c
, 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 ("__ichar_%d", c
->ts
.kind
);
1288 gfc_resolve_ichar (gfc_expr
*f
, gfc_expr
*c
, gfc_expr
*kind
)
1290 f
->ts
.type
= BT_INTEGER
;
1292 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1294 f
->ts
.kind
= gfc_default_integer_kind
;
1295 f
->value
.function
.name
= gfc_get_string ("__ichar_%d", c
->ts
.kind
);
1300 gfc_resolve_idnint (gfc_expr
*f
, gfc_expr
*a
)
1302 gfc_resolve_nint (f
, a
, NULL
);
1307 gfc_resolve_ierrno (gfc_expr
*f
)
1309 f
->ts
.type
= BT_INTEGER
;
1310 f
->ts
.kind
= gfc_default_integer_kind
;
1311 f
->value
.function
.name
= gfc_get_string (PREFIX ("ierrno_i%d"), f
->ts
.kind
);
1316 gfc_resolve_ieor (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
1318 /* If the kind of i and j are different, then g77 cross-promoted the
1319 kinds to the largest value. The Fortran 95 standard requires the
1321 if (i
->ts
.kind
!= j
->ts
.kind
)
1323 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
1324 gfc_convert_type (j
, &i
->ts
, 2);
1326 gfc_convert_type (i
, &j
->ts
, 2);
1330 f
->value
.function
.name
= gfc_get_string ("__ieor_%d", i
->ts
.kind
);
1335 gfc_resolve_ior (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
1337 /* If the kind of i and j are different, then g77 cross-promoted the
1338 kinds to the largest value. The Fortran 95 standard requires the
1340 if (i
->ts
.kind
!= j
->ts
.kind
)
1342 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
1343 gfc_convert_type (j
, &i
->ts
, 2);
1345 gfc_convert_type (i
, &j
->ts
, 2);
1349 f
->value
.function
.name
= gfc_get_string ("__ior_%d", i
->ts
.kind
);
1354 gfc_resolve_index_func (gfc_expr
*f
, gfc_expr
*str
,
1355 gfc_expr
*sub_str ATTRIBUTE_UNUSED
, gfc_expr
*back
,
1361 f
->ts
.type
= BT_INTEGER
;
1363 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1365 f
->ts
.kind
= gfc_default_integer_kind
;
1367 if (back
&& back
->ts
.kind
!= gfc_default_integer_kind
)
1369 ts
.type
= BT_LOGICAL
;
1370 ts
.kind
= gfc_default_integer_kind
;
1371 ts
.u
.derived
= NULL
;
1373 gfc_convert_type (back
, &ts
, 2);
1376 f
->value
.function
.name
1377 = gfc_get_string ("__index_%d_i%d", str
->ts
.kind
, f
->ts
.kind
);
1382 gfc_resolve_int (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
1384 f
->ts
.type
= BT_INTEGER
;
1385 f
->ts
.kind
= (kind
== NULL
)
1386 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
1387 f
->value
.function
.name
1388 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1389 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1394 gfc_resolve_int2 (gfc_expr
*f
, gfc_expr
*a
)
1396 f
->ts
.type
= BT_INTEGER
;
1398 f
->value
.function
.name
1399 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1400 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1405 gfc_resolve_int8 (gfc_expr
*f
, gfc_expr
*a
)
1407 f
->ts
.type
= BT_INTEGER
;
1409 f
->value
.function
.name
1410 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1411 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1416 gfc_resolve_long (gfc_expr
*f
, gfc_expr
*a
)
1418 f
->ts
.type
= BT_INTEGER
;
1420 f
->value
.function
.name
1421 = gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
,
1422 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1427 gfc_resolve_iparity (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*mask
)
1429 resolve_transformational ("iparity", f
, array
, dim
, mask
);
1434 gfc_resolve_isatty (gfc_expr
*f
, gfc_expr
*u
)
1439 f
->ts
.type
= BT_LOGICAL
;
1440 f
->ts
.kind
= gfc_default_integer_kind
;
1441 if (u
->ts
.kind
!= gfc_c_int_kind
)
1443 ts
.type
= BT_INTEGER
;
1444 ts
.kind
= gfc_c_int_kind
;
1445 ts
.u
.derived
= NULL
;
1447 gfc_convert_type (u
, &ts
, 2);
1450 f
->value
.function
.name
= gfc_get_string (PREFIX ("isatty_l%d"), f
->ts
.kind
);
1455 gfc_resolve_ishft (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
)
1458 f
->value
.function
.name
1459 = gfc_get_string ("__ishft_%d_%d", i
->ts
.kind
, shift
->ts
.kind
);
1464 gfc_resolve_rshift (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
)
1467 f
->value
.function
.name
1468 = gfc_get_string ("__rshift_%d_%d", i
->ts
.kind
, shift
->ts
.kind
);
1473 gfc_resolve_lshift (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
)
1476 f
->value
.function
.name
1477 = gfc_get_string ("__lshift_%d_%d", i
->ts
.kind
, shift
->ts
.kind
);
1482 gfc_resolve_ishftc (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift
, gfc_expr
*size
)
1486 s_kind
= (size
== NULL
) ? gfc_default_integer_kind
: size
->ts
.kind
;
1489 f
->value
.function
.name
1490 = gfc_get_string ("__ishftc_%d_%d_%d", i
->ts
.kind
, shift
->ts
.kind
, s_kind
);
1495 gfc_resolve_kill (gfc_expr
*f
, gfc_expr
*p ATTRIBUTE_UNUSED
,
1496 gfc_expr
*s ATTRIBUTE_UNUSED
)
1498 f
->ts
.type
= BT_INTEGER
;
1499 f
->ts
.kind
= gfc_default_integer_kind
;
1500 f
->value
.function
.name
= gfc_get_string (PREFIX ("kill_i%d"), f
->ts
.kind
);
1505 gfc_resolve_lbound (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
1507 resolve_bound (f
, array
, dim
, kind
, "__lbound", false);
1512 gfc_resolve_lcobound (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
1514 resolve_bound (f
, array
, dim
, kind
, "__lcobound", true);
1519 gfc_resolve_len (gfc_expr
*f
, gfc_expr
*string
, gfc_expr
*kind
)
1521 f
->ts
.type
= BT_INTEGER
;
1523 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1525 f
->ts
.kind
= gfc_default_integer_kind
;
1526 f
->value
.function
.name
1527 = gfc_get_string ("__len_%d_i%d", string
->ts
.kind
,
1528 gfc_default_integer_kind
);
1533 gfc_resolve_len_trim (gfc_expr
*f
, gfc_expr
*string
, gfc_expr
*kind
)
1535 f
->ts
.type
= BT_INTEGER
;
1537 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1539 f
->ts
.kind
= gfc_default_integer_kind
;
1540 f
->value
.function
.name
= gfc_get_string ("__len_trim%d", string
->ts
.kind
);
1545 gfc_resolve_lgamma (gfc_expr
*f
, gfc_expr
*x
)
1548 f
->value
.function
.name
1549 = gfc_get_string ("__lgamma_%d", x
->ts
.kind
);
1554 gfc_resolve_link (gfc_expr
*f
, gfc_expr
*p1 ATTRIBUTE_UNUSED
,
1555 gfc_expr
*p2 ATTRIBUTE_UNUSED
)
1557 f
->ts
.type
= BT_INTEGER
;
1558 f
->ts
.kind
= gfc_default_integer_kind
;
1559 f
->value
.function
.name
= gfc_get_string (PREFIX ("link_i%d"), f
->ts
.kind
);
1564 gfc_resolve_loc (gfc_expr
*f
, gfc_expr
*x
)
1566 f
->ts
.type
= BT_INTEGER
;
1567 f
->ts
.kind
= gfc_index_integer_kind
;
1568 f
->value
.function
.name
= gfc_get_string ("__loc_%d", x
->ts
.kind
);
1573 gfc_resolve_log (gfc_expr
*f
, gfc_expr
*x
)
1576 f
->value
.function
.name
1577 = gfc_get_string ("__log_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
1582 gfc_resolve_log10 (gfc_expr
*f
, gfc_expr
*x
)
1585 f
->value
.function
.name
1586 = gfc_get_string ("__log10_%c%d", gfc_type_letter (x
->ts
.type
),
1592 gfc_resolve_logical (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
1594 f
->ts
.type
= BT_LOGICAL
;
1595 f
->ts
.kind
= (kind
== NULL
)
1596 ? gfc_default_logical_kind
: mpz_get_si (kind
->value
.integer
);
1599 f
->value
.function
.name
1600 = gfc_get_string ("__logical_%d_%c%d", f
->ts
.kind
,
1601 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1606 gfc_resolve_matmul (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*b
)
1610 if (a
->ts
.type
== BT_LOGICAL
&& b
->ts
.type
== BT_LOGICAL
)
1612 f
->ts
.type
= BT_LOGICAL
;
1613 f
->ts
.kind
= gfc_default_logical_kind
;
1617 temp
.expr_type
= EXPR_OP
;
1618 gfc_clear_ts (&temp
.ts
);
1619 temp
.value
.op
.op
= INTRINSIC_NONE
;
1620 temp
.value
.op
.op1
= a
;
1621 temp
.value
.op
.op2
= b
;
1622 gfc_type_convert_binary (&temp
, 1);
1626 f
->rank
= (a
->rank
== 2 && b
->rank
== 2) ? 2 : 1;
1628 if (a
->rank
== 2 && b
->rank
== 2)
1630 if (a
->shape
&& b
->shape
)
1632 f
->shape
= gfc_get_shape (f
->rank
);
1633 mpz_init_set (f
->shape
[0], a
->shape
[0]);
1634 mpz_init_set (f
->shape
[1], b
->shape
[1]);
1637 else if (a
->rank
== 1)
1641 f
->shape
= gfc_get_shape (f
->rank
);
1642 mpz_init_set (f
->shape
[0], b
->shape
[1]);
1647 /* b->rank == 1 and a->rank == 2 here, all other cases have
1648 been caught in check.c. */
1651 f
->shape
= gfc_get_shape (f
->rank
);
1652 mpz_init_set (f
->shape
[0], a
->shape
[0]);
1656 f
->value
.function
.name
1657 = gfc_get_string (PREFIX ("matmul_%c%d"), gfc_type_letter (f
->ts
.type
),
1663 gfc_resolve_minmax (const char *name
, gfc_expr
*f
, gfc_actual_arglist
*args
)
1665 gfc_actual_arglist
*a
;
1667 f
->ts
.type
= args
->expr
->ts
.type
;
1668 f
->ts
.kind
= args
->expr
->ts
.kind
;
1669 /* Find the largest type kind. */
1670 for (a
= args
->next
; a
; a
= a
->next
)
1672 if (a
->expr
->ts
.kind
> f
->ts
.kind
)
1673 f
->ts
.kind
= a
->expr
->ts
.kind
;
1676 /* Convert all parameters to the required kind. */
1677 for (a
= args
; a
; a
= a
->next
)
1679 if (a
->expr
->ts
.kind
!= f
->ts
.kind
)
1680 gfc_convert_type (a
->expr
, &f
->ts
, 2);
1683 f
->value
.function
.name
1684 = gfc_get_string (name
, gfc_type_letter (f
->ts
.type
), f
->ts
.kind
);
1689 gfc_resolve_max (gfc_expr
*f
, gfc_actual_arglist
*args
)
1691 gfc_resolve_minmax ("__max_%c%d", f
, args
);
1694 /* The smallest kind for which a minloc and maxloc implementation exists. */
1696 #define MINMAXLOC_MIN_KIND 4
1699 gfc_resolve_maxloc (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
1700 gfc_expr
*mask
, gfc_expr
*kind
)
1707 f
->ts
.type
= BT_INTEGER
;
1709 /* The library versions only exist for kinds 4, 8 and 16. For smaller kinds,
1710 we do a type conversion further down. */
1712 fkind
= mpz_get_si (kind
->value
.integer
);
1714 fkind
= gfc_default_integer_kind
;
1716 if (fkind
< MINMAXLOC_MIN_KIND
)
1717 f
->ts
.kind
= MINMAXLOC_MIN_KIND
;
1724 f
->shape
= gfc_get_shape (1);
1725 mpz_init_set_si (f
->shape
[0], array
->rank
);
1729 f
->rank
= array
->rank
- 1;
1730 gfc_resolve_dim_arg (dim
);
1731 if (array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
1733 idim
= (int) mpz_get_si (dim
->value
.integer
);
1734 f
->shape
= gfc_get_shape (f
->rank
);
1735 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
1737 if (i
== (idim
- 1))
1739 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
1746 if (mask
->rank
== 0)
1751 resolve_mask_arg (mask
);
1758 if (array
->ts
.type
!= BT_CHARACTER
|| f
->rank
!= 0)
1766 f
->value
.function
.name
1767 = gfc_get_string (PREFIX ("%s%d_%d_%c%d"), name
, d_num
, f
->ts
.kind
,
1768 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1771 fkind
= mpz_get_si (kind
->value
.integer
);
1773 fkind
= gfc_default_integer_kind
;
1775 if (fkind
!= f
->ts
.kind
)
1780 ts
.type
= BT_INTEGER
;
1782 gfc_convert_type_warn (f
, &ts
, 2, 0);
1788 gfc_resolve_maxval (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
1798 f
->rank
= array
->rank
- 1;
1799 gfc_resolve_dim_arg (dim
);
1801 if (f
->rank
&& array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
1803 idim
= (int) mpz_get_si (dim
->value
.integer
);
1804 f
->shape
= gfc_get_shape (f
->rank
);
1805 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
1807 if (i
== (idim
- 1))
1809 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
1816 if (mask
->rank
== 0)
1821 resolve_mask_arg (mask
);
1826 if (array
->ts
.type
!= BT_CHARACTER
)
1827 f
->value
.function
.name
1828 = gfc_get_string (PREFIX ("%s_%c%d"), name
,
1829 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1831 f
->value
.function
.name
1832 = gfc_get_string (PREFIX ("%s%d_%c%d"), name
, f
->rank
!= 0,
1833 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1838 gfc_resolve_mclock (gfc_expr
*f
)
1840 f
->ts
.type
= BT_INTEGER
;
1842 f
->value
.function
.name
= PREFIX ("mclock");
1847 gfc_resolve_mclock8 (gfc_expr
*f
)
1849 f
->ts
.type
= BT_INTEGER
;
1851 f
->value
.function
.name
= PREFIX ("mclock8");
1856 gfc_resolve_mask (gfc_expr
*f
, gfc_expr
*i ATTRIBUTE_UNUSED
,
1859 f
->ts
.type
= BT_INTEGER
;
1860 f
->ts
.kind
= kind
? mpz_get_si (kind
->value
.integer
)
1861 : gfc_default_integer_kind
;
1863 if (f
->value
.function
.isym
->id
== GFC_ISYM_MASKL
)
1864 f
->value
.function
.name
= gfc_get_string ("__maskl_i%d", f
->ts
.kind
);
1866 f
->value
.function
.name
= gfc_get_string ("__maskr_i%d", f
->ts
.kind
);
1871 gfc_resolve_merge (gfc_expr
*f
, gfc_expr
*tsource
,
1872 gfc_expr
*fsource ATTRIBUTE_UNUSED
,
1873 gfc_expr
*mask ATTRIBUTE_UNUSED
)
1875 if (tsource
->ts
.type
== BT_CHARACTER
&& tsource
->ref
)
1876 gfc_resolve_substring_charlen (tsource
);
1878 if (fsource
->ts
.type
== BT_CHARACTER
&& fsource
->ref
)
1879 gfc_resolve_substring_charlen (fsource
);
1881 if (tsource
->ts
.type
== BT_CHARACTER
)
1882 check_charlen_present (tsource
);
1884 f
->ts
= tsource
->ts
;
1885 f
->value
.function
.name
1886 = gfc_get_string ("__merge_%c%d", gfc_type_letter (tsource
->ts
.type
),
1892 gfc_resolve_merge_bits (gfc_expr
*f
, gfc_expr
*i
,
1893 gfc_expr
*j ATTRIBUTE_UNUSED
,
1894 gfc_expr
*mask ATTRIBUTE_UNUSED
)
1897 f
->value
.function
.name
= gfc_get_string ("__merge_bits_i%d", i
->ts
.kind
);
1902 gfc_resolve_min (gfc_expr
*f
, gfc_actual_arglist
*args
)
1904 gfc_resolve_minmax ("__min_%c%d", f
, args
);
1909 gfc_resolve_minloc (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
1910 gfc_expr
*mask
, gfc_expr
*kind
)
1917 f
->ts
.type
= BT_INTEGER
;
1919 /* The library versions only exist for kinds 4, 8 and 16. For smaller kinds,
1920 we do a type conversion further down. */
1922 fkind
= mpz_get_si (kind
->value
.integer
);
1924 fkind
= gfc_default_integer_kind
;
1926 if (fkind
< MINMAXLOC_MIN_KIND
)
1927 f
->ts
.kind
= MINMAXLOC_MIN_KIND
;
1934 f
->shape
= gfc_get_shape (1);
1935 mpz_init_set_si (f
->shape
[0], array
->rank
);
1939 f
->rank
= array
->rank
- 1;
1940 gfc_resolve_dim_arg (dim
);
1941 if (array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
1943 idim
= (int) mpz_get_si (dim
->value
.integer
);
1944 f
->shape
= gfc_get_shape (f
->rank
);
1945 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
1947 if (i
== (idim
- 1))
1949 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
1956 if (mask
->rank
== 0)
1961 resolve_mask_arg (mask
);
1968 if (array
->ts
.type
!= BT_CHARACTER
|| f
->rank
!= 0)
1976 f
->value
.function
.name
1977 = gfc_get_string (PREFIX ("%s%d_%d_%c%d"), name
, d_num
, f
->ts
.kind
,
1978 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1980 if (fkind
!= f
->ts
.kind
)
1985 ts
.type
= BT_INTEGER
;
1987 gfc_convert_type_warn (f
, &ts
, 2, 0);
1993 gfc_resolve_minval (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
2003 f
->rank
= array
->rank
- 1;
2004 gfc_resolve_dim_arg (dim
);
2006 if (f
->rank
&& array
->shape
&& dim
->expr_type
== EXPR_CONSTANT
)
2008 idim
= (int) mpz_get_si (dim
->value
.integer
);
2009 f
->shape
= gfc_get_shape (f
->rank
);
2010 for (i
= 0, j
= 0; i
< f
->rank
; i
++, j
++)
2012 if (i
== (idim
- 1))
2014 mpz_init_set (f
->shape
[i
], array
->shape
[j
]);
2021 if (mask
->rank
== 0)
2026 resolve_mask_arg (mask
);
2031 if (array
->ts
.type
!= BT_CHARACTER
)
2032 f
->value
.function
.name
2033 = gfc_get_string (PREFIX ("%s_%c%d"), name
,
2034 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
2036 f
->value
.function
.name
2037 = gfc_get_string (PREFIX ("%s%d_%c%d"), name
, f
->rank
!= 0,
2038 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
2043 gfc_resolve_mod (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p
)
2045 f
->ts
.type
= a
->ts
.type
;
2047 f
->ts
.kind
= gfc_kind_max (a
,p
);
2049 f
->ts
.kind
= a
->ts
.kind
;
2051 if (p
!= NULL
&& a
->ts
.kind
!= p
->ts
.kind
)
2053 if (a
->ts
.kind
== gfc_kind_max (a
,p
))
2054 gfc_convert_type (p
, &a
->ts
, 2);
2056 gfc_convert_type (a
, &p
->ts
, 2);
2059 f
->value
.function
.name
2060 = gfc_get_string ("__mod_%c%d", gfc_type_letter (f
->ts
.type
), f
->ts
.kind
);
2065 gfc_resolve_modulo (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p
)
2067 f
->ts
.type
= a
->ts
.type
;
2069 f
->ts
.kind
= gfc_kind_max (a
,p
);
2071 f
->ts
.kind
= a
->ts
.kind
;
2073 if (p
!= NULL
&& a
->ts
.kind
!= p
->ts
.kind
)
2075 if (a
->ts
.kind
== gfc_kind_max (a
,p
))
2076 gfc_convert_type (p
, &a
->ts
, 2);
2078 gfc_convert_type (a
, &p
->ts
, 2);
2081 f
->value
.function
.name
2082 = gfc_get_string ("__modulo_%c%d", gfc_type_letter (f
->ts
.type
),
2087 gfc_resolve_nearest (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*p
)
2089 if (p
->ts
.kind
!= a
->ts
.kind
)
2090 gfc_convert_type (p
, &a
->ts
, 2);
2093 f
->value
.function
.name
2094 = gfc_get_string ("__nearest_%c%d", gfc_type_letter (a
->ts
.type
),
2099 gfc_resolve_nint (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
2101 f
->ts
.type
= BT_INTEGER
;
2102 f
->ts
.kind
= (kind
== NULL
)
2103 ? gfc_default_integer_kind
: mpz_get_si (kind
->value
.integer
);
2104 f
->value
.function
.name
2105 = gfc_get_string ("__nint_%d_%d", f
->ts
.kind
, a
->ts
.kind
);
2110 gfc_resolve_norm2 (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
)
2112 resolve_transformational ("norm2", f
, array
, dim
, NULL
);
2117 gfc_resolve_not (gfc_expr
*f
, gfc_expr
*i
)
2120 f
->value
.function
.name
= gfc_get_string ("__not_%d", i
->ts
.kind
);
2125 gfc_resolve_or (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
2127 f
->ts
.type
= i
->ts
.type
;
2128 f
->ts
.kind
= gfc_kind_max (i
, j
);
2130 if (i
->ts
.kind
!= j
->ts
.kind
)
2132 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
2133 gfc_convert_type (j
, &i
->ts
, 2);
2135 gfc_convert_type (i
, &j
->ts
, 2);
2138 f
->value
.function
.name
2139 = gfc_get_string ("__or_%c%d", gfc_type_letter (i
->ts
.type
), f
->ts
.kind
);
2144 gfc_resolve_pack (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*mask
,
2145 gfc_expr
*vector ATTRIBUTE_UNUSED
)
2147 if (array
->ts
.type
== BT_CHARACTER
&& array
->ref
)
2148 gfc_resolve_substring_charlen (array
);
2153 resolve_mask_arg (mask
);
2155 if (mask
->rank
!= 0)
2157 if (array
->ts
.type
== BT_CHARACTER
)
2158 f
->value
.function
.name
2159 = array
->ts
.kind
== 1 ? PREFIX ("pack_char")
2161 (PREFIX ("pack_char%d"),
2164 f
->value
.function
.name
= PREFIX ("pack");
2168 if (array
->ts
.type
== BT_CHARACTER
)
2169 f
->value
.function
.name
2170 = array
->ts
.kind
== 1 ? PREFIX ("pack_s_char")
2172 (PREFIX ("pack_s_char%d"),
2175 f
->value
.function
.name
= PREFIX ("pack_s");
2181 gfc_resolve_parity (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
)
2183 resolve_transformational ("parity", f
, array
, dim
, NULL
);
2188 gfc_resolve_product (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
2191 resolve_transformational ("product", f
, array
, dim
, mask
);
2196 gfc_resolve_rank (gfc_expr
*f
, gfc_expr
*array ATTRIBUTE_UNUSED
)
2198 f
->ts
.type
= BT_INTEGER
;
2199 f
->ts
.kind
= gfc_default_integer_kind
;
2200 f
->value
.function
.name
= gfc_get_string ("__rank");
2205 gfc_resolve_real (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*kind
)
2207 f
->ts
.type
= BT_REAL
;
2210 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2212 f
->ts
.kind
= (a
->ts
.type
== BT_COMPLEX
)
2213 ? a
->ts
.kind
: gfc_default_real_kind
;
2215 f
->value
.function
.name
2216 = gfc_get_string ("__real_%d_%c%d", f
->ts
.kind
,
2217 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
2222 gfc_resolve_realpart (gfc_expr
*f
, gfc_expr
*a
)
2224 f
->ts
.type
= BT_REAL
;
2225 f
->ts
.kind
= a
->ts
.kind
;
2226 f
->value
.function
.name
2227 = gfc_get_string ("__real_%d_%c%d", f
->ts
.kind
,
2228 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
2233 gfc_resolve_rename (gfc_expr
*f
, gfc_expr
*p1 ATTRIBUTE_UNUSED
,
2234 gfc_expr
*p2 ATTRIBUTE_UNUSED
)
2236 f
->ts
.type
= BT_INTEGER
;
2237 f
->ts
.kind
= gfc_default_integer_kind
;
2238 f
->value
.function
.name
= gfc_get_string (PREFIX ("rename_i%d"), f
->ts
.kind
);
2243 gfc_resolve_repeat (gfc_expr
*f
, gfc_expr
*string
,
2248 f
->ts
.type
= BT_CHARACTER
;
2249 f
->ts
.kind
= string
->ts
.kind
;
2250 f
->value
.function
.name
= gfc_get_string ("__repeat_%d", string
->ts
.kind
);
2252 /* If possible, generate a character length. */
2253 if (f
->ts
.u
.cl
== NULL
)
2254 f
->ts
.u
.cl
= gfc_new_charlen (gfc_current_ns
, NULL
);
2257 if (string
->expr_type
== EXPR_CONSTANT
)
2259 len
= string
->value
.character
.length
;
2260 tmp
= gfc_get_int_expr (gfc_default_integer_kind
, NULL
, len
);
2262 else if (string
->ts
.u
.cl
&& string
->ts
.u
.cl
->length
)
2264 tmp
= gfc_copy_expr (string
->ts
.u
.cl
->length
);
2268 f
->ts
.u
.cl
->length
= gfc_multiply (tmp
, gfc_copy_expr (ncopies
));
2273 gfc_resolve_reshape (gfc_expr
*f
, gfc_expr
*source
, gfc_expr
*shape
,
2274 gfc_expr
*pad ATTRIBUTE_UNUSED
,
2275 gfc_expr
*order ATTRIBUTE_UNUSED
)
2281 if (source
->ts
.type
== BT_CHARACTER
&& source
->ref
)
2282 gfc_resolve_substring_charlen (source
);
2286 gfc_array_size (shape
, &rank
);
2287 f
->rank
= mpz_get_si (rank
);
2289 switch (source
->ts
.type
)
2296 kind
= source
->ts
.kind
;
2310 if (source
->ts
.type
== BT_COMPLEX
|| source
->ts
.type
== BT_REAL
)
2311 f
->value
.function
.name
2312 = gfc_get_string (PREFIX ("reshape_%c%d"),
2313 gfc_type_letter (source
->ts
.type
),
2315 else if (source
->ts
.type
== BT_CHARACTER
)
2316 f
->value
.function
.name
= gfc_get_string (PREFIX ("reshape_char%d"),
2319 f
->value
.function
.name
2320 = gfc_get_string (PREFIX ("reshape_%d"), source
->ts
.kind
);
2324 f
->value
.function
.name
= (source
->ts
.type
== BT_CHARACTER
2325 ? PREFIX ("reshape_char") : PREFIX ("reshape"));
2329 if (shape
->expr_type
== EXPR_ARRAY
&& gfc_is_constant_expr (shape
))
2332 f
->shape
= gfc_get_shape (f
->rank
);
2333 c
= gfc_constructor_first (shape
->value
.constructor
);
2334 for (i
= 0; i
< f
->rank
; i
++)
2336 mpz_init_set (f
->shape
[i
], c
->expr
->value
.integer
);
2337 c
= gfc_constructor_next (c
);
2341 /* Force-convert both SHAPE and ORDER to index_kind so that we don't need
2342 so many runtime variations. */
2343 if (shape
->ts
.kind
!= gfc_index_integer_kind
)
2345 gfc_typespec ts
= shape
->ts
;
2346 ts
.kind
= gfc_index_integer_kind
;
2347 gfc_convert_type_warn (shape
, &ts
, 2, 0);
2349 if (order
&& order
->ts
.kind
!= gfc_index_integer_kind
)
2350 gfc_convert_type_warn (order
, &shape
->ts
, 2, 0);
2355 gfc_resolve_rrspacing (gfc_expr
*f
, gfc_expr
*x
)
2358 f
->value
.function
.name
= gfc_get_string ("__rrspacing_%d", x
->ts
.kind
);
2362 gfc_resolve_fe_runtime_error (gfc_code
*c
)
2365 gfc_actual_arglist
*a
;
2367 name
= gfc_get_string (PREFIX ("runtime_error"));
2369 for (a
= c
->ext
.actual
->next
; a
; a
= a
->next
)
2372 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2376 gfc_resolve_scale (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*i ATTRIBUTE_UNUSED
)
2379 f
->value
.function
.name
= gfc_get_string ("__scale_%d", x
->ts
.kind
);
2384 gfc_resolve_scan (gfc_expr
*f
, gfc_expr
*string
,
2385 gfc_expr
*set ATTRIBUTE_UNUSED
,
2386 gfc_expr
*back ATTRIBUTE_UNUSED
, gfc_expr
*kind
)
2388 f
->ts
.type
= BT_INTEGER
;
2390 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2392 f
->ts
.kind
= gfc_default_integer_kind
;
2393 f
->value
.function
.name
= gfc_get_string ("__scan_%d", string
->ts
.kind
);
2398 gfc_resolve_secnds (gfc_expr
*t1
, gfc_expr
*t0
)
2401 t1
->value
.function
.name
= gfc_get_string (PREFIX ("secnds"));
2406 gfc_resolve_set_exponent (gfc_expr
*f
, gfc_expr
*x
,
2407 gfc_expr
*i ATTRIBUTE_UNUSED
)
2410 f
->value
.function
.name
= gfc_get_string ("__set_exponent_%d", x
->ts
.kind
);
2415 gfc_resolve_shape (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*kind
)
2417 f
->ts
.type
= BT_INTEGER
;
2420 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2422 f
->ts
.kind
= gfc_default_integer_kind
;
2425 if (array
->rank
!= -1)
2427 f
->shape
= gfc_get_shape (1);
2428 mpz_init_set_ui (f
->shape
[0], array
->rank
);
2431 f
->value
.function
.name
= gfc_get_string (PREFIX ("shape_%d"), f
->ts
.kind
);
2436 gfc_resolve_shift (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*shift ATTRIBUTE_UNUSED
)
2439 if (f
->value
.function
.isym
->id
== GFC_ISYM_SHIFTA
)
2440 f
->value
.function
.name
= gfc_get_string ("shifta_i%d", f
->ts
.kind
);
2441 else if (f
->value
.function
.isym
->id
== GFC_ISYM_SHIFTL
)
2442 f
->value
.function
.name
= gfc_get_string ("shiftl_i%d", f
->ts
.kind
);
2443 else if (f
->value
.function
.isym
->id
== GFC_ISYM_SHIFTR
)
2444 f
->value
.function
.name
= gfc_get_string ("shiftr_i%d", f
->ts
.kind
);
2451 gfc_resolve_sign (gfc_expr
*f
, gfc_expr
*a
, gfc_expr
*b ATTRIBUTE_UNUSED
)
2454 f
->value
.function
.name
2455 = gfc_get_string ("__sign_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
2460 gfc_resolve_signal (gfc_expr
*f
, gfc_expr
*number
, gfc_expr
*handler
)
2462 f
->ts
.type
= BT_INTEGER
;
2463 f
->ts
.kind
= gfc_c_int_kind
;
2465 /* handler can be either BT_INTEGER or BT_PROCEDURE */
2466 if (handler
->ts
.type
== BT_INTEGER
)
2468 if (handler
->ts
.kind
!= gfc_c_int_kind
)
2469 gfc_convert_type (handler
, &f
->ts
, 2);
2470 f
->value
.function
.name
= gfc_get_string (PREFIX ("signal_func_int"));
2473 f
->value
.function
.name
= gfc_get_string (PREFIX ("signal_func"));
2475 if (number
->ts
.kind
!= gfc_c_int_kind
)
2476 gfc_convert_type (number
, &f
->ts
, 2);
2481 gfc_resolve_sin (gfc_expr
*f
, gfc_expr
*x
)
2484 f
->value
.function
.name
2485 = gfc_get_string ("__sin_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
2490 gfc_resolve_sinh (gfc_expr
*f
, gfc_expr
*x
)
2493 f
->value
.function
.name
2494 = gfc_get_string ("__sinh_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
2499 gfc_resolve_size (gfc_expr
*f
, gfc_expr
*array ATTRIBUTE_UNUSED
,
2500 gfc_expr
*dim ATTRIBUTE_UNUSED
, gfc_expr
*kind
)
2502 f
->ts
.type
= BT_INTEGER
;
2504 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2506 f
->ts
.kind
= gfc_default_integer_kind
;
2511 gfc_resolve_stride (gfc_expr
*f
, gfc_expr
*array ATTRIBUTE_UNUSED
,
2512 gfc_expr
*dim ATTRIBUTE_UNUSED
)
2514 f
->ts
.type
= BT_INTEGER
;
2515 f
->ts
.kind
= gfc_index_integer_kind
;
2520 gfc_resolve_spacing (gfc_expr
*f
, gfc_expr
*x
)
2523 f
->value
.function
.name
= gfc_get_string ("__spacing_%d", x
->ts
.kind
);
2528 gfc_resolve_spread (gfc_expr
*f
, gfc_expr
*source
, gfc_expr
*dim
,
2531 if (source
->ts
.type
== BT_CHARACTER
&& source
->ref
)
2532 gfc_resolve_substring_charlen (source
);
2534 if (source
->ts
.type
== BT_CHARACTER
)
2535 check_charlen_present (source
);
2538 f
->rank
= source
->rank
+ 1;
2539 if (source
->rank
== 0)
2541 if (source
->ts
.type
== BT_CHARACTER
)
2542 f
->value
.function
.name
2543 = source
->ts
.kind
== 1 ? PREFIX ("spread_char_scalar")
2545 (PREFIX ("spread_char%d_scalar"),
2548 f
->value
.function
.name
= PREFIX ("spread_scalar");
2552 if (source
->ts
.type
== BT_CHARACTER
)
2553 f
->value
.function
.name
2554 = source
->ts
.kind
== 1 ? PREFIX ("spread_char")
2556 (PREFIX ("spread_char%d"),
2559 f
->value
.function
.name
= PREFIX ("spread");
2562 if (dim
&& gfc_is_constant_expr (dim
)
2563 && ncopies
&& gfc_is_constant_expr (ncopies
) && source
->shape
[0])
2566 idim
= mpz_get_ui (dim
->value
.integer
);
2567 f
->shape
= gfc_get_shape (f
->rank
);
2568 for (i
= 0; i
< (idim
- 1); i
++)
2569 mpz_init_set (f
->shape
[i
], source
->shape
[i
]);
2571 mpz_init_set (f
->shape
[idim
- 1], ncopies
->value
.integer
);
2573 for (i
= idim
; i
< f
->rank
; i
++)
2574 mpz_init_set (f
->shape
[i
], source
->shape
[i
-1]);
2578 gfc_resolve_dim_arg (dim
);
2579 gfc_resolve_index (ncopies
, 1);
2584 gfc_resolve_sqrt (gfc_expr
*f
, gfc_expr
*x
)
2587 f
->value
.function
.name
2588 = gfc_get_string ("__sqrt_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
2592 /* Resolve the g77 compatibility function STAT AND FSTAT. */
2595 gfc_resolve_stat (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
,
2596 gfc_expr
*a ATTRIBUTE_UNUSED
)
2598 f
->ts
.type
= BT_INTEGER
;
2599 f
->ts
.kind
= gfc_default_integer_kind
;
2600 f
->value
.function
.name
= gfc_get_string (PREFIX ("stat_i%d"), f
->ts
.kind
);
2605 gfc_resolve_lstat (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
,
2606 gfc_expr
*a ATTRIBUTE_UNUSED
)
2608 f
->ts
.type
= BT_INTEGER
;
2609 f
->ts
.kind
= gfc_default_integer_kind
;
2610 f
->value
.function
.name
= gfc_get_string (PREFIX ("lstat_i%d"), f
->ts
.kind
);
2615 gfc_resolve_fstat (gfc_expr
*f
, gfc_expr
*n
, gfc_expr
*a ATTRIBUTE_UNUSED
)
2617 f
->ts
.type
= BT_INTEGER
;
2618 f
->ts
.kind
= gfc_default_integer_kind
;
2619 if (n
->ts
.kind
!= f
->ts
.kind
)
2620 gfc_convert_type (n
, &f
->ts
, 2);
2622 f
->value
.function
.name
= gfc_get_string (PREFIX ("fstat_i%d"), f
->ts
.kind
);
2627 gfc_resolve_fgetc (gfc_expr
*f
, gfc_expr
*u
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2632 f
->ts
.type
= BT_INTEGER
;
2633 f
->ts
.kind
= gfc_c_int_kind
;
2634 if (u
->ts
.kind
!= gfc_c_int_kind
)
2636 ts
.type
= BT_INTEGER
;
2637 ts
.kind
= gfc_c_int_kind
;
2638 ts
.u
.derived
= NULL
;
2640 gfc_convert_type (u
, &ts
, 2);
2643 f
->value
.function
.name
= gfc_get_string (PREFIX ("fgetc"));
2648 gfc_resolve_fget (gfc_expr
*f
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2650 f
->ts
.type
= BT_INTEGER
;
2651 f
->ts
.kind
= gfc_c_int_kind
;
2652 f
->value
.function
.name
= gfc_get_string (PREFIX ("fget"));
2657 gfc_resolve_fputc (gfc_expr
*f
, gfc_expr
*u
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2662 f
->ts
.type
= BT_INTEGER
;
2663 f
->ts
.kind
= gfc_c_int_kind
;
2664 if (u
->ts
.kind
!= gfc_c_int_kind
)
2666 ts
.type
= BT_INTEGER
;
2667 ts
.kind
= gfc_c_int_kind
;
2668 ts
.u
.derived
= NULL
;
2670 gfc_convert_type (u
, &ts
, 2);
2673 f
->value
.function
.name
= gfc_get_string (PREFIX ("fputc"));
2678 gfc_resolve_fput (gfc_expr
*f
, gfc_expr
*c ATTRIBUTE_UNUSED
)
2680 f
->ts
.type
= BT_INTEGER
;
2681 f
->ts
.kind
= gfc_c_int_kind
;
2682 f
->value
.function
.name
= gfc_get_string (PREFIX ("fput"));
2687 gfc_resolve_ftell (gfc_expr
*f
, gfc_expr
*u
)
2692 f
->ts
.type
= BT_INTEGER
;
2693 f
->ts
.kind
= gfc_intio_kind
;
2694 if (u
->ts
.kind
!= gfc_c_int_kind
)
2696 ts
.type
= BT_INTEGER
;
2697 ts
.kind
= gfc_c_int_kind
;
2698 ts
.u
.derived
= NULL
;
2700 gfc_convert_type (u
, &ts
, 2);
2703 f
->value
.function
.name
= gfc_get_string (PREFIX ("ftell"));
2708 gfc_resolve_storage_size (gfc_expr
*f
, gfc_expr
*a ATTRIBUTE_UNUSED
,
2711 f
->ts
.type
= BT_INTEGER
;
2713 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
2715 f
->ts
.kind
= gfc_default_integer_kind
;
2720 gfc_resolve_sum (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*mask
)
2722 resolve_transformational ("sum", f
, array
, dim
, mask
);
2727 gfc_resolve_symlnk (gfc_expr
*f
, gfc_expr
*p1 ATTRIBUTE_UNUSED
,
2728 gfc_expr
*p2 ATTRIBUTE_UNUSED
)
2730 f
->ts
.type
= BT_INTEGER
;
2731 f
->ts
.kind
= gfc_default_integer_kind
;
2732 f
->value
.function
.name
= gfc_get_string (PREFIX ("symlnk_i%d"), f
->ts
.kind
);
2736 /* Resolve the g77 compatibility function SYSTEM. */
2739 gfc_resolve_system (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
2741 f
->ts
.type
= BT_INTEGER
;
2743 f
->value
.function
.name
= gfc_get_string (PREFIX ("system"));
2748 gfc_resolve_tan (gfc_expr
*f
, gfc_expr
*x
)
2751 f
->value
.function
.name
2752 = gfc_get_string ("__tan_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
2757 gfc_resolve_tanh (gfc_expr
*f
, gfc_expr
*x
)
2760 f
->value
.function
.name
2761 = gfc_get_string ("__tanh_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
2765 /* Build an expression for converting degrees to radians. */
2768 get_radians (gfc_expr
*deg
)
2770 gfc_expr
*result
, *factor
;
2771 gfc_actual_arglist
*mod_args
;
2773 gcc_assert (deg
->ts
.type
== BT_REAL
);
2775 /* Set deg = deg % 360 to avoid offsets from large angles. */
2776 factor
= gfc_get_constant_expr (deg
->ts
.type
, deg
->ts
.kind
, °
->where
);
2777 mpfr_set_d (factor
->value
.real
, 360.0, GFC_RND_MODE
);
2779 mod_args
= gfc_get_actual_arglist ();
2780 mod_args
->expr
= deg
;
2781 mod_args
->next
= gfc_get_actual_arglist ();
2782 mod_args
->next
->expr
= factor
;
2784 result
= gfc_get_expr ();
2785 result
->ts
= deg
->ts
;
2786 result
->where
= deg
->where
;
2787 result
->expr_type
= EXPR_FUNCTION
;
2788 result
->value
.function
.isym
= gfc_intrinsic_function_by_id (GFC_ISYM_MOD
);
2789 result
->value
.function
.actual
= mod_args
;
2791 /* Set factor = pi / 180. */
2792 factor
= gfc_get_constant_expr (deg
->ts
.type
, deg
->ts
.kind
, °
->where
);
2793 mpfr_const_pi (factor
->value
.real
, GFC_RND_MODE
);
2794 mpfr_div_ui (factor
->value
.real
, factor
->value
.real
, 180, GFC_RND_MODE
);
2796 /* Result is rad = (deg % 360) * (pi / 180). */
2797 result
= gfc_multiply (result
, factor
);
2802 /* Build an expression for converting radians to degrees. */
2805 get_degrees (gfc_expr
*rad
)
2807 gfc_expr
*result
, *factor
;
2808 gfc_actual_arglist
*mod_args
;
2811 gcc_assert (rad
->ts
.type
== BT_REAL
);
2813 /* Set rad = rad % 2pi to avoid offsets from large angles. */
2814 factor
= gfc_get_constant_expr (rad
->ts
.type
, rad
->ts
.kind
, &rad
->where
);
2815 mpfr_const_pi (factor
->value
.real
, GFC_RND_MODE
);
2816 mpfr_mul_ui (factor
->value
.real
, factor
->value
.real
, 2, GFC_RND_MODE
);
2818 mod_args
= gfc_get_actual_arglist ();
2819 mod_args
->expr
= rad
;
2820 mod_args
->next
= gfc_get_actual_arglist ();
2821 mod_args
->next
->expr
= factor
;
2823 result
= gfc_get_expr ();
2824 result
->ts
= rad
->ts
;
2825 result
->where
= rad
->where
;
2826 result
->expr_type
= EXPR_FUNCTION
;
2827 result
->value
.function
.isym
= gfc_intrinsic_function_by_id (GFC_ISYM_MOD
);
2828 result
->value
.function
.actual
= mod_args
;
2830 /* Set factor = 180 / pi. */
2831 factor
= gfc_get_constant_expr (rad
->ts
.type
, rad
->ts
.kind
, &rad
->where
);
2832 mpfr_set_ui (factor
->value
.real
, 180, GFC_RND_MODE
);
2834 mpfr_const_pi (tmp
, GFC_RND_MODE
);
2835 mpfr_div (factor
->value
.real
, factor
->value
.real
, tmp
, GFC_RND_MODE
);
2838 /* Result is deg = (rad % 2pi) * (180 / pi). */
2839 result
= gfc_multiply (result
, factor
);
2844 /* Resolve a call to a trig function. */
2847 resolve_trig_call (gfc_expr
*f
, gfc_expr
*x
)
2849 switch (f
->value
.function
.isym
->id
)
2852 return gfc_resolve_acos (f
, x
);
2854 return gfc_resolve_asin (f
, x
);
2856 return gfc_resolve_atan (f
, x
);
2857 case GFC_ISYM_ATAN2
:
2858 /* NB. arg3 is unused for atan2 */
2859 return gfc_resolve_atan2 (f
, x
, NULL
);
2861 return gfc_resolve_cos (f
, x
);
2862 case GFC_ISYM_COTAN
:
2863 return gfc_resolve_cotan (f
, x
);
2865 return gfc_resolve_sin (f
, x
);
2867 return gfc_resolve_tan (f
, x
);
2873 /* Resolve degree trig function as trigd (x) = trig (radians (x)). */
2876 gfc_resolve_trigd (gfc_expr
*f
, gfc_expr
*x
)
2878 if (is_trig_resolved (f
))
2881 x
= get_radians (x
);
2882 f
->value
.function
.actual
->expr
= x
;
2884 resolve_trig_call (f
, x
);
2888 /* Resolve degree inverse trig function as atrigd (x) = degrees (atrig (x)). */
2891 gfc_resolve_atrigd (gfc_expr
*f
, gfc_expr
*x
)
2893 gfc_expr
*result
, *fcopy
;
2895 if (is_trig_resolved (f
))
2898 resolve_trig_call (f
, x
);
2900 fcopy
= copy_replace_function_shallow (f
);
2901 result
= get_degrees (fcopy
);
2902 gfc_replace_expr (f
, result
);
2906 /* Resolve atan2d(x) = degrees(atan2(x)). */
2909 gfc_resolve_atan2d (gfc_expr
*f
, gfc_expr
*x
, gfc_expr
*y ATTRIBUTE_UNUSED
)
2911 /* Note that we lose the second arg here - that's okay because it is
2912 unused in gfc_resolve_atan2 anyway. */
2913 gfc_resolve_atrigd (f
, x
);
2917 /* Resolve failed_images (team, kind). */
2920 gfc_resolve_failed_images (gfc_expr
*f
, gfc_expr
*team ATTRIBUTE_UNUSED
,
2923 static char failed_images
[] = "_gfortran_caf_failed_images";
2925 f
->ts
.type
= BT_INTEGER
;
2927 f
->ts
.kind
= gfc_default_integer_kind
;
2929 gfc_extract_int (kind
, &f
->ts
.kind
);
2930 f
->value
.function
.name
= failed_images
;
2934 /* Resolve image_status (image, team). */
2937 gfc_resolve_image_status (gfc_expr
*f
, gfc_expr
*image ATTRIBUTE_UNUSED
,
2938 gfc_expr
*team ATTRIBUTE_UNUSED
)
2940 static char image_status
[] = "_gfortran_caf_image_status";
2941 f
->ts
.type
= BT_INTEGER
;
2942 f
->ts
.kind
= gfc_default_integer_kind
;
2943 f
->value
.function
.name
= image_status
;
2947 /* Resolve image_index (...). */
2950 gfc_resolve_image_index (gfc_expr
*f
, gfc_expr
*array ATTRIBUTE_UNUSED
,
2951 gfc_expr
*sub ATTRIBUTE_UNUSED
)
2953 static char image_index
[] = "__image_index";
2954 f
->ts
.type
= BT_INTEGER
;
2955 f
->ts
.kind
= gfc_default_integer_kind
;
2956 f
->value
.function
.name
= image_index
;
2960 /* Resolve stopped_images (team, kind). */
2963 gfc_resolve_stopped_images (gfc_expr
*f
, gfc_expr
*team ATTRIBUTE_UNUSED
,
2966 static char stopped_images
[] = "_gfortran_caf_stopped_images";
2968 f
->ts
.type
= BT_INTEGER
;
2970 f
->ts
.kind
= gfc_default_integer_kind
;
2972 gfc_extract_int (kind
, &f
->ts
.kind
);
2973 f
->value
.function
.name
= stopped_images
;
2978 gfc_resolve_this_image (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
,
2979 gfc_expr
*distance ATTRIBUTE_UNUSED
)
2981 static char this_image
[] = "__this_image";
2982 if (array
&& gfc_is_coarray (array
))
2983 resolve_bound (f
, array
, dim
, NULL
, "__this_image", true);
2986 f
->ts
.type
= BT_INTEGER
;
2987 f
->ts
.kind
= gfc_default_integer_kind
;
2988 f
->value
.function
.name
= this_image
;
2994 gfc_resolve_time (gfc_expr
*f
)
2996 f
->ts
.type
= BT_INTEGER
;
2998 f
->value
.function
.name
= gfc_get_string (PREFIX ("time_func"));
3003 gfc_resolve_time8 (gfc_expr
*f
)
3005 f
->ts
.type
= BT_INTEGER
;
3007 f
->value
.function
.name
= gfc_get_string (PREFIX ("time8_func"));
3012 gfc_resolve_transfer (gfc_expr
*f
, gfc_expr
*source ATTRIBUTE_UNUSED
,
3013 gfc_expr
*mold
, gfc_expr
*size
)
3015 /* TODO: Make this do something meaningful. */
3016 static char transfer0
[] = "__transfer0", transfer1
[] = "__transfer1";
3018 if (mold
->ts
.type
== BT_CHARACTER
3019 && !mold
->ts
.u
.cl
->length
3020 && gfc_is_constant_expr (mold
))
3023 if (mold
->expr_type
== EXPR_CONSTANT
)
3025 len
= mold
->value
.character
.length
;
3026 mold
->ts
.u
.cl
->length
= gfc_get_int_expr (gfc_default_integer_kind
,
3031 gfc_constructor
*c
= gfc_constructor_first (mold
->value
.constructor
);
3032 len
= c
->expr
->value
.character
.length
;
3033 mold
->ts
.u
.cl
->length
= gfc_get_int_expr (gfc_default_integer_kind
,
3040 if (size
== NULL
&& mold
->rank
== 0)
3043 f
->value
.function
.name
= transfer0
;
3048 f
->value
.function
.name
= transfer1
;
3049 if (size
&& gfc_is_constant_expr (size
))
3051 f
->shape
= gfc_get_shape (1);
3052 mpz_init_set (f
->shape
[0], size
->value
.integer
);
3059 gfc_resolve_transpose (gfc_expr
*f
, gfc_expr
*matrix
)
3062 if (matrix
->ts
.type
== BT_CHARACTER
&& matrix
->ref
)
3063 gfc_resolve_substring_charlen (matrix
);
3069 f
->shape
= gfc_get_shape (2);
3070 mpz_init_set (f
->shape
[0], matrix
->shape
[1]);
3071 mpz_init_set (f
->shape
[1], matrix
->shape
[0]);
3074 switch (matrix
->ts
.kind
)
3080 switch (matrix
->ts
.type
)
3084 f
->value
.function
.name
3085 = gfc_get_string (PREFIX ("transpose_%c%d"),
3086 gfc_type_letter (matrix
->ts
.type
),
3092 /* Use the integer routines for real and logical cases. This
3093 assumes they all have the same alignment requirements. */
3094 f
->value
.function
.name
3095 = gfc_get_string (PREFIX ("transpose_i%d"), matrix
->ts
.kind
);
3099 if (matrix
->ts
.type
== BT_CHARACTER
&& matrix
->ts
.kind
== 4)
3100 f
->value
.function
.name
= PREFIX ("transpose_char4");
3102 f
->value
.function
.name
= PREFIX ("transpose");
3108 f
->value
.function
.name
= (matrix
->ts
.type
== BT_CHARACTER
3109 ? PREFIX ("transpose_char")
3110 : PREFIX ("transpose"));
3117 gfc_resolve_trim (gfc_expr
*f
, gfc_expr
*string
)
3119 f
->ts
.type
= BT_CHARACTER
;
3120 f
->ts
.kind
= string
->ts
.kind
;
3121 f
->value
.function
.name
= gfc_get_string ("__trim_%d", string
->ts
.kind
);
3126 gfc_resolve_ubound (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
3128 resolve_bound (f
, array
, dim
, kind
, "__ubound", false);
3133 gfc_resolve_ucobound (gfc_expr
*f
, gfc_expr
*array
, gfc_expr
*dim
, gfc_expr
*kind
)
3135 resolve_bound (f
, array
, dim
, kind
, "__ucobound", true);
3139 /* Resolve the g77 compatibility function UMASK. */
3142 gfc_resolve_umask (gfc_expr
*f
, gfc_expr
*n
)
3144 f
->ts
.type
= BT_INTEGER
;
3145 f
->ts
.kind
= n
->ts
.kind
;
3146 f
->value
.function
.name
= gfc_get_string (PREFIX ("umask_i%d"), n
->ts
.kind
);
3150 /* Resolve the g77 compatibility function UNLINK. */
3153 gfc_resolve_unlink (gfc_expr
*f
, gfc_expr
*n ATTRIBUTE_UNUSED
)
3155 f
->ts
.type
= BT_INTEGER
;
3157 f
->value
.function
.name
= gfc_get_string (PREFIX ("unlink"));
3162 gfc_resolve_ttynam (gfc_expr
*f
, gfc_expr
*unit
)
3167 f
->ts
.type
= BT_CHARACTER
;
3168 f
->ts
.kind
= gfc_default_character_kind
;
3170 if (unit
->ts
.kind
!= gfc_c_int_kind
)
3172 ts
.type
= BT_INTEGER
;
3173 ts
.kind
= gfc_c_int_kind
;
3174 ts
.u
.derived
= NULL
;
3176 gfc_convert_type (unit
, &ts
, 2);
3179 f
->value
.function
.name
= gfc_get_string (PREFIX ("ttynam"));
3184 gfc_resolve_unpack (gfc_expr
*f
, gfc_expr
*vector
, gfc_expr
*mask
,
3185 gfc_expr
*field ATTRIBUTE_UNUSED
)
3187 if (vector
->ts
.type
== BT_CHARACTER
&& vector
->ref
)
3188 gfc_resolve_substring_charlen (vector
);
3191 f
->rank
= mask
->rank
;
3192 resolve_mask_arg (mask
);
3194 if (vector
->ts
.type
== BT_CHARACTER
)
3196 if (vector
->ts
.kind
== 1)
3197 f
->value
.function
.name
3198 = gfc_get_string (PREFIX ("unpack%d_char"), field
->rank
> 0 ? 1 : 0);
3200 f
->value
.function
.name
3201 = gfc_get_string (PREFIX ("unpack%d_char%d"),
3202 field
->rank
> 0 ? 1 : 0, vector
->ts
.kind
);
3205 f
->value
.function
.name
3206 = gfc_get_string (PREFIX ("unpack%d"), field
->rank
> 0 ? 1 : 0);
3211 gfc_resolve_verify (gfc_expr
*f
, gfc_expr
*string
,
3212 gfc_expr
*set ATTRIBUTE_UNUSED
,
3213 gfc_expr
*back ATTRIBUTE_UNUSED
, gfc_expr
*kind
)
3215 f
->ts
.type
= BT_INTEGER
;
3217 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
3219 f
->ts
.kind
= gfc_default_integer_kind
;
3220 f
->value
.function
.name
= gfc_get_string ("__verify_%d", string
->ts
.kind
);
3225 gfc_resolve_xor (gfc_expr
*f
, gfc_expr
*i
, gfc_expr
*j
)
3227 f
->ts
.type
= i
->ts
.type
;
3228 f
->ts
.kind
= gfc_kind_max (i
, j
);
3230 if (i
->ts
.kind
!= j
->ts
.kind
)
3232 if (i
->ts
.kind
== gfc_kind_max (i
, j
))
3233 gfc_convert_type (j
, &i
->ts
, 2);
3235 gfc_convert_type (i
, &j
->ts
, 2);
3238 f
->value
.function
.name
3239 = gfc_get_string ("__xor_%c%d", gfc_type_letter (i
->ts
.type
), f
->ts
.kind
);
3243 /* Intrinsic subroutine resolution. */
3246 gfc_resolve_alarm_sub (gfc_code
*c
)
3249 gfc_expr
*seconds
, *handler
;
3253 seconds
= c
->ext
.actual
->expr
;
3254 handler
= c
->ext
.actual
->next
->expr
;
3255 ts
.type
= BT_INTEGER
;
3256 ts
.kind
= gfc_c_int_kind
;
3258 /* handler can be either BT_INTEGER or BT_PROCEDURE.
3259 In all cases, the status argument is of default integer kind
3260 (enforced in check.c) so that the function suffix is fixed. */
3261 if (handler
->ts
.type
== BT_INTEGER
)
3263 if (handler
->ts
.kind
!= gfc_c_int_kind
)
3264 gfc_convert_type (handler
, &ts
, 2);
3265 name
= gfc_get_string (PREFIX ("alarm_sub_int_i%d"),
3266 gfc_default_integer_kind
);
3269 name
= gfc_get_string (PREFIX ("alarm_sub_i%d"),
3270 gfc_default_integer_kind
);
3272 if (seconds
->ts
.kind
!= gfc_c_int_kind
)
3273 gfc_convert_type (seconds
, &ts
, 2);
3275 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3279 gfc_resolve_cpu_time (gfc_code
*c
)
3282 name
= gfc_get_string (PREFIX ("cpu_time_%d"), c
->ext
.actual
->expr
->ts
.kind
);
3283 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3287 /* Create a formal arglist based on an actual one and set the INTENTs given. */
3289 static gfc_formal_arglist
*
3290 create_formal_for_intents (gfc_actual_arglist
* actual
, const sym_intent
* ints
)
3292 gfc_formal_arglist
* head
;
3293 gfc_formal_arglist
* tail
;
3299 head
= tail
= gfc_get_formal_arglist ();
3300 for (i
= 0; actual
; actual
= actual
->next
, tail
= tail
->next
, ++i
)
3304 sym
= gfc_new_symbol ("dummyarg", NULL
);
3305 sym
->ts
= actual
->expr
->ts
;
3307 sym
->attr
.intent
= ints
[i
];
3311 tail
->next
= gfc_get_formal_arglist ();
3319 gfc_resolve_atomic_def (gfc_code
*c
)
3321 const char *name
= "atomic_define";
3322 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3327 gfc_resolve_atomic_ref (gfc_code
*c
)
3329 const char *name
= "atomic_ref";
3330 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3334 gfc_resolve_event_query (gfc_code
*c
)
3336 const char *name
= "event_query";
3337 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3341 gfc_resolve_mvbits (gfc_code
*c
)
3343 static const sym_intent INTENTS
[] = {INTENT_IN
, INTENT_IN
, INTENT_IN
,
3344 INTENT_INOUT
, INTENT_IN
};
3350 /* FROMPOS, LEN and TOPOS are restricted to small values. As such,
3351 they will be converted so that they fit into a C int. */
3352 ts
.type
= BT_INTEGER
;
3353 ts
.kind
= gfc_c_int_kind
;
3354 if (c
->ext
.actual
->next
->expr
->ts
.kind
!= gfc_c_int_kind
)
3355 gfc_convert_type (c
->ext
.actual
->next
->expr
, &ts
, 2);
3356 if (c
->ext
.actual
->next
->next
->expr
->ts
.kind
!= gfc_c_int_kind
)
3357 gfc_convert_type (c
->ext
.actual
->next
->next
->expr
, &ts
, 2);
3358 if (c
->ext
.actual
->next
->next
->next
->next
->expr
->ts
.kind
!= gfc_c_int_kind
)
3359 gfc_convert_type (c
->ext
.actual
->next
->next
->next
->next
->expr
, &ts
, 2);
3361 /* TO and FROM are guaranteed to have the same kind parameter. */
3362 name
= gfc_get_string (PREFIX ("mvbits_i%d"),
3363 c
->ext
.actual
->expr
->ts
.kind
);
3364 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3365 /* Mark as elemental subroutine as this does not happen automatically. */
3366 c
->resolved_sym
->attr
.elemental
= 1;
3368 /* Create a dummy formal arglist so the INTENTs are known later for purpose
3369 of creating temporaries. */
3370 c
->resolved_sym
->formal
= create_formal_for_intents (c
->ext
.actual
, INTENTS
);
3375 gfc_resolve_random_number (gfc_code
*c
)
3380 kind
= c
->ext
.actual
->expr
->ts
.kind
;
3381 if (c
->ext
.actual
->expr
->rank
== 0)
3382 name
= gfc_get_string (PREFIX ("random_r%d"), kind
);
3384 name
= gfc_get_string (PREFIX ("arandom_r%d"), kind
);
3386 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3391 gfc_resolve_random_seed (gfc_code
*c
)
3395 name
= gfc_get_string (PREFIX ("random_seed_i%d"), gfc_default_integer_kind
);
3396 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3401 gfc_resolve_rename_sub (gfc_code
*c
)
3406 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
3407 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
3409 kind
= gfc_default_integer_kind
;
3411 name
= gfc_get_string (PREFIX ("rename_i%d_sub"), kind
);
3412 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3417 gfc_resolve_kill_sub (gfc_code
*c
)
3422 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
3423 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
3425 kind
= gfc_default_integer_kind
;
3427 name
= gfc_get_string (PREFIX ("kill_i%d_sub"), kind
);
3428 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3433 gfc_resolve_link_sub (gfc_code
*c
)
3438 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
3439 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
3441 kind
= gfc_default_integer_kind
;
3443 name
= gfc_get_string (PREFIX ("link_i%d_sub"), kind
);
3444 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3449 gfc_resolve_symlnk_sub (gfc_code
*c
)
3454 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
3455 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
3457 kind
= gfc_default_integer_kind
;
3459 name
= gfc_get_string (PREFIX ("symlnk_i%d_sub"), kind
);
3460 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3464 /* G77 compatibility subroutines dtime() and etime(). */
3467 gfc_resolve_dtime_sub (gfc_code
*c
)
3470 name
= gfc_get_string (PREFIX ("dtime_sub"));
3471 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3475 gfc_resolve_etime_sub (gfc_code
*c
)
3478 name
= gfc_get_string (PREFIX ("etime_sub"));
3479 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3483 /* G77 compatibility subroutines itime(), idate(), ltime() and gmtime(). */
3486 gfc_resolve_itime (gfc_code
*c
)
3489 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("itime_i%d"),
3490 gfc_default_integer_kind
));
3494 gfc_resolve_idate (gfc_code
*c
)
3497 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("idate_i%d"),
3498 gfc_default_integer_kind
));
3502 gfc_resolve_ltime (gfc_code
*c
)
3505 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("ltime_i%d"),
3506 gfc_default_integer_kind
));
3510 gfc_resolve_gmtime (gfc_code
*c
)
3513 = gfc_get_intrinsic_sub_symbol (gfc_get_string (PREFIX ("gmtime_i%d"),
3514 gfc_default_integer_kind
));
3518 /* G77 compatibility subroutine second(). */
3521 gfc_resolve_second_sub (gfc_code
*c
)
3524 name
= gfc_get_string (PREFIX ("second_sub"));
3525 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3530 gfc_resolve_sleep_sub (gfc_code
*c
)
3535 if (c
->ext
.actual
->expr
!= NULL
)
3536 kind
= c
->ext
.actual
->expr
->ts
.kind
;
3538 kind
= gfc_default_integer_kind
;
3540 name
= gfc_get_string (PREFIX ("sleep_i%d_sub"), kind
);
3541 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3545 /* G77 compatibility function srand(). */
3548 gfc_resolve_srand (gfc_code
*c
)
3551 name
= gfc_get_string (PREFIX ("srand"));
3552 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3556 /* Resolve the getarg intrinsic subroutine. */
3559 gfc_resolve_getarg (gfc_code
*c
)
3563 if (c
->ext
.actual
->expr
->ts
.kind
!= gfc_default_integer_kind
)
3568 ts
.type
= BT_INTEGER
;
3569 ts
.kind
= gfc_default_integer_kind
;
3571 gfc_convert_type (c
->ext
.actual
->expr
, &ts
, 2);
3574 name
= gfc_get_string (PREFIX ("getarg_i%d"), gfc_default_integer_kind
);
3575 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3579 /* Resolve the getcwd intrinsic subroutine. */
3582 gfc_resolve_getcwd_sub (gfc_code
*c
)
3587 if (c
->ext
.actual
->next
->expr
!= NULL
)
3588 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
3590 kind
= gfc_default_integer_kind
;
3592 name
= gfc_get_string (PREFIX ("getcwd_i%d_sub"), kind
);
3593 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3597 /* Resolve the get_command intrinsic subroutine. */
3600 gfc_resolve_get_command (gfc_code
*c
)
3604 kind
= gfc_default_integer_kind
;
3605 name
= gfc_get_string (PREFIX ("get_command_i%d"), kind
);
3606 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3610 /* Resolve the get_command_argument intrinsic subroutine. */
3613 gfc_resolve_get_command_argument (gfc_code
*c
)
3617 kind
= gfc_default_integer_kind
;
3618 name
= gfc_get_string (PREFIX ("get_command_argument_i%d"), kind
);
3619 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3623 /* Resolve the get_environment_variable intrinsic subroutine. */
3626 gfc_resolve_get_environment_variable (gfc_code
*code
)
3630 kind
= gfc_default_integer_kind
;
3631 name
= gfc_get_string (PREFIX ("get_environment_variable_i%d"), kind
);
3632 code
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3637 gfc_resolve_signal_sub (gfc_code
*c
)
3640 gfc_expr
*number
, *handler
, *status
;
3644 number
= c
->ext
.actual
->expr
;
3645 handler
= c
->ext
.actual
->next
->expr
;
3646 status
= c
->ext
.actual
->next
->next
->expr
;
3647 ts
.type
= BT_INTEGER
;
3648 ts
.kind
= gfc_c_int_kind
;
3650 /* handler can be either BT_INTEGER or BT_PROCEDURE */
3651 if (handler
->ts
.type
== BT_INTEGER
)
3653 if (handler
->ts
.kind
!= gfc_c_int_kind
)
3654 gfc_convert_type (handler
, &ts
, 2);
3655 name
= gfc_get_string (PREFIX ("signal_sub_int"));
3658 name
= gfc_get_string (PREFIX ("signal_sub"));
3660 if (number
->ts
.kind
!= gfc_c_int_kind
)
3661 gfc_convert_type (number
, &ts
, 2);
3662 if (status
!= NULL
&& status
->ts
.kind
!= gfc_c_int_kind
)
3663 gfc_convert_type (status
, &ts
, 2);
3665 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3669 /* Resolve the SYSTEM intrinsic subroutine. */
3672 gfc_resolve_system_sub (gfc_code
*c
)
3675 name
= gfc_get_string (PREFIX ("system_sub"));
3676 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3680 /* Determine if the arguments to SYSTEM_CLOCK are INTEGER(4) or INTEGER(8) */
3683 gfc_resolve_system_clock (gfc_code
*c
)
3687 gfc_expr
*count
= c
->ext
.actual
->expr
;
3688 gfc_expr
*count_max
= c
->ext
.actual
->next
->next
->expr
;
3690 /* The INTEGER(8) version has higher precision, it is used if both COUNT
3691 and COUNT_MAX can hold 64-bit values, or are absent. */
3692 if ((!count
|| count
->ts
.kind
>= 8)
3693 && (!count_max
|| count_max
->ts
.kind
>= 8))
3696 kind
= gfc_default_integer_kind
;
3698 name
= gfc_get_string (PREFIX ("system_clock_%d"), kind
);
3699 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3703 /* Resolve the EXECUTE_COMMAND_LINE intrinsic subroutine. */
3705 gfc_resolve_execute_command_line (gfc_code
*c
)
3708 name
= gfc_get_string (PREFIX ("execute_command_line_i%d"),
3709 gfc_default_integer_kind
);
3710 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3714 /* Resolve the EXIT intrinsic subroutine. */
3717 gfc_resolve_exit (gfc_code
*c
)
3724 /* The STATUS argument has to be of default kind. If it is not,
3726 ts
.type
= BT_INTEGER
;
3727 ts
.kind
= gfc_default_integer_kind
;
3728 n
= c
->ext
.actual
->expr
;
3729 if (n
!= NULL
&& n
->ts
.kind
!= ts
.kind
)
3730 gfc_convert_type (n
, &ts
, 2);
3732 name
= gfc_get_string (PREFIX ("exit_i%d"), ts
.kind
);
3733 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3737 /* Resolve the FLUSH intrinsic subroutine. */
3740 gfc_resolve_flush (gfc_code
*c
)
3747 ts
.type
= BT_INTEGER
;
3748 ts
.kind
= gfc_default_integer_kind
;
3749 n
= c
->ext
.actual
->expr
;
3750 if (n
!= NULL
&& n
->ts
.kind
!= ts
.kind
)
3751 gfc_convert_type (n
, &ts
, 2);
3753 name
= gfc_get_string (PREFIX ("flush_i%d"), ts
.kind
);
3754 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3759 gfc_resolve_ctime_sub (gfc_code
*c
)
3764 /* ctime TIME argument is a INTEGER(KIND=8), says the doc */
3765 if (c
->ext
.actual
->expr
->ts
.kind
!= 8)
3767 ts
.type
= BT_INTEGER
;
3769 ts
.u
.derived
= NULL
;
3771 gfc_convert_type (c
->ext
.actual
->expr
, &ts
, 2);
3774 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("ctime_sub"));
3779 gfc_resolve_fdate_sub (gfc_code
*c
)
3781 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("fdate_sub"));
3786 gfc_resolve_gerror (gfc_code
*c
)
3788 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("gerror"));
3793 gfc_resolve_getlog (gfc_code
*c
)
3795 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("getlog"));
3800 gfc_resolve_hostnm_sub (gfc_code
*c
)
3805 if (c
->ext
.actual
->next
->expr
!= NULL
)
3806 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
3808 kind
= gfc_default_integer_kind
;
3810 name
= gfc_get_string (PREFIX ("hostnm_i%d_sub"), kind
);
3811 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3816 gfc_resolve_perror (gfc_code
*c
)
3818 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("perror_sub"));
3821 /* Resolve the STAT and FSTAT intrinsic subroutines. */
3824 gfc_resolve_stat_sub (gfc_code
*c
)
3827 name
= gfc_get_string (PREFIX ("stat_i%d_sub"), gfc_default_integer_kind
);
3828 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3833 gfc_resolve_lstat_sub (gfc_code
*c
)
3836 name
= gfc_get_string (PREFIX ("lstat_i%d_sub"), gfc_default_integer_kind
);
3837 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3842 gfc_resolve_fstat_sub (gfc_code
*c
)
3848 u
= c
->ext
.actual
->expr
;
3849 ts
= &c
->ext
.actual
->next
->expr
->ts
;
3850 if (u
->ts
.kind
!= ts
->kind
)
3851 gfc_convert_type (u
, ts
, 2);
3852 name
= gfc_get_string (PREFIX ("fstat_i%d_sub"), ts
->kind
);
3853 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3858 gfc_resolve_fgetc_sub (gfc_code
*c
)
3865 u
= c
->ext
.actual
->expr
;
3866 st
= c
->ext
.actual
->next
->next
->expr
;
3868 if (u
->ts
.kind
!= gfc_c_int_kind
)
3870 ts
.type
= BT_INTEGER
;
3871 ts
.kind
= gfc_c_int_kind
;
3872 ts
.u
.derived
= NULL
;
3874 gfc_convert_type (u
, &ts
, 2);
3878 name
= gfc_get_string (PREFIX ("fgetc_i%d_sub"), st
->ts
.kind
);
3880 name
= gfc_get_string (PREFIX ("fgetc_i%d_sub"), gfc_default_integer_kind
);
3882 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3887 gfc_resolve_fget_sub (gfc_code
*c
)
3892 st
= c
->ext
.actual
->next
->expr
;
3894 name
= gfc_get_string (PREFIX ("fget_i%d_sub"), st
->ts
.kind
);
3896 name
= gfc_get_string (PREFIX ("fget_i%d_sub"), gfc_default_integer_kind
);
3898 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3903 gfc_resolve_fputc_sub (gfc_code
*c
)
3910 u
= c
->ext
.actual
->expr
;
3911 st
= c
->ext
.actual
->next
->next
->expr
;
3913 if (u
->ts
.kind
!= gfc_c_int_kind
)
3915 ts
.type
= BT_INTEGER
;
3916 ts
.kind
= gfc_c_int_kind
;
3917 ts
.u
.derived
= NULL
;
3919 gfc_convert_type (u
, &ts
, 2);
3923 name
= gfc_get_string (PREFIX ("fputc_i%d_sub"), st
->ts
.kind
);
3925 name
= gfc_get_string (PREFIX ("fputc_i%d_sub"), gfc_default_integer_kind
);
3927 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3932 gfc_resolve_fput_sub (gfc_code
*c
)
3937 st
= c
->ext
.actual
->next
->expr
;
3939 name
= gfc_get_string (PREFIX ("fput_i%d_sub"), st
->ts
.kind
);
3941 name
= gfc_get_string (PREFIX ("fput_i%d_sub"), gfc_default_integer_kind
);
3943 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
3948 gfc_resolve_fseek_sub (gfc_code
*c
)
3956 unit
= c
->ext
.actual
->expr
;
3957 offset
= c
->ext
.actual
->next
->expr
;
3958 whence
= c
->ext
.actual
->next
->next
->expr
;
3960 if (unit
->ts
.kind
!= gfc_c_int_kind
)
3962 ts
.type
= BT_INTEGER
;
3963 ts
.kind
= gfc_c_int_kind
;
3964 ts
.u
.derived
= NULL
;
3966 gfc_convert_type (unit
, &ts
, 2);
3969 if (offset
->ts
.kind
!= gfc_intio_kind
)
3971 ts
.type
= BT_INTEGER
;
3972 ts
.kind
= gfc_intio_kind
;
3973 ts
.u
.derived
= NULL
;
3975 gfc_convert_type (offset
, &ts
, 2);
3978 if (whence
->ts
.kind
!= gfc_c_int_kind
)
3980 ts
.type
= BT_INTEGER
;
3981 ts
.kind
= gfc_c_int_kind
;
3982 ts
.u
.derived
= NULL
;
3984 gfc_convert_type (whence
, &ts
, 2);
3987 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("fseek_sub"));
3991 gfc_resolve_ftell_sub (gfc_code
*c
)
3999 unit
= c
->ext
.actual
->expr
;
4000 offset
= c
->ext
.actual
->next
->expr
;
4002 if (unit
->ts
.kind
!= gfc_c_int_kind
)
4004 ts
.type
= BT_INTEGER
;
4005 ts
.kind
= gfc_c_int_kind
;
4006 ts
.u
.derived
= NULL
;
4008 gfc_convert_type (unit
, &ts
, 2);
4011 name
= gfc_get_string (PREFIX ("ftell_i%d_sub"), offset
->ts
.kind
);
4012 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
4017 gfc_resolve_ttynam_sub (gfc_code
*c
)
4022 if (c
->ext
.actual
->expr
->ts
.kind
!= gfc_c_int_kind
)
4024 ts
.type
= BT_INTEGER
;
4025 ts
.kind
= gfc_c_int_kind
;
4026 ts
.u
.derived
= NULL
;
4028 gfc_convert_type (c
->ext
.actual
->expr
, &ts
, 2);
4031 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("ttynam_sub"));
4035 /* Resolve the UMASK intrinsic subroutine. */
4038 gfc_resolve_umask_sub (gfc_code
*c
)
4043 if (c
->ext
.actual
->next
->expr
!= NULL
)
4044 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
4046 kind
= gfc_default_integer_kind
;
4048 name
= gfc_get_string (PREFIX ("umask_i%d_sub"), kind
);
4049 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
4052 /* Resolve the UNLINK intrinsic subroutine. */
4055 gfc_resolve_unlink_sub (gfc_code
*c
)
4060 if (c
->ext
.actual
->next
->expr
!= NULL
)
4061 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
4063 kind
= gfc_default_integer_kind
;
4065 name
= gfc_get_string (PREFIX ("unlink_i%d_sub"), kind
);
4066 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);