Skip to content

Commit a1dced9

Browse files
klauslerjustinfargnoli
authored andcommitted
[flang] Add portability warning for F'2008 feature (llvm#77526)
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.
1 parent 6606a71 commit a1dced9

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

flang/docs/Extensions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,9 @@ end
465465
* A `SEQUENCE` derived type is required (F'2023 C745) to have
466466
at least one component. No compiler enforces this constraint;
467467
this compiler emits a warning.
468+
* Many compilers disallow a `VALUE` assumed-length character dummy
469+
argument, which has been standard since F'2008.
470+
We accept this usage with an optional portability warning.
468471

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

flang/lib/Semantics/check-declarations.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,12 @@ void CheckHelper::CheckValue(
570570
messages_.Say(
571571
"VALUE attribute may not apply to an assumed-rank array"_err_en_US);
572572
}
573+
if (context_.ShouldWarn(common::UsageWarning::Portability) &&
574+
IsAssumedLengthCharacter(symbol)) {
575+
// F'2008 feature not widely implemented
576+
messages_.Say(
577+
"VALUE attribute on assumed-length CHARACTER may not be portable"_port_en_US);
578+
}
573579
}
574580

575581
void CheckHelper::CheckAssumedTypeEntity( // C709

flang/test/Semantics/call14.f90

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
! RUN: %python %S/test_errors.py %s %flang_fc1
1+
! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
22
! Test 8.5.18 constraints on the VALUE attribute
33

44
module m
@@ -7,7 +7,7 @@ module m
77
end type
88
contains
99
!ERROR: VALUE attribute may apply only to a dummy data object
10-
subroutine C863(notData,assumedSize,coarray,coarrayComponent,assumedRank)
10+
subroutine C863(notData,assumedSize,coarray,coarrayComponent,assumedRank,assumedLen)
1111
external :: notData
1212
!ERROR: VALUE attribute may apply only to a dummy argument
1313
real, value :: notADummy
@@ -20,6 +20,8 @@ subroutine C863(notData,assumedSize,coarray,coarrayComponent,assumedRank)
2020
type(hasCoarray), value :: coarrayComponent
2121
!ERROR: VALUE attribute may not apply to an assumed-rank array
2222
real, value :: assumedRank(..)
23+
!PORTABILITY: VALUE attribute on assumed-length CHARACTER may not be portable
24+
character(*), value :: assumedLen
2325
end subroutine
2426
subroutine C864(allocatable, inout, out, pointer, volatile)
2527
!ERROR: VALUE attribute may not apply to an ALLOCATABLE

0 commit comments

Comments
 (0)