-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The Fortran standards require (F'2023 C745) that a derived type with the SEQUENCE attribute have at least one component. No Fortran compiler actually enforces this constraint. Accept this usage with a warning. Pull request: llvm#66252
@llvm/pr-subscribers-flang-semantics ChangesThe Fortran standards require (F'2023 C745) that a derived type with the SEQUENCE attribute have at least one component. No Fortran compiler actually enforces this constraint. Accept this usage with a warning. -- Full diff: https://github.com//pull/66252.diff3 Files Affected:
diff --git a/flang/docs/Extensions.md b/flang/docs/Extensions.md index 49e78a10fa6bcdb..4d0b2c7319818a7 100644 --- a/flang/docs/Extensions.md +++ b/flang/docs/Extensions.md @@ -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 diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp index 865c198424696a9..f56f7a71f367be6 100644 --- a/flang/lib/Semantics/resolve-names.cpp +++ b/flang/lib/Semantics/resolve-names.cpp @@ -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, diff --git a/flang/test/Semantics/resolve31.f90 b/flang/test/Semantics/resolve31.f90 index 0c604c0ee9734b9..6bf8e877a515668 100644 --- a/flang/test/Semantics/resolve31.f90 +++ b/flang/test/Semantics/resolve31.f90 @@ -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 |
vdonaldson
approved these changes
Sep 13, 2023
ZijunZhaoCCK
pushed a commit
to ZijunZhaoCCK/llvm-project
that referenced
this pull request
Sep 19, 2023
The Fortran standards require (F'2023 C745) that a derived type with the SEQUENCE attribute have at least one component. No Fortran compiler actually enforces this constraint. Accept this usage with a warning.
zahiraam
pushed a commit
to tahonermann/llvm-project
that referenced
this pull request
Oct 24, 2023
The Fortran standards require (F'2023 C745) that a derived type with the SEQUENCE attribute have at least one component. No Fortran compiler actually enforces this constraint. Accept this usage with a warning.
zahiraam
pushed a commit
to tahonermann/llvm-project
that referenced
this pull request
Oct 24, 2023
The Fortran standards require (F'2023 C745) that a derived type with the SEQUENCE attribute have at least one component. No Fortran compiler actually enforces this constraint. Accept this usage with a warning.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Fortran standards require (F'2023 C745) that a derived type with the SEQUENCE attribute have at least one component. No Fortran compiler actually enforces this constraint. Accept this usage with a warning.