------- Comment #1 from burnus at gcc dot gnu dot org 2007-12-15 10:08 ------- Created an attachment (id=14765) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14765&action=view) Draft patch, does not work yet, looks clumsy
Attachment: Very rough draft patch, which does not work, but tries to fix this PR and PR 34471. The problem is either when to do the symbol checking or to do multiple symbol checking (which currently fails with ambiguous symbols (type) or with not re-evaluating (kind)). The following program is also valid: type(t) function func() type t integer :: i = 0 end type t end function func Test also the same with the combination of host-/use-associated/function-defined types to make sure the right one is picked. See: "5.1.1.1 TYPE [...] Where a data entity is declared explicitly using the TYPE type specifier, the specified derived type shall have been defined previously in the scoping unit or be accessible there by use or host association. If the data entity is a function result, the derived type may be specified in the FUNCTION statement provided the derived type is defined within the body of the function or is accessible there by use or host association. If the derived type is specified in the FUNCTION statement and is defined within the body of the function, it is as if the function result variable was declared with that derived type immediately following the derived-type-def of the specified derived type." This contrasts with kind/length parameters, which may not be defined in the function itself: "5.1.2.10 PARAMETER attribute [...] A named constant shall not be referenced unless it has been defined previously in the same statement, defined in a prior statement, or made accessible by use or host association." -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34431