llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.41k stars 12.15k forks source link

[Flang] Failed to compile CHARACTER type declaration statement for array #117372

Closed DanielCChen closed 14 hours ago

DanielCChen commented 1 week ago

Flang failed to compile the following code

character      cv3*(3)(3)
end

>flang-new -ffree-form ch1.f
error: Could not parse ch1.f
./ch1.f:1:18: error: expected end of statement
  character  cc*(3)(3)
                   ^
./ch1.f:1:1: in the context: specification construct
  character  cc*(3)(3)
  ^
./ch1.f:1:1: in the context: declaration construct
  character  cc*(3)(3)
  ^
./ch1.f:1:1: in the context: specification part
  character  cc*(3)(3)
  ^
./ch1.f:1:1: in the context: main program
  character  cc*(3)(3)
  ^

gfortran issues an error also. XLF and ifort both compile it successfully. The code seems standard conforming to me.

llvmbot commented 1 week ago

@llvm/issue-subscribers-bug

Author: Daniel Chen (DanielCChen)

Flang failed to compile the following code ``` character cv3*(3)(3) end >flang-new -ffree-form ch1.f error: Could not parse ch1.f ./ch1.f:1:18: error: expected end of statement character cc*(3)(3) ^ ./ch1.f:1:1: in the context: specification construct character cc*(3)(3) ^ ./ch1.f:1:1: in the context: declaration construct character cc*(3)(3) ^ ./ch1.f:1:1: in the context: specification part character cc*(3)(3) ^ ./ch1.f:1:1: in the context: main program character cc*(3)(3) ^ ``` gfortran issues an error also. XLF and ifort both compile it successfully. The code seems standard conforming to me.
llvmbot commented 1 week ago

@llvm/issue-subscribers-flang-frontend

Author: Daniel Chen (DanielCChen)

Flang failed to compile the following code ``` character cv3*(3)(3) end >flang-new -ffree-form ch1.f error: Could not parse ch1.f ./ch1.f:1:18: error: expected end of statement character cc*(3)(3) ^ ./ch1.f:1:1: in the context: specification construct character cc*(3)(3) ^ ./ch1.f:1:1: in the context: declaration construct character cc*(3)(3) ^ ./ch1.f:1:1: in the context: specification part character cc*(3)(3) ^ ./ch1.f:1:1: in the context: main program character cc*(3)(3) ^ ``` gfortran issues an error also. XLF and ifort both compile it successfully. The code seems standard conforming to me.
klausler commented 1 week ago

Yes, that's conforming usage. EDIT: no, it's not, see below.

klausler commented 1 week ago

Correction: it's not conforming in the context of an entity-decl; see F'2023 R803. But it seems like an extension worth supporting for portability reasons.

DanielCChen commented 1 week ago

Correction: it's not conforming in the context of an entity-decl; see F'2023 R803. But it seems like an extension worth supporting for portability reasons.

Yeah. You are right. The array-spec should following the object name. Thanks for adding the extension.