[clang] [clang][Parser] Fix crash on invalid attribute in constexpr function (PR #144286)
Iris Shi via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 16 06:40:56 PDT 2025
https://github.com/el-ev updated https://github.com/llvm/llvm-project/pull/144286
>From 6e10acb31f5975aad222bf211bcd61976a1c5108 Mon Sep 17 00:00:00 2001
From: Iris Shi <0.0 at owo.li>
Date: Mon, 16 Jun 2025 09:37:17 +0800
Subject: [PATCH] [clang][Parser] Fix crash on malformed using declaration in
constexpr function
---
clang/docs/ReleaseNotes.rst | 1 +
clang/lib/Parse/ParseDeclCXX.cpp | 4 ++++
2 files changed, 5 insertions(+)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 33ee8a53b5f37..59d9612268d30 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -704,6 +704,7 @@ Bug Fixes in This Version
- Fixed a bug with constexpr evaluation for structs containing unions in case of C++ modules. (#GH143168)
- Fixed incorrect token location when emitting diagnostics for tokens expanded from macros. (#GH143216)
- Fixed an infinite recursion when checking constexpr destructors. (#GH141789)
+- Fixed a crash when a malformed using declaration appears in a ``constexpr`` function. (#GH144264)
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index f31c9265a0074..a5c76501c7c18 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -760,6 +760,10 @@ Parser::DeclGroupPtrTy Parser::ParseUsingDeclaration(
Decl *AD = ParseAliasDeclarationAfterDeclarator(
TemplateInfo, UsingLoc, D, DeclEnd, AS, Attrs, &DeclFromDeclSpec);
+
+ if (!AD)
+ return nullptr;
+
return Actions.ConvertDeclToDeclGroup(AD, DeclFromDeclSpec);
}
More information about the cfe-commits
mailing list