diff mbox

[fortran] PR65792 - allocation of scalar elemental function with structure constructor fails

Message ID 554E07CA.2020808@sfr.fr
State New
Headers show

Commit Message

Mikael Morin May 9, 2015, 1:12 p.m. UTC
Le 01/05/2015 20:25, Paul Richard Thomas a écrit :
> Dear All,
> 
> By the time I went to commit, something had changed and the patch
> caused a regression. I presume that the version that I had of Andre's
> patch was not the same as the one committed. I'll cast an eye over it
> this weekend and see if I can understand what gives.
> 
Hello Paul,

to get things moving again, I propose the attached fix to your patch.
Tested on alloc_comp_deep_copy_1 only for now.

Mikael

Comments

Mikael Morin May 15, 2015, 5:01 p.m. UTC | #1
Le 09/05/2015 15:12, Mikael Morin a écrit :
> Le 01/05/2015 20:25, Paul Richard Thomas a écrit :
>> Dear All,
>>
>> By the time I went to commit, something had changed and the patch
>> caused a regression. I presume that the version that I had of Andre's
>> patch was not the same as the one committed. I'll cast an eye over it
>> this weekend and see if I can understand what gives.
>>
> Hello Paul,
> 
> to get things moving again, I propose the attached fix to your patch.
> Tested on alloc_comp_deep_copy_1 only for now.

Hello Paul,

any news?

Mikael
Paul Richard Thomas May 15, 2015, 5:59 p.m. UTC | #2
Dear Mikael, dear all,

I am struggling to find time for gfortran at present because of the
change in my personal circumstances. I am still working full time as a
consultant, whilst trying to sell the house and fix up all those
things that l'Administration Francaise makes so "interesting" (Having
had quasi-diplomatic status, there are all sorts of issues involved in
cars, pensions and... yes, the 2014 tax return).  Things will improve
on a timescale of three months because I am expecting an acceptable
offer for the house, next week.

In the meantime, to show willing, I will attend to this right now :-)

Cheers

Paul

On 15 May 2015 at 19:01, Mikael Morin <mikael.morin@sfr.fr> wrote:
> Le 09/05/2015 15:12, Mikael Morin a écrit :
>> Le 01/05/2015 20:25, Paul Richard Thomas a écrit :
>>> Dear All,
>>>
>>> By the time I went to commit, something had changed and the patch
>>> caused a regression. I presume that the version that I had of Andre's
>>> patch was not the same as the one committed. I'll cast an eye over it
>>> this weekend and see if I can understand what gives.
>>>
>> Hello Paul,
>>
>> to get things moving again, I propose the attached fix to your patch.
>> Tested on alloc_comp_deep_copy_1 only for now.
>
> Hello Paul,
>
> any news?
>
> Mikael
Paul Richard Thomas May 16, 2015, 8:13 a.m. UTC | #3
Dear Mikael,

With your tweak it bootstrapped and regtested OK. Also changed the
comment after Steve's pointing out that the last sentence was
incomprehensible:-)

Committed to trunk as revision 223234.

Cheers

Paul

2015-05-16  Mikael Morin  <mikael@gcc.gnu.org
        Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/65792
    * trans-expr.c (gfc_trans_subcomponent_assign): Always assign
    the expression component to the destination. In addition, if
    the component has allocatable components, copy them and
    deallocate those of the expression, if it is not a variable.
    The expression is fixed if not a variable to prevent multiple
    evaluations.

2015-05-16  Mikael Morin  <mikael@gcc.gnu.org>

    PR fortran/65792
    * gfortran.dg/derived_constructor_components_5: New test


On 15 May 2015 at 19:01, Mikael Morin <mikael.morin@sfr.fr> wrote:
> Le 09/05/2015 15:12, Mikael Morin a écrit :
>> Le 01/05/2015 20:25, Paul Richard Thomas a écrit :
>>> Dear All,
>>>
>>> By the time I went to commit, something had changed and the patch
>>> caused a regression. I presume that the version that I had of Andre's
>>> patch was not the same as the one committed. I'll cast an eye over it
>>> this weekend and see if I can understand what gives.
>>>
>> Hello Paul,
>>
>> to get things moving again, I propose the attached fix to your patch.
>> Tested on alloc_comp_deep_copy_1 only for now.
>
> Hello Paul,
>
> any news?
>
> Mikael
diff mbox

Patch

diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 6cf5fe2..532f4b7 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -7078,7 +7078,8 @@  gfc_trans_subcomponent_assign (tree dest, gfc_component * cm, gfc_expr * expr,
 	    }
 	  gfc_add_modify (&block, dest,
 			  fold_convert (TREE_TYPE (dest), se.expr));
-	  if (cm->ts.u.derived->attr.alloc_comp)
+	  if (cm->ts.u.derived->attr.alloc_comp
+	      && expr->expr_type != EXPR_NULL)
 	    {
 	      tmp = gfc_copy_alloc_comp (cm->ts.u.derived, se.expr,
 					 dest, expr->rank);