Fwd: Re: [PATCH] PR fortran/84511 -- Fix C_LOC in a transfer statement

2018-02-23 Thread Jerry DeLisle




 Forwarded Message 
Subject: Re: [PATCH] PR fortran/84511 -- Fix C_LOC in a transfer statement
Date: Fri, 23 Feb 2018 08:30:29 -0800
From: Jerry DeLisle 
To: s...@troutmask.apl.washington.edu

On 02/22/2018 12:01 PM, Steve Kargl wrote:

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?


OK Steve.

Regards,

Jerry


[PATCH] PR fortran/84511 -- Fix C_LOC in a transfer statement

2018-02-22 Thread Steve Kargl
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  

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

-- 
Steve
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;