[flang-commits] [flang] c7285cd - [flang] Don't emit portability warnings for things in module files
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Fri Sep 23 13:45:36 PDT 2022
Author: Peter Klausler
Date: 2022-09-23T13:45:09-07:00
New Revision: c7285cd09f21d3802f9a17cac60f963714426263
URL: https://github.com/llvm/llvm-project/commit/c7285cd09f21d3802f9a17cac60f963714426263
DIFF: https://github.com/llvm/llvm-project/commit/c7285cd09f21d3802f9a17cac60f963714426263.diff
LOG: [flang] Don't emit portability warnings for things in module files
Any symbol in a module file will have been already shamed with
portability warnings when the module was compiled, so don't pile
on when compiling other program units that use the module.
This also silences warnings about some symbols whose names were
created or extended by the compiler to avoid clashes.
Differential Revision: https://reviews.llvm.org/D134455
Added:
Modified:
flang/lib/Semantics/check-declarations.cpp
flang/lib/Semantics/resolve-names-utils.cpp
flang/lib/Semantics/resolve-names.cpp
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index 1326baeb6a35..c5ca5b63f12c 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -201,7 +201,9 @@ void CheckHelper::Check(
}
void CheckHelper::Check(const Symbol &symbol) {
- if (symbol.name().size() > common::maxNameLen) {
+ if (symbol.name().size() > common::maxNameLen &&
+ &symbol == &symbol.GetUltimate() &&
+ !FindModuleFileContaining(symbol.owner())) {
messages_.Say(symbol.name(),
"%s has length %d, which is greater than the maximum name length "
"%d"_port_en_US,
@@ -616,7 +618,8 @@ void CheckHelper::CheckObjectEntity(
messages_.Say("A dummy argument must not be initialized"_err_en_US);
} else if (IsFunctionResult(symbol)) {
messages_.Say("A function result must not be initialized"_err_en_US);
- } else if (IsInBlankCommon(symbol)) {
+ } else if (IsInBlankCommon(symbol) &&
+ !FindModuleFileContaining(symbol.owner())) {
messages_.Say(
"A variable in blank COMMON should not be initialized"_port_en_US);
}
@@ -1964,7 +1967,8 @@ void CheckHelper::CheckBindC(const Symbol &symbol) {
}
}
}
- if (derived->componentNames().empty()) { // C1805
+ if (derived->componentNames().empty() &&
+ !FindModuleFileContaining(symbol.owner())) { // C1805
messages_.Say(symbol.name(),
"A derived type with the BIND attribute is empty"_port_en_US);
}
diff --git a/flang/lib/Semantics/resolve-names-utils.cpp b/flang/lib/Semantics/resolve-names-utils.cpp
index 3b180dfe44cf..60ca695ea6ac 100644
--- a/flang/lib/Semantics/resolve-names-utils.cpp
+++ b/flang/lib/Semantics/resolve-names-utils.cpp
@@ -464,7 +464,9 @@ bool EquivalenceSets::CheckCanEquivalence(
}
}
}
- if (msg) {
+ if (msg &&
+ (!context_.IsInModuleFile(source) ||
+ msg->severity() == parser::Severity::Error)) {
context_.Say(source, std::move(*msg), sym1.name(), sym2.name());
return false;
}
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index f3d829fc4a9b..4beb0207710f 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -173,6 +173,8 @@ class BaseVisitor {
}
}
+ bool InModuleFile() const { return GetFoldingContext().inModuleFile(); }
+
// Make a placeholder symbol for a Name that otherwise wouldn't have one.
// It is not in any scope and always has MiscDetails.
void MakePlaceholder(const parser::Name &, MiscDetails::Kind);
@@ -4835,7 +4837,8 @@ bool DeclarationVisitor::Pre(const parser::DataComponentDefStmt &x) {
set_allowForwardReferenceToDerivedType(false);
if (derivedTypeInfo_.sequence) { // C740
if (const auto *declType{GetDeclTypeSpec()}) {
- if (!declType->AsIntrinsic() && !declType->IsSequenceType()) {
+ if (!declType->AsIntrinsic() && !declType->IsSequenceType() &&
+ !InModuleFile()) {
if (GetAttrs().test(Attr::POINTER) &&
context().IsEnabled(common::LanguageFeature::PointerInSeqType)) {
if (context().ShouldWarn(common::LanguageFeature::PointerInSeqType)) {
@@ -6635,7 +6638,7 @@ const parser::Name *DeclarationVisitor::ResolveName(const parser::Name &name) {
ApplyImplicitRules(*symbol);
}
if (checkIndexUseInOwnBounds_ &&
- *checkIndexUseInOwnBounds_ == name.source) {
+ *checkIndexUseInOwnBounds_ == name.source && !InModuleFile()) {
Say(name,
"Implied DO index '%s' uses an object of the same name in its bounds expressions"_port_en_US,
name.source);
More information about the flang-commits
mailing list