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

[Flang] Incorrect diagnose of DATA statement to initialize implicitly typed and subscripted components

Open DanielCChen opened this issue 2 years ago • 4 comments

Consider the following code:

  PROGRAM Data2
  IMPLICIT TYPE(DT)(V)
    TYPE :: DT
      INTEGER :: Id
      PROCEDURE(), NOPASS, POINTER :: ProcPtr
    END TYPE
  DIMENSION V1(3)
  DATA V1(1)%ProcPtr /NULL()/
  DATA V1(1)%Id /4/
  end

Flang currently issues error messages for both DATA statement.

error: Semantic errors in t.f
./t.f:8:14: error: Internal: no symbol found for 'procptr'
    DATA V1(1)%ProcPtr /NULL()/
               ^^^^^^^
./t.f:9:14: error: Internal: no symbol found for 'id'
    DATA V1(1)%Id /4/
               ^^

This seems incorrect.

  • If I change V1 to be explicitly typed, it compiles successfully, or
  • if I change V1 to be scalar, it compiles successfully.

DanielCChen avatar Feb 16 '24 23:02 DanielCChen

@llvm/issue-subscribers-flang-frontend

Author: Daniel Chen (DanielCChen)

Consider the following code: ``` PROGRAM Data2 IMPLICIT TYPE(DT)(V) TYPE :: DT INTEGER :: Id PROCEDURE(), NOPASS, POINTER :: ProcPtr END TYPE DIMENSION V1(3) DATA V1(1)%ProcPtr /NULL()/ DATA V1(1)%Id /4/ end ```

Flang currently issues error messages for both DATA statement.

error: Semantic errors in t.f
./t.f:8:14: error: Internal: no symbol found for 'procptr'
    DATA V1(1)%ProcPtr /NULL()/
               ^^^^^^^
./t.f:9:14: error: Internal: no symbol found for 'id'
    DATA V1(1)%Id /4/
               ^^

This seems incorrect.

  • If I change V1 to be explicitly typed, it compiles successfully, or
  • if I change V1 to be scalar, it compiles successfully.

llvmbot avatar Feb 16 '24 23:02 llvmbot

@llvm/issue-subscribers-bug

Author: Daniel Chen (DanielCChen)

Consider the following code: ``` PROGRAM Data2 IMPLICIT TYPE(DT)(V) TYPE :: DT INTEGER :: Id PROCEDURE(), NOPASS, POINTER :: ProcPtr END TYPE DIMENSION V1(3) DATA V1(1)%ProcPtr /NULL()/ DATA V1(1)%Id /4/ end ```

Flang currently issues error messages for both DATA statement.

error: Semantic errors in t.f
./t.f:8:14: error: Internal: no symbol found for 'procptr'
    DATA V1(1)%ProcPtr /NULL()/
               ^^^^^^^
./t.f:9:14: error: Internal: no symbol found for 'id'
    DATA V1(1)%Id /4/
               ^^

This seems incorrect.

  • If I change V1 to be explicitly typed, it compiles successfully, or
  • if I change V1 to be scalar, it compiles successfully.

llvmbot avatar Feb 16 '24 23:02 llvmbot

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

klausler avatar Feb 23 '24 20:02 klausler

I have verified PR #82825 fixed the reproducer and the original test case. Thanks for the quick fix! @klausler

DanielCChen avatar Feb 27 '24 16:02 DanielCChen