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  <ja...@gcc.gnu.org>

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


2018-02-13  Janus Weil  <ja...@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.
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 <ja...@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" }

Reply via email to