This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Patch, Fortran] PR39998: Procedure Pointer Assignments: Statement Functions & Internal Functions
- From: Janus Weil <janus at gcc dot gnu dot org>
- To: gfortran <fortran at gcc dot gnu dot org>, gcc patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 5 May 2009 22:15:52 +0200
- Subject: [Patch, Fortran] PR39998: Procedure Pointer Assignments: Statement Functions & Internal Functions
Hi all,
here is a straightforward patch for a little problem with procedure
pointer assignments, where statement functions and internal procedures
should be rejected. Regression-tested on x86_64-unknown-linux-gnu. Ok
for trunk?
Cheers,
Janus
2009-05-05 Janus Weil <janus@gcc.gnu.org>
PR fortran/39998
* expr.c (gfc_check_pointer_assign): Check for statement functions and
internal procedures in procedure pointer assignments.
2009-05-05 Janus Weil <janus@gcc.gnu.org>
PR fortran/39998
* gfortran.dg/proc_ptr_17.f90: New.
Index: gcc/testsuite/gfortran.dg/proc_ptr_17.f90
===================================================================
--- gcc/testsuite/gfortran.dg/proc_ptr_17.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/proc_ptr_17.f90 (revision 0)
@@ -0,0 +1,16 @@
+! { dg-do compile }
+! { dg-options "-std=f2003" }
+!
+! PR39998: Procedure Pointer Assignments: Statement Functions & Internal Functions.
+!
+! Contributed by Tobias Burnus <burnus@net-b.de>
+
+ procedure(), pointer :: p
+ f(x) = x**2
+ p => f ! { dg-error "invalid in procedure pointer assignment" }
+ p => sub ! { dg-error "invalid in procedure pointer assignment" }
+contains
+ subroutine sub
+ end subroutine sub
+end
+
Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c (revision 147126)
+++ gcc/fortran/expr.c (working copy)
@@ -3148,6 +3148,22 @@ gfc_check_pointer_assign (gfc_expr *lval
rvalue->symtree->name, &rvalue->where);
return FAILURE;
}
+ /* Check for C727. */
+ if (attr.flavor == FL_PROCEDURE)
+ {
+ if (attr.proc == PROC_ST_FUNCTION)
+ {
+ gfc_error ("Statement function '%s' is invalid "
+ "in procedure pointer assignment at %L",
+ rvalue->symtree->name, &rvalue->where);
+ return FAILURE;
+ }
+ if (attr.proc == PROC_INTERNAL &&
+ gfc_notify_std (GFC_STD_F2008, "Internal procedure '%s' is "
+ "invalid in procedure pointer assignment at %L",
+ rvalue->symtree->name, &rvalue->where) == FAILURE)
+ return FAILURE;
+ }
if (rvalue->expr_type == EXPR_VARIABLE
&& !gfc_compare_interfaces (lvalue->symtree->n.sym,
rvalue->symtree->n.sym, 0))