Skip to content

Commit 67d6679

Browse files
authored
[flang][prescanner] fix invalid check (#146613)
`TokenSequence::pop_back()` had a check assumed that tokens are never empty. Loosen this check since isn't true. towards #146362
1 parent 08ed9e1 commit 67d6679

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

flang/lib/Parser/token-sequence.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ void TokenSequence::clear() {
3030

3131
void TokenSequence::pop_back() {
3232
CHECK(!start_.empty());
33-
CHECK(nextStart_ > start_.back());
33+
// If the last token is empty then `nextStart_ == start_.back()`.
34+
CHECK(nextStart_ >= start_.back());
3435
std::size_t bytes{nextStart_ - start_.back()};
3536
nextStart_ = start_.back();
3637
start_.pop_back();

flang/test/Parser/issue-146362.1.f90

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
! RUN: %flang_fc1 -fsyntax-only -cpp %s 2>&1
2+
#define UNITY(k) 1_ ## k
3+
PROGRAM REPRODUCER
4+
WRITE(*,*) UNITY(4)
5+
END PROGRAM REPRODUCER

0 commit comments

Comments
 (0)