This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, fortran] PR26741 - Elemental functions not permitted in initialization expressions
- From: Paul Thomas <paulthomas2 at wanadoo dot fr>
- To: patch <gcc-patches at gcc dot gnu dot org>, "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>
- Date: Sat, 18 Mar 2006 06:15:01 +0100
- Subject: [Patch, fortran] PR26741 - Elemental functions not permitted in initialization expressions
In testing gfortran's capacity to deal with iso_varying_string, it was found
that the error "Specification function 'len_' at (1) must be PURE" was produced
- see testcase below. This is obviously incorrect because elemental functions
are pure.
Regtested on FC3/Athlon1700.
I intend to commit to trunk and 4.1 tommorrow under the "obvious" rule.
Paul Thomas
2006-03-18 Paul Thomas <pault@gcc.gnu.org>
PR fortran/26716
*expr.c (external_spec_function): Permit elemental functions.
2006-03-17 Paul Thomas <pault@gcc.gnu.org>
PR fortran/26716
* gfortran.dg/elemental_initializer_1.f90: New test.
! { dg-do compile }
! Tests the fix for elemental functions not being allowed in
! specification expressions in pure procedures.
!
! Testcase from iso_varying_string by Rich Townsend <rhdt@star.ucl.ac.uk <mailto:rhdt@star.ucl.ac.uk>>
! The allocatable component has been changed to a pointer for this testcase.
!
module iso_varying_string
type varying_string
private
character(LEN=1), dimension(:), pointer :: chars
end type varying_string
interface len
module procedure len_
end interface len
contains
pure function char_auto (string) result (char_string)
type(varying_string), intent(in) :: string
character(LEN=len(string)) :: char_string ! Error was here
end function char_auto
elemental function len_ (string) result (length)
type(varying_string), intent(in) :: string
integer :: length
end function len_
end module iso_varying_string
Index: gcc/fortran/expr.c
===================================================================
*** gcc/fortran/expr.c (revision 112139)
--- gcc/fortran/expr.c (working copy)
*************** external_spec_function (gfc_expr * e)
*** 1636,1642 ****
return FAILURE;
}
! if (!f->attr.pure)
{
gfc_error ("Specification function '%s' at %L must be PURE", f->name,
&e->where);
--- 1636,1642 ----
return FAILURE;
}
! if (!f->attr.pure && !f->attr.elemental)
{
gfc_error ("Specification function '%s' at %L must be PURE", f->name,
&e->where);