Skip to content

[Flang] Confusing error message on BOZ constant to complex type assignment. #124201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DanielCChen opened this issue Jan 23, 2025 · 1 comment · Fixed by #124331
Closed

[Flang] Confusing error message on BOZ constant to complex type assignment. #124201

DanielCChen opened this issue Jan 23, 2025 · 1 comment · Fixed by #124331
Assignees

Comments

@DanielCChen
Copy link
Contributor

Consider the following code:

complex(4) :: z4
z4= (z'00000000', z'80000000')
end

Flang currently issues an error as

error: Semantic errors in t.f
./t.f:2:5: error: operands must be INTEGER, UNSIGNED, REAL, or BOZ
  z4= (z'00000000', z'80000000')
      ^^^^^^^^^^^^^^^^^^^^^^^^^^

This is confusing as the operands is indeed BOZ.
Also, Flang has the extension to allow BOZ literal to real or integer. This seems a reasonable case that should be allowed.

@llvmbot
Copy link
Member

llvmbot commented Jan 23, 2025

@llvm/issue-subscribers-flang-frontend

Author: Daniel Chen (DanielCChen)

Consider the following code:
complex(4) :: z4
z4= (z'00000000', z'80000000')
end

Flang currently issues an error as

error: Semantic errors in t.f
./t.f:2:5: error: operands must be INTEGER, UNSIGNED, REAL, or BOZ
  z4= (z'00000000', z'80000000')
      ^^^^^^^^^^^^^^^^^^^^^^^^^^

This is confusing as the operands is indeed BOZ.
Also, Flang has the extension to allow BOZ literal to real or integer. This seems a reasonable case that should be allowed.

@klausler klausler self-assigned this Jan 24, 2025
klausler added a commit to klausler/llvm-project that referenced this issue Jan 24, 2025
A complex literal constant can have one BOZ component, since the
type and value of the literal can be determined by converting the
BOZ value to the type of the other component.  But a complex literal
constant with two BOZ components doesn't have a well-defined type.
The error message was confusing in the case; emit a better one.

Fixes llvm#124201.
github-actions bot pushed a commit to arm/arm-toolchain that referenced this issue Jan 27, 2025
…4331)

A complex literal constant can have one BOZ component, since the type
and value of the literal can be determined by converting the BOZ value
to the type of the other component. But a complex literal constant with
two BOZ components doesn't have a well-defined type. The error message
was confusing in the case; emit a better one.

Fixes llvm/llvm-project#124201.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants