public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tobias Burnus <burnus@net-b.de>
To: Paul Richard Thomas <paul.richard.thomas@gmail.com>,
	"fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [Patch, fortran] PR58618 - Wrong code with character substring and ASSOCIATE
Date: Wed, 17 Oct 2018 21:17:00 -0000	[thread overview]
Message-ID: <bcb48ca8-0212-f11e-70d9-2362d7f5b283@net-b.de> (raw)
In-Reply-To: <CAGkQGi+Rq08DYLx8C2yXjUX8m2-3NUuMjtpExrbWdpb3anEF=w@mail.gmail.com>

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

Hi Paul,

Paul Richard Thomas wrote:
> This problem concerned associate targets being substrings. It turns
> out that they are returned as pointer types (with a different cast for
> unity based substrings ***sigh***) and so can be assigned directly to
> the associate name. The patch quite simply removed the condition that
> such targets be allocatable, pointer or dummy.
> I noticed in the course of working up the testcase that
>      character (:), pointer :: ptr => NULL()
>      character (6), target :: tgt = 'lmnopq'
>      ptr => tgt
>      print *, len (ptr), ptr
> end
> ICEs on the NULL initialization of the pointer but works fine if this
> is removed. Has this already been posted as a PR?


I leave it to Dominique to search for a PR; otherwise, I believe the 
attach patch fixes the issue. – It just needs someone to package it with 
a test case, regtest and commit it.


> Bootstrapped and regtested on FC28/x86_64 - OK for trunk?

OK – thanks for the fix.

Tobias

> 2018-10-17  Paul Thomas  <pault@gcc.gnu.org>
>
>      PR fortran/58618
>      * trans-stmt.c (trans_associate_var): All strings that return
>      as pointer types can be assigned directly to the associate
>      name so remove 'attr' and the condition that uses it.
>
> 2018-10-17  Paul Thomas  <pault@gcc.gnu.org>
>
>      PR fortran/58618
>      * gfortran.dg/associate_45.f90 : New test.

[-- Attachment #2: null-init.diff --]
[-- Type: text/x-patch, Size: 849 bytes --]

diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index b0c12e5fc38..88f9f570725 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -1762,7 +1762,8 @@ gfc_get_symbol_decl (gfc_symbol * sym)
       gfc_finish_var_decl (length, sym);
       if (!sym->attr.associate_var
 	  && TREE_CODE (length) == VAR_DECL
-	  && sym->value && sym->value->ts.u.cl->length)
+	  && sym->value && sym->value->expr_type != EXPR_NULL
+	  && sym->value->ts.u.cl->length)
 	{
 	  gfc_expr *len = sym->value->ts.u.cl->length;
 	  DECL_INITIAL (length) = gfc_conv_initializer (len, &len->ts,
@@ -1772,7 +1773,7 @@ gfc_get_symbol_decl (gfc_symbol * sym)
 						DECL_INITIAL (length));
 	}
       else
-	gcc_assert (!sym->value);
+	gcc_assert (!sym->value || sym->value->expr_type == EXPR_NULL);
     }
 
   gfc_finish_var_decl (decl, sym);

  reply	other threads:[~2018-10-17 21:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-17 10:33 Paul Richard Thomas
2018-10-17 21:17 ` Tobias Burnus [this message]
2018-10-18 10:10   ` Paul Richard Thomas
2018-10-18 10:39   ` Paul Richard Thomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bcb48ca8-0212-f11e-70d9-2362d7f5b283@net-b.de \
    --to=burnus@net-b.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=paul.richard.thomas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).