Skip to content

Commit c24f881

Browse files
authored
[flang] Silence warnings from module files after recent change (#92834)
I modified declaration checking for interoperable objects to buffer its generated messages as I had previously done for derived types and procedure interfaces, but failed to modify all of the message creation statements to use the new buffer, so some are now escaping when a module file is being compiled. Fix to ensure that the new buffer is always used.
1 parent 975579b commit c24f881

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

flang/lib/Semantics/check-declarations.cpp

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3000,14 +3000,14 @@ parser::Messages CheckHelper::WhyNotInteroperableObject(
30003000
examinedByWhyNotInteroperable_.insert(symbol);
30013001
CHECK(symbol.has<ObjectEntityDetails>());
30023002
if (isExplicitBindC && !symbol.owner().IsModule()) {
3003-
messages_.Say(symbol.name(),
3003+
msgs.Say(symbol.name(),
30043004
"A variable with BIND(C) attribute may only appear in the specification part of a module"_err_en_US);
30053005
}
30063006
auto shape{evaluate::GetShape(foldingContext_, symbol)};
30073007
if (shape) {
30083008
if (evaluate::GetRank(*shape) == 0) { // 18.3.4
30093009
if (IsAllocatableOrPointer(symbol) && !IsDummy(symbol)) {
3010-
messages_.Say(symbol.name(),
3010+
msgs.Say(symbol.name(),
30113011
"A scalar interoperable variable may not be ALLOCATABLE or POINTER"_err_en_US);
30123012
}
30133013
} else if (auto extents{
@@ -3028,25 +3028,22 @@ parser::Messages CheckHelper::WhyNotInteroperableObject(
30283028
if (derived) {
30293029
if (derived->typeSymbol().attrs().test(Attr::BIND_C)) {
30303030
} else if (isError) {
3031-
if (auto *msg{messages_.Say(symbol.name(),
3032-
"The derived type of a BIND(C) object must also be BIND(C)"_err_en_US)}) {
3033-
msg->Attach(derived->typeSymbol().name(), "Non-BIND(C) type"_en_US);
3034-
}
3035-
context_.SetError(symbol);
3031+
msgs.Say(symbol.name(),
3032+
"The derived type of a BIND(C) object must also be BIND(C)"_err_en_US)
3033+
.Attach(derived->typeSymbol().name(), "Non-BIND(C) type"_en_US);
30363034
} else if (auto bad{WhyNotInteroperableDerivedType(
30373035
derived->typeSymbol(), /*isError=*/false)};
30383036
bad.AnyFatalError()) {
3039-
if (auto *msg{messages_.Say(symbol.name(),
3040-
"The derived type of an interoperable object must be interoperable, but is not"_err_en_US)}) {
3041-
msg->Attach(
3042-
derived->typeSymbol().name(), "Non-interoperable type"_en_US);
3043-
bad.AttachTo(*msg, parser::Severity::None);
3044-
}
3037+
bad.AttachTo(
3038+
msgs.Say(symbol.name(),
3039+
"The derived type of an interoperable object must be interoperable, but is not"_err_en_US)
3040+
.Attach(derived->typeSymbol().name(),
3041+
"Non-interoperable type"_en_US),
3042+
parser::Severity::None);
30453043
} else {
3046-
if (auto *msg{messages_.Say(symbol.name(),
3047-
"The derived type of an interoperable object should be BIND(C)"_warn_en_US)}) {
3048-
msg->Attach(derived->typeSymbol().name(), "Non-BIND(C) type"_en_US);
3049-
}
3044+
msgs.Say(symbol.name(),
3045+
"The derived type of an interoperable object should be BIND(C)"_warn_en_US)
3046+
.Attach(derived->typeSymbol().name(), "Non-BIND(C) type"_en_US);
30503047
}
30513048
}
30523049
if (type->IsAssumedType()) { // ok

0 commit comments

Comments
 (0)