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] Fix PR 38536


Hello world,

the attached patch fixes the PR by inserting additional checks in
resolve.c to catch the invalid array sections.

Regression-tested.  OK for trunk?

	Thomas

2011-01-15  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/38536
	* resolve.c (gfc_iso_c_func_interface):  For C_LOC,
	check for array sections which are illegal.

2011-01-15  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/38536
	* gfortran.dg/c_loc_tests_16.f90:  New test.
Index: resolve.c
===================================================================
--- resolve.c	(Revision 168614)
+++ resolve.c	(Arbeitskopie)
@@ -2709,6 +2709,8 @@ gfc_iso_c_func_interface (gfc_symbol *sym, gfc_act
         }
       else if (sym->intmod_sym_id == ISOCBINDING_LOC)
         {
+	  gfc_ref *ref;
+
           /* Make sure we have either the target or pointer attribute.  */
 	  if (!arg_attr.target && !arg_attr.pointer)
             {
@@ -2719,6 +2721,23 @@ gfc_iso_c_func_interface (gfc_symbol *sym, gfc_act
               retval = FAILURE;
             }
 
+	  /* Follow references to make sure there are no array
+	     slices.  */
+	  for (ref=args->expr->ref; ref; ref = ref->next)
+	    {
+	      if (ref->type == REF_ARRAY)
+		{
+		  if (ref->u.ar.type == AR_SECTION
+		      || (ref->u.ar.type != AR_ELEMENT &&
+			  ref->next && ref->next->type == REF_COMPONENT))
+		    {
+		      gfc_error_now ("Array section not permitted in '%s'"
+				     " call at %L", name, &(args->expr->where));
+		      retval = FAILURE;
+		    }
+		}
+	    }
+
           /* See if we have interoperable type and type param.  */
           if (verify_c_interop (arg_ts) == SUCCESS
               || gfc_check_any_c_kind (arg_ts) == SUCCESS)

Attachment: c_loc_tests_16.f90
Description: Text document


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