diff options
author | Peter Klausler <35819229+klausler@users.noreply.github.com> | 2024-05-01 14:33:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-01 14:33:14 -0700 |
commit | 505f6da1961ab55c601d7239648c53ce863b5d70 (patch) | |
tree | 383ed4a682d2d65a99a109ffe46ca4e08e48387d /flang/lib/Evaluate/intrinsics.cpp | |
parent | 37277d8da8afd3291240a14a19193024065cf7ca (diff) | |
download | llvm-505f6da1961ab55c601d7239648c53ce863b5d70.zip llvm-505f6da1961ab55c601d7239648c53ce863b5d70.tar.gz llvm-505f6da1961ab55c601d7239648c53ce863b5d70.tar.bz2 |
[flang] Ensure all warning/portability messages are guarded by Should… (#90518)
…Warn()
Many warning messages were being emitted unconditionally. Ensure that
all warnings are conditional on a true result from a call to
common::LanguageFeatureControl::ShouldWarn() so that it is easy for a
driver to disable them all, or, in the future, to provide per-warning
control over them.
Diffstat (limited to 'flang/lib/Evaluate/intrinsics.cpp')
-rw-r--r-- | flang/lib/Evaluate/intrinsics.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp index 1b73cad..441a762 100644 --- a/flang/lib/Evaluate/intrinsics.cpp +++ b/flang/lib/Evaluate/intrinsics.cpp @@ -2283,7 +2283,7 @@ std::optional<SpecificCall> IntrinsicInterface::Match( UnwrapWholeSymbolOrComponentDataRef(actualForDummy[*dimArg])}) { if (IsOptional(*whole) || IsAllocatableOrObjectPointer(whole)) { if (context.languageFeatures().ShouldWarn( - common::UsageWarning::DimMustBePresent)) { + common::UsageWarning::OptionalMustBePresent)) { if (rank == Rank::scalarIfDim || arrayRank.value_or(-1) == 1) { messages.Say( "The actual argument for DIM= is optional, pointer, or allocatable, and it is assumed to be present and equal to 1 at execution time"_warn_en_US); @@ -2741,16 +2741,21 @@ IntrinsicProcTable::Implementation::HandleC_F_Pointer( context.messages().Say(at, "FPTR= argument to C_F_POINTER() may not have a deferred type parameter"_err_en_US); } else if (type->category() == TypeCategory::Derived) { - if (type->IsUnlimitedPolymorphic()) { - context.messages().Say(at, - "FPTR= argument to C_F_POINTER() should not be unlimited polymorphic"_warn_en_US); - } else if (!type->GetDerivedTypeSpec().typeSymbol().attrs().test( - semantics::Attr::BIND_C)) { - context.messages().Say(at, - "FPTR= argument to C_F_POINTER() should not have a derived type that is not BIND(C)"_warn_en_US); + if (context.languageFeatures().ShouldWarn( + common::UsageWarning::Interoperability)) { + if (type->IsUnlimitedPolymorphic()) { + context.messages().Say(at, + "FPTR= argument to C_F_POINTER() should not be unlimited polymorphic"_warn_en_US); + } else if (!type->GetDerivedTypeSpec().typeSymbol().attrs().test( + semantics::Attr::BIND_C)) { + context.messages().Say(at, + "FPTR= argument to C_F_POINTER() should not have a derived type that is not BIND(C)"_warn_en_US); + } } } else if (!IsInteroperableIntrinsicType( - *type, &context.languageFeatures())) { + *type, &context.languageFeatures()) && + context.languageFeatures().ShouldWarn( + common::UsageWarning::Interoperability)) { context.messages().Say(at, "FPTR= argument to C_F_POINTER() should not have the non-interoperable intrinsic type %s"_warn_en_US, type->AsFortran()); @@ -2850,7 +2855,9 @@ std::optional<SpecificCall> IntrinsicProcTable::Implementation::HandleC_Loc( context.messages().Say(arguments[0]->sourceLocation(), "C_LOC() argument may not be zero-length character"_err_en_US); } else if (typeAndShape->type().category() != TypeCategory::Derived && - !IsInteroperableIntrinsicType(typeAndShape->type())) { + !IsInteroperableIntrinsicType(typeAndShape->type()) && + context.languageFeatures().ShouldWarn( + common::UsageWarning::Interoperability)) { context.messages().Say(arguments[0]->sourceLocation(), "C_LOC() argument has non-interoperable intrinsic type, kind, or length"_warn_en_US); } |