[clang] [clang][Parser] Fix an assertion during decltype error recovery with missing ; (PR #188123)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 31 13:05:32 PDT 2026
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/188123
>From b3f87b6f63ca319ffd99b696413a81c80f7695b7 Mon Sep 17 00:00:00 2001
From: Haojian Wu <hokein.wu at gmail.com>
Date: Mon, 23 Mar 2026 21:28:35 +0100
Subject: [PATCH 1/2] [clang][Parser] Fix crash during decltype error recovery
with missing semicolons
---
clang/lib/Parse/ParseDeclCXX.cpp | 1 -
clang/test/Parser/decltype-gh188014.cpp | 4 ++++
2 files changed, 4 insertions(+), 1 deletion(-)
create mode 100644 clang/test/Parser/decltype-gh188014.cpp
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 274c354d59808..5a7863506cc91 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -1082,7 +1082,6 @@ SourceLocation Parser::ParseDecltypeSpecifier(DeclSpec &DS) {
PP.RevertCachedTokens(2);
ConsumeToken(); // the semi.
EndLoc = ConsumeAnyToken();
- assert(Tok.is(tok::semi));
} else {
EndLoc = Tok.getLocation();
}
diff --git a/clang/test/Parser/decltype-gh188014.cpp b/clang/test/Parser/decltype-gh188014.cpp
new file mode 100644
index 0000000000000..e8403bdcbe3bb
--- /dev/null
+++ b/clang/test/Parser/decltype-gh188014.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// GH188014
+& decltype ( ( union { // expected-error {{expected ';' after union}} expected-error {{expected '}'}} expected-error {{expected ')'}} expected-error {{expected expression}} expected-error {{expected unqualified-id}} expected-note {{to match this '('}} expected-note {{to match this '{'}}
>From 88dbbc35f87e280b63b7100b0a1a983a330a5e68 Mon Sep 17 00:00:00 2001
From: Haojian Wu <hokein.wu at gmail.com>
Date: Tue, 31 Mar 2026 22:04:51 +0200
Subject: [PATCH 2/2] Add release note
---
clang/docs/ReleaseNotes.rst | 1 +
1 file changed, 1 insertion(+)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 45234c316eba8..1b31728a49957 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -402,6 +402,7 @@ Miscellaneous Clang Crashes Fixed
- Fixed a crash when subscripting a vector type with large unsigned integer values. (#GH180563)
- Fixed a crash when evaluating ``__is_bitwise_cloneable`` on invalid record types. (#GH183707)
- Fixed an assertion failure when casting a function pointer with a target with a non-default program address space. (#GH186210)
+- Fixed an assertion failure when parsing an invalid ``decltype`` specifier with missing parentheses or extra semicolons. (#GH188014)
OpenACC Specific Changes
------------------------
More information about the cfe-commits
mailing list