Bug 41106 - [F03] Procedure Pointers with CHARACTER results
Summary: [F03] Procedure Pointers with CHARACTER results
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: janus
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2009-08-18 14:35 UTC by janus
Modified: 2009-08-21 12:17 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-08-20 15:12:01


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description janus 2009-08-18 14:35:05 UTC
There are some problems with CHARACTER-valued procedure pointers (and procedure pointer components).


First example (with PPCs):

module m
 type :: t
 procedure(character(len=5)), pointer, nopass :: ptr
 end type
contains
 function abc()
  character(len=5) :: abc
  abc = 'abcde'
 end function abc
end module m

use m
 type(t) :: x
 character(len=5) :: str
 x%ptr => abc
 str = x%ptr()
end

gives the error:

test.f90:12:0: internal compiler error: in gfc_conv_component_ref, at
fortran/trans-expr.c:477


Second example (similar, but with simple procedure pointers):

procedure(character(len=5)), pointer :: pp
pp => abc
contains
 function abc()
 character(len=5) :: abc
 abc = 'abcde'
 end function abc
end

gives:

internal compiler error: in gfc_trans_pointer_assignment, at fortran/trans-expr.c:4237
Comment 1 janus 2009-08-21 09:43:21 UTC
Subject: Bug 41106

Author: janus
Date: Fri Aug 21 09:43:04 2009
New Revision: 150987

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150987
Log:
2009-08-21  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/41106
	* primary.c (gfc_variable_attr): Make it work also on EXPR_FUNCTION.
	(gfc_expr_attr): Use gfc_variable_attr for procedure pointer components.
	* resolve.c (resolve_fl_derived): Handle CHARACTER-valued procedure
	pointer components.
	* trans-expr.c (gfc_conv_component_ref): Ditto.
	(gfc_conv_variable): Ditto.
	(gfc_conv_procedure_call): Ditto.
	(gfc_trans_pointer_assignment): Ditto.
	* trans-types.c (gfc_get_derived_type): Ditto.


2009-08-21  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/41106
	* gfortran.dg/proc_ptr_23.f90: New.
	* gfortran.dg/proc_ptr_comp_15.f90: New.
	* gfortran.dg/proc_ptr_comp_16.f90: New.
	* gfortran.dg/proc_ptr_comp_17.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/proc_ptr_23.f90
    trunk/gcc/testsuite/gfortran.dg/proc_ptr_comp_15.f90
    trunk/gcc/testsuite/gfortran.dg/proc_ptr_comp_16.f90
    trunk/gcc/testsuite/gfortran.dg/proc_ptr_comp_17.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/primary.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/fortran/trans-types.c
    trunk/gcc/testsuite/ChangeLog

Comment 2 janus 2009-08-21 12:17:39 UTC
Fixed with r150987. Closing.