Skip to content

Commit 73eb7e9

Browse files
committed
remove AddWarning
1 parent e4113e9 commit 73eb7e9

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

flang/include/flang/Parser/message.h

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -335,24 +335,12 @@ class Messages {
335335
return messages_.emplace_back(std::forward<A>(args)...);
336336
}
337337

338-
// AddWarning bypasses the language feature control, it is only exposed for
339-
// legacy code that cannot be easily refactored to use Warn().
340-
template <typename... A>
341-
Message &AddWarning(common::UsageWarning warning, A &&...args) {
342-
return messages_.emplace_back(warning, std::forward<A>(args)...);
343-
}
344-
345-
template <typename... A>
346-
Message &AddWarning(common::LanguageFeature feature, A &&...args) {
347-
return messages_.emplace_back(feature, std::forward<A>(args)...);
348-
}
349-
350338
template <typename... A>
351339
Message *Warn(bool isInModuleFile,
352340
const common::LanguageFeatureControl &control,
353341
common::LanguageFeature feature, A &&...args) {
354342
if (!isInModuleFile && control.ShouldWarn(feature)) {
355-
return &AddWarning(feature, std::forward<A>(args)...);
343+
return &addWarning(feature, std::forward<A>(args)...);
356344
}
357345
return nullptr;
358346
}
@@ -362,7 +350,7 @@ class Messages {
362350
const common::LanguageFeatureControl &control,
363351
common::UsageWarning warning, A &&...args) {
364352
if (!isInModuleFile && control.ShouldWarn(warning)) {
365-
return &AddWarning(warning, std::forward<A>(args)...);
353+
return &addWarning(warning, std::forward<A>(args)...);
366354
}
367355
return nullptr;
368356
}
@@ -383,6 +371,14 @@ class Messages {
383371
bool AnyFatalError(bool warningsAreErrors = false) const;
384372

385373
private:
374+
template <typename... A>
375+
Message &addWarning(common::UsageWarning warning, A &&...args) {
376+
return messages_.emplace_back(warning, std::forward<A>(args)...);
377+
}
378+
template <typename... A>
379+
Message &addWarning(common::LanguageFeature feature, A &&...args) {
380+
return messages_.emplace_back(feature, std::forward<A>(args)...);
381+
}
386382
std::list<Message> messages_;
387383
};
388384

flang/lib/Semantics/check-declarations.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3134,12 +3134,12 @@ parser::Messages CheckHelper::WhyNotInteroperableDerivedType(
31343134
*dyType, &context_.languageFeatures())
31353135
.value_or(false)) {
31363136
if (type->category() == DeclTypeSpec::Logical) {
3137-
msgs.AddWarning(common::UsageWarning::LogicalVsCBool,
3137+
context().Warn(msgs, common::UsageWarning::LogicalVsCBool,
31383138
component.name(),
31393139
"A LOGICAL component of an interoperable type should have the interoperable KIND=C_BOOL"_port_en_US);
31403140
} else if (type->category() == DeclTypeSpec::Character && dyType &&
31413141
dyType->kind() == 1) {
3142-
msgs.AddWarning(common::UsageWarning::BindCCharLength,
3142+
context().Warn(msgs, common::UsageWarning::BindCCharLength,
31433143
component.name(),
31443144
"A CHARACTER component of an interoperable type should have length 1"_port_en_US);
31453145
} else {
@@ -3156,7 +3156,7 @@ parser::Messages CheckHelper::WhyNotInteroperableDerivedType(
31563156
}
31573157
}
31583158
if (derived->componentNames().empty()) { // F'2023 C1805
3159-
msgs.AddWarning(common::LanguageFeature::EmptyBindCDerivedType,
3159+
context().Warn(msgs, common::LanguageFeature::EmptyBindCDerivedType,
31603160
symbol.name(),
31613161
"A derived type with the BIND attribute should not be empty"_warn_en_US);
31623162
}

0 commit comments

Comments
 (0)