-
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] Add portability warning for F'2008 feature #77526
Conversation
Using the VALUE attribute for assumed-length CHARACTER dummy arguments became standard in F'2008 but still lacks widespread implementation; emit a portability warning when they are enabled. Resolves llvm-test-suite/Fortran/gfortran/regression/value_5.f90.
@llvm/pr-subscribers-flang-semantics Author: Peter Klausler (klausler) ChangesUsing the VALUE attribute for assumed-length CHARACTER dummy arguments became standard in F'2008 but still lacks widespread implementation; emit a portability warning when they are enabled. Resolves llvm-test-suite/Fortran/gfortran/regression/value_5.f90. Full diff: https://github.com/llvm/llvm-project/pull/77526.diff 3 Files Affected:
diff --git a/flang/docs/Extensions.md b/flang/docs/Extensions.md
index 16eb67f2e27c81..c1b64c088fa228 100644
--- a/flang/docs/Extensions.md
+++ b/flang/docs/Extensions.md
@@ -451,6 +451,9 @@ end
* 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.
+* Many compilers disallow a `VALUE` assumed-length character dummy
+ argument, which has been standard since F'2008.
+ We accept this usage with an optional portability warning.
## Behavior in cases where the standard is ambiguous or indefinite
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index 777e6a9f23fbf8..14dd60fc37d2f1 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -572,6 +572,12 @@ void CheckHelper::CheckValue(
messages_.Say(
"VALUE attribute may not apply to an assumed-rank array"_err_en_US);
}
+ if (context_.ShouldWarn(common::UsageWarning::Portability) &&
+ IsAssumedLengthCharacter(symbol)) {
+ // F'2008 feature not widely implemented
+ messages_.Say(
+ "VALUE attribute on assumed-length CHARACTER may not be portable"_port_en_US);
+ }
}
void CheckHelper::CheckAssumedTypeEntity( // C709
diff --git a/flang/test/Semantics/call14.f90 b/flang/test/Semantics/call14.f90
index da273050b6f3a9..042243b5605938 100644
--- a/flang/test/Semantics/call14.f90
+++ b/flang/test/Semantics/call14.f90
@@ -1,4 +1,4 @@
-! RUN: %python %S/test_errors.py %s %flang_fc1
+! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
! Test 8.5.18 constraints on the VALUE attribute
module m
@@ -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,assumedRank)
+ subroutine C863(notData,assumedSize,coarray,coarrayComponent,assumedRank,assumedLen)
external :: notData
!ERROR: VALUE attribute may apply only to a dummy argument
real, value :: notADummy
@@ -20,6 +20,8 @@ subroutine C863(notData,assumedSize,coarray,coarrayComponent,assumedRank)
type(hasCoarray), value :: coarrayComponent
!ERROR: VALUE attribute may not apply to an assumed-rank array
real, value :: assumedRank(..)
+ !PORTABILITY: VALUE attribute on assumed-length CHARACTER may not be portable
+ character(*), value :: assumedLen
end subroutine
subroutine C864(allocatable, inout, out, pointer, volatile)
!ERROR: VALUE attribute may not apply to an ALLOCATABLE
|
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.
All builds and tests correctly and looks good.
Using the VALUE attribute for assumed-length CHARACTER dummy arguments became standard in F'2008 but still lacks widespread implementation; emit a portability warning when they are enabled. Resolves llvm-test-suite/Fortran/gfortran/regression/value_5.f90.
Using the VALUE attribute for assumed-length CHARACTER dummy arguments became standard in F'2008 but still lacks widespread implementation; emit a portability warning when they are enabled.
Resolves llvm-test-suite/Fortran/gfortran/regression/value_5.f90.