Procedure pointers in COMMON are currently rejected (gfc_error), but they are
valid and should thus be supported.

"5.5.2 COMMON statement"
"R558 common-block-object is variable-name [ ( explicit-shape-spec-list ) ]
                          or proc-pointer-name"

Test program (hopefully correct):

subroutine one()
 implicit none
 integer :: a,b
 procedure(real), pointer :: p
 common /com/ a,b
 if(a /= 5 .or. b /= -9) call abort()
 if(p(0.0)/= 1.0) call abort
end subroutine one

program main
 implicit none
 integer  x
 integer  y
 intrinsic cos
 external func1
 pointer  func1
 procedure(real), pointer :: func2
 common /com/ x,func1,y,func2
 x = 5
 y = -9
 func1 => cos
 func2 => cos
 call one()
end program main


First patch:

--- symbol.c    (revision 136801)
+++ symbol.c    (working copy)
@@ -1114,7 +1131,7 @@ gfc_add_in_common (symbol_attribute *att
  if (check_conflict (attr, name, where) == FAILURE)
    return FAILURE;

-  if (attr->flavor == FL_VARIABLE)
+  if (attr->flavor == FL_VARIABLE || attr->proc_pointer)
    return SUCCESS;

  return gfc_add_flavor (attr, FL_VARIABLE, name, where);


Actually, there is probably the following missing as well:
" || (attr->pointer && attr->external && attr->if_source != IFSRC_IFBODY)"

But this is not enough and produces tons of ICEs.


-- 
           Summary: F2003: Procedure pointer in COMMON
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org
 BugsThisDependsOn: 32580


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36592

Reply via email to