This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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: fortran-experiments: patch for more error checking


On Sat, Jan 20, 2007 at 04:18:29PM -0700, Christopher D. Rickett wrote:
>hello all,
>
>i've attached a patch for the following:
>
>- more error checking on BIND(C) variables
>- error checking on the second arg of C_F_POINTER
>- 2 new test cases

Below just cosmetic nitpicks ..

>Index: gcc/fortran/symbol.c
>===================================================================
>--- gcc/fortran/symbol.c	(revision 121011)
>+++ gcc/fortran/symbol.c	(working copy)
>@@ -2909,6 +2909,18 @@ try verify_bind_c_derived_type (gfc_symb
>     gfc_internal_error("verify_bind_c_derived_type(): Given symbol is "
> 		       "unexpectedly NULL");
>   
>+  /* The derived type must have the BIND attribute to be interoperable
>+     J3/04-007, Section 15.2.3. */
>+  if (derived_sym->attr.is_bind_c != 1)
>+    {
>+      derived_sym->ts.is_c_interop = 0;
>+      gfc_error ("Derived type '%s' declared at %L must have the BIND "
>+                 "attribute to be C interoperable", derived_sym->name,
>+                 &(derived_sym->declared_at));
>+/*       return FAILURE; */

/* remove? */

>+      retval = FAILURE;
>+    }
>+  
>   curr_comp = derived_sym->components;
>   /* is this really an error??	 --Rickett, 10.24.05 */
>   if (curr_comp == NULL)
>Index: gcc/fortran/resolve.c
>===================================================================
>--- gcc/fortran/resolve.c	(revision 121011)
>+++ gcc/fortran/resolve.c	(working copy)
>@@ -1873,6 +1874,19 @@ match gfc_iso_c_sub_interface (gfc_code 
> 		  gfc_error ("Missing SHAPE parameter for call to %s "
> 			     "at %L", sym->name, &(c->loc));
> 		}
>+              /* Make sure the param is a POINTER.  No need to make sure
>+                 it does not have INTENT(IN) since it is a POINTER.  */
>+              tmp_sym = c->ext.actual->next->expr->symtree->n.sym;
>+              if (tmp_sym != NULL)
>+                {
>+                  if (tmp_sym->attr.pointer != 1)

I think that the convention is to fold both if statements into one:
if (tmp_sym && tmp_sym->attr.pointer != 1)
  {
>+                    {
>+                      gfc_error ("Argument '%s' to C_F_POINTER at %L "
>+                                 "must have the POINTER attribute",
>+                                 tmp_sym->name, &(c->loc));
>+                      m = MATCH_ERROR;
>+                    }
>+                }
> 	    }
> 	}
>       

cheers,


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