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

             Bug #: 53699
           Summary: Missing "restrict" qualifier for OPTIONAL dummy
                    arguments
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: bur...@gcc.gnu.org


When looking at the dump of the following program, I realized that "arg1"
doesn't have a "restrict" attribute. Given that it is just OPTIONAL but has no
pointer or target attribute, there is no reason why "arg2" is "restrict" but
"arg1" is not:


sub1 (struct array1_integer(kind=4) * arg1, struct array1_integer(kind=4) &
restrict arg2)

! ------------------

Program main
  implicit none
  integer :: arr(2)

  call sub1(arg2=arr)
contains
   subroutine sub1(arg1,arg2)
      integer, optional :: arg1(:)
      integer :: arg2(:)
      print *,fun1(arg1,arg2)
   end subroutine

   elemental function fun1(arg1,arg2)
      integer,intent(in), optional :: arg1
      integer,intent(in)          :: arg2
      integer                     :: fun1
      fun1 = arg2
   end function
end program

Reply via email to