From: Janus Weil Date: Tue, 13 Feb 2018 21:00:37 +0000 (+0100) Subject: re PR fortran/84313 ([F08] reject procedure pointers in COMMON blocks) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4155fafc7f43234fc0c819a6f9c6ebaffc59e8cc;p=gcc.git re PR fortran/84313 ([F08] reject procedure pointers in COMMON blocks) 2018-02-13 Janus Weil PR fortran/84313 * symbol.c (check_conflict): Reject procedure pointers in common blocks. 2018-02-13 Janus Weil 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. From-SVN: r257636 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c3db796b7e8..01e2a906443 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2018-02-13 Janus Weil + + PR fortran/84313 + * symbol.c (check_conflict): Reject procedure pointers in common blocks. + 2018-02-13 Alastair McKinstry Janne Blomqvist diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index 344c644bac9..ce6b1e93644 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -809,7 +809,9 @@ check_conflict (symbol_attribute *attr, const char *name, locus *where) 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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 19c0832f2cd..e0edbe57b56 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-02-13 Janus Weil + + 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. + 2018-02-13 Jakub Jelinek PR c/82210 diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_common_1.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_common_1.f90 index df2ef0b79cc..c6a4e6a3673 100644 --- a/gcc/testsuite/gfortran.dg/proc_ptr_common_1.f90 +++ b/gcc/testsuite/gfortran.dg/proc_ptr_common_1.f90 @@ -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 . 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 diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_common_2.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_common_2.f90 index f401c3a15c3..f49c0a3f86a 100644 --- a/gcc/testsuite/gfortran.dg/proc_ptr_common_2.f90 +++ b/gcc/testsuite/gfortran.dg/proc_ptr_common_2.f90 @@ -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" }