llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[Flang] Incorrect diagnose on SELECT TYPE selector

Open DanielCChen opened this issue 2 years ago • 4 comments

Consider the following code:

module m
type base
integer i
end type
end module

subroutine sub(arg)
use m
class(base) :: arg(*)
select type (arg)
  type is (Base)
     print *, "typeis"
  class default
     print *, "classdefault"
  end select
end

Flang currently issues an error as:

error: Semantic errors in t.f
./t.f:10:14: error: Whole assumed-size array 'arg' may not appear here without subscripts
  select type (arg)
               ^^^
./t.f:9:16: Declaration of 'arg'
  class(base) :: arg(*)
                 ^^^

It doesn't seem correct to me. The SELECT TYPE inquires the dynamic type of the selctor. It shouldn't matter if it is a assumed-size whole array or not.

DanielCChen avatar Feb 15 '24 19:02 DanielCChen

@llvm/issue-subscribers-flang-frontend

Author: Daniel Chen (DanielCChen)

Consider the following code: ``` module m type base integer i end type end module

subroutine sub(arg) use m class(base) :: arg(*) select type (arg) type is (Base) print *, "typeis" class default print *, "classdefault" end select end


Flang currently issues an error as:

error: Semantic errors in t.f ./t.f:10:14: error: Whole assumed-size array 'arg' may not appear here without subscripts select type (arg) ^^^ ./t.f:9:16: Declaration of 'arg' class(base) :: arg(*) ^^^


It doesn't seem correct to me. The SELECT TYPE inquires the dynamic type of the `selctor`. It shouldn't matter if it is a assumed-size whole array or not.
</details>

llvmbot avatar Feb 15 '24 19:02 llvmbot

@llvm/issue-subscribers-bug

Author: Daniel Chen (DanielCChen)

Consider the following code: ``` module m type base integer i end type end module

subroutine sub(arg) use m class(base) :: arg(*) select type (arg) type is (Base) print *, "typeis" class default print *, "classdefault" end select end


Flang currently issues an error as:

error: Semantic errors in t.f ./t.f:10:14: error: Whole assumed-size array 'arg' may not appear here without subscripts select type (arg) ^^^ ./t.f:9:16: Declaration of 'arg' class(base) :: arg(*) ^^^


It doesn't seem correct to me. The SELECT TYPE inquires the dynamic type of the `selctor`. It shouldn't matter if it is a assumed-size whole array or not.
</details>

llvmbot avatar Feb 15 '24 20:02 llvmbot

https://github.com/llvm/llvm-project/pull/82806

klausler avatar Feb 23 '24 18:02 klausler

I have verified PR #82806 has fixed the reproducer and the origin test case. Thanks for the quick fix! @klausler

DanielCChen avatar Feb 27 '24 15:02 DanielCChen