re PR fortran/20786 (Can't use AINT intrinsic with KIND parameter)
authorSteven G. Kargl <kargls@comcast.net>
Tue, 11 Oct 2005 23:58:17 +0000 (23:58 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Tue, 11 Oct 2005 23:58:17 +0000 (23:58 +0000)
PR fortran/20786
* iresolve.c (gfc_resolve_aint, gfc_resolve_anint ): Type conversion
  of the argument.

gfortran.dg/aint_anint_1.f90: New test.

From-SVN: r105276

gcc/fortran/ChangeLog
gcc/fortran/iresolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/aint_anint_1.f90 [new file with mode: 0644]

index 9da5b9400ec1e2e00f47ca38868adc2f32d50293..85b6ce8fafed698025f71cb3055d86314d107149 100644 (file)
@@ -1,3 +1,9 @@
+2005-10-11  Steven G. Kargl <kargls@comcast.net>
+
+       PR fortran/20786
+       *iresolve.c (gfc_resolve_aint, gfc_resolve_anint ): Type conversion 
+       of the argument.
+
 2005-10-11  Jakub Jelinek  <jakub@redhat.com>
 
        * f95-lang.c (gfc_init_decl_processing): Initialize
index 195f05ed990e3635bb1c4284ad91549594bcb18d..6c23d4a2c74dbf857eb5790932cab1649dde5db1 100644 (file)
@@ -105,9 +105,17 @@ gfc_resolve_aimag (gfc_expr * f, gfc_expr * x)
 void
 gfc_resolve_aint (gfc_expr * f, gfc_expr * a, gfc_expr * kind)
 {
+  gfc_typespec ts;
+  
   f->ts.type = a->ts.type;
   f->ts.kind = (kind == NULL) ? a->ts.kind : mpz_get_si (kind->value.integer);
 
+  if (a->ts.kind != f->ts.kind)
+    {
+      ts.type = f->ts.type;
+      ts.kind = f->ts.kind;
+      gfc_convert_type (a, &ts, 2);
+    }
   /* The resolved name is only used for specific intrinsics where
      the return kind is the same as the arg kind.  */
   f->value.function.name =
@@ -143,9 +151,18 @@ gfc_resolve_all (gfc_expr * f, gfc_expr * mask, gfc_expr * dim)
 void
 gfc_resolve_anint (gfc_expr * f, gfc_expr * a, gfc_expr * kind)
 {
+  gfc_typespec ts;
+  
   f->ts.type = a->ts.type;
   f->ts.kind = (kind == NULL) ? a->ts.kind : mpz_get_si (kind->value.integer);
 
+  if (a->ts.kind != f->ts.kind)
+    {
+      ts.type = f->ts.type;
+      ts.kind = f->ts.kind;
+      gfc_convert_type (a, &ts, 2);
+    }
+
   /* The resolved name is only used for specific intrinsics where
      the return kind is the same as the arg kind.  */
   f->value.function.name =
index d21780a7726399a8bc424ac7d34c88f8d9805d5b..340cfa36958474befb244b385ceff688788e6ac8 100644 (file)
@@ -1,3 +1,8 @@
+2005-10-11  Steven G. Kargl  <kargls@comcast.net>
+
+       PR fortran/20786
+       gfortran.dg/aint_anint_1.f90: New test.
+
 2005-10-11  Steven G. Kargl  <kargls@comcast.net>
 
        PR libgfortran/24313
diff --git a/gcc/testsuite/gfortran.dg/aint_anint_1.f90 b/gcc/testsuite/gfortran.dg/aint_anint_1.f90
new file mode 100644 (file)
index 0000000..179748c
--- /dev/null
@@ -0,0 +1,26 @@
+program aint_anint_1
+    
+  implicit none
+
+  real(4) :: r = 42.7, r1, r2
+  real(8) :: s = 42.7D0, s1, s2
+
+  r1 = aint(r)
+  r2 = aint(r,kind=8)
+  if (abs(r1 - r2) > 0.1) call abort()
+
+  r1 = anint(r)
+  r2 = anint(r,kind=8)
+  if (abs(r1 - r2) > 0.1) call abort()
+
+  s1 = aint(s)
+  s2 = aint(s, kind=4)
+  if (abs(s1 - s2) > 0.1) call abort()
+
+  s1 = anint(s)
+  s2 = anint(s, kind=4)
+  if (abs(s1 - s2) > 0.1) call abort()
+
+
+end program aint_anint_1
+