This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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);





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]