This is the mail archive of the 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] initialization expressions

Hi all,

a while ago, I promised Jerry to have a look at PR31639, an ICE with 
initialization expressions. Here are the results ...

Fixing the actual ICE would have been quite easy, giving a useful diagnostic 
turned out to be more challenging. To that end, I implemented some parts of 
the initialization expression as described in PR29662 (F95, 7.1.6; F2003, 

Two thirds of the patch are straight forward and start with a TODO item: add 
class information (elemental, inquiry, transformational) to intrinsic 
functions in intrinsic.c. The first one was already available, the latter two 
were added. Further, checks for init expr were moved from intrinsic.c to 
expr.c were viable. The same was done with checks for transformational 
functions which were moved from check.c to expr.c. Finally, a set of new 
check functions implement the actual restrictions described by the cited 
standard sections (check.c(check_init_expr)). 

The diff contains large chunks of text quoted directly from the standard 
drafts, these may be dropped before committing. I kept them for the 
reviewers, so it may be easier to see what I intended to implement :)

I am aware of the following PRs that are affected by this patch:
  * 29662 - Initialization expressions checking, partially implemented
  * 31253 - ICE-on-invalid, fixed
  * 31265 - rejects-valid, fixed
  * 31639 - ICE-on-invalid, fixed
  * 25104 - ICE-on-valid if -std=f2003, revived (next on list)

These PRs related to specification expressions may be easier to fix with the 
patch in place:
  * 31259 - ICE-on-invalid
  * 31592 - diagnostic
  * 31817 - diagnostic

Please give it a good shot, there will be quite a number of unhandled cases 
left ...

:ADDPATCH fortran:

2007-07-17  Daniel Franke  <>

	PR fortran/29662
	PR fortran/31253
	PR fortran/31265
	PR fortran/31639
	* gfortran.h (gfc_intrinsic_sym): Changed members elemental, pure, generic,
	specific, actual_ok, noreturn into bits of a bitfield, added bits for 
	inquiry, transformational, conversion.
	* check.c (non_init_transformational): Removed, removed all callers.
	* intrinsic.c (enum class): New.
	(add_sym*): Replaced argument elemetal by enum class. Changed all callers.
	(add_functions): Assign appropriate classes to intrinsic functions.
	(add_subroutines): Assign appropriate classes to intrinsic subroutines.
	(add_conv): Set conversion attribute.
	(gfc_init_expr_extensions): Removed, removed all callers.
	(gfc_intrinsic_func_interface): Reimplemented check for non-standard
	initializatione expressions.
	* expr.c (check_specification_function): New.
	(gfc_is_constant_expr): Added check for specification functions.
	(check_init_expr_arguments): New.
	(check_inquiry): Changed return value to MATCH, added checks for inquiry
	functions defined by F2003.
	(check_transformational): New.
	(check_null): New.
	(check_elemental): New.
	(check_conversion): New.
	(check_init_expr): Call new check functions, add more specfic error messages.

2007-07-17  Daniel Franke  <>

	PR fortran/29662
	* gfortran.dg/initialization_1.f90: Adjusted messages.
	* gfortran.dg/array_initializer_1.f90: Removed warning.
	* gfortran.dg/nested_modules_6.f90: Removed warning.

	PR fortran/31253
	* gfortran.dg/initialization_7.f90: New test.

	PR fortran/31639
	* gfortran.dg/initialization_8.f90: New test.

There is no testcase for PR31265 as nested_modules_6.f90 already includes the 
test in question.

Bootstrapped and regression tested on i686-pc-linux-gnu. Ok for trunk?


Attachment: init-expr.patch.gz
Description: GNU Zip compressed data

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