Bug 63727 - [F03] Checks missing for proc-pointer components: Usage as actual argument when elemental
Summary: [F03] Checks missing for proc-pointer components: Usage as actual argument wh...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: ---
Assignee: janus
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2014-11-03 20:20 UTC by Tobias Burnus
Modified: 2014-12-15 16:14 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-12-14 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2014-11-03 20:20:13 UTC
The PPC lacks some argument check as the code below should have been rejected with something like: ELEMENTAL non-INTRINSIC procedure 'x%ptr' is not allowed as an actual argument.


interface
  elemental subroutine foo()
  end subroutine
end interface

type t
  procedure(foo), pointer, nopass :: ptr
end type t

type(t) :: x
call bar(x%ptr)
end
Comment 1 janus 2014-12-14 09:31:37 UTC
The following is sufficient to reject the code (not regtested yet):


Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(Revision 218705)
+++ 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))
Comment 2 janus 2014-12-15 16:11:22 UTC
Author: janus
Date: Mon Dec 15 16:10:50 2014
New Revision: 218751

URL: https://gcc.gnu.org/viewcvs?rev=218751&root=gcc&view=rev
Log:
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.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/coarray_collectives_14.f90
Comment 3 janus 2014-12-15 16:14:19 UTC
Fixed with r218751. Closing.