public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran, F08] PR 84313: reject procedure pointers in COMMON blocks
@ 2018-02-13 18:24 Janus Weil
  2018-02-13 19:14 ` Steve Kargl
  2018-02-14 11:30 ` Jakub Jelinek
  0 siblings, 2 replies; 8+ messages in thread
From: Janus Weil @ 2018-02-13 18:24 UTC (permalink / raw)
  To: gfortran, gcc-patches, Richard Guenther, Jakub Jelinek

[-- Attachment #1: Type: text/plain, Size: 1145 bytes --]

Hi all,

as the subject line says, the attached patch rejects procedure
pointers in COMMON blocks (which is forbidden in F08). Since it's
apparently legal in F03, I'm still accepting it with -std=f2003 and
add that flag to a test case where this 'feature' is used. In another
one, I'm adding the error message that one gets with -std=f2008.

As my last submission, this fixes fallout from
https://groups.google.com/forum/?fromgroups#!topic/comp.lang.fortran/AIHRQ2kJv3c.
As the last one, it is a very simple fix for an accepts-invalid
problem (which is not a regression), so I hope this one will also
still be suitable for trunk (if not, I hope the release managers, in
CC, will stop me).

It does regtest cleanly on x86_64-linux-gnu. Ok for trunk?

Cheers,
Janus


2018-02-13  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/84313
    * symbol.c (check_conflict): Reject procedure pointers in common blocks.


2018-02-13  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/84313
    * gfortran.dg/proc_ptr_common_1.f90: Fix invalid test case,
    add necessary compiler options.
    * gfortran.dg/proc_ptr_common_2.f90: Add missing error message.

[-- Attachment #2: pr84313.diff --]
[-- Type: text/plain, Size: 1873 bytes --]

Index: gcc/fortran/symbol.c
===================================================================
--- gcc/fortran/symbol.c	(revision 257589)
+++ gcc/fortran/symbol.c	(working copy)
@@ -809,7 +809,9 @@ check_conflict (symbol_attribute *attr, const char
 	    conf2 (threadprivate);
 	}
 
-      if (!attr->proc_pointer)
+      /* Procedure pointers in COMMON blocks are allowed in F03,
+       * but forbidden per F08:C5100.  */
+      if (!attr->proc_pointer || (gfc_option.allow_std & GFC_STD_F2008))
 	conf2 (in_common);
 
       conf2 (omp_declare_target_link);
Index: gcc/testsuite/gfortran.dg/proc_ptr_common_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/proc_ptr_common_1.f90	(revision 257589)
+++ gcc/testsuite/gfortran.dg/proc_ptr_common_1.f90	(working copy)
@@ -1,16 +1,18 @@
 ! { dg-do run }
-
+! { dg-options "-std=f2003 -fall-intrinsics" }
+!
 ! PR fortran/36592
 !
 ! Procedure Pointers inside COMMON blocks.
+! (Allowed in F03, but forbidden in F08.)
 !
 ! Contributed by Janus Weil <janus@gcc.gnu.org>.
 
 subroutine one()
   implicit none
-  common /com/ p1,p2,a,b
   procedure(real), pointer :: p1,p2
   integer :: a,b
+  common /com/ p1,p2,a,b
   if (a/=5 .or. b/=-9 .or. p1(0.0)/=1.0 .or. p2(0.0)/=0.0) call abort()
 end subroutine one
 
Index: gcc/testsuite/gfortran.dg/proc_ptr_common_2.f90
===================================================================
--- gcc/testsuite/gfortran.dg/proc_ptr_common_2.f90	(revision 257589)
+++ gcc/testsuite/gfortran.dg/proc_ptr_common_2.f90	(working copy)
@@ -12,7 +12,7 @@ abstract interface
 end interface
 
 procedure(foo), pointer, bind(C) :: proc
-common /com/ proc,r
+common /com/ proc,r  ! { dg-error "PROCEDURE attribute conflicts with COMMON attribute" }
 
 common s
 call s()  ! { dg-error "PROCEDURE attribute conflicts with COMMON attribute" }

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-02-14 15:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-13 18:24 [Patch, Fortran, F08] PR 84313: reject procedure pointers in COMMON blocks Janus Weil
2018-02-13 19:14 ` Steve Kargl
2018-02-13 19:55   ` Richard Biener
2018-02-13 21:16     ` Janus Weil
2018-02-14 11:30 ` Jakub Jelinek
2018-02-14 11:48   ` Jakub Jelinek
2018-02-14 12:09     ` Janus Weil
2018-02-14 15:57       ` Janus Weil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).