+2004-12-10 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
+
+ PR fortran/17175
+ * iresolve.c (gfc_resolve_scale): Convert 'I' argument if not of
+ same kind as C's 'int'.
+ (gfc_resolve_set_eponent): Convert 'I' argument if not of kind 4.
+
2004-12-08 Richard Henderson <rth@redhat.com>
* intrinsic.c (gfc_convert_type_warn): Propagate the input shape
void
-gfc_resolve_scale (gfc_expr * f, gfc_expr * x,
- gfc_expr * y ATTRIBUTE_UNUSED)
+gfc_resolve_scale (gfc_expr * f, gfc_expr * x, gfc_expr * i)
{
f->ts = x->ts;
- f->value.function.name = gfc_get_string ("__scale_%d_%d", x->ts.kind,
- x->ts.kind);
+
+ /* The implementation calls scalbn which takes an int as the
+ second argument. */
+ if (i->ts.kind != gfc_c_int_kind)
+ {
+ gfc_typespec ts;
+
+ ts.type = BT_INTEGER;
+ ts.kind = gfc_default_integer_kind;
+
+ gfc_convert_type_warn (i, &ts, 2, 0);
+ }
+
+ f->value.function.name = gfc_get_string ("__scale_%d", x->ts.kind);
}
{
f->ts = x->ts;
- f->value.function.name =
- gfc_get_string ("__set_exponent_%d_%d", x->ts.kind, i->ts.kind);
+
+ /* The library implementation uses GFC_INTEGER_4 unconditionally,
+ convert type so we don't have to implment all possible
+ permutations. */
+ if (i->ts.kind != 4)
+ {
+ gfc_typespec ts;
+
+ ts.type = BT_INTEGER;
+ ts.kind = gfc_default_integer_kind;
+
+ gfc_convert_type_warn (i, &ts, 2, 0);
+ }
+
+ f->value.function.name = gfc_get_string ("__set_exponent_%d", x->ts.kind);
}
--- /dev/null
+! { dg-do run }
+! inspired by PR17175
+REAL X
+DOUBLE PRECISION Y
+
+INTEGER, PARAMETER :: DP = KIND(Y)
+
+INTEGER*1 I1
+INTEGER*2 I2
+INTEGER*4 I4
+INTEGER*8 I8
+
+X = 1.
+Y = 1._DP
+
+I1 = 10
+I2 = -10
+I4 = 20
+I8 = -20
+
+X = SCALE (X, I1)
+X = SCALE (X, I2)
+IF (X.NE.1.) CALL ABORT()
+X = SCALE (X, I4)
+X = SCALE (X, I8)
+IF (X.NE.1.) CALL ABORT()
+
+Y = SCALE (Y, I1)
+Y = SCALE (Y, I2)
+IF (Y.NE.1._DP) CALL ABORT()
+Y = SCALE (Y, I4)
+Y = SCALE (Y, I8)
+IF (Y.NE.1._DP) CALL ABORT()
+
+END