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]

Re: [Patch, Fortran, OOP] PR 45290/45271: pointer initialization / vtab init

On 08/20/2010 11:49 AM, Janus Weil wrote:
this patch fixes PR 45271 by giving static initializers to the PPC
components of the vtabs. This is made possible by the recent progress
on pointer initialization (PR 45290). A prerequisite for vtab
initialization was fixing comment #6 of that PR, which is accomplished
simply by removing an 'gcc_assert' in 'build_function_decl'.

I like the patch - the only thing I do not quite understand is the removal of the
- gcc_assert (!sym->backend_decl);
assert in build_function_decl.

How does the sym->backend_decl get set? More specifically, I worry about generating two declarations for the same procedure as on has later in build_function_decl:
sym->backend_decl = fndecl;

Having two declarations for the same procedures not only wastes memory but it causes severe problems as the middle end does not expect this. Using -fwhole-file (now default) with -fwhole-program and high optimization settings (-O3) causes a lot of wrong optimizations if there are two declarations. We had a hard time to fix most of them when enabling -fwhole-file by default - thus I do not want to introduce new problems.

Currently, one has two methods of getting the backend_decl for a procedure:
a) Via gfc_create_function_decl
b) Via gfc_get_extern_function_decl

If in the same file a procedure exists both as external function and is defined then a lot of effort is made that both have the share backend_decl. Thus, I fear that part of the patch is not correct.

The rest is fine though I would use true and false rather than 0 and 1 in the calls to gfc_conv_initializer as this is more readable and the parameter is defined as "bool".


2010-08-20 Janus Weil<>

	PR fortran/45271
	PR fortran/45290
	* class.c (add_proc_comp): Add static initializer for PPCs.
	(add_procs_to_declared_vtab): Modified comment.
	* module.c (mio_component): Add argument 'vtype'. Don't read/write the
	initializer if the component is part of a vtype.
	(mio_component_list): Add argument 'vtype', pass it on to
	(mio_symbol): Modified call to 'mio_component_list'.
	* trans.h (gfc_conv_initializer): Modified prototype.
	(gfc_trans_assign_vtab_procs): Removed.
	* trans-common.c (create_common): Modified call to
	* trans-decl.c (gfc_get_symbol_decl,get_proc_pointer_decl,
	gfc_emit_parameter_debug_info): Modified call to
	(build_function_decl): Remove assertion.
	* trans-expr.c (gfc_conv_derived_to_class,gfc_trans_class_assign):
	Removed call to 'gfc_trans_assign_vtab_procs'.
	(gfc_conv_initializer): Add argument 'procptr'.
	(gfc_conv_structure): Modified call to 'gfc_conv_initializer'.
	(gfc_trans_assign_vtab_procs): Removed.
	* trans-stmt.c (gfc_trans_allocate): Removed call to

2010-08-20 Janus Weil<>

	PR fortran/45271
	PR fortran/45290
	* gfortran.dg/pointer_init_5.f90: New.
	* gfortran.dg/typebound_call_18.f03: New.

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