Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flang/include/flang/Parser/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ class Message : public common::ReferenceCounted<Message> {
bool Merge(const Message &);
bool operator==(const Message &that) const;
bool operator!=(const Message &that) const { return !(*this == that); }
bool AtSameLocation(const Message &) const;

private:
bool AtSameLocation(const Message &) const;
std::variant<ProvenanceRange, CharBlock> location_;
std::variant<MessageFixedText, MessageFormattedText, MessageExpectedText>
text_;
Expand Down
24 changes: 20 additions & 4 deletions flang/lib/Parser/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,15 +477,31 @@ void Messages::Emit(llvm::raw_ostream &o, const AllCookedSources &allCooked,
}
std::stable_sort(sorted.begin(), sorted.end(),
[](const Message *x, const Message *y) { return x->SortBefore(*y); });
const Message *lastMsg{nullptr};
std::vector<const Message *> msgsWithLastLocation;
std::size_t errorsEmitted{0};
for (const Message *msg : sorted) {
if (lastMsg && *msg == *lastMsg) {
// Don't emit two identical messages for the same location
bool shouldSkipMsg{false};
// Don't emit two identical messages for the same location.
// At the same location, messages are sorted by the order they were
// added to the Messages buffer, which is a decent proxy for the
// causality of the messages.
if (!msgsWithLastLocation.empty()) {
if (msgsWithLastLocation[0]->AtSameLocation(*msg)) {
for (const Message *msgAtThisLocation : msgsWithLastLocation) {
if (*msg == *msgAtThisLocation) {
shouldSkipMsg = true; // continue loop over sorted messages
break;
}
}
} else {
msgsWithLastLocation.clear();
}
}
if (shouldSkipMsg) {
continue;
}
msgsWithLastLocation.push_back(msg);
msg->Emit(o, allCooked, echoSourceLines, hintFlagPtr);
lastMsg = msg;
if (warningsAreErrors || msg->IsFatal()) {
++errorsEmitted;
}
Expand Down
2 changes: 0 additions & 2 deletions flang/test/Semantics/associated.f90
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,6 @@ subroutine test(assumedRank)
lvar = associated(intPointerVar1, targetIntCoarray[1])
!ERROR: 'neverdeclared' is not a procedure
!ERROR: Could not characterize intrinsic function actual argument 'badpointer'
!ERROR: 'neverdeclared' is not a procedure
!ERROR: Could not characterize intrinsic function actual argument 'badpointer'
lvar = associated(badPointer)
end subroutine test
end subroutine assoc