[gfortran] PATCH Fix the broken INT() intrinsic

Steve Kargl sgk@troutmask.apl.washington.edu
Tue Feb 1 19:26:00 GMT 2005


On Tue, Feb 01, 2005 at 10:43:53AM -0800, Steve Kargl wrote:
> The attached patch fixes the INT() intrinsic.  The
> test case will not run without this patch.
> 
> 2005-02-01  Steven G. Kargl  <kargls@comcast.com>
> 
>       * check.c (gfc_check_int): improve checking of optional kind
>       * simplify.c (gfc_simplify_int): Change BT_REAL to BT_INTEGER
> 
> -  kind = get_kind (BT_REAL, k, "INT", gfc_default_real_kind);
> +  kind = get_kind (BT_INTEGER, k, "INT", gfc_default_real_kind);

Crude.  gfc_default_real_kind should have been gfc_default_integer_kind.

-- 
Steve
-------------- next part --------------
Index: check.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/check.c,v
retrieving revision 1.23
diff -u -r1.23 check.c
--- check.c	29 Jan 2005 17:46:30 -0000	1.23
+++ check.c	1 Feb 2005 19:22:22 -0000
@@ -936,10 +946,18 @@
 try
 gfc_check_int (gfc_expr * x, gfc_expr * kind)
 {
-  if (numeric_check (x, 0) == FAILURE
-      || kind_check (kind, 1, BT_INTEGER) == FAILURE)
+  if (numeric_check (x, 0) == FAILURE)
+    return FAILURE;
+
+  if (kind != NULL)
+    {
+      if (type_check (kind, 1, BT_INTEGER) == FAILURE)
     return FAILURE;
 
+      if (scalar_check (kind, 1) == FAILURE)
+	return FAILURE;
+    }
+
   return SUCCESS;
 }
 
Index: simplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/simplify.c,v
retrieving revision 1.17
diff -u -r1.17 simplify.c
--- simplify.c	18 Jan 2005 12:11:54 -0000	1.17
+++ simplify.c	1 Feb 2005 19:22:22 -0000
@@ -1473,7 +1473,7 @@
   gfc_expr *rpart, *rtrunc, *result;
   int kind;
 
-  kind = get_kind (BT_REAL, k, "INT", gfc_default_real_kind);
+  kind = get_kind (BT_INTEGER, k, "INT", gfc_default_integer_kind);
   if (kind == -1)
     return &gfc_bad_expr;
 


More information about the Fortran mailing list