diff mbox

[Fortran] PR 63727: Checks missing for proc-pointer components: Usage as actual argument when elemental

Message ID CAKwh3qgndH6BzR3_S3Us6h0MeApJebLY-oJp9yEr+=c7BDeumg@mail.gmail.com
State New
Headers show

Commit Message

Janus Weil Dec. 15, 2014, 1:19 p.m. UTC
Hi all,

here is another small diagnostic enhancement for procedure pointer
components. Regtested on x86_64-unknown-linux-gnu. Ok for trunk?

(I'm not adding a dedicated test case, since coarray_collectives_14
already includes this case as a FIXME, which I now transformed into a
dg-error.)

Cheers,
Janus


2014-12-15  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/63727
    * resolve.c (resolve_actual_arglist): Check for elemental procedure
    pointer components.


2014-12-15  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/63727
    * gfortran.dg/coarray_collectives_14.f90: Address FIXME item.
diff mbox

Patch

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(Revision 218721)
+++ gcc/fortran/resolve.c	(Arbeitskopie)
@@ -1740,6 +1740,7 @@  resolve_actual_arglist (gfc_actual_arglist *arg, p
   gfc_symbol *sym;
   gfc_symtree *parent_st;
   gfc_expr *e;
+  gfc_component *comp;
   int save_need_full_assumed_size;
   bool return_value = false;
   bool actual_arg_sav = actual_arg, first_actual_arg_sav = first_actual_arg;
@@ -1967,6 +1968,14 @@  resolve_actual_arglist (gfc_actual_arglist *arg, p
 	    }
 	}
 
+      comp = gfc_get_proc_ptr_comp(e);
+      if (comp && comp->attr.elemental)
+	{
+	    gfc_error ("ELEMENTAL procedure pointer component %qs is not "
+		       "allowed as an actual argument at %L", comp->name,
+		       &e->where);
+	}
+
       /* Fortran 2008, C1237.  */
       if (e->expr_type == EXPR_VARIABLE && gfc_is_coindexed (e)
 	  && gfc_has_ultimate_pointer (e))
Index: gcc/testsuite/gfortran.dg/coarray_collectives_14.f90
===================================================================
--- gcc/testsuite/gfortran.dg/coarray_collectives_14.f90	(Revision 218721)
+++ gcc/testsuite/gfortran.dg/coarray_collectives_14.f90	(Arbeitskopie)
@@ -62,7 +62,7 @@  program test
   call co_reduce(caf, arg3) ! { dg-error "shall have two arguments" }
   call co_reduce(caf, dt%arg3) ! { dg-error "shall have two arguments" }
   call co_reduce(caf, elem) ! { dg-error "ELEMENTAL non-INTRINSIC procedure 'elem' is not allowed as an actual argument" }
-  call co_reduce(caf, dt%elem) ! { FIXME: "ELEMENTAL non-INTRINSIC procedure 'elem' is not allowed as an actual argument" }
+  call co_reduce(caf, dt%elem) ! { dg-error "ELEMENTAL procedure pointer component 'elem' is not allowed as an actual argument" }
   call co_reduce(caf, realo) ! { dg-error "A argument at .1. has type INTEGER.4. but the function passed as OPERATOR at .2. returns REAL.4." }
   call co_reduce(caf, dt%realo) ! { dg-error "A argument at .1. has type INTEGER.4. but the function passed as OPERATOR at .2. returns REAL.4." }
   call co_reduce(caf, int8) ! { dg-error "A argument at .1. has type INTEGER.4. but the function passed as OPERATOR at .2. returns INTEGER.8." }