The following code is invalid, but accepted by gfortran:

interface
  real function bar()
  end function bar
end interface
dimension :: bar(4)

It is invalid, since section 12.3.2.1 of the Fortran 2003 standard states:

"An interface body specifies all of the characteristics of the explicit
specific interface or abstract interface. The specification part of
an interface body may specify attributes or define values for data
entities that do not determine characteristics of the procedure. Such
specifications have no effect."

This means that there may be no additional attributes specified outside of the
interface body.

g95 correctly gives the following error message for this test case:

dimension :: bar(4)
             1
Error: Attribute declaration of 'bar' at (1) is outside of the INTERFACE body

The test case also has to be rejected when the order of the statements is
exchanged:

dimension :: bar(4)
interface
  real function bar()
  end function bar
end interface

This is probably even harder to detect. g95's error message for this case is:

dimension :: bar(4)
             1
Error: Symbol 'bar' at (1) conflicts with the same name in an encompassing
program unit

I think it would be desirable for gfortran to print out the same message for
both cases.


-- 
           Summary: attribute declaration outside of INTERFACE body
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: janus at gcc dot gnu dot org


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

Reply via email to