Using VOLATILE, TARGET etc. for function names is valid, but only if there is
no extra RESULT variable.

I thought the following would fix it, but it does not seem to work:


  if (attr->function && !attr->result)
    {
      a1 = function;
      conf2 (allocatable);
      conf2 (asynchronous);
      conf2 (dimension);
      conf2 (pointer);
      conf2 (target);
      conf2 (volatile_);
    }


Test case:

integer function func()
  asynchronous :: func
  integer, asynchronous:: b
  allocatable :: c
  volatile :: func
  type t
    sequence
    integer :: i = 5
  end type t
end function func

function func2() result(res)
  volatile res
  volatile func2     ! { dg-error "FUNCTION attribute conflicts with VOLATILE"
}
  asynchronous res
  asynchronous func2 ! { dg-error "FUNCTION attribute conflicts with
ASYNCHRONOUS" }
  allocatable func2  ! { dg-error "FUNCTION attribute conflicts with
ALLOCATABLE" }
  target func2       ! { dg-error "FUNCTION attribute conflicts with TARGET" }
  dimension func2(2) ! { dg-error "FUNCTION attribute conflicts with DIMENSION"
}
end function func2


-- 
           Summary: Functions with result: Wrongly accepts attributes to
                    function name
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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

Reply via email to