Skip to content

[Flang] Incorrect diagnostic on intrinsic ASSOCIATED when the TARGET argument is unlimited polymorphic #125774

@DanielCChen

Description

@DanielCChen

Consider the following code

    type :: bType
        integer*4 :: i1
    end type

    type base
        type (bType), pointer :: b1
    end type

    class (*), allocatable, target :: x

    type (base) :: b1

    if (.not. associated (b1%b1, x)) error stop(2_4)
end

Flang currently issues an error as:

./t.f:13:15: error: Arguments of ASSOCIATED() must be a pointer and an optional valid target
      if (.not. associated (b1%b1, x)) error stop(2_4)
                ^^^^^^^^^^^^^^^^^^^^^

The code seems valid as the standard requires the type of TARGET to be compatible with POINTER argument.
Unlimited polymorphic entity is type compatible with all entities.

All ifort, gfortran and XLF compile the code successfully.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions