[PATCH] fortran/28548 -- Optional argument fails.

Steve Kargl sgk@troutmask.apl.washington.edu
Thu Aug 3 06:22:00 GMT 2006


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.

-- 
Steve
-------------- next part --------------
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 " 
-------------- next part --------------
! { 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


More information about the Fortran mailing list