-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[flang] Enforce C839 #71239
Merged
Merged
[flang] Enforce C839 #71239
Conversation
This file contains 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
An assumed-rank array may not be a coarray and may not have the VALUE attribute.
llvmbot
added
flang
Flang issues not falling into any other category
flang:semantics
labels
Nov 3, 2023
@llvm/pr-subscribers-flang-semantics Author: Peter Klausler (klausler) ChangesAn assumed-rank array may not be a coarray and may not have the VALUE attribute. Full diff: https://github.com/llvm/llvm-project/pull/71239.diff 3 Files Affected:
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index 6d69eb187bda089..ce7df5ea7ea13bc 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -564,6 +564,10 @@ void CheckHelper::CheckValue(
"VALUE attribute may not apply to a type with a coarray ultimate component"_err_en_US);
}
}
+ if (evaluate::IsAssumedRank(symbol)) {
+ messages_.Say(
+ "VALUE attribute may not apply to an assumed-rank array"_err_en_US);
+ }
}
void CheckHelper::CheckAssumedTypeEntity( // C709
@@ -657,6 +661,10 @@ void CheckHelper::CheckObjectEntity(
"Coarray '%s' may not have type TEAM_TYPE, C_PTR, or C_FUNPTR"_err_en_US,
symbol.name());
}
+ if (evaluate::IsAssumedRank(symbol)) {
+ messages_.Say("Coarray '%s' may not be an assumed-rank array"_err_en_US,
+ symbol.name());
+ }
}
if (details.isDummy()) {
if (IsIntentOut(symbol)) {
diff --git a/flang/test/Semantics/call14.f90 b/flang/test/Semantics/call14.f90
index 477c22b02f2cdb2..da273050b6f3a94 100644
--- a/flang/test/Semantics/call14.f90
+++ b/flang/test/Semantics/call14.f90
@@ -7,7 +7,7 @@ module m
end type
contains
!ERROR: VALUE attribute may apply only to a dummy data object
- subroutine C863(notData,assumedSize,coarray,coarrayComponent)
+ subroutine C863(notData,assumedSize,coarray,coarrayComponent,assumedRank)
external :: notData
!ERROR: VALUE attribute may apply only to a dummy argument
real, value :: notADummy
@@ -18,6 +18,8 @@ subroutine C863(notData,assumedSize,coarray,coarrayComponent)
real, value :: coarray[*]
!ERROR: VALUE attribute may not apply to a type with a coarray ultimate component
type(hasCoarray), value :: coarrayComponent
+ !ERROR: VALUE attribute may not apply to an assumed-rank array
+ real, value :: assumedRank(..)
end subroutine
subroutine C864(allocatable, inout, out, pointer, volatile)
!ERROR: VALUE attribute may not apply to an ALLOCATABLE
diff --git a/flang/test/Semantics/misc-declarations.f90 b/flang/test/Semantics/misc-declarations.f90
index ca5f6f7ccd976ce..74b71c0847f59a1 100644
--- a/flang/test/Semantics/misc-declarations.f90
+++ b/flang/test/Semantics/misc-declarations.f90
@@ -38,4 +38,8 @@ subroutine C868(coarray,coarrayComponent)
volatile :: coarrayComponent
end block
end subroutine
+ subroutine C839(x)
+ !ERROR: Coarray 'x' may not be an assumed-rank array
+ real, intent(in) :: x(..)[*]
+ end
end module
|
psteinfeld
approved these changes
Nov 3, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
zahiraam
pushed a commit
to zahiraam/llvm-project
that referenced
this pull request
Nov 20, 2023
An assumed-rank array may not be a coarray and may not have the VALUE attribute.
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.
An assumed-rank array may not be a coarray and may not have the VALUE attribute.