[patch, fortran] PR42354, accepts invalid init expr

Daniel Franke franke.daniel@gmail.com
Sun Dec 13 20:58:00 GMT 2009


Hi all.

Functions from ISO_C_BINDING are generally not allowed in initialization 
expressions (exception C_SIZEOF in F2008). Attached simple patch rejects any 
specification function that has 'is_iso_c' set - which is currently not a 
problem for the exception as C_SIZEOF is (a) in the wrong scope (see PR40568) 
and (b) generally being rejected as initialization expression (not marked 
CLASS_INQUIRY, not in the list of intrinsics being allowed in init 
expressions). I'll add a note to PR40568 if this change goes in.


2009-12-12  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/42354
	* expr.c (check_specification_function): Reject
	functions from ISO_C_BINDING.

2009-12-12  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/42354
	* gfortran.dg/iso_c_binding_init_expr.f03: New.


Regression tested on i686-pc-linux-gnu. Ok for trunk?

Cheers

	Daniel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr42354.diff
Type: text/x-patch
Size: 469 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20091213/39fb9df6/attachment.bin>
-------------- next part --------------
! { dg-do "compile" }
! PR fortran/42354

use iso_c_binding
implicit none
integer, target :: a
type t
  type(c_ptr) :: ptr = c_loc(a)    ! { dg-error "must be an intrinsic or a specification function" }
end type t
type(c_ptr) :: ptr2 = c_loc(a)     ! { dg-error "must be an intrinsic or a specification function" }
end


More information about the Fortran mailing list