public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] PR58754 - [4.9/5 Regression] ICE on allocating character array with source
@ 2015-10-22 14:32 Paul Richard Thomas
  2015-10-22 17:32 ` Paul Richard Thomas
  2015-10-22 17:34 ` FX
  0 siblings, 2 replies; 4+ messages in thread
From: Paul Richard Thomas @ 2015-10-22 14:32 UTC (permalink / raw)
  To: fortran, gcc-patches

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

Dear All,

This patch speaks for itself. It is by no means as comprehensive as
the work on ALLOCATE that Andre has done on 6 branch but has the
advantage for 5 branch that it is simple and steers the failing code
to the standard assignment, which should be safe.

Bootstraps and regtests on FC21/x86_64.

OK for 4.9 and 5 branches?

Cheers

Paul

2015-10-22  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/58754
    * trans-stmt.c (gfc_trans_allocate): Do not use the scalar
    character assignment if the allocate expression sis an array
    descriptor.

2015-10-22  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/58754
    * gfortran.dg/pr58754.f90: New test

[-- Attachment #2: submit.diff --]
[-- Type: text/plain, Size: 1687 bytes --]

Index: gcc/fortran/trans-stmt.c
===================================================================
*** gcc/fortran/trans-stmt.c	(revision 229096)
--- gcc/fortran/trans-stmt.c	(working copy)
*************** gfc_trans_allocate (gfc_code * code)
*** 5629,5635 ****
  	      tmp = gfc_copy_class_to_class (expr3, to,
  					     nelems, upoly_expr);
  	    }
! 	  else if (code->expr3->ts.type == BT_CHARACTER)
  	    {
  	      tmp = INDIRECT_REF_P (se.expr) ?
  			se.expr :
--- 5629,5636 ----
  	      tmp = gfc_copy_class_to_class (expr3, to,
  					     nelems, upoly_expr);
  	    }
! 	  else if (code->expr3->ts.type == BT_CHARACTER
! 		   && !GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (se.expr)))
  	    {
  	      tmp = INDIRECT_REF_P (se.expr) ?
  			se.expr :
Index: gcc/testsuite/gfortran.dg/pr58754.f90
===================================================================
*** gcc/testsuite/gfortran.dg/pr58754.f90	(revision 0)
--- gcc/testsuite/gfortran.dg/pr58754.f90	(working copy)
***************
*** 0 ****
--- 1,24 ----
+ ! { dg-do compile }
+ !
+ ! Tests the fix for PR58754
+ !
+   type :: char_type
+     character, allocatable :: chr (:)
+   end type
+   character, allocatable :: c(:)
+   type(char_type) :: d
+   character :: t(1) = ["w"]
+ 
+   allocate (c (1), source = t)
+   if (any (c .ne. t)) call abort
+   c = ["a"]
+   if (any (c .ne. ["a"])) call abort
+   deallocate (c)
+ 
+ ! Check allocatable character components, whilst we are about it.
+   allocate (d%chr (2), source = [t, char (ichar (t) + 1)])
+   if (any (d%chr .ne. ["w", "x"])) call abort
+   d%chr = ["a","b","c","d"]
+   if (any (d%chr .ne. ["a","b","c","d"])) call abort
+   deallocate (d%chr)
+ end

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch, fortran] PR58754 - [4.9/5 Regression] ICE on allocating character array with source
  2015-10-22 14:32 [Patch, fortran] PR58754 - [4.9/5 Regression] ICE on allocating character array with source Paul Richard Thomas
@ 2015-10-22 17:32 ` Paul Richard Thomas
  2015-10-22 17:34 ` FX
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Richard Thomas @ 2015-10-22 17:32 UTC (permalink / raw)
  To: fortran, gcc-patches

Dear All,

Only the testcase will be applied to 4.9. At some time, it seems to
have fixed itself!

Cheers

Paul

On 22 October 2015 at 16:31, Paul Richard Thomas
<paul.richard.thomas@gmail.com> wrote:
> Dear All,
>
> This patch speaks for itself. It is by no means as comprehensive as
> the work on ALLOCATE that Andre has done on 6 branch but has the
> advantage for 5 branch that it is simple and steers the failing code
> to the standard assignment, which should be safe.
>
> Bootstraps and regtests on FC21/x86_64.
>
> OK for 4.9 and 5 branches?
>
> Cheers
>
> Paul
>
> 2015-10-22  Paul Thomas  <pault@gcc.gnu.org>
>
>     PR fortran/58754
>     * trans-stmt.c (gfc_trans_allocate): Do not use the scalar
>     character assignment if the allocate expression sis an array
>     descriptor.
>
> 2015-10-22  Paul Thomas  <pault@gcc.gnu.org>
>
>     PR fortran/58754
>     * gfortran.dg/pr58754.f90: New test



-- 
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.

Groucho Marx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch, fortran] PR58754 - [4.9/5 Regression] ICE on allocating character array with source
  2015-10-22 14:32 [Patch, fortran] PR58754 - [4.9/5 Regression] ICE on allocating character array with source Paul Richard Thomas
  2015-10-22 17:32 ` Paul Richard Thomas
@ 2015-10-22 17:34 ` FX
  2015-10-22 18:15   ` Paul Richard Thomas
  1 sibling, 1 reply; 4+ messages in thread
From: FX @ 2015-10-22 17:34 UTC (permalink / raw)
  To: Paul Richard Thomas; +Cc: fortran, gcc-patches

> 2015-10-22  Paul Thomas  <pault@gcc.gnu.org>
> 
>    PR fortran/58754
>    * trans-stmt.c (gfc_trans_allocate): Do not use the scalar
>    character assignment if the allocate expression sis an array
>    descriptor.
> 
> 2015-10-22  Paul Thomas  <pault@gcc.gnu.org>
> 
>    PR fortran/58754
>    * gfortran.dg/pr58754.f90: New test

OK, apart from typo in the ChangeLog (“sis an array”).

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch, fortran] PR58754 - [4.9/5 Regression] ICE on allocating character array with source
  2015-10-22 17:34 ` FX
@ 2015-10-22 18:15   ` Paul Richard Thomas
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Richard Thomas @ 2015-10-22 18:15 UTC (permalink / raw)
  To: FX; +Cc: fortran, gcc-patches

Thanks FX!

Committed to 5 branch as revision 229179 and the testcase to 4_9 as
revision 229180.

Cheers

Paul


On 22 October 2015 at 19:32, FX <fxcoudert@gmail.com> wrote:
>> 2015-10-22  Paul Thomas  <pault@gcc.gnu.org>
>>
>>    PR fortran/58754
>>    * trans-stmt.c (gfc_trans_allocate): Do not use the scalar
>>    character assignment if the allocate expression sis an array
>>    descriptor.
>>
>> 2015-10-22  Paul Thomas  <pault@gcc.gnu.org>
>>
>>    PR fortran/58754
>>    * gfortran.dg/pr58754.f90: New test
>
> OK, apart from typo in the ChangeLog (“sis an array”).
>



-- 
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.

Groucho Marx

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-22 18:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-22 14:32 [Patch, fortran] PR58754 - [4.9/5 Regression] ICE on allocating character array with source Paul Richard Thomas
2015-10-22 17:32 ` Paul Richard Thomas
2015-10-22 17:34 ` FX
2015-10-22 18:15   ` Paul Richard Thomas

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).