diff mbox series

PR fortran/84511 -- Fix C_LOC in a transfer statement

Message ID 20180222200136.GA44769@troutmask.apl.washington.edu
State New
Headers show
Series PR fortran/84511 -- Fix C_LOC in a transfer statement | expand

Commit Message

Steve Kargl Feb. 22, 2018, 8:01 p.m. UTC
All,

The attached patch handles C_LOC in a transfer statement
such as "print *, c_loc(xxx)".  The bug report contains
two files that must be compiled separately to exhibit 
the bug.  I have no idea how to write a testcase for this
situation.  If someone can write a testcase, I'm fine
with that.  If someone can tell me how to write a testcase,
I'm fine with that, too. 

Regression tested on x86_64-*-freebsd.  OK to commit?

2018-02-22  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/84511
	* trans-io.c (transfer_expr): Deal with C_LOC in transfer statement.
diff mbox series

Patch

Index: trans-io.c
===================================================================
--- trans-io.c	(revision 257695)
+++ trans-io.c	(working copy)
@@ -2289,6 +2289,16 @@  transfer_expr (gfc_se * se, gfc_typespec * ts, tree ad
       ts->kind = gfc_index_integer_kind;
     }
 
+  /* gfortran reaches here for "print *, c_loc(xxx)".  */
+  if (ts->type == BT_VOID
+      && code->expr1 && code->expr1->ts.type == BT_VOID
+      && code->expr1->symtree
+      && strcmp (code->expr1->symtree->name, "c_loc") == 0)
+    {
+      ts->type = BT_INTEGER;
+      ts->kind = gfc_index_integer_kind;
+    }
+
   kind = ts->kind;
   function = NULL;
   arg2 = NULL;