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]

[Patch, fortran] PR25097 - Component of optional argument allowed as arg. to PRESENT


:ADDPATCH fortran:

13.14.82 PRESENT(A)
......
Argument. A shall be the name of an optional dummy argument that is accessible in the subprogram in which the PRESENT function reference appears......


At present, gfortran allows subobjects of A to be the actual argument of PRESENT. The patch applies the requirement in check.c(check_present). It is straightforward, as is the test case.

Regtested on FC5/Athlon. OK for trunk and 4.1?

Paul

2006-07-11 Paul Thomas <pault@gcc.gnu.org>

   PR fortran/25097
   * check.c (check_present): The only permitted reference is a
   full array reference.

2006-07-11 Paul Thomas <pault@gcc.gnu.org>

   PR fortran/25097
   * gfortran.dg/present_1.f90: New test.
Index: gcc/fortran/check.c
===================================================================
*** gcc/fortran/check.c	(revision 115332)
--- gcc/fortran/check.c	(working copy)
*************** gfc_check_present (gfc_expr * a)
*** 1867,1872 ****
--- 1867,1883 ----
        return FAILURE;
      }
  
+   if (a->ref != NULL
+ 	&& !(a->ref->next == NULL
+ 	       && a->ref->type == REF_ARRAY
+ 	       && a->ref->u.ar.type == AR_FULL))
+     {
+       gfc_error ("'%s' argument of '%s' intrinsic at %L must not be a sub-"
+ 		 "object of '%s'", gfc_current_intrinsic_arg[0],
+ 		 gfc_current_intrinsic, &a->where, sym->name);
+       return FAILURE;
+     }
+ 
    return SUCCESS;
  }
  
! { dg-do compile }
! Test the fix for PR25097, in which subobjects of the optional dummy argument
! could appear as argument A of the PRESENT intrinsic.
! 
! Contributed by Joost VandeVondele <jv244@cam.ac.uk>
!
 MODULE M1
  TYPE T1
   INTEGER :: I
  END TYPE T1
 CONTAINS
  SUBROUTINE S1(D1)
   TYPE(T1), OPTIONAL :: D1(4)
   write(6,*) PRESENT(D1%I)  ! { dg-error "must not be a sub-object" }
   write(6,*) PRESENT(D1(1)) ! { dg-error "must not be a sub-object" }
   write(6,*) PRESENT(D1)
  END SUBROUTINE S1
 END MODULE
 END

2006-07-11  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/25097
	* check.c (check_present): The only permitted reference is a
	full array reference.

2006-07-11  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/25097
	* gfortran.dg/present_1.f90: New test.

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