Message ID | CAKwh3qi6Jw=MJdatmNxex+rHjHUkghkCJLLh2Ph+_T_af2maGg@mail.gmail.com |
---|---|
State | New |
Headers | show |
Ping! (I think this patch is pretty straightforward ...) Cheers, Janus 2015-01-06 16:19 GMT+01:00 Janus Weil <janus@gcc.gnu.org>: > Hi all, > > here is a patch which adds an interface check for procedure pointer > components as acual arguments. Such a check is there already for > ordinary procedures and procedure pointers, but missing for PPCs. It > checks the interface of the actual argument versus the interface of > the dummy procedure, according to the usual rules. > > Regtested on x86_64-unknown-linux-gnu. Ok for trunk? > > Cheers, > Janus > > > > 2015-01-06 Janus Weil <janus@gcc.gnu.org> > > PR fortran/64508 > * interface.c (compare_parameter): Interface check for > procedure-pointer component as actual argument. > > 2015-01-06 Janus Weil <janus@gcc.gnu.org> > > PR fortran/64508 > * gfortran.dg/proc_ptr_comp_41.f90: New.
Dear Janus, As you say, the patch is pretty straightforward :-) OK for trunk. Thanks for the patch Paul On 11 January 2015 at 11:21, Janus Weil <janus@gcc.gnu.org> wrote: > Ping! (I think this patch is pretty straightforward ...) > > Cheers, > Janus > > > > 2015-01-06 16:19 GMT+01:00 Janus Weil <janus@gcc.gnu.org>: >> Hi all, >> >> here is a patch which adds an interface check for procedure pointer >> components as acual arguments. Such a check is there already for >> ordinary procedures and procedure pointers, but missing for PPCs. It >> checks the interface of the actual argument versus the interface of >> the dummy procedure, according to the usual rules. >> >> Regtested on x86_64-unknown-linux-gnu. Ok for trunk? >> >> Cheers, >> Janus >> >> >> >> 2015-01-06 Janus Weil <janus@gcc.gnu.org> >> >> PR fortran/64508 >> * interface.c (compare_parameter): Interface check for >> procedure-pointer component as actual argument. >> >> 2015-01-06 Janus Weil <janus@gcc.gnu.org> >> >> PR fortran/64508 >> * gfortran.dg/proc_ptr_comp_41.f90: New.
Committed as r219431. Thanks for the review! Cheers, Janus 2015-01-11 16:16 GMT+01:00 Paul Richard Thomas <paul.richard.thomas@gmail.com>: > Dear Janus, > > As you say, the patch is pretty straightforward :-) OK for trunk. > > Thanks for the patch > > Paul > > On 11 January 2015 at 11:21, Janus Weil <janus@gcc.gnu.org> wrote: >> Ping! (I think this patch is pretty straightforward ...) >> >> Cheers, >> Janus >> >> >> >> 2015-01-06 16:19 GMT+01:00 Janus Weil <janus@gcc.gnu.org>: >>> Hi all, >>> >>> here is a patch which adds an interface check for procedure pointer >>> components as acual arguments. Such a check is there already for >>> ordinary procedures and procedure pointers, but missing for PPCs. It >>> checks the interface of the actual argument versus the interface of >>> the dummy procedure, according to the usual rules. >>> >>> Regtested on x86_64-unknown-linux-gnu. Ok for trunk? >>> >>> Cheers, >>> Janus >>> >>> >>> >>> 2015-01-06 Janus Weil <janus@gcc.gnu.org> >>> >>> PR fortran/64508 >>> * interface.c (compare_parameter): Interface check for >>> procedure-pointer component as actual argument. >>> >>> 2015-01-06 Janus Weil <janus@gcc.gnu.org> >>> >>> PR fortran/64508 >>> * gfortran.dg/proc_ptr_comp_41.f90: New. > > > > -- > Outside of a dog, a book is a man's best friend. Inside of a dog it's > too dark to read. > > Groucho Marx
Index: gcc/fortran/interface.c =================================================================== --- gcc/fortran/interface.c (Revision 219261) +++ gcc/fortran/interface.c (Arbeitskopie) @@ -1922,6 +1922,8 @@ compare_parameter (gfc_symbol *formal, gfc_expr *a { gfc_ref *ref; bool rank_check, is_pointer; + char err[200]; + gfc_component *ppc; /* If the formal arg has type BT_VOID, it's to one of the iso_c_binding procs c_f_pointer or c_f_procpointer, and we need to accept most @@ -1942,7 +1944,6 @@ compare_parameter (gfc_symbol *formal, gfc_expr *a if (actual->ts.type == BT_PROCEDURE) { - char err[200]; gfc_symbol *act_sym = actual->symtree->n.sym; if (formal->attr.flavor != FL_PROCEDURE) @@ -1976,6 +1977,19 @@ compare_parameter (gfc_symbol *formal, gfc_expr *a return 1; } + ppc = gfc_get_proc_ptr_comp (actual); + if (ppc) + { + if (!gfc_compare_interfaces (formal, ppc->ts.interface, ppc->name, 0, 1, + err, sizeof(err), NULL, NULL)) + { + if (where) + gfc_error ("Interface mismatch in dummy procedure %qs at %L: %s", + formal->name, &actual->where, err); + return 0; + } + } + /* F2008, C1241. */ if (formal->attr.pointer && formal->attr.contiguous && !gfc_is_simply_contiguous (actual, true))