Skip to content

[flang] Allow empty SEQUENCE types #66252

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

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions flang/docs/Extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,9 @@ end
* Since Fortran 90, INCLUDE lines have been allowed to have
a numeric kind parameter prefix on the file name. No other
Fortran compiler supports them that I can find.
* A `SEQUENCE` derived type is required (F'2023 C745) to have
at least one component. No compiler enforces this constraint;
this compiler emits a warning.

## Behavior in cases where the standard is ambiguous or indefinite

Expand Down
5 changes: 3 additions & 2 deletions flang/lib/Semantics/resolve-names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5225,9 +5225,10 @@ bool DeclarationVisitor::Pre(const parser::DerivedTypeDef &x) {
Walk(componentDefs);
if (derivedTypeInfo_.sequence) {
details.set_sequence(true);
if (componentDefs.empty()) { // C740
if (componentDefs.empty()) {
// F'2023 C745 - not enforced by any compiler
Say(stmt.source,
"A sequence type must have at least one component"_err_en_US);
"A sequence type should have at least one component"_warn_en_US);
}
if (!details.paramNames().empty()) { // C740
Say(stmt.source,
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Semantics/resolve31.f90
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module m4
!ERROR: A sequence type may not have a CONTAINS statement
contains
end type
!ERROR: A sequence type must have at least one component
!WARNING: A sequence type should have at least one component
type :: emptyType
sequence
end type emptyType
Expand Down