Skip to content

Commit 7dba404

Browse files
committed
initial commit
1 parent 5a52dca commit 7dba404

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

flang/include/flang/Parser/message.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,9 @@ class Message : public common::ReferenceCounted<Message> {
307307
bool Merge(const Message &);
308308
bool operator==(const Message &that) const;
309309
bool operator!=(const Message &that) const { return !(*this == that); }
310+
bool AtSameLocation(const Message &) const;
310311

311312
private:
312-
bool AtSameLocation(const Message &) const;
313313
std::variant<ProvenanceRange, CharBlock> location_;
314314
std::variant<MessageFixedText, MessageFormattedText, MessageExpectedText>
315315
text_;

flang/lib/Parser/message.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,15 +477,31 @@ void Messages::Emit(llvm::raw_ostream &o, const AllCookedSources &allCooked,
477477
}
478478
std::stable_sort(sorted.begin(), sorted.end(),
479479
[](const Message *x, const Message *y) { return x->SortBefore(*y); });
480-
const Message *lastMsg{nullptr};
480+
std::vector<const Message *> msgsWithLastLocation;
481481
std::size_t errorsEmitted{0};
482482
for (const Message *msg : sorted) {
483-
if (lastMsg && *msg == *lastMsg) {
484-
// Don't emit two identical messages for the same location
483+
bool shouldSkipMsg = false;
484+
// Don't emit two identical messages for the same location
485+
// At the same location messages are sorted by the order they were
486+
// added to the list, which is a decent proxy for the causality
487+
// of the messages.
488+
if (!msgsWithLastLocation.empty()) {
489+
if (msgsWithLastLocation[0]->AtSameLocation(*msg)) {
490+
for (const Message *msgAtThisLocation : msgsWithLastLocation) {
491+
if (*msg == *msgAtThisLocation) {
492+
shouldSkipMsg = true; // continue loop over sorted messages
493+
break;
494+
}
495+
}
496+
} else {
497+
msgsWithLastLocation.clear();
498+
}
499+
}
500+
if (shouldSkipMsg) {
485501
continue;
486502
}
503+
msgsWithLastLocation.push_back(msg);
487504
msg->Emit(o, allCooked, echoSourceLines, hintFlagPtr);
488-
lastMsg = msg;
489505
if (warningsAreErrors || msg->IsFatal()) {
490506
++errorsEmitted;
491507
}

flang/test/Semantics/associated.f90

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,6 @@ subroutine test(assumedRank)
253253
lvar = associated(intPointerVar1, targetIntCoarray[1])
254254
!ERROR: 'neverdeclared' is not a procedure
255255
!ERROR: Could not characterize intrinsic function actual argument 'badpointer'
256-
!ERROR: 'neverdeclared' is not a procedure
257-
!ERROR: Could not characterize intrinsic function actual argument 'badpointer'
258256
lvar = associated(badPointer)
259257
end subroutine test
260258
end subroutine assoc

flang/test/Semantics/intrinsics03.f90

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,5 @@ subroutine ichar_tests()
130130
integer, parameter :: a2 = ichar('B ')
131131
!ERROR: Character in intrinsic function ichar must have length one
132132
!ERROR: Value of named constant 'a3' (ichar("")) cannot be computed as a constant value
133-
!ERROR: Character in intrinsic function ichar must have length one
134-
!ERROR: Value of named constant 'a3' (ichar("")) cannot be computed as a constant value
135-
!ERROR: Character in intrinsic function ichar must have length one
136133
integer, parameter :: a3 = ichar('')
137134
end subroutine

flang/test/Semantics/intrinsics04.f90

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,5 @@ subroutine ichar_tests()
3030
integer, parameter :: a2 = ichar('B ')
3131
!ERROR: Character in intrinsic function ichar must have length one
3232
!ERROR: Value of named constant 'a3' (ichar("")) cannot be computed as a constant value
33-
!ERROR: Character in intrinsic function ichar must have length one
34-
!ERROR: Value of named constant 'a3' (ichar("")) cannot be computed as a constant value
35-
!ERROR: Character in intrinsic function ichar must have length one
3633
integer, parameter :: a3 = ichar('')
3734
end subroutine

0 commit comments

Comments
 (0)