Skip to content
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: 2 additions & 1 deletion flang/include/flang/Common/Fortran-features.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ ENUM_CLASS(LanguageFeature, BackslashEscapes, OldDebugLines,
NonBindCInteroperability, CudaManaged, CudaUnified,
PolymorphicActualAllocatableOrPointerToMonomorphicDummy, RelaxedPureDummy,
UndefinableAsynchronousOrVolatileActual, AutomaticInMainProgram, PrintCptr,
SavedLocalInSpecExpr, PrintNamelist, AssumedRankPassedToNonAssumedRank)
SavedLocalInSpecExpr, PrintNamelist, AssumedRankPassedToNonAssumedRank,
IgnoreIrrelevantAttributes)

// Portability and suspicious usage warnings
ENUM_CLASS(UsageWarning, Portability, PointerToUndefinable,
Expand Down
1 change: 1 addition & 0 deletions flang/lib/Common/Fortran-features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ LanguageFeatureControl::LanguageFeatureControl() {
warnLanguage_.set(LanguageFeature::BadBranchTarget);
warnLanguage_.set(LanguageFeature::HollerithPolymorphic);
warnLanguage_.set(LanguageFeature::ListDirectedSize);
warnLanguage_.set(LanguageFeature::IgnoreIrrelevantAttributes);
warnUsage_.set(UsageWarning::ShortArrayActual);
warnUsage_.set(UsageWarning::FoldingException);
warnUsage_.set(UsageWarning::FoldingAvoidsRuntimeCrash);
Expand Down
10 changes: 8 additions & 2 deletions flang/lib/Semantics/check-declarations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,14 @@ void CheckHelper::Check(const Symbol &symbol) {
if (symbol.attrs().HasAny({Attr::INTENT_IN, Attr::INTENT_INOUT,
Attr::INTENT_OUT, Attr::OPTIONAL, Attr::VALUE}) &&
!IsDummy(symbol)) {
messages_.Say(
"Only a dummy argument may have an INTENT, VALUE, or OPTIONAL attribute"_err_en_US);
if (context_.IsEnabled(
common::LanguageFeature::IgnoreIrrelevantAttributes)) {
context_.Warn(common::LanguageFeature::IgnoreIrrelevantAttributes,
"Only a dummy argument should have an INTENT, VALUE, or OPTIONAL attribute"_warn_en_US);
} else {
messages_.Say(
"Only a dummy argument may have an INTENT, VALUE, or OPTIONAL attribute"_err_en_US);
}
} else if (symbol.attrs().test(Attr::VALUE)) {
CheckValue(symbol, derived);
}
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Semantics/call14.f90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module m
!ERROR: VALUE attribute may apply only to a dummy data object
subroutine C863(notData,assumedSize,coarray,coarrayComponent,assumedRank,assumedLen)
external :: notData
!ERROR: Only a dummy argument may have an INTENT, VALUE, or OPTIONAL attribute
!WARNING: Only a dummy argument should have an INTENT, VALUE, or OPTIONAL attribute
real, value :: notADummy
value :: notData
!ERROR: VALUE attribute may not apply to an assumed-size array
Expand Down
8 changes: 4 additions & 4 deletions flang/test/Semantics/resolve58.f90
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ subroutine s6()

!ERROR: Implied-shape array 'local1' must be a named constant or a dummy argument
real, dimension (*) :: local1
!ERROR: Only a dummy argument may have an INTENT, VALUE, or OPTIONAL attribute
!WARNING: Only a dummy argument should have an INTENT, VALUE, or OPTIONAL attribute
real, intent(in) :: local2
!ERROR: Only a dummy argument may have an INTENT, VALUE, or OPTIONAL attribute
!WARNING: Only a dummy argument should have an INTENT, VALUE, or OPTIONAL attribute
procedure(), intent(in) :: p1
!ERROR: Only a dummy argument may have an INTENT, VALUE, or OPTIONAL attribute
!WARNING: Only a dummy argument should have an INTENT, VALUE, or OPTIONAL attribute
real, optional :: local3
!ERROR: Only a dummy argument may have an INTENT, VALUE, or OPTIONAL attribute
!WARNING: Only a dummy argument should have an INTENT, VALUE, or OPTIONAL attribute
procedure(), optional :: p2
end subroutine
Loading