This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Patch, Fortran] PR42922 - Wrongly rejected derived types with default initializers in PURE procedures
- From: Tobias Burnus <burnus at net-b dot de>
- To: gcc patches <gcc-patches at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Mon, 01 Feb 2010 20:47:26 +0100
- Subject: [Patch, Fortran] PR42922 - Wrongly rejected derived types with default initializers in PURE procedures
A variant of PR 42008 and close to be obvious.
Build & regtested on x86-64-linux. OK for the trunk?
Tobias
2010-02-01 Tobias Burnus <burnus@net-b.de>
PR fortran/42922
* decl.c (variable_decl): Allow default initializer in
TYPE declarations in PURE functions.
2010-02-01 Tobias Burnus <burnus@net-b.de>
PR fortran/42922
* gfortran.dg/pure_initializer_3.f90: News test.
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c (revision 156428)
+++ gcc/fortran/decl.c (working copy)
@@ -1809,7 +1815,8 @@ variable_decl (int elem)
m = MATCH_ERROR;
}
- if (current_attr.flavor != FL_PARAMETER && gfc_pure (NULL))
+ if (current_attr.flavor != FL_PARAMETER && gfc_pure (NULL)
+ && gfc_state_stack->state != COMP_DERIVED)
{
gfc_error ("Initialization of variable at %C is not allowed in "
"a PURE procedure");
Index: gcc/testsuite/gfortran.dg/pure_initializer_3.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pure_initializer_3.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/pure_initializer_3.f90 (revision 0)
@@ -0,0 +1,12 @@
+! { dg-do compile }
+!
+! PR fortran/42922
+!
+! Contributed by mrestelli@gmail.com
+!
+pure subroutine psub()
+ implicit none
+ type ilist
+ integer :: i = 0
+ end type ilist
+end subroutine psub