* [Patch, fortran] PR32903 - [regression] Default initializer and intent(OUT): default initializer not used
@ 2007-07-27 9:27 Paul Thomas
2007-07-27 10:54 ` Tobias Burnus
0 siblings, 1 reply; 3+ messages in thread
From: Paul Thomas @ 2007-07-27 9:27 UTC (permalink / raw)
To: Fortran List, gcc-patches
I have committed a patch for this as 'obvious'. It was a regression
that I caused by forgetting to set intent(out) derived types, to which
the default initializer is applied, as referenced. The patch is a one
and a half liner.
Cheers
Paul
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch, fortran] PR32903 - [regression] Default initializer and intent(OUT): default initializer not used
2007-07-27 9:27 [Patch, fortran] PR32903 - [regression] Default initializer and intent(OUT): default initializer not used Paul Thomas
@ 2007-07-27 10:54 ` Tobias Burnus
2007-07-27 11:29 ` Paul Thomas
0 siblings, 1 reply; 3+ messages in thread
From: Tobias Burnus @ 2007-07-27 10:54 UTC (permalink / raw)
Cc: Fortran List, gcc-patches
Paul Thomas wrote:
> I have committed a patch for this as 'obvious'. It was a regression
> that I caused by forgetting to set intent(out) derived types, to which
> the default initializer is applied, as referenced. The patch is a one
> and a half liner.
Thanks. I now added also the test case to make sure it will never regress.
Tobias
My Patch:
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (Revision 126974)
+++ gcc/testsuite/ChangeLog (Arbeitskopie)
@@ -1,3 +1,8 @@
+2007-07-27 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/32903
+ * gfortran.dg/initialization_11.f90: New test.
+
2007-07-27 Richard Sandiford <richard@codesourcery.com>
* gcc.target/mips/ins-1.c: New test.
Index: gcc/testsuite/gfortran.dg/initialization_11.f90
===================================================================
--- gcc/testsuite/gfortran.dg/initialization_11.f90 (Revision 0)
+++ gcc/testsuite/gfortran.dg/initialization_11.f90 (Revision 0)
@@ -0,0 +1,20 @@
+! { dg-do run }
+! PR fortran/32903
+!
+program test
+ implicit none
+ type data_type
+ integer :: i=2
+ end type data_type
+ type(data_type) :: d
+ d%i = 4
+ call set(d)
+ if(d%i /= 2) then
+ print *, 'Expect: 2, got: ', d%i
+ call abort()
+ end if
+contains
+ subroutine set(x1)
+ type(data_type),intent(out):: x1
+ end subroutine set
+end program test
Paul's patch:
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog (Revision 126973)
+++ gcc/fortran/ChangeLog (Revision 126974)
@@ -1,10 +1,17 @@
+2007-07-27 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/32903
+ * trans-decl.c (gfc_trans_deferred_vars): Set intent(out)
+ derived types as referenced, if they have the the default
+ initializer set.
+
Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c (Revision 126973)
+++ gcc/fortran/trans-decl.c (Revision 126974)
@@ -2735,8 +2735,7 @@ gfc_trans_deferred_vars (gfc_symbol * pr
/* If an INTENT(OUT) dummy of derived type has a default
initializer, it must be initialized here. */
- if (f->sym && f->sym->attr.referenced
- && f->sym->attr.intent == INTENT_OUT
+ if (f->sym && f->sym->attr.intent == INTENT_OUT
&& f->sym->ts.type == BT_DERIVED
&& !f->sym->ts.derived->attr.alloc_comp
&& f->sym->value)
@@ -2744,6 +2743,7 @@ gfc_trans_deferred_vars (gfc_symbol * pr
gfc_expr *tmpe;
tree tmp, present;
gcc_assert (!f->sym->attr.allocatable);
+ gfc_set_sym_referenced (f->sym);
tmpe = gfc_lval_expr_from_sym (f->sym);
tmp = gfc_trans_assignment (tmpe, f->sym->value, false);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch, fortran] PR32903 - [regression] Default initializer and intent(OUT): default initializer not used
2007-07-27 10:54 ` Tobias Burnus
@ 2007-07-27 11:29 ` Paul Thomas
0 siblings, 0 replies; 3+ messages in thread
From: Paul Thomas @ 2007-07-27 11:29 UTC (permalink / raw)
To: Tobias Burnus; +Cc: Fortran List, gcc-patches
Tobias,
>> and a half liner.
>>
> Thanks. I now added also the test case to make sure it will never regress.
>
Thanks for doing that. I did think long and hard as to whether or not
to add the testscase. I decided that this feature was never likely to
break but.... it does no harm either!
Cheers
Paul
> Tobias
>
> My Patch:
>
> Index: gcc/testsuite/ChangeLog
> ===================================================================
> --- gcc/testsuite/ChangeLog (Revision 126974)
> +++ gcc/testsuite/ChangeLog (Arbeitskopie)
> @@ -1,3 +1,8 @@
> +2007-07-27 Tobias Burnus <burnus@net-b.de>
> +
> + PR fortran/32903
> + * gfortran.dg/initialization_11.f90: New test.
> +
> 2007-07-27 Richard Sandiford <richard@codesourcery.com>
>
> * gcc.target/mips/ins-1.c: New test.
> Index: gcc/testsuite/gfortran.dg/initialization_11.f90
> ===================================================================
> --- gcc/testsuite/gfortran.dg/initialization_11.f90 (Revision 0)
> +++ gcc/testsuite/gfortran.dg/initialization_11.f90 (Revision 0)
> @@ -0,0 +1,20 @@
> +! { dg-do run }
> +! PR fortran/32903
> +!
> +program test
> + implicit none
> + type data_type
> + integer :: i=2
> + end type data_type
> + type(data_type) :: d
> + d%i = 4
> + call set(d)
> + if(d%i /= 2) then
> + print *, 'Expect: 2, got: ', d%i
> + call abort()
> + end if
> +contains
> + subroutine set(x1)
> + type(data_type),intent(out):: x1
> + end subroutine set
> +end program test
>
> Paul's patch:
> Index: gcc/fortran/ChangeLog
> ===================================================================
> --- gcc/fortran/ChangeLog (Revision 126973)
> +++ gcc/fortran/ChangeLog (Revision 126974)
> @@ -1,10 +1,17 @@
> +2007-07-27 Paul Thomas <pault@gcc.gnu.org>
> +
> + PR fortran/32903
> + * trans-decl.c (gfc_trans_deferred_vars): Set intent(out)
> + derived types as referenced, if they have the the default
> + initializer set.
> +
> Index: gcc/fortran/trans-decl.c
> ===================================================================
> --- gcc/fortran/trans-decl.c (Revision 126973)
> +++ gcc/fortran/trans-decl.c (Revision 126974)
> @@ -2735,8 +2735,7 @@ gfc_trans_deferred_vars (gfc_symbol * pr
>
> /* If an INTENT(OUT) dummy of derived type has a default
> initializer, it must be initialized here. */
> - if (f->sym && f->sym->attr.referenced
> - && f->sym->attr.intent == INTENT_OUT
> + if (f->sym && f->sym->attr.intent == INTENT_OUT
> && f->sym->ts.type == BT_DERIVED
> && !f->sym->ts.derived->attr.alloc_comp
> && f->sym->value)
> @@ -2744,6 +2743,7 @@ gfc_trans_deferred_vars (gfc_symbol * pr
> gfc_expr *tmpe;
> tree tmp, present;
> gcc_assert (!f->sym->attr.allocatable);
> + gfc_set_sym_referenced (f->sym);
> tmpe = gfc_lval_expr_from_sym (f->sym);
> tmp = gfc_trans_assignment (tmpe, f->sym->value, false);
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-27 11:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-27 9:27 [Patch, fortran] PR32903 - [regression] Default initializer and intent(OUT): default initializer not used Paul Thomas
2007-07-27 10:54 ` Tobias Burnus
2007-07-27 11:29 ` Paul 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).