This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: test for allocatable function (f95 extension)
Brooks, 1
Error: ALLOCATABLE attribute conflicts with FUNCTION attribute at (1)
This message emerges from symbol.c(check-conflict). This is a one-stop
check of the attr field of gfc_symbol.
Fortran 95 Draft standard, section 5.2.6: "Constraint: The array-name
[in an ALLOCATABLE statement] shall not be a ... function result."
I can't find where it directly gives the same constraint for
ALLOCATABLE as an attribute rather than in a statement of its own, but
the first paragraph of 5.2 says, regarding attribute specification
statements: "The combination of attributes that may be specified for a
particular entity is subject to the same restrictions as for type
declaration statements regardless of the method of specification,"
which I would infer is intended to mean that this constraint applies
to the case you illustrate as well.
This is, I believe, something added in one of the F95 TRs and in F2003.
Whether correctly or not, 'allocatable' is one of the attribute bits of
gfc_sym.attr, as is 'result' and 'function'. In one of the passes
through check-conflict, the constraint that the two bits should not be
set for the same symbol has tripped the error.
This is why the language is the way it is in the error message.
I have a mind to implement the extensions to attribute over the next few
months- they seem to me to be one of the most useful features from the
TRs/F2003 to import into gfortran.
Paul