public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR fortran/84511 -- Fix C_LOC in a transfer statement
@ 2018-02-22 20:01 Steve Kargl
  0 siblings, 0 replies; only message in thread
From: Steve Kargl @ 2018-02-22 20:01 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 577 bytes --]

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.

-- 
Steve

[-- Attachment #2: pr84511.diff --]
[-- Type: text/x-diff, Size: 657 bytes --]

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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-02-22 20:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-22 20:01 [PATCH] PR fortran/84511 -- Fix C_LOC in a transfer statement Steve Kargl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).