Issue 234273
Summary [flang] Misleading diagnostics for enumeration types in CLASS and in pointer assignment from CLASS(*)
Labels flang
Assignees kwyatt-ext
Reporter kwyatt-ext
    Enumeration types (F2023 7.6.2) are non-extensible, but were implemented as a custom derived type internal to Flang.  Two existing messages read wrong when the type involved is an enumeration type.

**1. Pointer assignment from an unlimited polymorphic target** (`flang/lib/Semantics/pointer-assignment.cpp`)

```fortran
enumeration type :: color
  enumerator :: red, green
end enumeration type
class(*), pointer :: q
type(color), pointer :: p
p => q
```
```
error: Pointer type must be unlimited polymorphic or non-extensible derived type when target is unlimited polymorphic
```

`color` is non-extensible, so the message seems to permit this. F2023 C1017 requires the pointer to be "unlimited polymorphic, or of a type with the BIND attribute or the SEQUENCE attribute". The message should use that wording.

**2. CLASS of an enumeration type** (`flang/lib/Semantics/resolve-names.cpp`)

```fortran
class(color), allocatable :: x
```
```
error: Non-extensible derived type 'color' may not be used with CLASS keyword
```

An enumeration type is not a derived type. The message should either say "enumeration type" in this case or drop "derived".

Both checks already reject the code correctly; only the wording is wrong. Expected test fallout: `flang/test/Semantics/enumeration-type-extensible.f90`, plus any existing tests that match these message strings.

Raised in review of #231641.

(Assisted-by: AI)

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to