Skip to content

Commit da3cddb

Browse files
committed
clarify code
1 parent 2693db8 commit da3cddb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

flang/lib/Parser/message.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,12 +492,17 @@ void Messages::AttachTo(Message &msg, std::optional<Severity> severity) {
492492
}
493493

494494
bool Messages::AnyFatalError(bool warningsAreErrors) const {
495+
// Short-circuit in the most common case.
495496
if (messages_.empty()) {
496497
return false;
497498
}
499+
// If warnings are errors and there are warnings or errors, this is fatal.
500+
// This preserves the compiler's current behavior of treating any non-fatal
501+
// message as a warning. We may want to refine this in the future.
498502
if (warningsAreErrors) {
499503
return true;
500504
}
505+
// Otherwise, check the message buffer for fatal errors.
501506
for (const auto &msg : messages_) {
502507
if (msg.IsFatal()) {
503508
return true;

0 commit comments

Comments
 (0)