[flang-commits] [PATCH] D134455: [flang] Don't emit portability warnings for things in module files
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Thu Sep 22 10:10:19 PDT 2022
klausler created this revision.
klausler added a reviewer: clementval.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.
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.
https://reviews.llvm.org/D134455
Files:
flang/lib/Semantics/check-declarations.cpp
flang/lib/Semantics/resolve-names-utils.cpp
flang/lib/Semantics/resolve-names.cpp
Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -173,6 +173,8 @@
}
}
+ 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);
@@ -4777,7 +4779,8 @@
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)) {
@@ -6577,7 +6580,7 @@
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);
Index: flang/lib/Semantics/resolve-names-utils.cpp
===================================================================
--- flang/lib/Semantics/resolve-names-utils.cpp
+++ flang/lib/Semantics/resolve-names-utils.cpp
@@ -464,7 +464,9 @@
}
}
}
- if (msg) {
+ if (msg &&
+ (!context_.IsInModuleFile(source) ||
+ msg->severity() == parser::Severity::Error)) {
context_.Say(source, std::move(*msg), sym1.name(), sym2.name());
return false;
}
Index: flang/lib/Semantics/check-declarations.cpp
===================================================================
--- flang/lib/Semantics/check-declarations.cpp
+++ flang/lib/Semantics/check-declarations.cpp
@@ -201,7 +201,9 @@
}
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 @@
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);
}
@@ -1957,7 +1960,8 @@
}
}
}
- 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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134455.462225.patch
Type: text/x-patch
Size: 3328 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220922/fc023cba/attachment.bin>
More information about the flang-commits
mailing list