Issue 126806
Summary [Flang] Incorrect diagnostic on deallocating unlimited polymorphic pointer component
Labels flang:frontend
Assignees
Reporter DanielCChen
    Consider the following code:
```
module m
    type base
        class (*), pointer :: data ="" null()         !! Error
        !real, pointer :: data ="" null() !! Pass

        contains
        final :: finalizeBase
 end type

    contains

    elemental subroutine finalizeBase (b)
 type (base), intent(inout) :: b

      if (associated(b%data)) deallocate (b%data)
    end subroutine
end module
```

Flang is currently issue an error as
```
error: Semantic errors in t3.f
./t3.f:15:45: error: Object in DEALLOCATE statement is not deallocatable
        if (associated(b%data)) deallocate (b%data)
 ^^^^
./t3.f:15:45: because: 'data' is polymorphic in a pure subprogram
 if (associated(b%data)) deallocate (b%data)
 ^^^^
./t3.f:3:31: Declaration of 'data'
          class (*), pointer :: data ="" null()
 ^^^^
```

The compilation is successful if the pointer component is intrinsic type.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to