[flang-commits] [flang] 67d6679 - [flang][prescanner] fix invalid check (#146613)
via flang-commits
flang-commits at lists.llvm.org
Thu Jul 3 12:36:36 PDT 2025
Author: Andre Kuhlenschmidt
Date: 2025-07-03T12:36:34-07:00
New Revision: 67d6679c91e14e17981e4ea0340f91c79e9524da
URL: https://github.com/llvm/llvm-project/commit/67d6679c91e14e17981e4ea0340f91c79e9524da
DIFF: https://github.com/llvm/llvm-project/commit/67d6679c91e14e17981e4ea0340f91c79e9524da.diff
LOG: [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
Added:
flang/test/Parser/issue-146362.1.f90
Modified:
flang/lib/Parser/token-sequence.cpp
Removed:
################################################################################
diff --git a/flang/lib/Parser/token-sequence.cpp b/flang/lib/Parser/token-sequence.cpp
index 40a074eaf0a47..9deb513e4f64f 100644
--- a/flang/lib/Parser/token-sequence.cpp
+++ b/flang/lib/Parser/token-sequence.cpp
@@ -30,7 +30,8 @@ void TokenSequence::clear() {
void TokenSequence::pop_back() {
CHECK(!start_.empty());
- CHECK(nextStart_ > start_.back());
+ // If the last token is empty then `nextStart_ == start_.back()`.
+ CHECK(nextStart_ >= start_.back());
std::size_t bytes{nextStart_ - start_.back()};
nextStart_ = start_.back();
start_.pop_back();
diff --git a/flang/test/Parser/issue-146362.1.f90 b/flang/test/Parser/issue-146362.1.f90
new file mode 100644
index 0000000000000..a37fd4b182a7f
--- /dev/null
+++ b/flang/test/Parser/issue-146362.1.f90
@@ -0,0 +1,5 @@
+! RUN: %flang_fc1 -fsyntax-only -cpp %s 2>&1
+#define UNITY(k) 1_ ## k
+PROGRAM REPRODUCER
+WRITE(*,*) UNITY(4)
+END PROGRAM REPRODUCER
\ No newline at end of file
More information about the flang-commits
mailing list