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/28548 -- Optional argument fails.


OK with the proviso that the error is turned into a warning; yes, I think that Martin is correct about the standard stating that this is only an error if the argument is missing. Applying a runtime error looked horribly messy, although a library function might be the way around it. I have suggested a new wording in a Bugzilla atachment to the PR. This means that the dg-error's in the original testcase must be changed to dg-warning's. Would it be an idea to make this conditional on -pedantic too?

I do apologise for not reading the section carefully enough and thank you, Steve, for covering my a**e whilst I was away. An upside is that we have all learned that attr.elemental is not always what it appears to be!

Best regards and thanks


The attach patch appears to fix the problem noted in
fortran/28548. The problem is that the internal functions
__convert_* are marked as elemental Fortran procedures,
so that the elemental infrastructure can be used to deal
with both scalar and array arguments. Enforcement of
section of the standard is catching these functions (as it should if these weren't internal functions).

I've bootstrapped and regression tested this patch on

2006-08-01 Steven G. Kargl <>

	PR fortran/28548
	* resolve.c (resolve_elemental_actual): Special case __convert_*
	with respect to section

* gfortran.dg/internal_convert.f90: New test.


Index: resolve.c
--- resolve.c (revision 115827)
+++ resolve.c (working copy)
@@ -1012,7 +1012,8 @@
&& arg->expr->symtree->n.sym->attr.optional
&& formal_optional
&& arg->expr->rank
- && (set_by_optional || arg->expr->rank != rank)) + && (set_by_optional || arg->expr->rank != rank)
+ && !(isym && isym->generic_id == GFC_ISYM_CONVERSION))
gfc_error ("'%s' at %L is an array and OPTIONAL; it cannot "
"therefore be an actual argument of an ELEMENTAL "


! { dg-do compile }
! Test fix for PR fortran/28548.
SUBROUTINE foo(a, d)
real a
integer, dimension(3), optional :: d
if (present(d)) d = d + a

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