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



             Bug #: 54958

           Summary: Wrongly rejects ac-implied-DO variables which also

                    occur with INTENT(IN)

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Keywords: rejects-valid

          Severity: normal

          Priority: P3

         Component: fortran

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: bur...@gcc.gnu.org





gfortran rejects all four uses of "i" in the following program with



  Error: Dummy argument 'i' with INTENT(IN) in variable definition context

         (iterator variable) at (1)



However, it should only reject the use as variable in io-implied-do and in the

do-stmt and not the (ac-,data-)implied-do variable. Cf. IR 000076 at

ftp://ftp.nag.co.uk/sc22wg5/n1351-n1400/N1393.txt



g95, pathf95 and NAG properly handle this case, gfortran 4.1 to 4.8 doesn't.





subroutine test(i)

  integer, intent(in) :: i

  integer :: A(5)

  ! Valid: data-implied-do  [WRONGLY rejected by gfortran]

  DATA (A(i), i=1,5)/5*42/



  ! Valid: ac-implied-do  [WRONGLY rejected by gfortran]

  print *, [(i, i=1,5 )]



  ! Invalid: io-implied-do  [OK: rejected by gfortran]

  print *, (i, i=1,5 )



  ! Invalid: do-variable in a do-stmt  [OK: rejected by gfortran]

  do i = 1, 5

  end do

end









>From the standard (F2008):



"C539 (R523) A nonpointer object with the INTENT (IN) attribute shall not

appear in a variable definition context (16.6.7)."



and in "16.6.7 Variable definition context":



"(4) a do-variable in a do-stmt or io-implied-do;"





The reason that a data-implied-do and ac-implied-do is allowed is given at

"16.4 Statement and construct entities":



"The name of a data-i-do-variable in a DATA statement or an ac-do-variable in

an array constructor has a scope of its data-implied-do or ac-implied-do. [...]

The appearance of a name as a data-i-do-variable of an implied DO in a DATA

statement or an ac-do-variable in an array constructor is not an implicit

declaration of a variable whose scope is the scoping unit that contains the

statement."

Reply via email to