This is the mail archive of the gcc-patches@gcc.gnu.org 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.


Steve,

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 12.4.1.5 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

Paul

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 12.4.1.5 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
i386-*-freebsd.

2006-08-01 Steven G. Kargl <kargls@comcast.net>

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

* 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
END SUBROUTINE




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