mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-18 19:16:43 +00:00
[flang] Improve error message output (#102324)
When a local character variable with non-constant length has an initializer, it's an error in a couple of ways (SAVE variable with unknown size, static initializer that isn't constant due to conversion to an unknown length). The error that f18 reports is the latter, but the message contains a formatted representation of the initialization expression that exposes a non-Fortran %SET_LENGTH() operation. Print the original expression in the message instead.
This commit is contained in:
parent
b949a6f5e3
commit
7ea78643fe
@ -493,7 +493,7 @@ std::optional<Expr<SomeType>> NonPointerInitializationExpr(const Symbol &symbol,
|
||||
} else {
|
||||
context.messages().Say(
|
||||
"Initialization expression for '%s' (%s) cannot be computed as a constant value"_err_en_US,
|
||||
symbol.name(), folded.AsFortran());
|
||||
symbol.name(), x.AsFortran());
|
||||
}
|
||||
} else if (xType) {
|
||||
context.messages().Say(
|
||||
|
@ -14,7 +14,7 @@ module module1
|
||||
integer(kind=ik) :: ix = int(0,kind=ik)
|
||||
real(kind=rk) :: rx = real(0.,kind=rk)
|
||||
complex(kind=zk) :: zx = cmplx(0.,0.,kind=zk)
|
||||
!ERROR: Initialization expression for 'cx' (%SET_LENGTH(" ",len)) cannot be computed as a constant value
|
||||
!ERROR: Initialization expression for 'cx' (" ") cannot be computed as a constant value
|
||||
character(kind=ck,len=len) :: cx = ' '
|
||||
logical(kind=lk) :: lx = .false.
|
||||
real(kind=rk), pointer :: rp => NULL()
|
||||
|
Loading…
x
Reference in New Issue
Block a user